/* ==========================================================================
   mycoche — design system
   Comparador de precios Kia · light + dark, tokens, mobile-first, AA
   ========================================================================== */

/* ---- Design tokens (light) ------------------------------------------------ */
:root {
  color-scheme: light;

  /* Brand */
  --brand: #0b5cff;
  --brand-strong: #0846c9;
  --brand-soft: #e8efff;
  --accent: #05c27a;          /* precio / verde "ahorro" */
  --accent-strong: #038a56;

  /* Surfaces */
  --bg: #f6f8fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --header-bg: rgba(255, 255, 255, 0.82);

  /* Text */
  --text: #0e1726;
  --text-muted: #5a6678;
  --text-faint: #8a94a6;

  /* Lines & shadows */
  --border: #e2e7f0;
  --border-strong: #cdd5e3;
  --ring: rgba(11, 92, 255, 0.35);
  --shadow-sm: 0 1px 2px rgba(13, 26, 51, 0.06), 0 1px 3px rgba(13, 26, 51, 0.05);
  --shadow-md: 0 4px 14px rgba(13, 26, 51, 0.08), 0 2px 6px rgba(13, 26, 51, 0.05);
  --shadow-lg: 0 12px 36px rgba(13, 26, 51, 0.12);

  /* State chips */
  --nuevo-bg: #e2f7ea; --nuevo-fg: #0a7d3f; --nuevo-bd: #b6ead0;
  --km0-bg: #fff2d9;   --km0-fg: #9a6b00;   --km0-bd: #f3deaf;
  --ocasion-bg: #fde6e6; --ocasion-fg: #b3261e; --ocasion-bd: #f5c6c3;
  --neutral-bg: #eef1f6; --neutral-fg: #51607a; --neutral-bd: #dde3ee;

  /* Spacing scale */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem; --sp-8: 4rem;

  /* Radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-pill: 999px;

  /* Type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --font-num: "Inter", ui-sans-serif, system-ui, sans-serif;
}

/* ---- Dark theme ----------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --brand: #5a8cff;
  --brand-strong: #7aa3ff;
  --brand-soft: #16233f;
  --accent: #2bd68d;
  --accent-strong: #5fe3a8;

  --bg: #0a0f1a;
  --bg-elev: #111827;
  --surface: #131b2b;
  --surface-2: #1a2233;
  --header-bg: rgba(13, 19, 32, 0.78);

  --text: #eaf0fb;
  --text-muted: #9aa6bd;
  --text-faint: #6b778f;

  --border: #232d40;
  --border-strong: #33405a;
  --ring: rgba(90, 140, 255, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.55);

  --nuevo-bg: #0f2e1d; --nuevo-fg: #5fe3a8; --nuevo-bd: #1d5236;
  --km0-bg: #33280c;   --km0-fg: #f5c969;   --km0-bd: #574411;
  --ocasion-bg: #381719; --ocasion-fg: #f49a93; --ocasion-bd: #5c2a2a;
  --neutral-bg: #1c2538; --neutral-fg: #9aa6bd; --neutral-bd: #2a3650;
}

/* ---- Reset / base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--brand-soft), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--sp-3); letter-spacing: -0.01em; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute; left: var(--sp-3); top: -3rem;
  background: var(--brand); color: #fff; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm); z-index: 100; transition: top .15s ease;
}
.skip-link:focus { top: var(--sp-3); text-decoration: none; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 var(--sp-4); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Header --------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding: var(--sp-3) var(--sp-4);
  max-width: 1040px; margin: 0 auto;
}
.brand {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em;
  color: var(--text); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand__mark { display: block; flex: none; }
.brand__name { color: var(--text); }
.brand__name b { color: var(--brand); font-weight: 800; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex: none;
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-muted);
  cursor: pointer; transition: color .15s ease, border-color .15s ease,
            background .15s ease, transform .12s ease;
}
.theme-toggle:hover { color: var(--brand); border-color: var(--brand); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---- Hero ----------------------------------------------------------------- */
.hero { padding: var(--sp-7) 0 var(--sp-5); }
.hero__inner { display: grid; gap: var(--sp-5); align-items: center; }
.hero__copy { text-align: center; }
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--brand); background: var(--brand-soft);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill);
  margin-bottom: var(--sp-4);
}
.hero__eyebrow .ico { width: 15px; height: 15px; }
.hero h1 {
  font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 800;
  margin-bottom: var(--sp-3); line-height: 1.1;
}
.hero p.lede {
  font-size: clamp(1rem, 2.4vw, 1.2rem); color: var(--text-muted);
  max-width: 38ch; margin: 0 auto var(--sp-2);
}
.hero__art { display: flex; justify-content: center; color: var(--brand); }
.hero__art .hero-svg { width: 100%; max-width: 360px; height: auto; }
@media (min-width: 880px) {
  .hero__inner { grid-template-columns: 1.05fr 0.95fr; gap: var(--sp-6); }
  .hero__copy { text-align: left; }
  .hero__copy .hero p.lede, .hero__copy p.lede { margin-left: 0; margin-right: 0; }
}

