/* basket.css — mindeat.app/basket (paste-a-list price comparison).
   Design tokens mirror hosting/index.html; RTL-first via logical props. */

:root {
  color-scheme: light dark;
  --brand: #128269;
  --brand-bright: #1fbe8d;
  --brand-dark: #0b6657;
  --background: #f6faf8;
  --surface: #ffffff;
  --surface-soft: #edf5f2;
  --text: #17211e;
  --muted: #5d6c67;
  --border: rgba(23, 33, 30, 0.09);
  --hairline: rgba(23, 33, 30, 0.12);
  --shadow: 0 24px 70px rgba(18, 130, 105, 0.14);
  --danger: #c0392b;
  --warn: #b06a00;
  --warn-bg: rgba(247, 147, 30, 0.12);
  --ok-bg: rgba(18, 130, 105, 0.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0d1211;
    --surface: #171d1b;
    --surface-soft: #1d2523;
    --text: #edf3f1;
    --muted: #9fb0aa;
    --border: rgba(237, 243, 241, 0.09);
    --hairline: rgba(237, 243, 241, 0.14);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    --warn: #f0a94b;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(31, 190, 141, 0.14), transparent 60%),
    var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Header / footer (match landing) ─────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100% - 40px, 980px);
  margin: 0 auto;
  padding-block: 18px 6px;
}

.site-brand img { height: 30px; display: block; }

.header-actions { display: flex; align-items: center; gap: 14px; }

.header-cta {
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 9px 16px;
  border-radius: 999px;
  white-space: nowrap;
}

.header-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}

footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: min(100% - 40px, 980px);
  margin: 40px auto 26px;
  color: var(--muted);
  font-size: 0.86rem;
}

footer nav { display: flex; gap: 16px; }
footer a { color: inherit; text-decoration: none; }
footer a:hover { color: var(--brand); }

main { width: min(100% - 32px, 980px); margin: 0 auto; padding-block-end: 40px; }

.hidden { display: none !important; }

/* ── Step 1: paste ────────────────────────────────────────────────── */

.hero-basket { text-align: center; padding-block: 26px 6px; }

.hero-basket h1 {
  font-size: clamp(1.7rem, 4.6vw, 2.5rem);
  line-height: 1.2;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

.hero-basket h1 span { color: var(--brand); }

.hero-basket .sub {
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 560px;
  margin: 0 auto 20px;
}

.paste-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 18px;
  max-width: 640px;
  margin: 0 auto;
  text-align: start;
}

.paste-card textarea {
  width: 100%;
  min-height: 168px;
  resize: vertical;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  padding: 14px;
  outline: none;
}

.paste-card textarea:focus { border-color: var(--brand); }

.input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-block: 12px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.chip-btn:hover { border-color: var(--brand); }

.seg {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 14px;
  cursor: pointer;
}

.seg button.on { background: var(--brand); color: #fff; }

.button.primary {
  display: block;
  width: 100%;
  border: 0;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.button.primary:hover { background: var(--brand-dark); }
.button.primary:active { transform: scale(0.985); }
.button.primary[disabled] { opacity: 0.55; cursor: default; }

.trust {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  margin: 12px 0 0;
}

.error-box {
  max-width: 640px;
  margin: 14px auto 0;
  background: rgba(192, 57, 43, 0.1);
  border: 1px solid rgba(192, 57, 43, 0.35);
  color: var(--danger);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.95rem;
}

.examples {
  max-width: 640px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.examples button {
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: underline;
}

/* ── Loading ──────────────────────────────────────────────────────── */

.loading-wrap { max-width: 640px; margin: 26px auto; text-align: center; }

.loading-line { color: var(--muted); font-size: 0.95rem; margin-block-end: 14px; }

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-bright));
  transition: width 0.35s ease;
}

/* ── Step 2: review ───────────────────────────────────────────────── */

.step-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-block: 22px 12px;
}

.step-head h2 { margin: 0; font-size: 1.35rem; }

.link-btn {
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  padding: 4px;
}

.review-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
}

.item-main { flex: 1; min-width: 0; }

.item-name { font-weight: 600; font-size: 1rem; }

.item-brand { color: var(--muted); font-weight: 400; }

.item-match {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  margin-block-start: 2px;
}

.match-chip {
  display: inline-block;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.match-exact { background: var(--ok-bg); color: var(--brand); }
.match-close { background: var(--warn-bg); color: var(--warn); }
.match-none { background: rgba(192, 57, 43, 0.12); color: var(--danger); }
.match-weighted { background: var(--surface-soft); color: var(--muted); }

.qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 2px;
  flex-shrink: 0;
}

