/* Light only, deliberately. Li Auto's site is white throughout, and the dark
   variant fought the product photography — press shots are shot on white, so
   a dark page put a hard edge around every car. No prefers-color-scheme block:
   this is a committed single look, not a missing one. */
:root {
  --ink: #0a0a0a;
  --ink-soft: #6b6b6b;
  --line: #ebebe9;
  --bg: #ffffff;
  --bg-soft: #f6f6f4;
  --accent: #c0392b;
  --radius: 2px;
  /* Tile grid: a slight inset and gap so the cards read as separate cards,
     with corners rounded to match. Changing --tile-gap is safe — the wide
     tiles' heights are derived from it (see .card--w2/.card--w4). */
  --tile-gap: 10px;
  --tile-radius: 12px;
  --bar-height: 56px;
}

* { box-sizing: border-box; }

/* Available to screen readers and crawlers, invisible on screen. Used for the
   homepage H1, which the full-bleed grid design has no room to show. */
.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;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Logo pinned left, the full brand list next (the only flexible item, so it
   takes the slack and scrolls when it runs out), utility links pinned right. */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--bar-height);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
}

.topbar-side {
  display: flex;
  align-items: center;
  gap: 18px;
  /* Equal-basis side columns so the brand strip sits on the bar's true centre.
     With `flex: none` the sides kept their natural widths (logo 167px vs links
     181px) and the gap between them was not symmetric, leaving the brands ~7px
     off. Flex items default to min-width:auto, so neither side can be squeezed
     below its own content. */
  flex: 1 1 0;
}

.topbar-right { justify-content: flex-end; }

/* The brand list is the only flexible element, so it absorbs the spare width
   and the logo stays pinned left with the utility links pinned right.
   `min-width: 0` is what lets it shrink below its content width instead of
   pushing the utility links off the bar. */
.topbar-brands {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* `safe` matters: with plain `center`, once the list overflows its box the
     overflow is split both sides and the first brands become unreachable —
     you cannot scroll back past the start. `safe center` centres while it
     fits and falls back to flex-start the moment it does not. */
  justify-content: safe center;
}

.topbar-brands::-webkit-scrollbar { display: none; }

.topbar-brands a {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

/* Base colour is already full black, so hover needs a different signal. */
.topbar-brands a:hover { opacity: 0.55; }

.topbar-link {
  /* A step smaller than the brand strip and uppercase to match it: these are
     secondary destinations, and the size difference says so without needing a
     second colour. */
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.topbar-link:hover { opacity: 0.55; }

.topbar-logo {
  display: flex;
  align-items: center;
  flex: 1 1 0;
}

.topbar-logo img {
  /* The mark carries ~10% padding of its own, so the box is bigger than the
     visible logo. The earlier version needed 26px because of its stacked 中国
     block; this one is plain bold letterforms plus a spark, so it reads clean
     smaller and sits better against 14px nav text. */
  height: 27px;
  width: auto;
  display: block;
}

@media (max-width: 620px) {
  .topbar { padding: 0 14px; gap: 14px; }
  .topbar-side { gap: 12px; }
  .topbar-link { font-size: 13px; }
  .topbar-logo img { height: 23px; }
  .topbar-brands { gap: 13px; }
  .topbar-brands a { font-size: 13px; }
  /* The utility links go rather than the brands: the brand strip scrolls, so
     it survives a narrow bar intact, while these two would eat most of it.
     Both stay reachable — /comparar is linked from the homepage and from every
     model page, /concesionarios from the footer. */
  .topbar-right { display: none; }
}

.hero {
  padding: 96px 0 64px;
  border-bottom: 1px solid var(--line);
}

.hero h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}

.hero-sub {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 640px;
  line-height: 1.5;
  margin: 0;
}

.section {
  padding: 0 0 1px;
  border-bottom: 1px solid var(--line);
}

.section-head {
  padding-top: 56px;
  padding-bottom: 24px;
}

.section-head h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

/* Near-full-bleed grid: a slight page inset and gap between tiles, corners
   rounded. Max 4 tiles per row. Widths come from `card--w2` / `card--w4`
   classes that the SERVER computes (see computeSpans in server.js) so every
   row sums to exactly 4 columns; an empty grid cell would render as page
   background. */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--tile-gap);
  /* Equal inset all round, so the rounded corners are not flush against the
     section's bottom rule. */
  padding: 0 var(--tile-gap) var(--tile-gap);
}

.card {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--tile-radius);
  background: var(--bg-soft);
  display: block;
}

