/* ==========================================================================
   Base: reset, typography, layout primitives, the light field, buttons
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

/*
  The router's FocusOnNavigate moves focus to the h1 on every route change, which
  is correct for screen readers but has a side effect: focusing an element scrolls
  it into view, and that scroll does not honour the scroll-padding above. The page
  ends up nudged down with the heading sitting under the fixed header.

  scroll-margin-top is honoured by scroll-into-view, so the heading keeps clear of
  the header whether it is reached by focus, by an anchor, or by a skip link.
*/
h1,
#main,
[tabindex="-1"] {
  scroll-margin-top: calc(var(--header-h) + 2rem);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading-body);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, h5 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
  /* Fraunces variable axes: SOFT rounds the terminals slightly, WONK off keeps
     the letterforms classical rather than quirky. */
  font-variation-settings: "SOFT" 20, "WONK" 0;
}

p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; }
img, svg, video { display: block; max-width: 100%; }

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

::selection { background: rgba(201, 192, 180, 0.26); color: #fff; }

:focus-visible {
  outline: 1px solid var(--stone);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Scrollbar ---------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: rgba(240, 236, 228, 0.16) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-sunken); }
::-webkit-scrollbar-thumb {
  background: rgba(240, 236, 228, 0.13);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-sunken);
}
::-webkit-scrollbar-thumb:hover { background: rgba(240, 236, 228, 0.24); }

/* ==========================================================================
   Light field
   The colourful aurora is gone. What remains is the same idea in monochrome:
   large, very low-opacity warm-white pools drifting on long offset loops, so
   the black never reads as flat paint. Fixed and GPU-composited.
   ========================================================================== */

.aurora {
  position: fixed;
  inset: 0;
  z-index: var(--z-aurora);
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1400px 900px at 50% -20%, rgba(240, 236, 228, 0.045), transparent 62%),
    var(--bg);
}

.aurora__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  will-change: transform;
  transform: translateZ(0);
}

.aurora__blob--1 {
  width: 55vw; height: 55vw; min-width: 420px; min-height: 420px;
  top: -20%; left: -12%;
  background: radial-gradient(circle, rgba(240, 236, 228, 0.075), transparent 68%);
  animation: drift-1 34s var(--ease-inout) infinite alternate;
}
.aurora__blob--2 {
  width: 48vw; height: 48vw; min-width: 380px; min-height: 380px;
  top: 6%; right: -16%;
  background: radial-gradient(circle, rgba(201, 192, 180, 0.062), transparent 68%);
  animation: drift-2 42s var(--ease-inout) infinite alternate;
}
.aurora__blob--3 {
  width: 60vw; height: 60vw; min-width: 420px; min-height: 420px;
  bottom: -30%; left: 14%;
  background: radial-gradient(circle, rgba(240, 236, 228, 0.05), transparent 70%);
  animation: drift-3 48s var(--ease-inout) infinite alternate;
}
.aurora__blob--4 {
  width: 38vw; height: 38vw; min-width: 300px; min-height: 300px;
  top: 44%; left: 48%;
  background: radial-gradient(circle, rgba(201, 192, 180, 0.04), transparent 68%);
  animation: drift-4 38s var(--ease-inout) infinite alternate;
}

@keyframes drift-1 { to { transform: translate3d(12vw, 9vh, 0) scale(1.16); } }
@keyframes drift-2 { to { transform: translate3d(-10vw, 14vh, 0) scale(0.88); } }
@keyframes drift-3 { to { transform: translate3d(14vw, -10vh, 0) scale(1.10); } }
@keyframes drift-4 { to { transform: translate3d(-14vw, -12vh, 0) scale(1.22); } }

/* A faint rule grid gives the glass something to refract and stops large dark
   areas reading as dead space. */
.aurora__grid {
  position: absolute;
  inset: -1px;
  background-image:
    linear-gradient(rgba(240, 236, 228, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 236, 228, 0.022) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 90% 65% at 50% 40%, #000 18%, transparent 76%);
  -webkit-mask-image: radial-gradient(ellipse 90% 65% at 50% 40%, #000 18%, transparent 76%);
}

/* Pointer-following light. Decorative, driven by --mx/--my. */
.aurora__spotlight {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    640px circle at var(--mx) var(--my),
    rgba(240, 236, 228, 0.045),
    transparent 62%
  );
  transition: opacity var(--dur) var(--ease-out);
}

/* Film grain. Essential here: on a near-black monochrome page, wide gradients
   band badly without it. */
.grain {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.038;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.app-shell {
  position: relative;
  z-index: var(--z-content);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

main { flex: 1; }

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--wide { max-width: var(--content-wide); }
.container--narrow { max-width: 820px; }

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: calc(var(--section-y) * 0.62); }

.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-6); }

