/* KF Crafts — the private analytics dashboard (stats.html). Same tokens as site.css: ink ground, champagne as a
   line or a number, never a fill block. Mobile first (the owner reads it on an iPhone). No web fonts are loaded:
   the Jost / Futura / Avenir stack falls back to the system face. Charts: one series each, one colour
   (champagne), hairline grid, 4 px rounded data ends, values always visible in text or a table. */

:root {
  color-scheme: dark;
  --ink: #0a0a0a;
  --ink-2: #121110;
  --ink-3: #1a1917;
  --gold: #c5a253;
  --champagne: #d8c79c;
  --gold-hi: #e3ce92;
  --paper: #f4f1ea;
  --text-strong: rgba(244, 241, 234, 0.96);
  --text: rgba(244, 241, 234, 0.84);
  --text-dim: rgba(244, 241, 234, 0.66);
  --line: rgba(216, 199, 156, 0.26);
  --line-strong: rgba(216, 199, 156, 0.55);
  --rule: rgba(244, 241, 234, 0.1);
  --grid: rgba(244, 241, 234, 0.08);
  --track: rgba(216, 199, 156, 0.12);
  --good: #5fc4bd;   /* status only, always with a word */
  --warn: #e3ce92;
  --poor: #e59c84;
  --sans: "Jost", "Futura PT", Futura, "Avenir Next", "Century Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --seal: "Cinzel", "Trajan Pro", Georgia, "Times New Roman", serif;
  --gutter: 16px;
  --radius: 14px;
}
@media (min-width: 700px) { :root { --gutter: 28px; } }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ink); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--ink);
  color: var(--text);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
::selection { background: rgba(216, 199, 156, 0.32); color: var(--paper); }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

.eyebrow { color: var(--gold); font: 500 0.6875rem/1.4 var(--seal); letter-spacing: 0.24em; text-transform: uppercase; }
.muted { color: var(--text-dim); }

/* ---------- header, then the period switch (one row, sticky, above everything it scopes) ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) var(--gutter) 10px;
}
.top__brand { display: flex; align-items: center; gap: 12px; }
.top__seal { width: 40px; height: 40px; }
.top__title { color: var(--text-strong); font-size: 1.375rem; font-weight: 300; letter-spacing: 0.01em; line-height: 1.1; }

.ranges {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px max(var(--gutter), calc((100% - 1180px) / 2 + var(--gutter)));
  background: rgba(10, 10, 10, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.ranges__btn, .ranges__refresh {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--text-dim);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
}
.ranges__btn { flex: 1 1 0; max-width: 8.5rem; }
.ranges__btn:hover { color: var(--text-strong); background: rgba(216, 199, 156, 0.06); }
.ranges__btn[aria-pressed="true"] { color: var(--text-strong); border-color: var(--line-strong); }
.ranges__refresh { flex: 0 0 44px; margin-left: auto; padding: 0; display: grid; place-items: center; color: var(--champagne); }
.ranges__refresh:hover { border-color: var(--line); }
.is-loading .ranges__refresh svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .is-loading .ranges__refresh svg { animation: none; } }

/* ---------- page ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 16px var(--gutter) 32px; }
.status { color: var(--text-dim); font-size: 0.8125rem; min-height: 1.4em; margin-bottom: 14px; }
.status--warn { color: var(--warn); }
.board { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); transition: opacity 0.2s; }
.is-loading .board { opacity: 0.55; }
@media (min-width: 900px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .card--wide { grid-column: 1 / -1; }
}

.card {
  position: relative;
  min-width: 0;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-2);
}
@media (min-width: 700px) { .card { padding: 22px 24px; } }
.card__title { color: var(--text-strong); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 4px; }
.card__sub { color: var(--text-dim); font-size: 0.8125rem; margin-bottom: 16px; }
.card__h { color: var(--champagne); font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; margin: 18px 0 8px; }
.card__h:first-of-type { margin-top: 4px; }
.empty { color: var(--text-dim); font-size: 0.875rem; padding: 6px 0; }

/* ---------- key numbers ---------- */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px; }
.hero__label { color: var(--text-dim); font-size: 0.875rem; }
.hero__value { color: var(--text-strong); font-size: clamp(3.25rem, 2.4rem + 4vw, 4.75rem); font-weight: 300; line-height: 1; letter-spacing: -0.02em; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 18px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.tile { padding: 12px 12px 14px; background: var(--ink-2); min-width: 0; }
.tile__label { color: var(--text-dim); font-size: 0.8125rem; line-height: 1.3; }
.tile__value { color: var(--text-strong); font-size: 1.75rem; font-weight: 400; line-height: 1.15; margin-top: 4px; }
.delta { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--text-dim); font-size: 0.75rem; white-space: nowrap; }
.delta__arrow { font-size: 0.625rem; }
.delta--up .delta__arrow { color: var(--good); }
.delta--down .delta__arrow { color: var(--poor); }
.hero .delta { font-size: 0.875rem; }

