/* ---------------------------------------------------------------------------
   Design tokens. Dark mode is a selected set of steps for the dark surface,
   not an automatic inversion. Declared under both the media query (OS setting)
   and the [data-theme] scope (explicit toggle), so the toggle wins either way.
   --------------------------------------------------------------------------- */
:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --muted:          #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,.10);
  --series-1:       #2a78d6;
  --good:           #006300;
  --critical:       #d03b3b;
  --accent-wash:    #eef4fd;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --muted:          #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,.10);
    --series-1:       #3987e5;
    --good:           #0ca30c;
    --critical:       #e66767;
    --accent-wash:    #16202c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page:           #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --muted:          #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,.10);
  --series-1:       #3987e5;
  --good:           #0ca30c;
  --critical:       #e66767;
  --accent-wash:    #16202c;
}

/* --------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 20px; }

.skip {
  position: absolute; left: -9999px;
  background: var(--surface-1); padding: 10px 16px; z-index: 10;
}
.skip:focus { left: 12px; top: 12px; }

.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;
}

a { color: var(--series-1); }
a:hover { text-decoration-thickness: 2px; }

h1 { font-size: 1.75rem; line-height: 1.25; margin: .4em 0 .3em; }
h2 { font-size: 1.15rem; margin: 2em 0 .7em; }

.lede { color: var(--text-secondary); max-width: 62ch; margin-top: 0; }
.note { color: var(--muted); font-size: .8125rem; margin: 8px 0 0; }
.muted { color: var(--muted); }
.empty { color: var(--text-secondary); padding: 32px 0; }

/* Header ------------------------------------------------------------------ */
.site-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.header-inner { display: flex; align-items: center; gap: 20px; padding-block: 14px; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); text-decoration: none; }
.nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: .875rem; margin-left: auto; }
.nav a { color: var(--text-secondary); text-decoration: none; }
.nav a:hover { color: var(--text-primary); text-decoration: underline; }
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-secondary); cursor: pointer; font-size: .9rem;
  width: 32px; height: 32px; line-height: 1;
}

/* Breadcrumbs ------------------------------------------------------------- */
.crumbs { font-size: .8125rem; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--text-secondary); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Hero + sections --------------------------------------------------------- */
.hero { padding: 8px 0 4px; }
.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-head h2 { margin-bottom: .7em; }
.more { font-size: .875rem; text-decoration: none; white-space: nowrap; }
.more:hover { text-decoration: underline; }