.qty-stepper button {
  border: 0;
  background: transparent;
  color: var(--brand);
  width: 30px;
  height: 30px;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.qty-stepper button:hover { background: var(--surface); }

.qty-val {
  min-width: 44px;
  text-align: center;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.icon-btn:hover { color: var(--danger); background: var(--surface-soft); }

.add-row { position: relative; margin-block: 14px; }

.add-row input {
  width: 100%;
  border: 1px dashed var(--hairline);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 12px 14px;
  outline: none;
}

.add-row input:focus { border-color: var(--brand); border-style: solid; }

.suggest-pop {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 30;
  max-height: 260px;
  overflow: auto;
}

.suggest-pop button {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  cursor: pointer;
  text-align: start;
}

.suggest-pop button:hover { background: var(--surface-soft); }

.suggest-pop .sub { color: var(--muted); font-size: 0.8rem; }

.sticky-cta {
  position: sticky;
  bottom: 12px;
  margin-block-start: 16px;
  z-index: 20;
}

.sticky-cta .button.primary {
  box-shadow: 0 12px 34px rgba(18, 130, 105, 0.35);
}

/* ── Step 3: results ──────────────────────────────────────────────── */

.answer-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
  margin-block: 18px 16px;
}

.answer-kicker { color: var(--muted); font-size: 0.92rem; margin-block-end: 4px; }

.answer-price {
  font-size: clamp(2rem, 7vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.answer-price .chain { color: var(--brand); }

.answer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-block-start: 8px;
}

.tag-badge {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 700;
}

.tag-cheapest { background: var(--brand); color: #fff; }
.tag-closest { background: rgba(0, 122, 255, 0.14); color: #0a66c2; }
.tag-best { background: var(--warn-bg); color: var(--warn); }
.tag-online { background: var(--surface-soft); color: var(--muted); font-weight: 600; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-block: 6px 14px;
}

.controls .spacer { flex: 1; }

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

.chain-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.08s ease;
  position: relative;
}

.chain-card:hover { border-color: var(--brand); }
.chain-card.cheapest { border-color: var(--brand); }
.chain-card.expanded { grid-column: 1 / -1; cursor: default; }

.chain-head { display: flex; align-items: center; gap: 8px; }

.chain-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chain-name { font-weight: 700; font-size: 0.98rem; flex: 1; min-width: 0; }

.chain-branch {
  color: var(--muted);
  font-size: 0.82rem;
  margin-block-start: 2px;
  min-height: 1.1em;
}

.chain-total {
  font-size: 1.45rem;
  font-weight: 800;
  margin-block-start: 10px;
  font-variant-numeric: tabular-nums;
}

.chain-cover { color: var(--muted); font-size: 0.84rem; }

.chain-cover .warn { color: var(--warn); }

.chain-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-block-start: 8px; min-height: 20px; }

.card-details { margin-block-start: 12px; border-block-start: 1px solid var(--hairline); padding-block-start: 10px; }

.line-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-block: 7px;
  border-block-end: 1px dashed var(--hairline);
  font-size: 0.92rem;
}

.line-row:last-child { border-block-end: 0; }

.line-main { flex: 1; min-width: 0; }

.line-product { font-weight: 600; }

.line-sub { color: var(--muted); font-size: 0.8rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.line-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.line-swap {
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 4px;
  white-space: nowrap;
}

.missing-block {
  background: var(--warn-bg);
  border-radius: 12px;
  padding: 10px 12px;
  margin-block-start: 10px;
  font-size: 0.88rem;
}

.missing-block .title { font-weight: 700; color: var(--warn); margin-block-end: 4px; }

.missing-row { display: flex; justify-content: space-between; gap: 8px; padding-block: 3px; }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-block: 22px 8px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.96rem;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
}

.action-btn:hover { border-color: var(--brand); color: var(--brand); }

.action-btn.solid { background: var(--brand); border-color: var(--brand); color: #fff; }
.action-btn.solid:hover { background: var(--brand-dark); color: #fff; }

.methodology {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  max-width: 640px;
  margin: 14px auto 0;
}

.methodology summary { cursor: pointer; color: var(--brand); }
.methodology[open] summary { margin-block-end: 6px; }

.empty-note {
  text-align: center;
  color: var(--muted);
  margin-block: 30px;
}

/* ── Modal (product swap / city picker) ───────────────────────────── */

.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 15, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 12px;
}

.modal-sheet {
  background: var(--surface);
  border-radius: 22px;
  width: min(100%, 560px);
  max-height: min(78vh, 640px);
  overflow: auto;
  padding: 16px;
  box-shadow: var(--shadow);
}

.modal-sheet h3 { margin: 2px 0 4px; font-size: 1.08rem; }

.modal-sheet .modal-sub { color: var(--muted); font-size: 0.86rem; margin: 0 0 10px; }

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  border-radius: 14px;
  padding: 11px 13px;
  margin-block-end: 8px;
  cursor: pointer;
  text-align: start;
}

.option-row:hover { border-color: var(--brand); }
.option-row.on { border-color: var(--brand); background: var(--ok-bg); }

.option-main { flex: 1; min-width: 0; }

.option-name { font-weight: 600; font-size: 0.95rem; }

.option-sub { color: var(--muted); font-size: 0.8rem; }

.option-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.num { direction: ltr; unicode-bidi: isolate; }

@media (max-width: 640px) {
  .site-header { width: min(100% - 28px, 980px); }
  main { width: min(100% - 20px, 980px); }
  .paste-card { padding: 14px; border-radius: 22px; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .chain-card.expanded { grid-column: 1 / -1; }
  .answer-hero { padding: 18px 14px; }
  .modal-scrim { padding: 0; }
  .modal-sheet { border-end-start-radius: 0; border-end-end-radius: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .button.primary, .chain-card { transition: none; }
}
