@view-transition { navigation: auto; }

:root {
  --ink-950: hsl(222 35% 7%);
  --ink-900: hsl(222 30% 11%);
  --ink-800: hsl(222 24% 17%);
  --slate-900: hsl(220 30% 12%);
  --steel-500: hsl(218 10% 46%);
  --steel-400: hsl(218 12% 62%);
  --steel-200: hsl(216 16% 84%);
  --paper-50: hsl(210 20% 98%);
  --paper-100: hsl(210 18% 94%);
  --sodium-400: hsl(38 96% 58%);
  --sodium-700: hsl(30 90% 32%);
  --signal-400: hsl(190 85% 52%);
  --signal-700: hsl(192 90% 28%);
  --stop-400: hsl(350 80% 64%);
  --stop-500: hsl(350 70% 50%);
  --display: "Big Shoulders Display", "Big Shoulders", "Arial Narrow", sans-serif;
  --text: "Schibsted Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --pad: clamp(20px, 5vw, 96px);
  --dots: radial-gradient(hsl(222 24% 17% / 0.7) 1px, transparent 1px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--ink-950); }
html.lenis, html.lenis body { height: auto; }
body {
  font-family: var(--text); font-size: clamp(17px, 1.2vw, 19px); line-height: 1.6;
  color: var(--slate-900); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--sodium-400); outline-offset: 3px; }

/* ---------- Top bar ---------- */
.hud { position: fixed; z-index: 30; pointer-events: none; color: var(--slate-900); transition: color 400ms; }
.hud a, .hud button { pointer-events: auto; }
body.night .hud { color: var(--paper-50); }
.hud-top { top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 20px var(--pad); view-transition-name: topbar; }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: 0.02em; text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.brand rect { fill: none; stroke: currentColor; stroke-width: 2; }
.brand .lit { fill: var(--sodium-400); stroke: none; transition: transform 300ms var(--ease-out); transform-box: fill-box; transform-origin: center; }
.brand:hover .lit { transform: scale(1.35); }
.nav { display: flex; align-items: center; gap: 28px; font-size: 15px; font-weight: 500; }
.nav a { position: relative; text-decoration: none; padding: 6px 0; }
.nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--sodium-400); transform: scaleX(0); transform-origin: left; transition: transform 360ms var(--ease-out); }
.nav a:hover::after, .nav a[aria-current="page"]::after { transform: scaleX(1); }
.kbd { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; border: 1px solid currentColor; border-radius: 2px; padding: 3px 7px; opacity: 0.7; background: none; color: inherit; cursor: pointer; }
.kbd:hover { opacity: 1; color: var(--sodium-400); }
.menu-btn { display: none; background: none; border: 1px solid currentColor; color: inherit; border-radius: 2px; padding: 7px 12px; font: 500 14px var(--text); cursor: pointer; }

/* Phone menu: full-screen, links rise in one by one */
.menu { position: fixed; inset: 0; z-index: 60; background-color: var(--ink-950); background-image: var(--dots); background-size: 24px 24px; color: var(--paper-50);
  display: grid; align-content: center; gap: 6px; padding: 0 var(--pad); clip-path: inset(0 0 100% 0); transition: clip-path 520ms var(--ease-out); pointer-events: none; }
.menu.open { clip-path: inset(0 0 0 0); pointer-events: auto; }
.menu a { font-family: var(--display); font-weight: 900; font-size: clamp(56px, 16vw, 120px); line-height: 0.95; text-transform: uppercase; text-decoration: none;
  transform: translateY(40px); opacity: 0; transition: transform 600ms var(--ease-out), opacity 600ms; transition-delay: calc(var(--i) * 50ms + 120ms); }
.menu.open a { transform: none; opacity: 1; }
.menu a[aria-current="page"] { color: var(--sodium-400); }
.menu .close-menu { position: absolute; top: 20px; right: var(--pad); }

