/* Base: reset, type, layout helpers and the shared components.
   Shared classes: .wrap .placeholder .frame .sheet .button .visually-hidden
   .skip-link .prose pre code. Chapter fades live in chapters.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
/* html and body paint var(--bg) (tokens.css), so the whole viewport follows the active palette. */
body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-body);
  line-height: 1.5;
  letter-spacing: -0.01em;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, video, picture { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; text-wrap: balance; }
p, ul, ol, dl, figure, blockquote { margin: 0; }
p { text-wrap: pretty; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
/* Chapters are snap targets: any scroll-margin would shift where they land, so only other anchors get one. */
:target:not([data-chapter]) { scroll-margin-top: var(--space-8); }
/* The hidden attribute always wins over component display rules (e.g. .button), with or without JS. */
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }

a { color: inherit; text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 0.14em; }

/* Focus: always visible, never removed */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

/* Layout */
.wrap { width: 100%; max-width: var(--max-w); margin-inline: auto; padding-inline: var(--margin); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); }
.section { padding-block-start: var(--section-gap); }
.section-title { font-size: var(--step-head); }

/* Accessibility helpers */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--margin); top: var(--space-2); z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: var(--space-3) var(--space-4); font-weight: 600; font-size: var(--step-small);
  text-decoration: none;
  transform: translateY(-160%);
}
.skip-link:focus, .skip-link:focus-visible { transform: none; }

/* The one button: square, flat, in the page accent */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: var(--space-3) var(--space-5);
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 0;
  font-weight: 600; font-size: var(--step-small); line-height: 1.2; letter-spacing: 0;
  text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-button);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
/* Colour transitions only while hovered, so buttons never trail the page palette fade. */
.button:hover {
  background: color-mix(in srgb, var(--accent) 86%, var(--ink));
  box-shadow: var(--shadow-button-hover);
  transform: translateY(-1px);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.button:active { transform: translateY(1px); box-shadow: var(--shadow-button-press); background: color-mix(in srgb, var(--accent) 72%, var(--ink)); transition: none; }
/* Quiet variant: same shape, surface fill (for secondary controls such as "Copy email") */
.button--quiet { background: var(--surface); color: var(--ink); }
.button--quiet:hover { background: var(--surface-2); }
.button--quiet:active { background: color-mix(in srgb, var(--surface-2) 82%, var(--ink)); }

/* Text link with an arrow, used for "Read the build" style links */
.text-link { font-weight: 600; color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

/* Placeholders: visible, honest, never mistaken for content */
.placeholder {
  background: var(--surface-2); color: var(--muted);
  font-size: 0.875em; font-weight: 600; font-style: normal;
  padding: 0.1em 0.4em; box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
figure.placeholder, .frame.placeholder {
  display: flex; align-items: flex-end;
  background: var(--surface); color: var(--muted);
  padding: var(--space-3); font-size: var(--step-small); line-height: 1.3;
  outline: 2px dashed var(--muted); outline-offset: -2px; /* reads as "to be supplied", not as a broken frame */
}

/* Frame: a square-cornered image tile */
.frame { position: relative; display: block; margin: 0; overflow: hidden; background: var(--surface); }
.frame img, .frame picture { width: 100%; height: 100%; object-fit: cover; }
.frame--contain img { object-fit: contain; }
.frame--text {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: var(--space-3); font-size: 0.8125rem; line-height: 1.35; font-weight: 600;
}
a.frame { transition: transform var(--dur) var(--ease); }
a.frame:hover { transform: translateY(-2px); }

/* Sheet: one contact-sheet run (title, then frames at a fixed row height).
   Set --frame-h on .sheet to change the row height (project pages: 140px). */
.sheet { --frame-h: 96px; display: grid; gap: var(--space-2); align-content: start; }
.sheet-title { font-size: var(--step-small); font-weight: 600; line-height: 1.4; }
.sheet-title span { color: var(--muted); font-weight: 400; }
.sheet-frames { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; margin: 0; }
.sheet-frames > * { flex: none; height: var(--frame-h); aspect-ratio: 4 / 3; }
.sheet-frames > .is-square { aspect-ratio: 1; }
.sheet-frames > .is-tall { aspect-ratio: 3 / 4; }
@media (max-width: 599px) {
  /* Phone: two per row at natural ratio */
  .sheet-frames > * { height: auto; width: calc(50% - var(--space-1)); }
}
@media (min-width: 1024px) { .sheet { --frame-h: 120px; } }

/* Prose */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1em; }
.prose h2, .prose h3 { margin-top: 1.6em; }
.prose h2 { font-size: var(--step-head); }
.prose h3 { font-size: var(--step-lead); letter-spacing: -0.02em; }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li + li { margin-top: 0.4em; }
.prose a { text-decoration-color: var(--accent); }

/* Code: monospace only here */
code, kbd, samp { font-family: var(--font-mono); font-size: 0.9em; letter-spacing: 0; }
pre {
  margin: 0; padding: var(--space-4) var(--space-5);
  background: var(--surface); color: var(--ink);
  overflow-x: auto; tab-size: 2;
  font-size: 0.875rem; line-height: 1.55;
}
pre code { font-size: inherit; background: none; padding: 0; white-space: pre; }
:not(pre) > code { background: var(--surface); padding: 0.05em 0.3em; }

/* Entrances: widgets/rise.js (project pages) marks elements below the fold with .will-rise, then .is-in.
   Without JS nothing is ever hidden. */
.will-rise { opacity: 0; transform: translateY(16px); }
.will-rise.is-in {
  opacity: 1; transform: none;
  transition: opacity 480ms var(--ease), transform 480ms var(--ease);
  transition-delay: calc(var(--i, 0) * 60ms);
}

/* Reduced motion: no travel, no stagger, instant swaps */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important;
    transition-duration: 1ms !important; transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
  .will-rise { opacity: 1; transform: none; }
  a.frame:hover { transform: none; }
}
