/* ============================================================
   petswap.me — styles
   Dark theme, magenta accent (#EC2C79), soft rounded shapes.
   ============================================================ */

:root {
  --bg: #0D0B10;
  --surface: #17141C;
  --surface-2: #1E1924;
  --surface-3: #262030;
  --border: #2C2733;
  --border-soft: #221E29;

  --text: #F3EEF5;
  --text-muted: #9A90A3;
  --text-faint: #6E6577;

  --magenta: #EC2C79;
  --magenta-strong: #FF4C93;
  --magenta-soft: rgba(236, 44, 121, 0.14);
  --magenta-glow: rgba(236, 44, 121, 0.35);

  --win: #34D399;
  --win-soft: rgba(52, 211, 153, 0.14);

  --radius-lg: 26px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --font-display: "Baloo 2", "Nunito", sans-serif;
  --font-body: "Nunito", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 48px;
}

/* ---------- Header ---------- */

.site-header {
  text-align: center;
  margin-bottom: 28px;
}

.wordmark {
  margin: 0;
  line-height: 0;
}

.wordmark-logo {
  height: clamp(48px, 9vw, 72px);
  width: auto;
  display: block;
  margin: 0 auto;
}

.subheader {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.98rem;
  font-weight: 600;
}

/* ---------- Shell / card ---------- */

.calc-shell {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.calc-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

/* ---------- Totals + verdict ---------- */

.totals-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.total-you { justify-content: flex-start; }
.total-them { justify-content: flex-end; }

.total-label {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.total-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 4.5vw, 1.8rem);
}

.verdict {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
  transition: background 0.25s ease, color 0.25s ease;
}

.verdict.is-win {
  background: var(--win-soft);
  color: var(--win);
}

.verdict.is-lose {
  background: var(--magenta-soft);
  color: var(--magenta-strong);
}

/* ---------- Scale bar ---------- */

.scale-wrap {
  margin-bottom: 20px;
}

.scale-track {
  position: relative;
  height: 16px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}

.scale-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--win) 0%, var(--win) 60%, var(--magenta) 100%);
  transition: width 0.4s cubic-bezier(.2,.7,.3,1), background 0.4s ease;
}

.scale-center {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 3px;
  height: 24px;
  transform: translateX(-50%);
  background: var(--text-faint);
  border-radius: 2px;
}

/* ---------- Sides / grids ---------- */

.sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.side-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 10px;
  text-align: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
}

.tile {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.tile-add {
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  color: var(--text-faint);
  font-size: 1.6rem;
  font-weight: 700;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.tile-add:hover {
  border-color: var(--magenta);
  color: var(--magenta);
  background: var(--magenta-soft);
}

.tile-item {
  background: var(--surface-3);
  border: 1px solid var(--border);
  flex-direction: column;
  padding: 4px;
  gap: 2px;
  overflow: hidden;
}

.tile-thumb {
  width: 60%;
  height: 60%;
  border-radius: var(--radius-sm);
  background: var(--magenta-soft);
  color: var(--magenta-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  overflow: hidden;
}

.tile-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.tile-name {
  font-size: 0.6rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.tile-tags {
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--magenta);
  letter-spacing: 0.04em;
}

.tile-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

.tile-remove:hover {
  color: var(--magenta-strong);
  border-color: var(--magenta);
}

/* ---------- Disclaimer ---------- */

.disclaimer {
  max-width: 640px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.72rem;
  line-height: 1.5;
  margin-top: 22px;
  padding: 0 12px;
}

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 8, 0.72);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}

.modal-overlay.open {
  display: flex;
}

@media (min-width: 560px) {
  .modal-overlay {
    align-items: center;
    padding: 20px;
  }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.4);
}

@media (min-width: 560px) {
  .modal {
    border-radius: var(--radius-lg);
    max-height: 78vh;
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: var(--surface-2);
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--magenta); }

/* Category tabs */

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 40px 12px 0;
  margin-bottom: 4px;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tab-btn.active {
  background: var(--magenta-soft);
  color: var(--magenta-strong);
  border-color: var(--magenta);
}

.search-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  margin-bottom: 14px;
  outline: none;
}

.search-input:focus {
  border-color: var(--magenta);
}

.search-input::placeholder { color: var(--text-faint); }

.item-results {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  padding-bottom: 4px;
}

.result-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.result-tile:hover {
  border-color: var(--magenta);
  background: var(--magenta-soft);
}

.result-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--magenta-soft);
  color: var(--magenta-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  overflow: hidden;
}

.result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.result-name {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.result-value {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  padding: 24px 0;
}

/* Variant popup */

.variant-modal {
  align-items: center;
  text-align: center;
}

.variant-image {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-md);
  background: var(--magenta-soft);
  color: var(--magenta-strong);
  margin: 8px auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  overflow: hidden;
}

.variant-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.variant-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.variant-toggles {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.variant-btn {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.variant-btn.selected {
  border-color: var(--magenta);
  background: var(--magenta-soft);
  color: var(--magenta-strong);
}

.add-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--magenta);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.add-btn:hover { background: var(--magenta-strong); }
.add-btn:active { transform: scale(0.98); }

/* ---------- Mobile tightening ---------- */

@media (max-width: 420px) {
  .calc-card { padding: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .tile-name { font-size: 0.55rem; }
  .total-label { font-size: 0.7rem; }
}