/* ---- Section heading ------------------------------------------------------ */
.section { padding: var(--sp-5) 0; }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap;
}
.section__head h2 { font-size: 1.4rem; margin: 0; }
.section__head .hint { color: var(--text-faint); font-size: 0.9rem; }

/* ---- Highlight cards ------------------------------------------------------ */
.cards {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.deal {
  position: relative; display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-5); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  color: inherit; text-decoration: none; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  overflow: hidden;
}
.deal::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--brand); opacity: 0; transition: opacity .18s ease;
}
.deal:hover {
  transform: translateY(-3px); text-decoration: none;
  box-shadow: var(--shadow-lg); border-color: var(--border-strong);
}
.deal:hover::before { opacity: 1; }
.deal--accent::before { background: var(--accent); }

.deal__tag {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
}
.deal__tag .ico { width: 16px; height: 16px; flex: none; color: var(--brand); }
.deal--accent .deal__tag .ico { color: var(--accent-strong); }
.deal__title { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.deal__price {
  font-family: var(--font-num); font-size: 1.7rem; font-weight: 800;
  color: var(--accent-strong); font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.deal__note { font-size: 0.86rem; color: var(--text-faint); line-height: 1.45; }
.deal__cta {
  margin-top: auto; font-size: 0.85rem; font-weight: 600; color: var(--brand);
  display: inline-flex; align-items: center; gap: var(--sp-1);
}
.deal:hover .deal__cta { gap: var(--sp-2); }

/* ---- Compare panel (model selector) --------------------------------------- */
.compare {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: var(--sp-6);
  box-shadow: var(--shadow-md);
}
.compare h2 { font-size: 1.4rem; }
.compare p { color: var(--text-muted); margin-top: 0; }
.compare__form {
  display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-4);
}
.field { flex: 1 1 240px; display: flex; flex-direction: column; gap: var(--sp-2); }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }

.select-wrap { position: relative; display: block; }
.select-wrap::after {
  content: ""; position: absolute; right: var(--sp-4); top: 50%;
  width: 9px; height: 9px; border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-65%) rotate(45deg); pointer-events: none;
}
select {
  appearance: none; -webkit-appearance: none; width: 100%;
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-6) var(--sp-3) var(--sp-4); cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select:hover { border-color: var(--brand); }
select:focus-visible { outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring); }
select:disabled { cursor: default; opacity: 0.75; }
.btn.is-disabled { background: var(--border-strong); color: var(--text-faint);
  box-shadow: none; cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font: inherit; font-weight: 600; cursor: pointer;
  padding: var(--sp-3) var(--sp-5); border-radius: var(--r-md);
  border: 1px solid transparent; transition: background .15s ease,
            transform .12s ease, box-shadow .15s ease, color .15s ease;
}
.btn--primary {
  background: var(--brand); color: #fff; box-shadow: var(--shadow-sm);
  align-self: flex-end; flex: none;
}
.btn--primary:hover { background: var(--brand-strong); text-decoration: none;
  box-shadow: var(--shadow-md); }
.btn--primary:active { transform: translateY(1px); }
.btn--ghost {
  background: transparent; color: var(--brand); border-color: var(--border-strong);
}
.btn--ghost:hover { border-color: var(--brand); text-decoration: none; }

/* ---- Empty state ---------------------------------------------------------- */
.empty {
  text-align: center; padding: var(--sp-7) var(--sp-4);
  background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg); color: var(--text-muted);
}
.empty h2 { color: var(--text); }
.empty code {
  background: var(--surface-2); padding: 2px 7px; border-radius: 6px;
  font-size: 0.9em; border: 1px solid var(--border);
}

/* ---- Results page --------------------------------------------------------- */
.back-link {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: 0.9rem; font-weight: 600; color: var(--text-muted);
  margin: var(--sp-5) 0 var(--sp-4);
}
.back-link:hover { color: var(--brand); text-decoration: none; }