/* ---------- column chart (SVG) ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .bar { fill: var(--gold); pointer-events: none; }
.chart .bar--peak { fill: var(--gold-hi); }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar, .chart .bar.is-on { fill: var(--gold-hi); }
.chart .hit:focus-visible { stroke: var(--gold-hi); stroke-width: 1; }
.chart text { fill: var(--text-dim); font: 400 11px var(--sans); font-variant-numeric: tabular-nums; }
.chart .val { fill: var(--text-strong); font-size: 11px; }
.tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(18, 17, 16, 0.96);
  color: var(--text);
  font-size: 0.8125rem;
  line-height: 1.35;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.tip strong { display: block; color: var(--text-strong); font-weight: 500; font-size: 0.9375rem; }

/* ---------- bar lists (horizontal, HTML) ---------- */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.bars__label { color: var(--text); font-size: 0.875rem; overflow-wrap: anywhere; }
.bars__value { color: var(--text-strong); font-size: 0.875rem; font-variant-numeric: tabular-nums; text-align: right; }
.bars__value small { color: var(--text-dim); font-size: 0.75rem; margin-left: 6px; }
.bars__track { grid-column: 1 / -1; height: 6px; border-radius: 0 4px 4px 0; background: var(--track); overflow: hidden; }
.bars__fill { display: block; height: 100%; width: var(--w, 0%); min-width: 2px; border-radius: 0 4px 4px 0; background: var(--gold); transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.bars__fill--zero { min-width: 0; }
.bars--funnel .bars__track { height: 10px; }
@media (prefers-reduced-motion: reduce) { .bars__fill { transition: none; } }

/* ---------- tables ---------- */
/* If a table is ever wider than its card, a soft edge shows on the side that has more (scroll shadows). */
.tablewrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px;
  background:
    linear-gradient(90deg, var(--ink-2) 30%, rgba(18, 17, 16, 0)) left / 24px 100% no-repeat local,
    linear-gradient(270deg, var(--ink-2) 30%, rgba(18, 17, 16, 0)) right / 24px 100% no-repeat local,
    linear-gradient(90deg, rgba(216, 199, 156, 0.28), rgba(216, 199, 156, 0)) left / 12px 100% no-repeat scroll,
    linear-gradient(270deg, rgba(216, 199, 156, 0.28), rgba(216, 199, 156, 0)) right / 12px 100% no-repeat scroll;
}

