/* Comparativa Geek. Loads after tokens.css, styles.css and specs.css.
   Mobile first: the two models stay side by side at every width. Model names stick under the header while you scroll.
   Content on Paper (black in dark mode, as .band). Gold only for the difference dot and the footnote links. */

/* ---------- pickers (shown by JS; without JS the static names are enough) ---------- */
.cmp-pickers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--eg-space-3) var(--eg-space-4); }
/* Hidden until JS runs, but its space is reserved so the page does not jump. Without scripting the space is released. */
.cmp-pickers[hidden] { display: grid; visibility: hidden; }
@media (scripting: none) { .cmp-pickers[hidden], .cmp-chips[hidden] { display: none; } }
/* Chip bar above the pickers: brand row, then the families of the chosen brand. Space is kept while hidden so the page does not move. */
.cmp-chips { margin-bottom: var(--eg-space-4); min-height: var(--eg-chip-h); }
.s-filter.cmp-chips[hidden] { display: grid; visibility: hidden; }
.cmp-pick { position: relative; }
.cmp-pick label { display: block; margin-bottom: var(--eg-space-1); color: var(--eg-fg-muted); font-size: var(--eg-size-xs); }
/* Own arrow: the native one is removed. Drawn with borders (the landing CSP blocks data: images). It sits on the select's centre line, 24px above the bottom. */
.cmp-pick::after {
  content: ""; position: absolute; right: var(--eg-space-4); bottom: 21px; width: 8px; height: 8px;
  border-right: 2px solid var(--eg-fg-muted); border-bottom: 2px solid var(--eg-fg-muted);
  transform: rotate(45deg); pointer-events: none; transition: border-color var(--eg-dur-fast) var(--eg-ease-in-out);
}
@media (hover: hover) { .cmp-pick:hover::after { border-color: var(--eg-fg); } }
.cmp-pick select {
  -webkit-appearance: none; appearance: none;
  width: 100%; min-height: var(--eg-field-h); padding: 0 var(--eg-space-7) 0 var(--eg-field-pad);
  border: 1px solid var(--eg-fg-muted); border-radius: var(--eg-radius-control);
  background: transparent; color: var(--eg-fg);
  font: inherit; font-size: var(--eg-field-size);
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color var(--eg-dur-fast) var(--eg-ease-in-out), background-color var(--eg-dur-fast) var(--eg-ease-in-out);
}
/* Hover and press raise the border from muted to full ink. */
@media (hover: hover) { .cmp-pick select:hover { border-color: var(--eg-fg); } }
.cmp-pick select:active { border-color: var(--eg-fg); background-color: color-mix(in srgb, var(--eg-fg) 6%, transparent); }
.cmp-pick select:disabled { opacity: 0.5; cursor: not-allowed; }
.cmp-only { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: var(--eg-space-3); min-height: 44px; font-size: var(--eg-size-sm); cursor: pointer; }
.cmp-only input { flex: none; width: 24px; height: 24px; margin: 0; border-radius: 6px; accent-color: var(--eg-gold-deep); cursor: pointer; transition: box-shadow var(--eg-dur-fast) var(--eg-ease-in-out); }
/* The checkbox gets a soft halo on hover and press (the label is the target). */
@media (hover: hover) { .cmp-only:hover input { box-shadow: 0 0 0 5px color-mix(in srgb, var(--eg-accent-text) 14%, transparent); } }
.cmp-only:active input { box-shadow: 0 0 0 5px color-mix(in srgb, var(--eg-accent-text) 26%, transparent); }
.cmp-legend { margin-top: var(--eg-space-4); max-width: 62ch; color: var(--eg-fg-muted); font-size: var(--eg-size-xs); }

/* ---------- sticky model names ---------- */
/* Keyboard focus must not hide under the header bar plus the sticky names (WCAG 2.4.11). */
html:has(#cmp) { scroll-padding-top: 160px; }
.cmp-names {
  position: sticky; top: 64px; z-index: 5;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--eg-space-4);
  margin-top: var(--eg-space-4); padding: var(--eg-space-3) 0;
  background: var(--eg-bg); border-bottom: 1px solid var(--eg-hairline);
}
:root[data-theme="dark"] .cmp-names { background: var(--eg-black); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cmp-names { background: var(--eg-black); } }
/* Shadow once the names are stuck under the bar: a scroll-state query (Chrome 133+). Other browsers keep the hairline. */
@supports (container-type: scroll-state) {
  .cmp-names { container-type: scroll-state; }
  .cmp-names::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
    box-shadow: 0 12px 16px -14px rgb(0 0 0 / 0.45);
    transition: opacity var(--eg-dur-fast) var(--eg-ease-in-out);
  }
  @container scroll-state(stuck: top) { .cmp-names::after { opacity: 1; } }
}
.cmp-corner { display: none; }
.cmp-name { min-width: 0; }
.cmp-meta { display: block; color: var(--eg-fg-muted); font-size: var(--eg-size-xs); }
.cmp-model { display: block; font-size: var(--eg-size-sm); font-weight: var(--eg-weight-strong); line-height: 1.25; overflow-wrap: anywhere; text-wrap: balance; }