.results-head { margin-bottom: var(--sp-5); }
.results-head h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.results-head .sub { color: var(--text-muted); margin: 0; }

/* Province accordion */
.province {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.province[open] { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.province__summary {
  cursor: pointer; list-style: none; display: flex; align-items: center;
  gap: var(--sp-3); padding: var(--sp-4) var(--sp-5);
}
.province__summary::-webkit-details-marker { display: none; }
.province__summary:hover { background: var(--surface-2); }
.province__chevron {
  flex: none; width: 18px; height: 18px; color: var(--text-faint);
  transition: transform .2s ease;
}
.province[open] .province__chevron { transform: rotate(90deg); }
.province__name { font-weight: 700; font-size: 1.05rem; }
.province__price {
  font-family: var(--font-num); font-weight: 700; color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}
.province__price .label { color: var(--text-faint); font-weight: 500;
  font-size: 0.82rem; margin-right: 2px; }
.province__count {
  margin-left: auto; font-size: 0.82rem; color: var(--text-faint);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: var(--r-pill); white-space: nowrap;
}

.province__body { padding: 0 var(--sp-4) var(--sp-4); }

/* Offers: table on desktop, cards on mobile */
.offers { width: 100%; border-collapse: collapse; }
.offers thead th {
  text-align: left; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint);
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border);
}
.offers tbody td {
  padding: var(--sp-3); border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.offers tbody tr:last-child td { border-bottom: 0; }
.offers tbody tr { transition: background .12s ease; }
.offers tbody tr:hover { background: var(--surface-2); }
.offers tbody tr.is-best td { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.cell-price {
  font-family: var(--font-num); font-weight: 700; font-size: 1.05rem;
  color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.best-flag {
  display: inline-block; font-size: 0.65rem; font-weight: 700; color: var(--accent-strong);
  text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px;
}
.cell-dealer { font-weight: 600; }
.cell-city { color: var(--text-muted); }
.cell-title { color: var(--text-muted); font-size: 0.9rem; max-width: 22ch; }
.cell-date { color: var(--text-faint); font-size: 0.85rem; white-space: nowrap; }

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: 0.74rem; font-weight: 600; padding: 2px 9px;
  border-radius: var(--r-pill); border: 1px solid var(--neutral-bd);
  background: var(--neutral-bg); color: var(--neutral-fg); white-space: nowrap;
}
.chip--nuevo { background: var(--nuevo-bg); color: var(--nuevo-fg); border-color: var(--nuevo-bd); }
.chip--km0 { background: var(--km0-bg); color: var(--km0-fg); border-color: var(--km0-bd); }
.chip--ocasion { background: var(--ocasion-bg); color: var(--ocasion-fg); border-color: var(--ocasion-bd); }
.chip--dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}

.offer-link {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-weight: 600; font-size: 0.86rem; white-space: nowrap;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); color: var(--brand);
  transition: background .15s ease, border-color .15s ease;
}
.offer-link:hover { background: var(--brand-soft); border-color: var(--brand);
  text-decoration: none; }
.offer-link svg { width: 13px; height: 13px; }

/* Legend */
.legend {
  margin-top: var(--sp-5); padding: var(--sp-4) var(--sp-5);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text-muted); font-size: 0.88rem;
  line-height: 1.6;
}
.legend strong { color: var(--text); }
.legend .legend__row { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-bottom: var(--sp-2); }

/* ---- Footer --------------------------------------------------------------- */
.site-footer {
  margin-top: var(--sp-8); padding: var(--sp-5) 0; border-top: 1px solid var(--border);
  color: var(--text-faint); font-size: 0.86rem; text-align: center;
}

/* ---- Mobile: offers become stacked cards ---------------------------------- */
@media (max-width: 720px) {
  .offers, .offers thead, .offers tbody, .offers tr, .offers td { display: block; }
  .offers thead { position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); }
  .offers tbody tr {
    border: 1px solid var(--border); border-radius: var(--r-md);
    margin-bottom: var(--sp-3); padding: var(--sp-3); background: var(--surface);
  }
  .offers tbody tr:hover { background: var(--surface); }
  .offers tbody td { border: 0; padding: var(--sp-1) 0;
    display: flex; align-items: center; gap: var(--sp-3); }
  .offers tbody td::before {
    content: attr(data-label); flex: none; width: 92px;
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-faint);
  }
  .cell-title { max-width: none; }
  .offer-link { width: 100%; justify-content: center; }
}

/* ---- Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