/* ---------- forms: one row per form, outcomes as words (wraps on a phone, never scrolls sideways) ---------- */
.formrows { list-style: none; margin: 0; padding: 0; }
.formrow { display: grid; grid-template-columns: minmax(6.5em, 0.8fr) minmax(0, 2fr); gap: 4px 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.formrow:last-child { border-bottom: 0; }
.formrow__name { color: var(--text-strong); font-size: 0.875rem; }
.formrow__out { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-dim); font-size: 0.8125rem; }
.outcome b { color: var(--text-strong); font-weight: 500; font-variant-numeric: tabular-nums; }
.outcome--ok b { color: var(--good); }
.outcome--bad b { color: var(--poor); }
.outcome--warn b { color: var(--warn); }
.outcome--nf { color: var(--champagne); }
.formrows__none { margin: 10px 0 0; }
@media (max-width: 420px) { .formrow { grid-template-columns: minmax(0, 1fr); } }
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
@media (min-width: 700px) { table { font-size: 0.875rem; } }
th, td { padding: 8px 5px; border-bottom: 1px solid var(--rule); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 6.5em; }
th { color: var(--text-dim); font-weight: 400; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
td { color: var(--text); }
td:first-child { color: var(--text-strong); }
tr:last-child td { border-bottom: 0; }

details.more { margin-top: 12px; }
details.more > summary { display: inline-flex; align-items: center; min-height: 44px; color: var(--champagne); font-size: 0.8125rem; cursor: pointer; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "+"; display: inline-block; width: 1.2em; color: var(--gold); }
details.more[open] > summary::before { content: "−"; }

/* ---------- small grids ---------- */
.split { display: grid; gap: 4px 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .split { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.facts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 8px; }
.fact__v { color: var(--text-strong); font-size: 1.375rem; font-weight: 400; line-height: 1.2; }
.fact__l { color: var(--text-dim); font-size: 0.8125rem; }

/* ---------- Core Web Vitals ---------- */
.vital { display: inline-grid; grid-template-columns: auto auto; align-items: center; justify-items: end; gap: 2px 6px; }
.vital__v { grid-column: 1 / -1; color: var(--text); }
.vital__n { display: block; color: var(--text-dim); font-size: 0.75rem; }
.vital__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.vital--good .vital__dot { background: var(--good); }
.vital--warn .vital__dot { background: var(--warn); }
.vital--poor .vital__dot { background: var(--poor); }
.vital__word { color: var(--text-dim); font-size: 0.75rem; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; color: var(--text-dim); font-size: 0.75rem; }

/* ---------- the key form ---------- */
.keyform { max-width: 28rem; margin: 8vh auto 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-2); display: grid; gap: 12px; }
.keyform__label { color: var(--text-dim); font-size: 0.8125rem; }
.keyform__row { display: flex; gap: 8px; }
.keyform__input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--ink); color: var(--text-strong); font-size: 16px; }
.btn { min-height: 44px; padding: 0 18px; border: 1px solid var(--gold); border-radius: 999px; background: none; color: var(--text-strong); cursor: pointer; letter-spacing: 0.04em; }
.btn:hover { background: rgba(197, 162, 83, 0.12); }

/* ---------- opt-out.html (the "Don't count my visits" switch) ---------- */
.optout { max-width: 40rem; }
.optout a, .foot a { color: var(--text-strong); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.optout__state { color: var(--text-strong); font-size: 1rem; margin: 4px 0 14px; }
.optout__small { font-size: 0.8125rem; line-height: 1.6; margin-top: 14px; }

.foot { max-width: 1180px; margin: 0 auto; padding: 8px var(--gutter) 40px; color: var(--text-dim); font-size: 0.75rem; line-height: 1.6; }
.foot p { max-width: 62rem; border-top: 1px solid var(--line); padding-top: 16px; }

@media (forced-colors: active) {
  .bars__fill, .chart .bar { background: CanvasText; fill: CanvasText; }
}

/* ---------- Round 9: journeys of visitors who accepted the cookie ---------- */
.journeys { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.journey { padding: 12px 12px 13px; background: var(--ink-2); min-width: 0; }
.journey--lead { box-shadow: inset 3px 0 0 var(--good); }
.journey--tap { box-shadow: inset 3px 0 0 var(--gold); }
.journey__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.journey__head b { color: var(--text-strong); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.journey__tag { color: var(--good); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.journey__tag--tap { color: var(--gold-hi); }
.journey__meta { margin-top: 3px; color: var(--text-dim); font-size: 0.8125rem; overflow-wrap: anywhere; }
.journey__steps { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 8px 0 0; padding: 0; list-style: none; font-size: 0.8125rem; color: var(--text); }
.journey__steps li { overflow-wrap: anywhere; }
.journey__steps li + li::before { content: "→"; margin: 0 6px; color: var(--gold); }
td b { color: var(--text-strong); font-weight: 500; }