/* Rhythm: [big, small, small] then a row of four equal tiles, repeating —
   the same cadence as Li Auto's vehicle grid.

   The wide tile keeps the row's HEIGHT and only doubles its WIDTH: aspect-
   locked cards do NOT stretch to fill a taller row, so a mismatch leaves blank
   page under the short tiles.

   With a gap this can no longer be a fixed ratio. A span-2 tile is
   `2·col + gap` wide, so `aspect-ratio: 8/3` would make it 3·gap/8 TALLER than
   its 4/3 neighbours — a few px of misalignment, which rounded corners make
   obvious. Percentage padding resolves against the element's own width, so the
   height is expressed exactly instead:

     col    = (W - 3·gap) / 4          target height = 3·col/4
     span-2 own width = W/2 - gap/2  ->  h = 37.5%  - 0.375·gap
     span-4 own width = W            ->  h = 18.75% - 0.5625·gap

   Verified: with gap 0 these collapse back to the old 8/3 and 16/3. */
.card--w2,
.card--w4 {
  aspect-ratio: auto;
}

.card--w2::before,
.card--w4::before {
  content: "";
  display: block;
}

.card--w2 {
  grid-column: span 2;
}
.card--w2::before {
  padding-top: calc(37.5% - 0.375 * var(--tile-gap));
}

/* Only ever used to close out a final row that would otherwise be short. */
.card--w4 {
  grid-column: span 4;
}
.card--w4::before {
  padding-top: calc(18.75% - 0.5625 * var(--tile-gap));
}

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .card--w2, .card--w4 { grid-column: span 2; }
  /* Full-width and alone on the row here, so no neighbour to match — back to a
     plain ratio, and the spacer must be removed or it would stack with it. */
  .card--w2, .card--w4 { aspect-ratio: 16 / 9; }
  .card--w2::before, .card--w4::before { content: none; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  /* One per row, so every tile shares the same 4:3 crop. */
  .grid .card { grid-column: span 1; }
  .card--w2, .card--w4 { aspect-ratio: 4 / 3; }
}

/* A lone tile would otherwise span all four columns and become an extreme
   letterbox — the aspect ratio that flatters a row of four is wrong for one.
   Capped and centred instead, at the same 4:3 the small tiles use. Two tiles
   get the same treatment at half the cap each. */
.grid--n1 {
  grid-template-columns: minmax(0, 620px);
  justify-content: center;
}

.grid--n2 {
  grid-template-columns: repeat(2, minmax(0, 460px));
  justify-content: center;
}

.grid--n1 .card,
.grid--n2 .card {
  grid-column: span 1;
  aspect-ratio: 4 / 3;
}

/* The wide variants size themselves with a ::before spacer; it has to go or it
   would stack on top of the aspect-ratio above. */
.grid--n1 .card::before,
.grid--n2 .card::before {
  content: none;
}

/* Brand pages centre their header and section titles. Scoped to .page-brand so
   the homepage grid headings stay left-aligned. */
.page-brand .brand-logo {
  margin-left: auto;
  margin-right: auto;
  object-position: center;
}

.page-brand .page-title,
.page-brand .hero-sub,
.page-brand .section-head,
.page-brand .breadcrumb {
  text-align: center;
}

.page-brand .hero-sub {
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 700px) {
  .grid--n2 { grid-template-columns: minmax(0, 460px); }
}

.card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.card:hover .card-image {
  transform: scale(1.04);
}

.card-body {
  position: absolute;
  inset: 0;
  padding: 8% 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
}

.card-name {
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 12px rgba(0, 0, 0, 0.25);
  margin-bottom: 4px;
}

.card-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 12px rgba(0, 0, 0, 0.25);
}

/* Press-announced models have no photograph available anywhere, so they are
   listed as rows instead of being forced into the photo grid as blank tiles. */
.plist {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.prow {
  display: grid;
  grid-template-columns: 96px 1fr auto auto;
  gap: 20px;
  align-items: baseline;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.prow-when {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.prow-name {
  font-size: 16px;
  font-weight: 600;
}

.prow-type,
.prow-price {
  font-size: 13px;
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  .prow {
    grid-template-columns: 1fr auto;
    gap: 4px 16px;
  }
  .prow-when { grid-column: 1 / -1; }
  .prow-type { grid-column: 1; }
}

.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  padding: 3px 7px;
  margin-bottom: 10px;
  width: fit-content;
}

.note {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 20px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
}

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

.chip--brand {
  font-size: 12px;
  padding: 6px 14px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 72px 0 0;
  margin: 0;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.wrap--narrow {
  max-width: 880px;
}

.section--first {
  padding-top: 72px;
}

.section--top {
  padding-top: calc(var(--bar-height) + var(--tile-gap));
}

.brand-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 18px;
}

.page-title {
  font-size: clamp(28px, 4.5vw, 44px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 12px;
}

/* Model page — full-bleed hero with the name overlaid, then a big-number spec
   strip, mirroring Li Auto's individual vehicle pages. */
.mhero {
  position: relative;
  width: 100%;
  height: min(78vh, 760px);
  overflow: hidden;
  background: var(--bg-soft);
}

.mhero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mhero-copy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12vh 24px 0;
}

.mhero-brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  margin: 0 0 10px;
}

.mhero-title {
  font-size: clamp(34px, 6vw, 68px);
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  margin: 0 0 14px;
}

.mhero-sub {
  font-size: clamp(14px, 1.6vw, 17px);
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  margin: 0;
}

.specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-bottom: 1px solid var(--line);
}

