/* The site shell: header, menu, footer, theme switch, focus, reveal, spotlight, page transitions.
   Tokens only (tokens.css). Motion follows the app: arrive on --ease-enter, leave faster on --ease-exit,
   and everything ambient stops under prefers-reduced-motion. */

[hidden] { display: none !important; }
html { background: var(--ground); scroll-padding-top: calc(var(--header-h) + var(--space-4)); }
body { font-family: var(--font-sans); color: var(--ink); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: rgb(var(--glow) / .32); color: var(--ink-max); }
img, svg { max-width: 100%; }
/* headings never leave one word alone on a line */
.h2, h2.sg, h1, h2, h3 { text-wrap: balance; }
:where(a, button, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--space-2); }

/* skip link */
.skip { position: absolute; left: var(--space-4); top: -100px; z-index: calc(var(--z-menu) + 1); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-pill); background: var(--accent); color: var(--on-accent); font-weight: 500; text-decoration: none;
  transition: top var(--dur-calm) var(--ease-enter); }
.skip:focus { top: var(--space-3); }

/* ---- header ---- */
.site-header { position: sticky; top: 0; z-index: var(--z-header); transition: box-shadow var(--dur-calm) var(--ease-enter), background var(--dur-calm); view-transition-name: site-header; }
.site-header.is-scrolled { box-shadow: 0 10px 40px rgb(var(--shade) / calc(.35 * var(--shade-k))); }
.site-header__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand .mark { transition: transform var(--dur-screen) var(--ease-enter); }
.brand:hover .mark { transform: rotate(-30deg) scale(1.06); }
.brand__word { font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.site-nav { display: flex; align-items: center; gap: 2px; }
.site-nav .nl { position: relative; }
.site-nav .nl[aria-current="page"] { color: var(--ink); background: rgb(var(--fg) / .06); }
.site-nav .nl[aria-current="page"]::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgb(var(--glow) / .9); }
.site-header__end { display: flex; gap: var(--space-2); align-items: center; }
.btn--sm { min-height: 44px; padding: 0 20px; font-size: var(--text-small); background: var(--accent); }

.icon-btn { all: unset; box-sizing: border-box; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgb(var(--fg) / .14); color: var(--ink-3); cursor: pointer;
  transition: color var(--dur-quick), background var(--dur-quick), transform var(--dur-quick) var(--ease-enter); }
.icon-btn:hover { color: var(--ink-max); background: rgb(var(--fg) / .06); }
.icon-btn:active { transform: scale(var(--press)); }
.icon-btn svg { grid-area: 1 / 1; transition: transform var(--dur-screen) var(--ease-enter), opacity var(--dur-calm); }
[data-theme="dark"] .i-moon, [data-theme="light"] .i-sun { opacity: 0; transform: rotate(-90deg) scale(.5); }

.menu-btn { display: none; }
.menu-btn__bars { display: grid; gap: 5px; width: 18px; }
.menu-btn__bars i { display: block; height: 1.6px; border-radius: 2px; background: currentColor; transition: transform var(--dur-calm) var(--ease-enter); }
.menu-btn[aria-expanded="true"] .menu-btn__bars i:first-child { transform: translateY(3.3px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-btn__bars i:last-child { transform: translateY(-3.3px) rotate(-45deg); }
.site-menu { border-top: 1px solid rgb(var(--fg) / .07); max-height: calc(100dvh - var(--header-h)); overflow-y: auto; }
html.menu-open { overflow: hidden; }
.site-menu__list a[aria-current="page"] { color: var(--accent); }
.site-menu__list a[aria-current="page"]::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 10px; vertical-align: middle;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgb(var(--glow) / .9); }
.site-menu__list { display: flex; flex-direction: column; padding-top: var(--space-2); padding-bottom: var(--space-6); }
.site-menu__list a { padding: var(--space-4) 0; font: 500 22px/1.2 var(--font-display); letter-spacing: -.02em; color: var(--ink); text-decoration: none;
  border-bottom: 1px solid rgb(var(--fg) / .06); animation: develop var(--dur-screen) var(--ease-enter) both; }
.site-menu__list a:nth-child(2) { animation-delay: 30ms; } .site-menu__list a:nth-child(3) { animation-delay: 60ms; }
.site-menu__list a:nth-child(4) { animation-delay: 90ms; } .site-menu__list a:nth-child(5) { animation-delay: 120ms; }
@media (max-width: 860px) {
  .site-nav { display: none; }
  .menu-btn { display: inline-grid; }
}
@media (max-width: 420px) { .site-header__end .btn--sm { padding: 0 14px; } }

/* ---- footer ---- */
.site-footer { border-top: 1px solid rgb(var(--fg) / .07); padding: 40px 0 32px; }
.site-footer__row { display: flex; flex-wrap: wrap; gap: var(--space-8); justify-content: space-between; align-items: flex-start; }
.site-footer__brand { display: flex; flex-direction: column; gap: var(--space-3); max-width: 320px; }
.site-footer__brand p { margin: 0; font-size: var(--text-small); line-height: 1.6; color: var(--ink-4); }
.site-footer__nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1) 40px; font-size: var(--text-small); }
.site-footer__nav a { color: var(--ink-3); text-decoration: none; padding: var(--space-2) 0; transition: color var(--dur-quick); }
.site-footer__nav a:hover { color: var(--ink-max); }
.site-footer__legal { margin-top: 28px; font-size: 13px; color: var(--ink-4b); }
.site-footer__legal a { color: inherit; }