/* Jump menu (Cmd or Ctrl + K) */
.palette { position: fixed; inset: 0; z-index: 70; display: none; place-items: start center; padding-top: 16vh; background: hsl(222 35% 4% / 0.6); backdrop-filter: blur(6px); }
.palette.open { display: grid; }
.palette-box { width: min(620px, 92vw); background: var(--ink-900); border: 1px solid var(--ink-800); color: var(--paper-50); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); animation: pop 260ms var(--ease-out); }
@keyframes pop { from { transform: translateY(-10px) scale(0.98); opacity: 0; } }
.palette input { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--ink-800); color: inherit; font: 500 18px var(--text); padding: 18px 20px; outline: none; }
.palette ul { list-style: none; max-height: 52vh; overflow: auto; padding: 8px 0; }
.palette li a { display: flex; justify-content: space-between; gap: 16px; padding: 10px 20px; text-decoration: none; }
.palette li a .mono { color: var(--steel-400); font-size: 11px; }
.palette li.sel a { background: var(--ink-800); color: var(--sodium-400); }
.palette .hint { padding: 10px 20px; border-top: 1px solid var(--ink-800); color: var(--steel-400); font-size: 11px; }

/* ---------- Shared parts ---------- */
.tag { display: inline-block; font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; padding: 5px 9px; border: 1px solid currentColor; border-radius: 2px; text-transform: uppercase; }
.tag.amber { color: var(--sodium-700); }
body.night .tag.amber { color: var(--sodium-400); }
.src { position: relative; display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--steel-500); cursor: help; pointer-events: auto; }
.src::before { content: ""; width: 7px; height: 7px; border: 1px solid currentColor; }
.src.v::before { background: var(--signal-700); border-color: var(--signal-700); }
body.night .src { color: var(--steel-400); }
body.night .src.v::before { background: var(--signal-400); border-color: var(--signal-400); }
.src:hover::after, .src:focus::after { content: attr(data-src); position: absolute; left: 0; bottom: 22px; width: 260px; background: var(--slate-900); color: var(--paper-50); padding: 10px 12px; font-size: 11px; line-height: 1.5; text-transform: none; letter-spacing: 0; z-index: 5; border: 1px solid var(--ink-800); }
.win { display: inline-grid; grid-template-columns: repeat(3, 6px); gap: 2px; padding: 3px; border: 1px solid currentColor; }
.win i { width: 6px; height: 6px; border: 1px solid currentColor; opacity: 0.5; }
.win[data-state="lit"] i:nth-child(6) { background: var(--sodium-400); border-color: var(--sodium-400); opacity: 1; }
.win[data-state="half"] i:nth-child(6) { background: linear-gradient(to top, var(--sodium-400) 50%, transparent 50%); border-color: var(--sodium-400); opacity: 1; }

/* ---------- Inner pages ---------- */
body.page { background-color: var(--ink-950); background-image: var(--dots); background-size: 24px 24px; color: var(--paper-50); }
body.page.day { background-color: var(--paper-50); background-image: radial-gradient(var(--steel-200) 1px, transparent 1px); color: var(--slate-900); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--pad); }
.page-head { padding: 22vh 0 8vh; display: grid; gap: 22px; }
.display { font-family: var(--display); font-weight: 900; line-height: 0.84; text-transform: uppercase; letter-spacing: -0.005em; }
.page-head h1 { font-size: clamp(72px, 13vw, 220px); }
.page-head p { max-width: 52ch; font-size: clamp(19px, 1.6vw, 23px); line-height: 1.45; color: hsl(210 20% 88%); }
body.day .page-head p { color: var(--slate-900); }
.kick { color: var(--steel-400); }
body.day .kick { color: var(--steel-500); }
.rule { border: 0; border-top: 1px solid var(--ink-800); }
body.day .rule { border-top-color: var(--steel-200); }

/* Split headline: each word rises out of a mask */
.split .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.04em; }
.split .w > span { display: inline-block; transform: translateY(105%); transition: transform 900ms var(--ease-out); transition-delay: calc(var(--i) * 70ms); }
.split.in .w > span { transform: none; }

