/* Shared base: reset, type, header, buttons, footer. Previous site's language,
   on theme tokens (light: paper and carbon; dark: carbon and paper). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--header-h); background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 var(--body)/1.55 var(--sans);
  font-feature-settings: 'tnum' 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; overflow-x: clip;
}
img, video, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin-block: 16px; }
h1, h2, h3 { font-weight: 500; letter-spacing: -0.045em; line-height: 1; }
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 2px solid var(--hl-a); outline-offset: 3px; border-radius: 4px; }
.stray-dot { color: var(--stray); }
.mono { font-family: var(--mono); font-weight: 400; letter-spacing: 0; }
.label { font: 400 var(--label)/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--fg-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--inv-bg); color: var(--inv-fg); padding: 8px 12px; border-radius: 6px; }
.skip:focus { top: 12px; }

/* masked word reveal: words rise out of a clip (the film's grammar) */
.rv-w { display: inline-block; overflow: clip; overflow-clip-margin: 0.12em; vertical-align: top; padding-bottom: .14em; margin-bottom: -.14em; }
.rv-i { display: inline-block; will-change: transform; }
.js .rv:not(.rv-done) .rv-i { transform: translateY(115%); }
.js [data-reveal]:not(.rv) { opacity: 0; }

/* ---------- header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 var(--gutter); color: var(--fg); transition: transform .28s var(--ease-out);
  background: var(--glass); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: 0 1px 0 var(--rule);   /* the hairline is permanent */
}
.site-header.is-hidden { transform: translateY(-100%); }
.brand { display: flex; align-items: center; color: var(--fg); }
.brand svg { height: 24px; width: auto; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a:not(.btn) { padding: 8px 12px; border-radius: 8px; font-size: 15px; color: var(--fg); opacity: .72; transition: opacity .2s, background-color .2s; }
.nav a:not(.btn):hover { opacity: 1; background: var(--rule); }
.theme-toggle { width: 36px; height: 36px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--fg); opacity: .72; margin: 0 4px; transition: opacity .2s, background-color .2s; }
.theme-toggle:hover { opacity: 1; background: var(--rule); }
.theme-toggle svg { width: 18px; height: 18px; grid-area: 1 / 1; }
.theme-toggle .i-sun, :root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme-lock] .theme-toggle { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: var(--r-lg);
  font: 500 15px/1 var(--sans); letter-spacing: -0.01em; white-space: nowrap;
  transition: transform .14s var(--ease-out), background-color .2s, color .2s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--inv-bg); color: var(--inv-fg); }
.btn-primary:hover { opacity: .88; }
.btn-primary.inverse { background: var(--bg); color: var(--fg); }
.btn-ghost { box-shadow: inset 0 0 0 1px var(--rule-2); color: var(--fg); }
.btn-ghost:hover { box-shadow: inset 0 0 0 1px var(--fg); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }

/* keycaps */
.keys { display: inline-flex; gap: 8px; align-items: center; }
.key {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 7px;
  background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--rule-2), 0 1px 0 var(--rule-2);
  font: 500 14px/1 var(--sans); color: var(--fg);
}

/* ---------- footer: Carbon in both themes, as the previous site ---------- */
.site-footer { background: #121212; color: var(--paper); padding: 96px var(--gutter) 40px; position: relative; overflow: hidden; border-top: 1px solid var(--rule); }
.foot-grid { max-width: var(--max); margin: 0 auto; display: grid; grid-template-columns: 1.4fr repeat(2, 1fr); gap: 48px; }
.foot-brand svg { height: 28px; width: auto; }
.site-footer .brand { color: var(--paper); }
.foot-brand p { margin-top: 20px; color: var(--ash); max-width: 32ch; }
.foot-col h2 { font: 400 var(--label)/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ash); margin-bottom: 20px; }
.foot-col a { display: block; padding: 8px 0; color: var(--paper); opacity: .82; width: fit-content; }
.foot-col a:hover { opacity: 1; }
.foot-base { max-width: var(--max); margin: 72px auto 0; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding-top: 24px; border-top: 1px solid var(--line-dark); color: var(--ash); font-size: var(--small); }
.foot-pixel { width: 14px; height: 14px; background: var(--stray); }

@media (max-width: 760px) {
  :root { --header-h: 56px; }
  .nav a:not(.btn) { display: none; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
}

/* page-to-page: the new page rises in, the old one steps back */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .2s var(--ease-out) both; }   /* the old page gets out of the way fast */
::view-transition-new(root) { animation: vt-in .6s cubic-bezier(.16,1,.3,1) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(24px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .12s !important; scroll-behavior: auto !important; }
  .js .rv:not(.rv-done) .rv-i { transform: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
