/* Shared layer for the redesign. Tokens and rules: docs/design-system.md */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/bricolage-grotesque-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-latin.woff2") format("woff2");
}

/* 1. Tokens */
:root {
  --bg: #f3efe7;
  --surface: #ebe5da;
  --ink: #22201c;
  --muted: #6b655a;
  --accent: #8a5a14;
  --rule: #d9d2c4;
  --on-image: #efece6;
  --on-image-muted: rgba(239, 236, 230, .78);
  --on-image-accent: #d2a85a;
  --head: "Bricolage Grotesque", Arial, sans-serif;
  --body: "Bricolage Grotesque", Arial, sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .1, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1a1b;
    --surface: #212122;
    --ink: #e9e7e2;
    --muted: #9a978f;
    --accent: #d2a85a;
    --rule: #34332f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1a1b;
  --surface: #212122;
  --ink: #e9e7e2;
  --muted: #9a978f;
  --accent: #d2a85a;
  --rule: #34332f;
  color-scheme: dark;
}

/* 2. Base */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 19px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .4s, color .4s;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }
button, input { font: inherit; }
h1, h2, h3 { font-weight: 400; text-wrap: balance; }
em { font-style: normal; color: var(--accent); }
.wrap { width: min(1440px, 100% - 64px); margin-inline: auto; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Mono: the record's voice (labels, dates, status, menu) */
.mono, .tile-lab, .sec-head h2, .sec-head a, .site-foot, .pause-foot {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* 3. Focus and skip link (D1, D2) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }
.skip-link {
  position: fixed; top: 12px; left: 16px; z-index: 70;
  background: var(--ink); color: var(--bg);
  font: 600 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 12px 16px;
  transform: translateY(-160%);
  transition: transform .3s var(--ease);
}
.skip-link:focus { transform: none; }
main:focus { outline: none; }

/* 4. Small parts */
.arr { display: inline-block; color: var(--accent); transition: transform .4s var(--ease); }
a:hover .arr, button:hover .arr { transform: translateX(6px); }
a:hover .arr-back, button:hover .arr-back { transform: translateX(-6px); }
.prog { flex: 1; max-width: 140px; height: 2px; background: var(--rule); overflow: hidden; }
.prog i {
  display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--accent);
  transform-origin: left; animation: grow 1.6s var(--ease) .9s both;
}
@keyframes grow { from { transform: scaleX(0); } }
.tile-lab { display: flex; align-items: center; gap: 8px; color: var(--muted); }

/* 5. Header */
header.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  transition: transform .5s var(--ease), background .4s;
}
header.top.hide { transform: translateY(-100%); }
header.top.solid {
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.top-inner {
  width: min(1440px, 100% - 64px); margin-inline: auto; padding: 22px 0 18px;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 24px;
}
.logo { font: 600 16px/1 var(--mono); letter-spacing: -.05em; white-space: nowrap; }
.logo span { display: inline-block; color: var(--accent); animation: caret 1s steps(1, end) infinite; }
@keyframes caret { 0%, 48% { opacity: 1; } 49%, 100% { opacity: 0; } }
.top-actions { display: flex; gap: clamp(28px, 4vw, 56px); align-items: center; justify-content: end; }
.top-nav { display: flex; gap: clamp(28px, 4vw, 56px); font: 600 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.top-nav a { opacity: .82; transition: opacity .2s, color .2s; }
.top-nav a:hover, .top-nav a[aria-current="page"] { opacity: 1; color: var(--accent); }
.icon-btn {
  background: none; border: 0; color: var(--ink); cursor: pointer; padding: 6px;
  display: grid; place-items: center;
}
.icon-btn svg { width: 20px; height: 20px; transition: transform .5s var(--ease); }
.menu-btn { display: flex; flex-direction: column; align-items: stretch; gap: 5px; width: 34px; padding: 10px 6px; }
.menu-btn i { display: block; height: 1.5px; background: currentColor; transform-origin: right; transition: transform .4s var(--ease); }
.menu-btn i:last-child { transform: scaleX(.6); }
.menu-btn:hover i:last-child { transform: none; }

/* Theme toggle: the icon shows the mode it switches to (moon in light, sun in dark) */
.theme-btn:hover svg { transform: rotate(40deg); }
.theme-btn svg { animation: icon-in .5s var(--ease); }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: none; }
}
@keyframes icon-in { from { transform: rotate(-90deg) scale(.6); opacity: 0; } }

/* 6. Pause menu: the site's only game reference */
.pause {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(.6);
  backdrop-filter: blur(14px) saturate(.6);
  opacity: 0; visibility: hidden; transition: opacity .35s, visibility 0s .35s;
}
.pause.open { opacity: 1; visibility: visible; transition: opacity .35s; }
.pause ul { list-style: none; padding: 0; text-align: center; }
.pause li { overflow: hidden; }
.pause a, .pause button {
  display: inline-block; position: relative; padding: 2px 24px;
  font: 400 clamp(40px, 6vw, 76px)/1.15 var(--head); letter-spacing: -.02em;
  background: none; border: 0; color: var(--ink); cursor: pointer;
  transform: translateY(100%); transition: transform .6s var(--ease), color .2s;
}
.pause.open a, .pause.open button { transform: none; transition-delay: calc(var(--i) * 45ms + 80ms); }
.pause a::before, .pause button::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  background: var(--accent); opacity: 0; transform: translateX(-8px);
  transition: opacity .2s, transform .3s var(--ease);
}
.pause a:hover::before, .pause button:hover::before,
.pause a:focus-visible::before, .pause button:focus-visible::before { opacity: 1; transform: none; }
.pause a:focus-visible, .pause button:focus-visible { outline-offset: -2px; }
.pause .resume { color: var(--accent); }
.pause-foot { position: absolute; bottom: 32px; color: var(--muted); }
body.paused { overflow: hidden; }
body.paused main, body.paused .site-foot { filter: grayscale(.4); }
body.paused main *, body.paused main *::before, body.paused main *::after,
body.paused header.top * { animation-play-state: paused !important; }