.spec {
  padding: 44px 24px;
  text-align: center;
  border-right: 1px solid var(--line);
}

.spec:last-child { border-right: none; }

.spec-value {
  font-size: clamp(24px, 3.4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.spec-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 10px;
}

.specs-note {
  margin-top: 16px;
}

.mblock {
  padding: 64px 0 8px;
}

.mblock-title {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}

.mblock-text {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 28px;
}

.mlinks {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.mlinks .cta { margin-top: 0; }

@media (max-width: 640px) {
  .mhero { height: 58vh; }
  .mhero-copy { padding-top: 14vh; }
  .spec { padding: 32px 16px; }
}

.tag--onsale {
  color: var(--ink);
  border-color: var(--ink);
}

.btn {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--ink);
  background: var(--bg-soft);
}

.cta {
  display: inline-block;
  margin-top: 24px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
  width: fit-content;
}

.footer {
  padding: 32px 0 64px;
}

.footer p {
  font-size: 12px;
  color: var(--ink-soft);
}

.footer a {
  text-decoration: underline;
}

/* ---- Galería de modelo ---- */
.gal {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--tile-gap);
  padding: 0 var(--tile-gap);
}

.gal-item {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--tile-radius);
  background: var(--bg-soft);
}

.gal-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.gal-item:hover img { transform: scale(1.03); }

/* CSS-only lightbox: hidden until its id is the :target. No JS needed. */
.gal-full {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.92);
  padding: 40px 20px;
  align-items: center;
  justify-content: center;
}

.gal-full:target { display: flex; }

.gal-full img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.gal-close {
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius);
}

.gal-close:hover { background: rgba(255, 255, 255, 0.12); }

@media (max-width: 700px) {
  .gal { grid-template-columns: 1fr; }
}

/* ---- Comparador ---- */
.chip--action {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.chip--action:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cmp-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 24px 0 32px;
}

.cmp-form select {
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: var(--radius);
  max-width: 100%;
}

.cmp-form button {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 22px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  cursor: pointer;
}

/* Wide tables must scroll inside their own container, never the page body. */
.cmp-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.cmp {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.cmp th,
.cmp td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.cmp thead th {
  position: sticky;
  top: 52px; /* clears the fixed topbar */
  background: var(--bg);
  z-index: 2;
  border-bottom: 1px solid var(--line);
}

.cmp tbody th[scope="row"] {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

.cmp td {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.cmp-grouprow th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--bg-soft);
  padding: 10px 18px;
}

.cmp-head {
  display: block;
  min-width: 150px;
}

.cmp-head img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--tile-radius);
  margin-bottom: 10px;
}

.cmp-brand {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cmp-model {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.cmp-best {
  font-weight: 700;
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
}

.cmp-na { color: var(--ink-soft); }

.cmp-sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-soft);
  margin-top: 2px;
}

.cmp-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 9px;
  cursor: help;
}

/* ---- Concesionarios ---- */
.dlr-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.dlr {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.dlr-name { font-size: 16px; font-weight: 600; }
.dlr-addr { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }

.dlr-brands { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.dlr-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}

.dlr-meta { text-align: right; flex: none; }
.dlr-dist { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.dlr-link {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
  text-decoration: underline;
}

.dlr-link:hover { color: var(--ink); }

/* ---- Cambios de precio ---- */
.pchg {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.pchg--down { color: #0d7a3d; background: rgba(13, 122, 61, 0.12); }
.pchg--up { color: var(--accent); background: rgba(192, 57, 43, 0.12); }
.pchg-when { font-weight: 400; opacity: 0.8; }

/* On photo tiles the badge sits over the image, so it needs its own ground. */
.card-sub .pchg {
  background: rgba(255, 255, 255, 0.92);
  text-shadow: none;
}

.drops { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

.drop { border-bottom: 1px solid var(--line); }

.drop a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px 0;
  flex-wrap: wrap;
}

.drop a:hover .drop-name { text-decoration: underline; }
.drop-name { font-size: 15px; font-weight: 600; }
.drop-figs { font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.drop-figs strong { color: var(--ink); }

.credit {
  font-size: 11px;
  color: var(--ink-soft);
  margin: 20px 0 0;
  line-height: 1.5;
}

.credit a {
  text-decoration: underline;
}
