/* ============================================================================
   base.css — reset, typography, shared "sticker" chrome (header, footer,
   buttons, cards, pills, switch, select, toast, hub tiles, prose). Buddy (V9).
   Uses ONLY contract tokens (var(--*)) + color-mix on them. No literal hex —
   enforced by tools/check-architecture.mjs so the theme swap can't rot.
   ============================================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.4px);
  background-size: 24px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  line-height: var(--lh-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h1 {
  font-size: var(--fs-h1);
}
h2 {
  font-size: var(--fs-h2);
}

p {
  color: var(--ink-soft);
}
strong {
  color: var(--ink);
  font-weight: 600;
}

a {
  color: var(--indigo);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
/* Links inside running text keep a persistent underline so they're not
   distinguished by colour alone (WCAG 1.4.1 / Lighthouse link-in-text-block). */
p a,
.lead a {
  text-decoration: underline;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

::selection {
  background: color-mix(in srgb, var(--indigo) 26%, transparent);
}

/* --- Focus: visible everywhere --------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* --- Skip link ------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: var(--z-modal);
  background: var(--indigo);
  color: var(--ac-contrast);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-pill);
}
.skip-link:focus {
  left: var(--space-3);
  top: var(--space-3);
}

/* --- Layout ---------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  /* respect the notch / rounded corners on phones (viewport-fit=cover) */
  padding-left: max(clamp(18px, 4vw, 26px), env(safe-area-inset-left));
  padding-right: max(clamp(18px, 4vw, 26px), env(safe-area-inset-right));
}
main {
  flex: 1 0 auto;
  width: 100%;
}
.section {
  padding-block: var(--space-7);
}
.muted {
  color: var(--ink-soft);
}
.lead {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 62ch;
}
.tnum {
  font-variant-numeric: tabular-nums;
}
.center {
  text-align: center;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Header ---------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--glass);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 66px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--indigo);
  color: var(--ac-contrast);
  border: 2px solid var(--line);
  box-shadow: var(--sticker-sm);
  flex: none;
}
.brand-mark .icon {
  width: 22px;
  height: 22px;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.wordmark .mark-accent {
  color: var(--indigo);
}
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* --- Footer ---------------------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  border-top: 2px dashed var(--line-2, var(--ink-dim));
  padding-block: var(--space-5);
  padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
  margin-top: var(--space-8);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: center;
  justify-content: space-between;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  list-style: none;
  padding: 0;
}
.footer-links a {
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-family: var(--font-display);
  font-weight: 500;
}
.footer-promise {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* --- Buttons (sticker press physics) --------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: 0 var(--space-5);
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--canvas);
  color: var(--ink);
  box-shadow: var(--sticker);
  transition: transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:hover {
  text-decoration: none;
  transform: translate(-1px, -1px);
  box-shadow: var(--sticker-lg);
}
.btn:active {
  transform: translate(3px, 3px);
  box-shadow: var(--sticker-press);
}
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: var(--sticker-sm);
  transform: none;
}
.btn-primary {
  background: var(--indigo);
  color: var(--ac-contrast);
}
.btn-primary:hover {
  background: var(--indigo-600);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-soft);
}
.btn-ghost:hover {
  background: var(--indigo-soft);
  color: var(--indigo);
  box-shadow: none;
  transform: none;
}
.btn-icon {
  min-height: 46px;
  min-width: 46px;
  padding: 0;
  border-radius: 14px;
  background: var(--canvas);
}
.btn .icon {
  width: 20px;
  height: 20px;
}
@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: background var(--dur-fast) ease;
  }
  .btn:hover,
  .btn:active {
    transform: none;
  }
}

/* --- Card ------------------------------------------------------------------ */
.card {
  background: var(--canvas);
  border: 3px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sticker-lg);
  padding: var(--space-5);
}