/* ---------- groups and rows ---------- */
.cmp-group { margin-top: var(--eg-space-7); }
.cmp-group h3 { font-size: var(--eg-size-lg); line-height: 1.25; }
/* Lab groups (wave 13): one plain line under the heading says whose figures they are and when they are compared. */
.cmp-gnote { margin-top: var(--eg-space-1); max-width: 64ch; color: var(--eg-fg-muted); font-size: var(--eg-size-sm); line-height: 1.4; text-wrap: pretty; }
.cmp-t { width: 100%; margin-top: var(--eg-space-3); border-collapse: collapse; }
.cmp-t, .cmp-t tbody, .cmp-t tr { display: block; }
.cmp-t .cmp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--eg-space-4); padding: var(--eg-space-3) 0; border-top: 1px solid var(--eg-hairline); }
.cmp-t tbody > .cmp-row:last-child { border-bottom: 1px solid var(--eg-hairline); }
.cmp-row th {
  grid-column: 1 / -1; margin-bottom: var(--eg-space-1);
  color: var(--eg-fg-muted); font-size: var(--eg-size-xs); font-weight: var(--eg-weight-strong); text-align: left;
}
.cmp-row td { min-width: 0; font-size: var(--eg-size-sm); line-height: 1.4; overflow-wrap: anywhere; color: var(--eg-fg-muted); font-variant-numeric: tabular-nums; }
.cmp-hint { display: block; font-weight: var(--eg-weight-regular); }
.cmp-note { display: block; margin-top: var(--eg-space-1); color: var(--eg-fg-muted); font-size: var(--eg-size-xs); line-height: 1.35; }
.cmp-na { color: var(--eg-fg-muted); }

/* A difference is quiet: a small gold dot by the data point's name, and the values at full ink. Equal values stay grey. */
.cmp-row[data-diff] td { color: var(--eg-fg); }
.cmp-row[data-diff] th::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 var(--eg-space-2) 1px 0;
  border-radius: 50%; background: var(--eg-accent-text);
}
.cmp-for .cmp-row td, .cmp-links td { color: var(--eg-fg); }
.cmp-links a { text-underline-offset: 0.2em; -webkit-tap-highlight-color: transparent; transition: opacity var(--eg-dur-fast) var(--eg-ease-out); }
@media (hover: hover) { .cmp-links a:hover { text-decoration-thickness: 2px; } }
.cmp-links a:active { opacity: 0.7; transition-duration: var(--eg-dur-press); }

.fn a { color: var(--eg-accent-text); }
.cmp-verified { margin-top: var(--eg-space-6); max-width: 62ch; color: var(--eg-fg-muted); font-size: var(--eg-size-xs); }

/* "Show differences only" (JS): hide equal rows, then groups without a difference. */
.cmp-only-diff .cmp-group:not(.cmp-for) .cmp-row:not([data-diff]) { display: none; }
.cmp-only-diff .cmp-group:not(.cmp-for):not(:has([data-diff])) { display: none; }

/* ---------- pair list ---------- */
.cmp-pairs { margin-top: var(--eg-space-3); border-top: 1px solid var(--eg-hairline); }
.cmp-pairs a { display: flex; align-items: center; min-height: 56px; padding: var(--eg-space-3) 0; border-bottom: 1px solid var(--eg-hairline); font-size: var(--eg-size-md); font-weight: var(--eg-weight-strong); text-decoration: none; -webkit-tap-highlight-color: transparent; transition: transform var(--eg-dur-fast) var(--eg-ease-out); }
.cmp-pairs a:active { transform: scale(var(--eg-press-scale-lg)); transition-duration: var(--eg-dur-press); }
.cmp-pairs a[aria-current="page"]::after { content: "\2713" / ""; margin-left: auto; color: var(--eg-accent-text); }
@media (hover: hover) { .cmp-pairs a:hover span { text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; } }

/* ---------- Ficha and index entry point ---------- */
.s-compare { margin-top: var(--eg-space-3); }

/* ---------- narrow phones: one picker per row so the full model name shows ---------- */
@media (max-width: 719.98px) {
  .cmp-pickers { grid-template-columns: 1fr; }
}