/* Product page ------------------------------------------------------------ */
.product-head { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.product-img {
  width: 220px; height: 220px; object-fit: contain;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.product-headline { flex: 1 1 320px; min-width: 0; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .06em; font-size: .75rem;
  color: var(--muted); margin: 0;
}

.stat-row { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 18px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* Proportional figures on stat values — tabular-nums makes large numbers loose. */
.stat-value { font-size: 1.5rem; font-weight: 650; line-height: 1.15; }
.stat-sub { font-size: .8125rem; color: var(--text-secondary); }

.delta-down { color: var(--good); }
.delta-up   { color: var(--critical); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8125rem; font-weight: 600; border-radius: 999px;
  padding: 4px 12px; margin-top: 16px;
}
.badge-good { background: var(--accent-wash); color: var(--good); }

/* Tables ------------------------------------------------------------------ */
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.price { font-weight: 650; }
.offer-table tr.best td { background: var(--accent-wash); }
.offer-table tr.best .price { color: var(--good); }

.stock.in  { color: var(--good); font-size: .8125rem; }
.stock.out { color: var(--muted); font-size: .8125rem; }

.btn {
  display: inline-block; background: var(--series-1); color: #fff;
  text-decoration: none; font-size: .8125rem; font-weight: 600;
  padding: 7px 14px; border-radius: 7px; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }

.listing-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text-primary); }
.listing-link:hover span { text-decoration: underline; }
.listing-link img { border-radius: 6px; object-fit: contain; background: var(--surface-1); flex: none; }

.table-view { margin-top: 14px; }
.table-view summary { cursor: pointer; font-size: .875rem; color: var(--text-secondary); }
.history-table { margin-top: 10px; max-width: 380px; }

/* Cards ------------------------------------------------------------------- */
.card-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.card { display: flex; }
.card-title { flex: 1 1 auto; }
.card a {
  display: flex; flex-direction: column; gap: 6px; height: 100%; width: 100%;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; text-decoration: none; color: var(--text-primary);
}
.card a:hover { border-color: var(--baseline); }
.card img { width: 100%; height: 110px; object-fit: contain; }
.card-title { font-size: .875rem; line-height: 1.35; }
.card-price { font-weight: 650; font-size: .9375rem; }
.card-price .was { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: .8125rem; }
.card-drop { color: var(--good); font-size: .8125rem; font-weight: 600; }

.cat-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.cat-grid a {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; padding: 14px 16px; text-decoration: none; color: var(--text-primary);
}
.cat-grid a:hover { border-color: var(--baseline); }
.cat-count { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Alert form -------------------------------------------------------------- */
.alert-signup {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px; margin-top: 40px;
}
.alert-signup h2 { margin-top: 0; }
.alert-form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.alert-form input {
  padding: 9px 12px; border: 1px solid var(--baseline); border-radius: 7px;
  background: var(--page); color: var(--text-primary); font: inherit; font-size: .9375rem;
}
.alert-form input[type=email] { flex: 1 1 240px; }
.alert-form input[type=number] { width: 110px; font-variant-numeric: tabular-nums; }
.alert-form button {
  background: var(--series-1); color: #fff; border: 0; border-radius: 7px;
  padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer;
}

/* Pager + footer ---------------------------------------------------------- */
.pager { display: flex; gap: 18px; align-items: center; justify-content: center;
         margin: 28px 0; font-size: .875rem; color: var(--text-secondary); }

.site-footer {
  margin-top: 56px; padding: 24px 0 40px;
  border-top: 1px solid var(--border); background: var(--surface-1);
}
.disclosure { font-size: .8125rem; color: var(--text-secondary); max-width: 70ch; }
.site-footer .meta { font-size: .75rem; color: var(--muted); }
.site-footer a { color: var(--text-secondary); }

@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  .product-img { width: 100%; height: 200px; }
  .offer-table th:nth-child(2), .offer-table td:nth-child(2) { display: none; }
  .nav { width: 100%; margin-left: 0; }
}

/* Prose pages (about, privacy) --------------------------------------------- */
.prose { max-width: 66ch; }
.prose h2 { font-size: 1.05rem; margin-top: 1.8em; }
.prose p, .prose li { color: var(--text-secondary); }
.prose li { margin-bottom: 4px; }

/* Converted price shown beside a non-euro offer ---------------------------- */
.conv { display: block; font-size: .75rem; font-weight: 400; color: var(--muted); }

/* Pre-launch notice ------------------------------------------------------- */
.prelaunch {
  background: var(--accent-wash);
  border-bottom: 1px solid var(--border);
  margin: -28px 0 28px;
  padding: 11px 0;
  font-size: .8125rem;
  color: var(--text-secondary);
}
.btn-disabled {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); cursor: default; font-weight: 500;
}
.btn-disabled:hover { filter: none; }

/* --- chart (generated from src/chart.py) --- */

.chart { margin: 0 0 8px; }
.chart-title { font-size: .8125rem; color: var(--text-secondary); margin-bottom: 6px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid, .chart .baseline { stroke: var(--gridline); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); }
.chart .series { stroke: var(--series-1); stroke-width: 2;
                 stroke-linejoin: round; stroke-linecap: round; }
.chart .pt-now { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .pt-low { fill: var(--surface-1); stroke: var(--series-1); stroke-width: 2; }
.chart .axis { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .lbl  { font-size: 12px; font-weight: 600; fill: var(--text-primary); }
.chart .lbl-low { font-weight: 500; fill: var(--text-secondary); }
.chart .hit  { fill: transparent; cursor: crosshair; }
/* SVG elements do not honour the HTML `hidden` attribute — without this the
   crosshair renders at 0,0 as a stray dot and a line down the y-axis. */
.chart .crosshair[hidden], .chart .tooltip[hidden] { display: none; }
.chart .cross-v { stroke: var(--baseline); stroke-width: 1; }
.chart .cross-pt { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: .8125rem; line-height: 1.35;
  box-shadow: 0 4px 14px rgba(0,0,0,.10); white-space: nowrap;
}
.chart .tooltip .tt-date { color: var(--text-secondary); font-size: .75rem; }
.chart .tooltip .tt-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-empty { color: var(--text-secondary); font-size: .875rem;
               padding: 20px 0; margin: 0; }