/* --- Pills / chips --------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  box-shadow: var(--sticker-sm);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--ink);
  background: var(--surface);
}
.pill .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-dim);
  flex: none;
}
.pill[data-state="live"] {
  background: var(--ac-soft);
}
.pill[data-state="live"] .dot {
  background: var(--ac);
  animation: dot-pulse 1.2s var(--ease) infinite;
}
@keyframes dot-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
    opacity: 0.6;
  }
}
@media (prefers-reduced-motion: reduce) {
  .pill[data-state="live"] .dot {
    animation: none;
  }
}

/* --- Toggle switch (sticker) ----------------------------------------------- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9rem;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch .track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 2px solid var(--line);
  transition: background var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-dim);
  border: 2px solid var(--line);
  transition: transform var(--dur-base) var(--ease),
    background var(--dur-fast) var(--ease);
}
.switch input:checked + .track {
  background: var(--indigo-soft);
}
.switch input:checked + .track .thumb {
  transform: translateX(20px);
  background: var(--indigo);
}
.switch input:focus-visible + .track {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .switch .track,
  .switch .thumb {
    transition: none;
  }
}

/* --- Select ---------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.field label {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-weight: 500;
}
.select {
  appearance: none;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--canvas);
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--sticker-sm);
  min-height: 46px;
  padding: 0 var(--space-6) 0 var(--space-4);
  width: 100%;
  cursor: pointer;
}
.select-wrap {
  position: relative;
}
.select-wrap .chevron {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--ink-soft);
  width: 18px;
  height: 18px;
}

/* --- Ad slot (reserved, empty at launch) ----------------------------------- */
.ad-slot {
  display: block;
  width: 100%;
  border: 2px dashed color-mix(in srgb, var(--line) 30%, transparent);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.ad-slot[data-format="leaderboard"] {
  min-height: 90px;
  margin-block: var(--space-4);
}
.ad-slot[data-format="rectangle"] {
  min-height: 250px;
  margin-block: var(--space-4);
}
.ad-slot[hidden] {
  display: none;
}

/* --- Tester tiles (hub) ---------------------------------------------------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border-radius: var(--r);
  border: 2px solid var(--line);
  box-shadow: var(--sticker);
  background: var(--canvas);
  color: var(--ink);
  transition: transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.tile:hover {
  text-decoration: none;
}
.tile-live:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--sticker-lg);
}
.tile-soon {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: var(--sticker-sm);
}
.tile .tile-icon {
  width: 30px;
  height: 30px;
  color: var(--ink-soft);
}
.tile-live .tile-icon {
  color: var(--indigo);
}
.tile .tile-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}
.tile .tile-cta {
  margin-top: auto;
  font-size: var(--fs-sm);
  color: var(--indigo);
  font-weight: 600;
  font-family: var(--font-display);
}
.tile .tile-badge {
  align-self: flex-start;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
}
.tile-live .tile-badge {
  background: var(--ok);
  color: var(--ac-contrast);
}
.tile-soon .tile-badge {
  background: var(--surface);
  color: var(--ink-dim);
}
@media (prefers-reduced-motion: reduce) {
  .tile,
  .tile-live:hover {
    transition: none;
    transform: none;
  }
}

/* --- Hub: search + category filters ---------------------------------------- */
.hub-controls {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin: var(--space-6) 0 var(--space-5);
}
.hub-search {
  position: relative;
  flex: 1 1 320px;
  display: flex;
  align-items: center;
}
.hub-search > .icon {
  position: absolute;
  left: var(--space-4);
  width: 20px;
  height: 20px;
  color: var(--ink-dim);
  pointer-events: none;
}
.hub-search input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: var(--space-3) var(--space-4) var(--space-3) calc(var(--space-4) + 28px);
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--canvas);
  color: var(--ink);
  box-shadow: var(--sticker-sm);
}
.hub-search input::placeholder { color: var(--ink-dim); }
.hub-search input:focus-visible {
  outline: none;
  border-color: var(--indigo);
  box-shadow: var(--sticker);
}
.hub-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.chip {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  background: var(--canvas);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--sticker-sm);
  transition: transform var(--dur-fast) var(--ease);
}
.chip:hover { transform: translate(-1px, -1px); }
.chip[aria-pressed="true"] {
  background: var(--indigo);
  color: var(--ac-contrast);
}

/* --- Hub: tools head + count ----------------------------------------------- */
.tools-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.tools-head h2 { margin: 0; }
.count-badge {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-soft);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  background: var(--surface);
}

