/* Affiliate hub
   Layout: a slim header, one filter row, then left-aligned content on a single
   sheet per view. Bronze carries the data (deeper = more, like tan shades);
   a deep sea-green carries the controls. One typeface throughout. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 400 900; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --page: #f1f3f2;
  --surface: #ffffff;
  --ink: #1f1410;
  --ink-2: #584840;
  --muted: #85776f;
  --line: #e5e0dc;
  --line-strong: #cfc7c1;
  --wash: #f6f3f1;

  --sea: #0c5a61;
  --sea-strong: #08454b;
  --sea-soft: #dff0ef;
  --on-sea: #ffffff;

  /* data colours (validated for colour-blind safety on this surface) */
  --series-refersion: #b0622a;
  --series-tiktok-uk: #00939c;
  --series-tiktok-ie: #6a4bc4;
  --shade-0: #f4f0ed;
  --shade-1: #f6e3d0;
  --shade-2: #ecc7a2;
  --shade-3: #dea672;
  --shade-4: #c98447;
  --shade-5: #b0622a;
  --shade-6: #8c481a;
  --shade-7: #68330f;
  --on-deep-shade: #ffffff;

  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --critical-text: #a82323;

  --font: "Schibsted Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --radius-small: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #14110f;
    --surface: #1e1a17;
    --ink: #f5eee9;
    --ink-2: #cbbdb3;
    --muted: #96887e;
    --line: #322b26;
    --line-strong: #473d36;
    --wash: #262019;

    --sea: #6ccdd2;
    --sea-strong: #92dde1;
    --sea-soft: #173a3d;
    --on-sea: #06282b;

    --series-refersion: #c47d41;
    --series-tiktok-uk: #22a3aa;
    --series-tiktok-ie: #8f79ea;
    --shade-0: #2a231d;
    --shade-1: #3b2717;
    --shade-2: #55341a;
    --shade-3: #74441f;
    --shade-4: #985b2b;
    --shade-5: #bd763c;
    --shade-6: #dc9a62;
    --shade-7: #f3c79b;
    --on-deep-shade: #1f1410;

    --good-text: #4fd04f;
    --critical-text: #f08a8a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--sea); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Header ---------- */
.top {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.top-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 8px 28px; flex-wrap: wrap; min-height: 60px;
}
.wordmark { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; }
/* Four tan shades, light to dark: the same idea the charts use for "more". */
.shades { display: inline-flex; gap: 3px; }
.shades i { width: 0.5em; height: 1.05em; border-radius: 2px; background: var(--shade-2); }
.shades i:nth-child(2) { background: var(--shade-4); }
.shades i:nth-child(3) { background: var(--shade-5); }
.shades i:nth-child(4) { background: var(--shade-7); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; }
.nav a {
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px;
  padding: 18px 12px 16px; border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--series-refersion); }
.account { position: relative; margin-left: auto; }
.account-button {
  background: none; border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 6px 14px; font-size: 14px; cursor: pointer; max-width: 240px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-button:hover { background: var(--wash); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 6px; box-shadow: 0 12px 32px rgba(31, 20, 16, 0.14);
}
.menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 9px 12px; border-radius: var(--radius-small); cursor: pointer; font-size: 15px;
}
.menu button:hover { background: var(--wash); }

/* ---------- Page frame ---------- */
.frame { max-width: 1240px; margin: 0 auto; padding: 20px 24px 80px; }
.filters {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; margin-bottom: 26px;
}
.field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.field select, .field input[type="date"], .field input[type="search"], .field input[type="text"],
.field input[type="email"], .field input[type="password"] {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-small);
  padding: 0 10px; font-size: 15px; font-weight: 400; color: var(--ink); height: 40px;
}
.field input[type="search"] { min-width: min(280px, 70vw); }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; color: var(--ink-2); min-height: 40px; }
.check input { width: 18px; height: 18px; accent-color: var(--sea); }

.view-title { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; }
.view-intro { color: var(--ink-2); max-width: 70ch; margin-top: 6px; }
.stale { opacity: 0.5; transition: opacity 120ms; }

.sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-top: 22px;
}
.section { padding: 22px 24px 24px; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; margin-bottom: 14px; }
.section-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.section-head .note { color: var(--muted); font-size: 14px; }
.push { margin-left: auto; }
.filters.within { margin-bottom: 16px; }
.filters.within + .notice { margin-bottom: 4px; }
.section > .notice.problem { margin-bottom: 18px; }
.view { min-height: 50vh; }
.prose { max-width: 70ch; color: var(--ink-2); }
.steps { margin: 0; padding-left: 22px; max-width: 72ch; color: var(--ink-2); display: grid; gap: 8px; }