/* 7. Sections */
.sec { position: relative; padding: 14vh 0 4vh; }
.sec-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 24px;
  border-top: 1px solid var(--ink); padding-top: 16px; margin-bottom: 24px;
}
.sec-head h2 { font-family: var(--mono); }
.sec-head a { color: var(--muted); transition: color .2s; }
.sec-head a:hover { color: var(--accent); }

/* Scroll reveal. Only active once site.js has run, so content never stays hidden without JS. */
.js-reveal .rv { opacity: 0; transform: translateY(40px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
.js-reveal .rv.in { opacity: 1; transform: none; }

/* 8. Newsletter */
.letters { padding: 14vh 0 10vh; }
.letters-box { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.letters-box > * { background: var(--bg); padding: 40px; }
.letters-box .lede { display: grid; gap: 14px; align-content: start; }
.letters-box h2 { font: 400 clamp(30px, 3.2vw, 48px)/1.08 var(--head); letter-spacing: -.02em; max-width: 16ch; }
.letters-box .lede p { color: var(--muted); font-size: 17px; line-height: 1.5; max-width: 40ch; }

/* Fields and the done panel share one grid cell so the box never changes height */
.sub { display: grid; grid-template-columns: minmax(0, 1fr); align-content: end; background: var(--surface); }
.sub > .fields, .sub > .done { grid-area: 1 / 1; min-width: 0; transition: opacity .35s var(--ease); }
.sub .fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: end; }
.sub .done { display: grid; gap: 12px; align-content: end; opacity: 0; visibility: hidden; }
.sub[data-state="done"] .fields { opacity: 0; visibility: hidden; }
.sub[data-state="done"] .done { opacity: 1; visibility: visible; }
.sub .done:focus { outline: none; }
.sub .done h3 { font: 500 28px/1.15 var(--head); letter-spacing: -.015em; }
.sub .done p { color: var(--muted); font-size: 17px; line-height: 1.5; max-width: 40ch; }
.sub .done p b { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.sub .row { display: flex; min-width: 0; border: 1px solid var(--ink); }
.sub .row:has([aria-invalid="true"]) { border-color: var(--accent); }
.sub input[type="email"] {
  flex: 1; min-width: 0; background: none; border: 0; color: var(--ink);
  font: 18px var(--body); padding: 14px 16px; outline: none;
}
.sub input[type="email"]::placeholder { color: var(--muted); }
.sub input[type="email"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sub input[readonly] { color: var(--muted); }
.sub button[type="submit"] {
  display: grid; place-items: center; background: var(--ink); color: var(--bg); border: 0;
  padding: 0 22px; cursor: pointer; font: 600 12px var(--mono); letter-spacing: .08em; text-transform: uppercase;
  transition: background .3s;
}
.sub button[type="submit"]:hover { background: var(--accent); }
.sub button[type="submit"]:disabled:hover { background: var(--ink); }
.sub button[type="submit"] > span { grid-area: 1 / 1; }
.sub button[type="submit"] .busy { visibility: hidden; }
.sub[data-state="sending"] button[type="submit"] .idle { visibility: hidden; }
.sub[data-state="sending"] button[type="submit"] .busy { visibility: visible; }
.sub[data-state="sending"] button[type="submit"] { cursor: progress; }
.sub .consent {
  display: flex; gap: 10px; align-items: center; cursor: pointer; color: var(--muted);
  font: 500 12px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase;
}
.sub .consent input { width: 14px; height: 14px; margin: 0; flex: none; accent-color: var(--accent); }
.sub .consent a { text-decoration: underline; text-underline-offset: 3px; }
.sub .consent a:hover { color: var(--accent); }
.sub .msg { font-size: 15px; line-height: 1.45; color: var(--accent); }
.sub .msg:empty { display: none; }
.sub .row + .msg { margin-top: -6px; }
.sub .consent + .msg { margin-top: -8px; }
.sub .again {
  justify-self: start; display: inline-flex; gap: 8px; margin-top: 4px; padding: 0;
  background: none; border: 0; color: var(--accent); cursor: pointer; font: 15px/1.4 var(--body);
}
.sub .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* 9. Footer */
.site-foot {
  border-top: 1px solid var(--rule); padding: 28px 0 48px;
  display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap;
  color: var(--muted);
}
.site-foot .left { display: flex; gap: 20px; align-items: center; }
.site-foot .logo { color: var(--ink); font-size: 14px; text-transform: none; }
.site-foot nav { display: flex; gap: 24px; flex-wrap: wrap; }
.site-foot nav a { transition: color .2s; }
.site-foot nav a:hover { color: var(--accent); }

/* 10. Mobile */
@media (max-width: 760px) {
  body { font-size: 18px; }
  .wrap, .top-inner { width: calc(100% - 32px); }
  .top-nav { display: none; }
  .top-actions { gap: 20px; }
  .letters-box { grid-template-columns: minmax(0, 1fr); }
  .letters-box > * { padding: 28px; }
  .site-foot nav { gap: 16px 20px; }
}

/* 11. Reduced motion: everything still, hidden items shown */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .logo span { opacity: 1; }
  .js-reveal .rv { opacity: 1; transform: none; }
  .pause a, .pause button { transform: none; }
}