/* --- Hub: tool cards ------------------------------------------------------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border-radius: var(--r);
  border: 2px solid var(--line);
  box-shadow: var(--sticker);
  background: var(--canvas);
  color: var(--ink);
  transition: transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.tool-card:hover {
  text-decoration: none;
  transform: translate(-2px, -2px);
  box-shadow: var(--sticker-lg);
}
.tool-card[hidden] {
  display: none;
}
.tool-chip {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  border: 2px solid var(--line);
  background: var(--indigo-soft);
}
.tool-chip .icon { width: 24px; height: 24px; color: var(--indigo); }
.tool-chip.c-teal { background: var(--teal-soft); }
.tool-chip.c-teal .icon { color: var(--teal); }
.tool-chip.c-amber { background: var(--amber-soft); }
.tool-chip.c-amber .icon { color: var(--warn); }
.tool-chip.c-sky { background: var(--sky-soft); }
.tool-chip.c-sky .icon { color: var(--sky); }
.tool-chip.c-lime { background: var(--lime-soft); }
.tool-chip.c-lime .icon { color: var(--lime); }
.tool-chip.c-pink { background: var(--pink-soft); }
.tool-chip.c-pink .icon { color: var(--danger); }
.tool-card .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}
.tool-card .desc {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}
.tool-foot {
  margin-top: auto;
  padding-top: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tool-badge {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
}
.tool-badge.b-ready { background: var(--ok-soft); color: var(--ok); }
.tool-badge.b-popular { background: var(--amber-soft); color: var(--warn); }
.tool-badge.b-new { background: var(--pink-soft); color: var(--danger); }
.tool-go {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  background: var(--canvas);
  color: var(--ink);
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.tool-go .icon { width: 18px; height: 18px; }
.tool-card:hover .tool-go {
  background: var(--indigo);
  color: var(--ac-contrast);
}
.tools-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-soft);
  padding: var(--space-6);
}

/* --- Hub: full-checkup callout --------------------------------------------- */
.checkup {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-6);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--r-lg);
  border: 2px solid var(--line);
  box-shadow: var(--sticker);
  background: linear-gradient(120deg, var(--indigo-soft), var(--pink-soft));
  color: var(--ink);
}
.checkup-chip {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  border: 2px solid var(--line);
  background: var(--canvas);
  flex-shrink: 0;
}
.checkup-chip .icon { width: 26px; height: 26px; color: var(--ok); }
.checkup-text { flex: 1 1 240px; }
.checkup-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.checkup-text span { color: var(--ink-soft); font-size: var(--fs-sm); }
@media (prefers-reduced-motion: reduce) {
  .tool-card:hover,
  .chip:hover {
    transition: none;
    transform: none;
  }
}

/* --- Hero ------------------------------------------------------------------ */
.hero {
  text-align: center;
  padding-block: var(--space-8) var(--space-7);
}
.hero h1 {
  font-size: var(--fs-hero);
  max-width: 18ch;
  margin-inline: auto;
}
.hero h1 .accent {
  color: var(--indigo);
}
.hero .lead {
  margin: var(--space-4) auto 0;
  text-align: center;
}
.hero-cta {
  margin-top: var(--space-6);
}

/* --- Prose (guides, legal) ------------------------------------------------- */
.prose {
  max-width: var(--maxw-prose);
  margin-inline: auto;
}
.prose h2 {
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}
.prose p,
.prose li {
  color: var(--ink-soft);
  margin-bottom: var(--space-3);
}
.prose ol,
.prose ul {
  padding-left: var(--space-5);
  margin-bottom: var(--space-4);
}
.prose a {
  text-decoration: underline;
}
.breadcrumb {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin-bottom: var(--space-4);
}
.callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--sticker-sm);
  background: var(--indigo-soft);
  margin-block: var(--space-5);
}

/* --- Inline icons ---------------------------------------------------------- */
.icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* --- Toast ----------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%) translateY(140%);
  z-index: var(--z-toast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--ink);
  color: var(--canvas);
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
  padding: var(--space-3) var(--space-5);
  box-shadow: var(--sticker);
  font-family: var(--font-display);
  font-weight: 500;
  transition: transform var(--dur-base) var(--ease),
    opacity var(--dur-base) var(--ease);
  opacity: 0;
}
.toast[data-show="true"] {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: opacity var(--dur-base) ease;
  }
}

/* --- Forced colors (Windows High Contrast) --------------------------------- */
/* The "sticker" look relies on hard shadows + colour fills, both of which the OS
   overrides here. Restore meaning with borders/outlines so stateful widgets
   (meter segments, pressed keys, live dot, badges) stay distinguishable. */
@media (forced-colors: active) {
  .btn,
  .card,
  .pill,
  .tile,
  .vtile,
  .key,
  .seg,
  .pad-btn,
  .verdict,
  .score-card,
  .step-card,
  .tip-card,
  .toast,
  .speaker-pad {
    box-shadow: none;
  }
  .seg.on,
  .key.pressed,
  .pad-btn.on,
  .net-bar.on {
    outline: 3px solid Highlight;
    outline-offset: -3px;
  }
  .key.tested {
    outline: 2px solid LinkText;
    outline-offset: -2px;
  }
  .pill[data-state="live"] .dot {
    outline: 2px solid Highlight;
  }
  .tile-live .tile-badge,
  .tile-soon .tile-badge {
    border: 1px solid CanvasText;
  }
}

/* --- Print ----------------------------------------------------------------- */
@media print {
  .site-header,
  .site-footer,
  .ad-slot,
  .header-nav {
    display: none !important;
  }
  body {
    background: white;
    color: black;
  }
}