.button {
  background: var(--sea); color: var(--on-sea); border: 1px solid var(--sea); border-radius: var(--radius-small);
  padding: 9px 16px; font-weight: 650; font-size: 15px; cursor: pointer; min-height: 40px;
}
.button:hover { background: var(--sea-strong); border-color: var(--sea-strong); }
.button.quiet { background: transparent; color: var(--sea); border-color: var(--line-strong); }
.button.quiet:hover { background: var(--sea-soft); }
.button.small { padding: 5px 11px; min-height: 32px; font-size: 14px; }
.button:disabled { opacity: 0.55; cursor: default; }
.linkish { background: none; border: 0; color: var(--sea); cursor: pointer; padding: 0; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Overview headline ---------- */
.headline { display: grid; gap: 18px 48px; grid-template-columns: minmax(0, 1fr); align-items: end; }
@media (min-width: 900px) { .headline { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } }
.hero-label { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.hero-figure { font-size: clamp(48px, 8vw, 84px); font-weight: 800; letter-spacing: -0.035em; line-height: 1; margin-top: 4px; }
.hero-context { color: var(--ink-2); margin-top: 10px; max-width: 46ch; }
.hero-note { color: var(--ink-2); font-size: 15px; margin-top: 8px; max-width: 46ch; }
.waiting-mark { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--warning); margin-right: 8px; }
.delta { font-weight: 650; white-space: nowrap; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--critical-text); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; }
@media (min-width: 560px) { .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.facts div { padding: 4px 16px 4px 0; border-left: 1px solid var(--line-strong); padding-left: 16px; margin-bottom: 12px; }
.facts dt { font-size: 14px; color: var(--ink-2); }
.facts dd { margin: 2px 0 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.facts dd small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; }

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-scroll { overflow-x: auto; }
.axis-text { fill: var(--muted); font-size: 12px; }
.axis-line { stroke: var(--line-strong); stroke-width: 1; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.mark { cursor: default; }
.mark:hover, .mark:focus-visible { filter: brightness(1.12); outline: none; }
.mark:focus-visible { stroke: var(--ink); stroke-width: 2; }
.value-text { fill: var(--ink); font-size: 13px; font-weight: 600; }
.label-text { fill: var(--ink-2); font-size: 13px; }
.cell-text { font-size: 11.5px; font-weight: 600; pointer-events: none; fill: var(--ink); }
.cell-text.on-shade-5, .cell-text.on-shade-6, .cell-text.on-shade-7 { fill: var(--on-deep-shade); }
.axis-text.strong { fill: var(--ink-2); font-weight: 650; }
.hit { fill: transparent; }
.bucket:hover .mark { filter: brightness(1.12); }
.fill-refersion { fill: var(--series-refersion); }
.fill-tiktok_uk { fill: var(--series-tiktok-uk); }
.fill-tiktok_ie { fill: var(--series-tiktok-ie); }
.swatch.fill-refersion { background: var(--series-refersion); }
.swatch.fill-tiktok_uk { background: var(--series-tiktok-uk); }
.swatch.fill-tiktok_ie { background: var(--series-tiktok-ie); }
svg .shade-0 { fill: var(--shade-0); } svg .shade-1 { fill: var(--shade-1); } svg .shade-2 { fill: var(--shade-2); }
svg .shade-3 { fill: var(--shade-3); } svg .shade-4 { fill: var(--shade-4); } svg .shade-5 { fill: var(--shade-5); }
svg .shade-6 { fill: var(--shade-6); } svg .shade-7 { fill: var(--shade-7); }
.scale .shade-1 { background: var(--shade-1); } .scale .shade-2 { background: var(--shade-2); } .scale .shade-3 { background: var(--shade-3); }
.scale .shade-4 { background: var(--shade-4); } .scale .shade-5 { background: var(--shade-5); } .scale .shade-6 { background: var(--shade-6); }
.scale .shade-7 { background: var(--shade-7); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); margin-top: 10px; align-items: center; }
.legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.scale { display: inline-flex; align-items: center; gap: 2px; margin: 0 6px; }
.scale i { display: inline-block; width: 22px; height: 12px; border-radius: 2px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 280px;
  background: var(--ink); color: var(--surface); border-radius: var(--radius-small);
  padding: 8px 11px; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.tooltip strong { display: block; font-size: 15px; }

.rank { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.rank li { display: grid; grid-template-columns: minmax(110px, 220px) minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 28px; }
.rank .who { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .who small { display: block; color: var(--muted); font-size: 12px; }
.rank .track { height: 16px; }
.rank .bar { display: block; height: 16px; border-radius: 0 4px 4px 0; background: var(--series-refersion); min-width: 2px; }
.rank .bar.tiktok_uk { background: var(--series-tiktok-uk); }
.rank .bar.tiktok_ie { background: var(--series-tiktok-ie); }
.rank .bar.neutral { background: var(--line-strong); }
.rank .amount { font-size: 14px; font-weight: 600; text-align: right; min-width: 84px; }
.rank .amount small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
@media (max-width: 560px) {
  .rank { gap: 16px; }
  .rank li { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; align-items: end; }
  .rank .track { grid-column: 1 / -1; order: 3; height: 12px; }
  .rank .bar { height: 12px; }
}

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 14.5px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { font-size: 13px; color: var(--ink-2); font-weight: 650; white-space: nowrap; border-bottom-color: var(--line-strong); }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tbody tr:hover { background: var(--wash); }
table.data .sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; font-weight: 650; }
table.data th[aria-sort] .sort::after { content: " ↓"; }
table.data th[aria-sort="ascending"] .sort::after { content: " ↑"; }
table.data th[aria-sort] .sort { color: var(--ink); text-decoration: underline; text-decoration-color: var(--series-refersion); text-decoration-thickness: 2px; text-underline-offset: 5px; }
table.data select { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-small); padding: 5px 8px; min-height: 32px; }
table.data .subtle { color: var(--muted); font-size: 13px; }
.pager { display: flex; gap: 12px; align-items: center; padding-top: 14px; font-size: 14px; color: var(--ink-2); flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; padding: 2px 10px 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.good::before { background: var(--good); }
.pill.bad { border-color: var(--critical); }
.pill.bad::before { background: var(--critical); border-radius: 1px; transform: rotate(45deg); }
.pill.wait::before { background: var(--warning); border-radius: 2px; }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-small); overflow: hidden; background: var(--surface); }
.segmented button { background: none; border: 0; padding: 0 16px; font-size: 15px; font-weight: 600; cursor: pointer; color: var(--ink-2); height: 38px; }
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button[aria-pressed="true"] { background: var(--sea); color: var(--on-sea); }

.notice { background: var(--wash); border-left: 3px solid var(--series-refersion); padding: 12px 16px; border-radius: 0 var(--radius-small) var(--radius-small) 0; font-size: 15px; color: var(--ink-2); max-width: 80ch; }
.notice.problem { border-left-color: var(--critical); color: var(--ink); }
.empty { color: var(--ink-2); padding: 18px 0; }

/* ---------- Sign in ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-box { width: min(420px, 100%); }
.gate-box .wordmark { font-size: 30px; display: flex; margin-bottom: 8px; }
.gate-box p.lead { color: var(--ink-2); margin-bottom: 22px; }
.gate-box form { display: grid; gap: 14px; }
.gate-box .field input { width: 100%; }
.gate-foot { color: var(--muted); font-size: 14px; margin-top: 18px; }
.gate-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.gate-box .notice { margin-bottom: 4px; }
.form-error { color: var(--critical-text); font-size: 15px; font-weight: 600; }
.form-ok { color: var(--good-text); font-size: 15px; font-weight: 600; }

dialog { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 24px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 14, 10, 0.5); }
dialog form { display: grid; gap: 14px; }
dialog h2 { font-size: 20px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (max-width: 760px) {
  /* Phone: name and account on the first line, sections on a second line that scrolls sideways. */
  .top { position: static; }
  .top-inner { padding: 10px 16px 0; gap: 6px 12px; min-height: 0; }
  .nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 8px; scrollbar-width: none; }
  .nav a { padding: 10px 8px 9px; white-space: nowrap; }
  .account-button { max-width: 46vw; }
  .frame { padding-left: 16px; padding-right: 16px; }
  .section { padding: 18px 16px 20px; }
  table.data td:first-child, table.data th:first-child { min-width: 150px; }
  .filters .push { margin-left: 0; }
}