.prose { max-width: var(--measure); color: var(--text-muted); }
.prose > * + * { margin-top: var(--space-5); }
.prose strong { color: var(--text); font-weight: 600; }

.grid { display: grid; gap: clamp(1rem, 0.5rem + 1.4vw, 1.75rem); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }

/* Text-heavy cards, capped at three across. Plain auto-fit would fit four on a
   wide screen, which crushes the card footers and leaves orphan rows. */
.grid--three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
@media (min-width: 1060px) { .grid--three { grid-template-columns: repeat(3, 1fr); } }

/* Emphasis without colour: italic serif is the whole trick. */
.text-accent { color: var(--stone); }
.text-emphasis {
  font-style: italic;
  font-variation-settings: "SOFT" 40, "WONK" 1;
  color: var(--text);
}
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -100px; left: var(--space-4); z-index: 200;
  padding: 0.7rem 1.1rem; border-radius: var(--radius-sm);
  background: var(--bone); color: var(--accent-ink); font-weight: 600;
}
.skip-link:focus { top: var(--space-4); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.82rem 1.55rem;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 1px solid var(--hairline-strong);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: transform var(--dur) var(--ease-spring),
              border-color var(--dur) var(--ease-out),
              background var(--dur) var(--ease-out),
              color var(--dur) var(--ease-out);
}

.btn:hover { border-color: rgba(240, 236, 228, 0.42); background: var(--surface); }
.btn:active { transform: scale(0.98); }

.btn svg { width: 1.05em; height: 1.05em; flex: none; }

/* Bone fill, ink label. The single strongest element on any page, which is
   why there is only ever one per view. */
.btn--primary {
  background: var(--bone);
  border-color: var(--bone);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn--primary:hover {
  background: #fffdf8;
  border-color: #fffdf8;
  color: var(--accent-ink);
}

/* A single pale sweep on hover. Restrained, and the only "effect" left. */
.btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, transparent 22%, rgba(255, 255, 255, 0.5) 50%, transparent 78%);
  transform: translateX(-130%);
  transition: transform 760ms var(--ease-out);
}
.btn--primary:hover::after { transform: translateX(130%); }

.btn--ghost { border-color: transparent; }
.btn--ghost:hover { border-color: var(--hairline); background: var(--surface); }

.btn--sm { padding: 0.56rem 1.1rem; font-size: var(--step--2); }
.btn--lg { padding: 1rem 1.95rem; font-size: var(--step-0); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--step--1);
  color: var(--text);
  border-bottom: 1px solid var(--hairline-accent);
  padding-bottom: 0.2rem;
}
.link-arrow svg { width: 1em; height: 1em; transition: transform var(--dur) var(--ease-out); }
.link-arrow:hover { color: var(--stone); }
.link-arrow:hover svg { transform: translateX(4px); }

.link-underline {
  background-image: linear-gradient(var(--stone), var(--stone));
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size var(--dur) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.link-underline:hover { color: var(--stone); background-size: 100% 1px; }

/* ==========================================================================
   Motion utilities
   Elements marked .reveal start hidden and are unhidden by IntersectionObserver
   in site.js. If JS never runs, .no-js on <html> keeps everything visible.
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  transition:
    opacity 820ms var(--ease-out) var(--reveal-delay, 0ms),
    transform 820ms var(--ease-out) var(--reveal-delay, 0ms),
    filter 820ms var(--ease-out) var(--reveal-delay, 0ms);
  filter: blur(5px);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; filter: none; }

.reveal--left  { transform: translate3d(-30px, 0, 0); }
.reveal--right { transform: translate3d(30px, 0, 0); }
.reveal--scale { transform: scale(0.96); }
.reveal--fade  { transform: none; }

.no-js .reveal { opacity: 1; transform: none; filter: none; }

@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-9px); }
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(201, 192, 180, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(201, 192, 180, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 192, 180, 0); }
}

@keyframes spin-slow { to { transform: rotate(360deg); } }

/* ==========================================================================
   Reduced motion. Honoured properly, not just by shortening durations: the
   light field stops drifting and reveals resolve instantly.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .reveal { opacity: 1; transform: none; filter: none; }
  .aurora__blob { animation: none; }
  .aurora__spotlight { display: none; }
  .marquee__track { animation: none; }
}
