/* LabourLens base layer: reset, type, surfaces, controls, motion primitives.
   Everything reads tokens.css (and theme.css for the manual toggle). */
:root {
  /* Derived alias, not a new palette entry: brass dark enough for small text on paper in both themes. */
  --brass-text: color-mix(in srgb, var(--brass) 62%, var(--ink));
  --nav-h: 64px;
  --gutter: clamp(20px, 4vw, 56px);
  --page: 1320px;
  --glass: color-mix(in srgb, var(--paper) 70%, transparent);
  --hair: 1px solid var(--line);
  --z-nav: 40;
  --z-menu: 50;
  --z-modal: 60;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html[data-presenter="on"] { font-size: 112.5%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
/* Paper grain: fixed, non-interactive, never part of a scrolling container. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] body::before { opacity: 0.07; mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { opacity: 0.07; mix-blend-mode: screen; } }

img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: var(--accent); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
::selection { background: var(--accent-soft); color: var(--ink); }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 16px; top: 16px; z-index: var(--z-modal);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--r-pill);
  opacity: 0; transform: translateY(-140%); pointer-events: none;
  transition: transform var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}
.skip-link:focus { opacity: 1; transform: none; pointer-events: auto; }

/* ---------- Type ---------- */
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 400; font-optical-sizing: auto; letter-spacing: -0.02em; line-height: 1.04; text-wrap: balance; }
h1 { font-size: clamp(3rem, 8.2vw, 7rem); letter-spacing: -0.035em; line-height: 0.94; }
h2 { font-size: clamp(2rem, 4.6vw, 3.6rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.6rem); letter-spacing: -0.01em; line-height: 1.15; }
p { margin: 0; text-wrap: pretty; }
em, .em { font-style: italic; color: var(--brass-text); font-weight: 380; }
.lead { font-size: clamp(1.05rem, 1.5vw, 1.28rem); line-height: 1.55; color: var(--ink-2); max-width: 54ch; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--font-mono); font-size: 0.82em; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums lining-nums; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px; width: max-content; max-width: 100%;
  padding: 6px 14px 6px 12px; border: var(--hair); border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-2);
}
.eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brass); flex: none; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: calc(var(--page) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }
.section { position: relative; z-index: 2; padding-block: clamp(72px, 11vw, 160px); }
.section-head { display: grid; gap: var(--space-4); max-width: 46rem; margin-bottom: clamp(32px, 5vw, 72px); }
.section-head > p:not(.eyebrow) { color: var(--ink-2); font-size: 1.08rem; max-width: 52ch; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- Double bezel ---------- */
.bezel {
  padding: var(--bezel);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  border: var(--hair);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}
.bezel-core {
  height: 100%;
  border-radius: calc(var(--r-lg) - var(--bezel));
  background: var(--surface);
  box-shadow: var(--inner-hi);
  padding: clamp(20px, 3vw, 36px);
  min-width: 0;
}
.bezel.tight .bezel-core { padding: clamp(14px, 2vw, 22px); }
.bezel.soft .bezel-core { background: var(--paper-2); }
.bezel.ink .bezel-core { background: var(--accent); color: var(--accent-ink); }

/* ---------- Pills, chips, badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-pill);
  border: var(--hair); background: color-mix(in srgb, var(--surface) 78%, transparent);
  font-size: 0.78rem; line-height: 1.2; color: var(--ink-2); white-space: nowrap;
}
.pill .dot, .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.pulse { position: relative; }
.dot.pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.55; } 100% { transform: scale(3.2); opacity: 0; } }

.badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 10px; border-radius: var(--r-pill);
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.01em; border: 1px solid currentColor;
}
.badge svg { width: 18px; height: 18px; }
.badge.answered { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.badge.abstained { color: var(--brass-text); background: var(--brass-soft); }
.badge.clarify { color: var(--info); background: color-mix(in srgb, var(--info) 10%, transparent); }
.badge.refused { color: var(--bad); background: var(--bad-soft); }
.badge.neutral { color: var(--ink-2); background: var(--paper-2); }

/* ---------- Icons ---------- */
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.lg { width: 28px; height: 28px; stroke-width: 1.1; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  min-height: 48px; padding: 8px 8px 8px 24px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  font-weight: 500; font-size: 0.95rem; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: transform var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; transform: none; box-shadow: none; }
.btn:disabled:hover { background-color: transparent; }
.btn-primary:disabled:hover { background: var(--accent); }
.btn .btn-ico {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  transition: transform var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.btn .btn-ico .icon { width: 16px; height: 16px; stroke-width: 1.5; }
.btn:hover:not(:disabled) .btn-ico { transform: translate(2px, -1px) scale(1.06); }
.btn.plain { padding: 8px 20px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 10px 28px -14px var(--accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-primary .btn-ico { background: color-mix(in srgb, var(--accent-ink) 16%, transparent); }
.btn.small { min-height: 38px; padding: 4px 6px 4px 16px; font-size: 0.85rem; gap: 10px; }
.btn.small.plain { padding: 4px 16px; }
.btn.small .btn-ico { width: 28px; height: 28px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  color: var(--ink); transition: background-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.icon-btn:active { transform: scale(0.94); }
.kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--paper-2); color: var(--ink-2);
  font-family: var(--font-mono); font-size: 0.7rem; line-height: 1;
}

/* ---------- Forms ---------- */
.field { display: grid; gap: 8px; }
.field > span, .field > legend { font-size: 0.8rem; font-weight: 500; color: var(--ink-2); }
.input, textarea.input {
  width: 100%; padding: 14px 16px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--paper) 55%, var(--surface)); color: var(--ink);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.input:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Motion primitives ---------- */
.js .reveal { opacity: 0; transform: translateY(32px); transition: opacity var(--dur-3) var(--ease), transform var(--dur-3) var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
.stagger > * { transition-delay: calc(var(--i, 0) * 70ms); }
.stagger > :nth-child(1) { --i: 0; } .stagger > :nth-child(2) { --i: 1; } .stagger > :nth-child(3) { --i: 2; }
.stagger > :nth-child(4) { --i: 3; } .stagger > :nth-child(5) { --i: 4; } .stagger > :nth-child(6) { --i: 5; }
.stagger > :nth-child(7) { --i: 6; } .stagger > :nth-child(8) { --i: 7; } .stagger > :nth-child(n+9) { --i: 8; }

.skeleton { position: relative; overflow: hidden; border-radius: var(--r-xs); background: var(--paper-3); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  transform: translateX(-100%); animation: shimmer 1.6s var(--ease) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0ms !important; }
  .skeleton::after { display: none; }
}
@media (max-width: 767px) {
  .bezel { --bezel: 5px; border-radius: var(--r-md); }
  .bezel-core { border-radius: calc(var(--r-md) - 5px); }
}

/* Grain is a screen treatment, not a printable background. */
@media print {
  body::before { display: none !important; }
}