/* ---- reveal: CSS scroll timelines where the browser has them (components.css .rv); else site.js adds .in ---- */
@supports not (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .js .rv, .js .rv-scale { opacity: 0; transform: translateY(28px); transition: opacity 900ms var(--ease-enter), transform 900ms var(--ease-enter); }
    .js .rv-scale { transform: scale(.94); }
    .js .rv.in, .js .rv-scale.in { opacity: 1; transform: none; }
  }
}

/* ---- the spotlight: a soft light follows the pointer across cards (fine pointers only) ---- */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .card, .bcard, .viz { --mx: 50%; --my: -40%; }
  .card::after, .bcard::after, .viz::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    background: radial-gradient(420px circle at var(--mx) var(--my), rgb(var(--glow) / .10), transparent 45%);
    opacity: 0; transition: opacity var(--dur-calm); }
  .card:hover::after, .bcard:hover::after, .viz:hover::after { opacity: 1; }
  .card, .viz { position: relative; }
}

/* ---- off-screen ambient motion pauses (site.js marks the section) ---- */
.is-offscreen, .is-offscreen * { animation-play-state: paused !important; }

/* ---- the theme change cross-fades; pages cross-fade too ---- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--dur-calm); }
html.theme-switching, html.theme-switching * { transition: background-color var(--dur-calm), color var(--dur-calm), border-color var(--dur-calm) !important; }


/* ---- the app's honesty about drawn screens ---- */
.sample-note { font-size: 13px; color: var(--ink-4); }

/* ---- small shared classes (were repeated inline styles; Website Design System.md, "Inline styles") ---- */
.section { padding: 0 0 var(--section-space); }
.section--sm { padding-bottom: var(--section-space-sm); }
.section--lg { padding-bottom: var(--section-space-lg); }
.copy { font-size: var(--text-body); line-height: 1.6; color: var(--ink-2b); }   /* body copy in cards and lists */
.ic-box { display: block; width: 28px; height: 28px; }                              /* a 28 px icon's box */
.flex-none { flex: none; }
.title-sm { font-size: 17px; font-weight: 600; }                                    /* a small card or row title */
.text-col { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }  /* a section's heading, lede and lines */
.text-col--wide { max-width: 780px; }
.card-body { padding: 26px; display: flex; flex-direction: column; gap: 14px; }    /* a card's padding and stack */
/* text colours (after .copy, so "copy c-ink-3" reads) */
.c-ink { color: var(--ink); }
.c-ink-2 { color: var(--ink-2); }
.c-ink-3 { color: var(--ink-3); }
.c-accent-2 { color: var(--accent-2); }
.c-sage-600 { color: var(--sage-600); }

/* THE reduced-motion reset (one place): every animation ends at once at its final frame, no delays, no loops;
   the mill's spiral, which a page rule marks !important, stops too. Page css adds only what this can't know. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0s !important; transition-duration: 1ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .spiral, .pt, .orbit-lab { animation: none !important; opacity: 0 !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ======================= motion layer (site.js adds the classes; all of it off under reduced motion) ======================= */
@media (prefers-reduced-motion: no-preference) {
  /* headings, ledes and eyebrows develop into view: blur to sharp, rising - the app's "develop" */
  .js .dv { opacity: 0; filter: blur(6px); transform: translateY(12px);
    transition: opacity var(--dur-develop) var(--ease-enter), filter var(--dur-develop) var(--ease-enter), transform var(--dur-develop) var(--ease-enter); transition-delay: var(--dv-d, 0ms); }
  .js .dv.in { opacity: 1; filter: none; transform: none; }

  /* a grid's items arrive one after another (the app's cascade: 12 px, 30-60 ms apart) */
  .js .cascade > * { opacity: 0; transform: translateY(12px);
    transition: opacity var(--dur-cascade) var(--ease-enter), transform var(--dur-cascade) var(--ease-enter); transition-delay: calc(var(--ci, 0) * var(--cascade-step)); }
  .js .cascade.in > * { opacity: 1; transform: none; }

  /* the primary button: a sheen passes on hover; it leans toward the pointer (site.js sets --bx/--by) */
  .btn-hot { position: relative; overflow: hidden; translate: var(--bx, 0) var(--by, 0); transition: translate var(--dur-calm) var(--ease-enter), transform 160ms var(--ease-enter), box-shadow 300ms ease; }
  .btn-hot::before { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / .45) 50%, transparent 65%);
    transform: translateX(-120%); transition: transform 800ms var(--ease-enter); pointer-events: none; }
  .btn-hot:hover::before { transform: translateX(120%); }

  /* paper cards and phones tilt under the pointer (site.js sets --rx/--ry) */
  .tilt { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 600ms var(--ease-enter); will-change: transform; }

}

/* reading progress: a hairline of accent along the header's foot */
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; transform-origin: left; transform: scaleX(var(--read, 0));
  background: linear-gradient(90deg, rgb(var(--glow) / 0), var(--accent)); box-shadow: 0 0 12px rgb(var(--glow) / .6); pointer-events: none; }

/* text links: an underline that draws in */
main p a:not(.btn), main li a:not(.btn), .site-footer__nav a { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size var(--dur-calm) var(--ease-enter), color var(--dur-quick); }
main p a:not(.btn):hover, main li a:not(.btn):hover, .site-footer__nav a:hover { background-size: 100% 1px; }