/* ---------- desktop: label column + two models ---------- */
@media (min-width: 720px) {
  .cmp-pickers { grid-template-columns: minmax(160px, 0.9fr) 1fr 1fr; align-items: end; }
  .cmp-pickers .cmp-pick:first-child { grid-column: 2; }
  .cmp-pickers .cmp-pick:nth-child(2) { grid-column: 3; }
  .cmp-only { grid-column: 1; grid-row: 1; align-self: end; }
  .cmp-names { grid-template-columns: minmax(160px, 0.9fr) 1fr 1fr; padding-block: var(--eg-space-4); }
  .cmp-corner { display: block; }
  .cmp-model { font-size: var(--eg-size-lg); }
  .cmp-meta { font-size: var(--eg-size-sm); }
  .cmp-t .cmp-row { grid-template-columns: minmax(160px, 0.9fr) 1fr 1fr; padding-block: var(--eg-space-4); }
  .cmp-row th { grid-column: auto; margin-bottom: 0; padding-right: var(--eg-space-3); color: var(--eg-fg); font-size: var(--eg-size-sm); }
  .cmp-hint { color: var(--eg-fg-muted); font-size: var(--eg-size-xs); }
  .cmp-row td { font-size: var(--eg-size-md); }
  .cmp-note { font-size: var(--eg-size-sm); }
  .cmp-pairs a { font-size: var(--eg-size-lg); }
}

@media (prefers-contrast: more) {
  .cmp-row, .cmp-names, .cmp-pairs, .cmp-pairs a { border-color: var(--eg-fg-muted); }
  .cmp-row td { color: var(--eg-fg); }
}

/* ---------- Phase D: model image above each column, four key figures under the sticky names ---------- */
.cmp-heads { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--eg-space-4); margin-top: var(--eg-space-5); }
.cmp-head { min-width: 0; }
.cmp-head--bare { display: flex; flex-direction: column; justify-content: flex-end; }
/* One plate for every image on paper: white in light, ink-2 in dark (--eg-well, shared/tokens.css). */
.cmp-plate { display: grid; place-items: center; aspect-ratio: 1 / 1; max-height: 320px; padding: 0; background: var(--eg-well); border-radius: var(--eg-radius-card); overflow: hidden; }
.cmp-plate picture { display: contents; }
.cmp-plate img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cmp-buy { margin-top: var(--eg-space-2); }
.cmp-buy .eg-more { display: inline-block; padding-block: 10px; font-size: var(--eg-size-sm); line-height: 1.3; }
.cmp-buy .eg-more::after { display: inline; }
.cmp-imgcap { grid-column: 1 / -1; margin-top: var(--eg-space-2); color: var(--eg-fg-muted); font-size: var(--eg-size-xs); }
.cmp-figs { margin-top: var(--eg-space-3); }
.cmp-figrow { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--eg-space-4); padding: var(--eg-space-4) 0; border-bottom: 1px solid var(--eg-hairline); }
.cmp-fig { display: grid; align-content: start; gap: var(--eg-space-1); min-width: 0; }
.cmp-fig-v { font-size: var(--eg-size-lg); font-weight: var(--eg-weight-strong); line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-wrap: balance; }
.cmp-fig-l { color: var(--eg-fg-muted); font-size: var(--eg-size-xs); line-height: 1.3; }
.cmp-fig-l .fn { line-height: 0; }
.cmp-fig-l .fn a { margin: -10px 0; vertical-align: 0.3em; }
.cmp-fig-l .fn a + a { margin-left: var(--eg-space-1); }
.cmp-fig.cmp-na .cmp-fig-v { color: var(--eg-fg-muted); font-weight: var(--eg-weight-regular); }
@media (min-width: 720px) {
  .cmp-heads { grid-template-columns: minmax(160px, 0.9fr) 1fr 1fr; }
  .cmp-imgcap { grid-column: 2 / -1; }
  .cmp-figrow { grid-template-columns: minmax(160px, 0.9fr) 1fr 1fr; padding-block: var(--eg-space-5); }
  .cmp-fig-v { font-size: var(--eg-size-xl); }
  .cmp-fig-l { font-size: var(--eg-size-sm); }
}

/* Pair pages: the H1 is "A vs B". It steps down one size when the two names are long (data-long, more than 48 characters; set by compare.mjs and by compare.js), and it wraps, never overflows. "Comparativa Geek" moves to the line above. */
.cmp-eyebrow { margin: 0 0 var(--eg-space-2); color: var(--eg-fg-muted); font-size: var(--eg-size-md); }
.s-hero h1.cmp-h1 { max-width: 28ch; font-size: var(--eg-size-xl); text-wrap: balance; overflow-wrap: anywhere; }
.s-hero h1.cmp-h1[data-long] { font-size: var(--eg-size-lg); }
@media (min-width: 720px) { .s-hero h1.cmp-h1 { max-width: 34ch; font-size: var(--eg-size-2xl); } .s-hero h1.cmp-h1[data-long] { font-size: var(--eg-size-xl); } }
@media (min-width: 1040px) { .s-hero h1.cmp-h1 { max-width: 40ch; } .s-hero h1.cmp-h1[data-long] { font-size: var(--eg-size-2xl); } }