/* Reveal on scroll */
.rv { opacity: 0; transform: translateY(28px); transition: opacity 800ms var(--ease-out), transform 900ms var(--ease-out); transition-delay: calc(var(--d, 0) * 1ms); }
.rv.in { opacity: 1; transform: none; }

/* Self-drawing lines */
.draw { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.draw.thin { stroke-width: 0.8; opacity: 0.6; }
.draw.amber { stroke: var(--sodium-400); }

.btn { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--ink-800); padding: 11px 16px; border-radius: 2px; font: 500 15px var(--text); text-decoration: none; background: none; color: inherit; cursor: pointer; transition: border-color 200ms, color 200ms; }
.btn:hover { border-color: var(--sodium-400); color: var(--sodium-400); }
body.day .btn { border-color: var(--steel-200); }
body.day .btn:hover { border-color: var(--sodium-700); color: var(--sodium-700); }

.site-foot { padding: 14vh 0 48px; display: grid; gap: 28px; }
.site-foot .big { font-size: clamp(56px, 9vw, 150px); }
.site-foot .big a { text-decoration: none; background: linear-gradient(var(--sodium-400), var(--sodium-400)) left bottom / 0 3px no-repeat; transition: background-size 500ms var(--ease-out); }
.site-foot .big a:hover { background-size: 100% 3px; }
.site-foot .row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; color: var(--steel-400); }
.site-foot .row a { text-decoration: none; }
.site-foot .row a:hover { color: var(--sodium-400); }
body.day .site-foot .row { color: var(--steel-500); }

/* ---------- Project diagrams ---------- */
.diagram { width: 100%; height: auto; overflow: visible; display: block; }
.diagram .edge { fill: none; stroke: var(--steel-400); stroke-width: 1.5; stroke-dasharray: 1; stroke-dashoffset: 1; }
.diagram .pulse { fill: var(--sodium-400); opacity: 0; }
.diagram .box { fill: var(--ink-950); stroke: var(--steel-400); stroke-width: 1.5; }
.diagram .human .box { stroke: var(--paper-50); stroke-width: 2; }
.diagram .ghost { fill: none; stroke: var(--sodium-400); stroke-dasharray: 4 4; opacity: var(--ghost, 0); }
.diagram text { font-family: var(--mono); font-size: 13px; letter-spacing: 0.05em; fill: var(--paper-50); text-transform: uppercase; }
.diagram .gate { fill: var(--stop-400); font-size: 11px; }
.diagram .gate.pass { fill: var(--signal-400); }

/* ---------- Page transitions ---------- */
::view-transition-old(root) { animation: 380ms var(--ease-out) both vt-out; }
::view-transition-new(root) { animation: 620ms var(--ease-out) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-24px); filter: blur(4px); } }
@keyframes vt-in { from { opacity: 0; clip-path: inset(100% 0 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
::view-transition-group(topbar) { animation-duration: 0s; }
html.vt-local::view-transition-old(root), html.vt-local::view-transition-new(root) { animation: none; }
html.vt-local::view-transition-group(*) { animation-duration: 560ms; animation-timing-function: var(--ease-out); }
::view-transition-group(case-title) { animation-duration: 700ms; animation-timing-function: var(--ease-out); }
::view-transition-old(case-title), ::view-transition-new(case-title) { height: 100%; width: auto; object-fit: contain; object-position: left; }

@media (max-width: 820px) {
  .nav { display: none; }
  .menu-btn { display: inline-block; }
  .page-head { padding-top: 18vh; }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .rv, .split .w > span, .menu a { transition: none; opacity: 1; transform: none; }
  .draw { stroke-dashoffset: 0; }
}
@media print {
  .hud, .menu, .palette, .site-foot, .no-print { display: none !important; }
  body.page, body.page.day { background: #fff; color: #000; }
}
