/* The hero is a photo plate: the full dark photo at night, just the cut-out of the person
   on the day ground. Below it the page is a set of dispatch waybills on form paper:
   day copy (light) or night shift (dark). */
@font-face {
  font-family: "Unbounded"; src: url("fonts/Unbounded-200-900.woff2") format("woff2");
  font-weight: 200 900; font-display: swap;
}
@font-face {
  font-family: "Archivo"; src: url("fonts/Archivo-400-900.woff2") format("woff2");
  font-weight: 400 900; font-stretch: 62% 125%; font-display: swap;
}

:root {
  /* fixed brand colours */
  --ink: #061317;
  --foam: #e4f0ec;
  --lagoon: #3df2d0;

  /* night shift (dark, default) */
  --ground: #061317;     /* page */
  --paper: #0a1c21;      /* slips, log and tools strip */
  --rule: #1f3e46;       /* form lines */
  --rule-strong: #2f5a63;
  --text: #e4f0ec;
  --text-soft: #c4d6d1;
  --muted: #8aa6a6;
  --accent: #3df2d0;
  --on-accent: #061317;
  --stamp: #3df2d0;
  --todo: #e6d3a8;
  --spot: rgba(61, 242, 208, 0.10);   /* pointer spotlight on panels */
  --edge-hi: rgba(228, 240, 236, 0.04);                       /* faint top highlight on panels */
  --lift: 0 18px 40px -28px rgba(0, 0, 0, 0.75);              /* soft offset shadow */
  --lift-hover: 0 26px 52px -30px rgba(0, 0, 0, 0.85);
  --hero-ground: transparent;
  --hero-text: var(--foam);
  --hero-accent: var(--lagoon);
  --unlit: color-mix(in srgb, #8aa6a6 60%, #061317);   /* statement words before they light up */

  /* Unbounded only for the big headlines (hero name, section heads, footer headline), sized to
     keep their old footprint. Archivo, with its width axis, for everything else. */
  --headline: "Unbounded", "Arial Black", Arial, sans-serif;
  --display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --gutter: clamp(16px, 4vw, 56px);
  --measure: 1200px;
  --step-0: clamp(1rem, 0.35vw + 0.9rem, 1.15rem);
  --step-1: clamp(1.2rem, 0.7vw + 1rem, 1.5rem);
  --step-2: clamp(1.5rem, 1.4vw + 1.05rem, 2.25rem);
  --step-3: clamp(2rem, 2.6vw + 1.1rem, 3.6rem);
  --step-hero: clamp(4rem, 17vw, 17rem);

  color-scheme: dark;
}
/* day copy (light) */
:root[data-theme="light"] {
  --ground: #eef3f2;
  --paper: #fbfdfc;
  --rule: #c5d3d0;
  --rule-strong: #9fb3af;
  --text: #0b2226;
  --text-soft: #24403f;
  --muted: #4c6466;
  --accent: #0b6f62;
  --on-accent: #ffffff;
  --stamp: #0b6f62;
  --todo: #8a5a00;
  --spot: rgba(11, 111, 98, 0.08);
  --edge-hi: rgba(255, 255, 255, 0.7);
  --lift: 0 16px 34px -26px rgba(11, 34, 38, 0.28);
  --lift-hover: 0 24px 46px -28px rgba(11, 34, 38, 0.34);
  --hero-ground: transparent;
  --hero-text: var(--text);
  --hero-accent: var(--accent);
  --unlit: color-mix(in srgb, #4c6466 80%, #eef3f2);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ground); scroll-behavior: smooth; overflow-x: clip; scrollbar-color: var(--rule-strong) var(--ground);
  transition: scrollbar-color .65s cubic-bezier(.4, 0, .2, 1); } /* the scrollbar sits outside the theme wave: fade it over the same time instead of flipping */
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.6;
  overflow-x: clip;
  padding-inline: var(--gutter);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--accent);
  accent-color: var(--accent);
}
/* colours ease only while the theme is being switched, never on load */
/* theme switch: the new theme is revealed as a circle from the button (main.js); no cross-fade */
::view-transition-group(*) { animation: none; }
::view-transition-old(*), ::view-transition-new(*) { animation: none; mix-blend-mode: normal; }
/* the grain canvas is lifted: while its grains move it stays live and draws the wave itself (old
   snapshot hidden); once settled (.vt-still) it gets the page's circle like the name in front of it */
.grain-box canvas { view-transition-name: grain; }
:root:not(.vt-still)::view-transition-old(grain) { display: none; }
.hero-name .line:nth-child(2) { view-transition-name: hero-front; }
.mono-front { view-transition-name: mono-front; }
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease, text-decoration-color .3s ease !important;
}
h1, h2, h3 { margin: 0; text-wrap: balance; }

/* film grain: barely-there printed texture in the page background (painted with the page,
   not as an overlay: a full-screen layer on top made animations drop frames) */
html, body { background-image: url("grain.png"); background-size: 160px 160px; }

/* Lenis smooth scroll (from lenis.css) */
html.lenis, html.lenis body { height: auto; }
html.lenis { scroll-behavior: auto; }
.lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
.lenis [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-smooth iframe { pointer-events: none; }

/* panels: solid paper, plus a soft spotlight that follows the pointer (only the hovered panel repaints) */
.slip, .glass {
  position: relative; isolation: isolate;
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift);
  transition: translate .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s ease, border-color .25s ease;
}
.slip:hover, .glass:hover { translate: 0 -3px; box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift-hover); }
.slip::after, .glass::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 70%);
  opacity: 0; transition: opacity .35s ease;
}
.slip:hover::after, .glass:hover::after { opacity: 1; }

p { margin: 0; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; }

.skip {
  position: absolute; left: var(--gutter); top: -100px; z-index: 50;
  background: var(--accent); color: var(--on-accent); padding: 8px 14px; font-weight: 700;
}
.skip:focus { top: 12px; }
.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;
}

/* scroll progress */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 40; pointer-events: none; }
.progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }

/* nav */
.nav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-inline: calc(-1 * var(--gutter));
  padding: 4px var(--gutter);
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
}
.brand, .nav nav a { display: inline-flex; align-items: center; min-height: 44px; }
/* the MS logo, drawn from assets/logo.svg as a mask so it takes the theme's text colour */
.brand { text-decoration: none; color: var(--text); }
.brand-mark {
  display: block; height: 30px; aspect-ratio: 436 / 283;
  background-color: currentColor;
  -webkit-mask: url("logo.svg") center / contain no-repeat;
  mask: url("logo.svg") center / contain no-repeat;
  transition: background-color .25s ease;
}
.brand:hover .brand-mark { background-color: var(--accent); }
.nav-end { display: flex; align-items: center; gap: clamp(10px, 2.4vw, 32px); }
.nav nav { display: flex; gap: clamp(14px, 3vw, 36px); }
.nav nav a {
  position: relative; text-decoration: none; color: var(--muted); font-size: 0.95rem; transition: color .2s;
}
.nav nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 8px; height: 2px;
  background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.nav nav a:hover { color: var(--text); }
.nav nav a[aria-current="true"] { color: var(--text); }
.nav nav a[aria-current="true"]::after { transform: scaleX(1); }

.theme {
  position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  background: transparent; color: var(--text); border: 0; border-radius: 50%; cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.theme:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
/* sun (night: switch to day) morphs into moon (day: switch to night) in place */
.theme-icon { width: 20px; height: 20px; overflow: visible; }
.theme-icon .morph { transform-box: fill-box; transform-origin: center; transition: transform .6s cubic-bezier(.65, 0, .35, 1), opacity .35s ease; }
.theme-icon .core { fill: currentColor; }
.theme-icon .rays { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-icon .bite { transform: translate(14px, -14px); }          /* parked outside: full sun */
:root[data-theme="light"] .theme-icon .core { transform: scale(1.6); }
:root[data-theme="light"] .theme-icon .bite { transform: translate(4px, -4px); }   /* slides in: crescent */
:root[data-theme="light"] .theme-icon .rays { transform: rotate(-90deg) scale(.4); opacity: 0; }
/* keep the morph's own timing while the page colours cross-fade */
.theme-anim .theme-icon .morph { transition: transform .6s cubic-bezier(.65, 0, .35, 1), opacity .35s ease, color .3s ease !important; }

/* hero: photo, then "MOHAMED" behind the head, then the cut-out of the person,
   then "SHAAFI" in front. The photo's background is tinted to --ink so it has no edge. */
.hero {
  position: relative;
  margin-inline: calc(-1 * var(--gutter));
  overflow: clip;
  background: var(--hero-ground); color: var(--hero-text);
}
.hero-stage {
  position: relative; isolation: isolate;
  height: min(82svh, 150vw);
}
.portrait {
  position: absolute; bottom: 0; left: 50%;
  height: 86%; width: auto; max-width: none;
  translate: -47% 0; /* the person sits a little left of the photo's centre */
  transform-origin: 50% 100%;
  /* fade the bottom and the side edges into the page */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 72%, transparent 98%), linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 72%, transparent 98%), linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  mask-composite: intersect;
  animation: fade 1.2s ease both;
}
.motion .portrait { animation: none; }
.portrait-cut { z-index: 2; }
/* the grain portrait (assets/grain.js) replaces both photos once it is drawn; the images stay
   in the page for their alt text and as the fallback */
.grain-box {
  aspect-ratio: 896 / 1195;
  -webkit-mask: none; mask: none;   /* the grains fade themselves; the box must not clip them */
}
.portrait.grain-box { -webkit-mask: none; mask: none; } /* beats the phone .portrait mask further down */
.grain-box canvas { position: absolute; display: block; pointer-events: none; }
.has-grain img.portrait { opacity: 0 !important; }
.mono { display: none; }
@keyframes fade { from { opacity: 0; } }

.hero-name {
  font-family: var(--headline);
  font-weight: 800;
  font-size: calc(var(--step-hero) * 0.8);
  line-height: 0.84;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.hero-name .line {
  position: absolute; left: 0; right: 0; z-index: 1;
  padding-inline: var(--gutter);
  overflow: clip; padding-bottom: 0.04em;
}
.hero-name .line:nth-child(1) { top: 15%; }
.hero-name .line:nth-child(2) { top: 64%; z-index: 3; text-align: right; color: var(--hero-accent); }
/* by day the dark photo (and its baked-in background) is dropped; the cut-out stands on the page */
:root[data-theme="light"] .portrait:not(.portrait-cut) { display: none; }
.hero-name .in { display: inline-block; scale: 0.8 1; transform-origin: 0 50%; animation: rise 1s cubic-bezier(.2,.8,.2,1) both; }
.hero-name .line:nth-child(2) .in { transform-origin: 100% 50%; }
.hero-name .line:nth-child(2) .in { animation-delay: .12s; }
@keyframes rise { from { transform: translateY(105%); } to { transform: none; } }
/* replayed after "back to top": a different entrance, the lines wipe in from their own sides */
.hero-name.replay .in { animation: wipe-l 1.05s cubic-bezier(.16, 1, .3, 1) both; }
.hero-name.replay .line:nth-child(2) .in { animation: wipe-r 1.05s cubic-bezier(.16, 1, .3, 1) .1s both; }
@keyframes wipe-l {
  from { clip-path: inset(0 100% 0 0); letter-spacing: 0.12em; filter: blur(6px); }
  to { clip-path: inset(0 0 0 0); letter-spacing: -0.02em; filter: none; }
}
@keyframes wipe-r {
  from { clip-path: inset(0 0 0 100%); letter-spacing: 0.12em; filter: blur(6px); }
  to { clip-path: inset(0 0 0 0); letter-spacing: -0.02em; filter: none; }
}


@media (min-width: 900px) {
  .hero-stage { height: calc(100svh - 58px); min-height: 560px; }
  .portrait { height: 100%; }
  .hero-name .line:nth-child(1) { top: 20%; }
  .hero-name .line:nth-child(2) { top: 57%; }
}

/* ---------- below the hero: dispatch waybills ---------- */
.intro, .work, .achievements, .tools-block { max-width: var(--measure); margin-inline: auto; }

/* about: one calm paragraph whose words light up as you read */
.intro { padding-block: clamp(80px, 14vh, 160px) clamp(56px, 9vh, 104px); }
.statement {
  font-family: var(--display); font-weight: 600; font-stretch: 100%;
  font-size: var(--step-2); line-height: 1.3; letter-spacing: -0.01em;
  max-width: 34ch;
}
.statement .w { transition: color .35s ease; }
.motion .statement .w { color: var(--unlit); }
.motion .statement .w.on { color: var(--text); }

/* section heads */
.section-head { margin-bottom: clamp(28px, 5vh, 48px); }
.section-head h2, .contact h2 {
  font-family: var(--headline); font-weight: 700;
  font-size: calc(var(--step-3) * 0.89); line-height: 1.05; letter-spacing: -0.02em;
}
.standfirst { color: var(--muted); margin-top: 12px; max-width: 52ch; }

/* work: slips stacked down one route line */
.work { padding-block: clamp(40px, 6vh, 72px); }
.slips { position: relative; display: grid; gap: clamp(20px, 3vh, 32px); padding-left: 32px; }
.route-line { position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--rule); }
.route-line span { display: block; height: 100%; background: var(--accent); transform-origin: top; transform: scaleY(var(--p, 1)); }

.slip {
  transition: border-color .25s ease;
}
/* route nodes: hollow squares that light up when the route line reaches them */
.node {
  position: absolute; left: -31px; top: 26px; width: 10px; height: 10px;
  background: var(--ground); border: 2px solid var(--accent);
  transition: transform .55s cubic-bezier(.34, 1.56, .64, 1), background-color .3s ease;
}
.node::after {
  content: ""; position: absolute; inset: -2px; border: 2px solid var(--accent); opacity: 0;
}
.slip.is-reached .node { background: var(--accent); transform: rotate(45deg) scale(1.3); }
.slip.is-reached .node::after { animation: ripple .8s cubic-bezier(.2, .8, .2, 1); }
@keyframes ripple {
  from { opacity: .9; transform: scale(1); }
  to { opacity: 0; transform: scale(3.2); }
}
.slip.is-reached .field-no dd { color: var(--accent); }
.slip:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--rule)); }
.slip-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 24px;
  padding: 16px 148px 16px 20px; border-bottom: 1px solid var(--rule);
}
.slip h3 {
  font-family: var(--display); font-weight: 800; font-stretch: 108%;
  font-size: var(--step-1); line-height: 1.15; letter-spacing: -0.01em;
}
.carrier { color: var(--muted); font-size: 0.9rem; }

.fields { margin: 0; display: grid; grid-template-columns: 1fr; }
.field { padding: 14px 20px; border-top: 1px solid var(--rule); min-width: 0; }
.field:first-child { border-top: 0; }
.field dt {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.field dd { margin: 0; font-weight: 600; line-height: 1.35; }
.field-no { display: flex; align-items: baseline; gap: 12px; }
.field-no dt { margin: 0; }
.field-no dd { font-weight: 800; font-variant-numeric: tabular-nums; transition: color .25s ease; }
.slip:hover .field-no dd { color: var(--accent); }
.field-route ol { list-style: none; margin: 0; padding: 0; counter-reset: leg; display: grid; gap: 2px; font-weight: 500; color: var(--text-soft); }
.field-route li { counter-increment: leg; display: grid; grid-template-columns: 1.4em 1fr; }
.field-route li::before { content: counter(leg); color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }

/* the stamp: heavy caps in ink, each pressed on at its own angle */
.stamp {
  position: absolute; top: 12px; right: var(--stamp-x, 18px);
  padding: 3px 10px; border: 2px solid var(--stamp); color: var(--stamp);
  font-family: var(--display); font-weight: 900; font-stretch: 112%;
  font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
  transform: rotate(var(--tilt, -4deg)); opacity: 0.92; pointer-events: none;
}
.slip:nth-of-type(1) .stamp { --tilt: -6deg; --stamp-x: 18px; }
.slip:nth-of-type(2) .stamp { --tilt: 4deg; --stamp-x: 30px; }
.slip:nth-of-type(3) .stamp { --tilt: -3deg; --stamp-x: 22px; }
.slip:nth-of-type(4) .stamp { --tilt: 6deg; --stamp-x: 34px; }
.slip:nth-of-type(5) .stamp { --tilt: -5deg; --stamp-x: 24px; }
.slip:nth-of-type(6) .stamp { --tilt: 3deg; --stamp-x: 28px; }
@media (max-width: 899px) { .slip .stamp { --stamp-x: 12px; } }


@media (min-width: 900px) {
  .slips { padding-left: 48px; }
  .route-line { left: 10px; }
  .node { left: -43px; top: 24px; }
  .slip-head { padding: 18px 210px 18px 24px; }
  .stamp { top: 14px; font-size: 0.95rem; padding: 4px 12px; }
  .fields { grid-template-columns: 88px 1fr 1fr minmax(230px, 0.95fr); }
  .field { padding: 18px 24px; border-top: 0; border-left: 1px solid var(--rule); }
  .field:first-child { border-left: 0; }
  .field-no { display: block; }
  .field-no dt { margin-bottom: 6px; }
  .field-no dd { font-size: var(--step-2); line-height: 1; }
  .field dd { font-size: 1.08rem; }
}

/* smaller jobs: a plain manifest under the slips */
.manifest { margin-top: clamp(28px, 5vh, 48px); padding-left: 32px; }
.manifest-title {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); padding-bottom: 10px; border-bottom: 1px solid var(--rule);
}
.manifest ul { list-style: none; margin: 0; padding: 0; }
.manifest li { padding: 12px 0; border-bottom: 1px solid var(--rule); color: var(--muted); }
.manifest b { color: var(--text); font-weight: 700; margin-right: 10px; }
@media (min-width: 900px) { .manifest { padding-left: 48px; } }

/* achievements: a ledger */
.achievements { padding-block: clamp(72px, 12vh, 140px) 0; }
.log { list-style: none; margin: 0; padding: 4px clamp(18px, 3vw, 32px); }
.entry { display: grid; gap: 4px 24px; padding: 18px 0; border-top: 1px solid var(--rule); }
.entry:first-child { border-top: 0; }
.entry time { color: var(--muted); font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.entry h3 { font-size: 1.1rem; font-weight: 700; line-height: 1.3; }
.entry p { color: var(--muted); max-width: 62ch; margin-top: 2px; }
.entry.next + .entry { border-top-style: dashed; }
.entry.next time { color: var(--accent); }
@media (min-width: 700px) { .entry { grid-template-columns: 140px 1fr; } }

/* tools: one labelled line */
.tools-block { padding-block: clamp(64px, 10vh, 120px) 0; }
.section-head-minor { margin-bottom: clamp(18px, 3vh, 28px); }
.section-head-minor h2 { font-size: var(--step-2); }
.tools-scroller { overflow: hidden; }
.tools { list-style: none; margin: 0; padding: 16px clamp(18px, 3vw, 28px); display: flex; flex-wrap: wrap; gap: 6px 0; font-weight: 600; font-size: 1.05rem; }
.tools li:not(:last-child)::after { content: "/"; color: var(--rule-strong); margin-inline: 12px; font-weight: 400; }
/* with motion the list becomes an endless strip (the copies are added by JS, hidden from screen readers) */
.tools-scroller.is-looping {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent);
}
.is-looping .tools { flex-wrap: nowrap; width: max-content; padding-inline: 0; white-space: nowrap; will-change: transform; }
.is-looping .tools li::after { content: "/"; color: var(--rule-strong); margin-inline: 14px; font-weight: 400; }

/* placeholders the owner still has to fill in */
.todo { color: var(--todo); text-decoration: underline dashed; text-underline-offset: 4px; }

/* ---------- finale: the footer is the contact scene, an echo of the hero ---------- */
.finale {
  position: relative; overflow: clip;
  margin-inline: calc(-1 * var(--gutter)); padding: 18px var(--gutter) 22px;
  min-height: 100svh; display: flex; flex-direction: column;
  border-top: 1px solid var(--rule);
  --trace: rgba(61, 242, 208, 0.30); --halo: #3df2d0; --core: #d9fff6; --halo-alpha: 0.35;
}
:root[data-theme="light"] .finale { --trace: rgba(11, 111, 98, 0.38); --halo: #0b6f62; --core: #0b6f62; --halo-alpha: 0.18; }

.finale-links {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 24px;
  font-family: var(--display); font-weight: 500; text-transform: uppercase; letter-spacing: 0.01em;
  font-size: clamp(0.95rem, 1.25vw, 1.35rem);
}
.finale-links a, .finale-links .todo {
  display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; color: var(--text);
  background: linear-gradient(currentColor, currentColor) left 80% / 0 2px no-repeat;
  transition: background-size .35s cubic-bezier(.2,.8,.2,1), color .2s ease;
}
.finale-links a:hover { background-size: 100% 2px; }
.finale-links { list-style: none; margin: 0; padding: 0; }
.finale-links .todo { color: var(--todo); }

.finale-stage { position: relative; flex: 1; display: grid; gap: 28px; padding-block: clamp(56px, 9vh, 96px) clamp(24px, 4vh, 48px); }
.finale-legal { color: var(--muted); font-size: 0.9rem; }
.finale-legal a { color: var(--text); text-decoration: none; }
.finale-legal a:hover { color: var(--accent); }
.finale-title {
  font-family: var(--headline); font-weight: 800;
  font-size: calc(clamp(3rem, 8.6vw, 9.5rem) * 0.92); line-height: 0.95; letter-spacing: -0.035em;
  position: relative; z-index: 1;
}
.ft-line { display: block; overflow: clip; padding-bottom: 0.06em; }
.ft-line > span { display: inline-block; }

.finale-contact { display: grid; gap: 16px; justify-items: start; }
.email {
  display: inline-flex; align-items: center; gap: 0.25em;
  font-family: var(--display); font-weight: 700; font-stretch: 100%;
  font-size: clamp(1.15rem, 2vw, 2.1rem); line-height: 1.1; letter-spacing: -0.015em;
  text-decoration: underline; text-decoration-color: var(--accent);
  text-decoration-thickness: 0.06em; text-underline-offset: 0.16em;
  overflow-wrap: anywhere; transition: color .2s ease;
}
.email .arrow { width: 0.8em; height: 0.8em; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.email:hover { color: var(--accent); }
.email:hover .arrow { transform: translate(0.08em, -0.08em); }
.finale-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.copy {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 18px;
  font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--on-accent); border: 0;
  transition: background-color .2s ease, transform .15s ease;
}
.copy:hover { background: var(--text); }
.copy:active { transform: translateY(1px); }
.copy .icon { width: 18px; height: 18px; }
.copy .icon-check { display: none; }
.copy.is-done .icon-copy { display: none; }
.copy.is-done .icon-check { display: block; animation: tick .3s ease-out; }
@keyframes tick { from { transform: scale(.4); opacity: 0; } }
.phone {
  display: inline-flex; align-items: center; min-height: 44px;
  font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums;
  text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.2em;
  transition: color .2s ease;
}
.phone:hover { color: var(--accent); }

/* rotating badge */
.badge { width: clamp(110px, 11vw, 190px); height: auto; overflow: visible; }
.badge text { fill: var(--text); font-family: var(--display); font-weight: 600; font-size: 15.5px; letter-spacing: 0.06em; }
.badge-dot { fill: var(--accent); }
.motion .badge { animation: spin 28s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* the logo behind the footer: a large, muted object in 3D. Darker copies stacked for
   thickness, a tinted face, faint light running along the lines. It leans toward the pointer. */
.energy-logo {
  position: relative; display: block; width: min(100%, 620px); aspect-ratio: 436 / 283;
  pointer-events: none;
  --m1: #11423d; --m2: #0b2c2b; --m3: #175a52; --m4: #0d3634; --edge: #062321; --spark: rgba(61, 242, 208, 0.32);
}
:root[data-theme="light"] .energy-logo {
  --m1: #d2e5e1; --m2: #bfd6d1; --m3: #e3efec; --m4: #c8ddd8; --edge: #a9c3be; --spark: rgba(11, 111, 98, 0.3);
}
.energy-fallback {
  position: absolute; inset: 0; background-color: var(--m3);
  -webkit-mask: url("logo.svg") center / contain no-repeat; mask: url("logo.svg") center / contain no-repeat;
}
.energy-logo.is-built .energy-fallback { display: none; }
/* the WebGL canvas is larger than the logo's box, so the turning solid never clips */
.el-canvas { position: absolute; left: -17.5%; top: -17.5%; width: 135%; height: 135%; }

@media (min-width: 900px) {
  /* one lockup: the title on the left, the logo behind its tail, both centred on the same line.
     Sized in title font-size units (--fs) so the overlap holds at every width. */
  .finale-stage { display: block; min-height: max(660px, 82svh); --fs: calc(clamp(3rem, 8.6vw, 9.5rem) * 0.92); }
  .energy-logo {
    --w: calc(var(--fs) * 5.1);
    position: absolute; left: calc(var(--fs) * 3.9); top: 50%; width: var(--w);
    margin-top: calc(var(--w) * -0.325); z-index: 0;
  }
  .finale-copy { position: absolute; left: 0; top: 50%; transform: translateY(-50%); z-index: 1; }
  .badge { position: absolute; left: 0; bottom: 4%; z-index: 1; }
  .finale-contact { position: absolute; right: 0; bottom: 4%; justify-items: end; text-align: right; z-index: 1; }
}

/* ---------- phones and small tablets only (desktop is untouched) ---------- */
@media (max-width: 899px) {
  :root { --nav-h: 53px; }
  /* the first screen is just the face and the name, filling the screen */
  .hero-stage { height: calc(100svh - var(--nav-h)); min-height: 460px; }
  .portrait {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 62%, transparent 92%), linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 62%, transparent 92%), linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  }
  /* the name is drawn as a monogram on two canvases; the h1 stays for screen readers and search */
  .hero-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .mono { display: block; position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
  .mono-front { z-index: 3; }
  /* the face lands right of centre on every phone, clear of the name on the left */
  .portrait { height: 94%; }
  /* the nav is fixed (not sticky) on phones: the steadiest bar while the page scrolls under it */
  .nav {
    position: fixed; top: 0; left: 0; right: 0; margin-inline: 0;
    background: var(--ground); -webkit-backdrop-filter: none; backdrop-filter: none;
    transform: translateZ(0);
  }
  main { padding-top: var(--nav-h); }
  /* with motion, the face stays put and dissolves while the text rises into its place */
  .motion .hero { position: sticky; top: var(--nav-h); z-index: 0; }
  /* grains may fly anywhere on screen: no clip, and while they fly at the top of the page the
     hero sits above the nav (grain.js .grain-up), so they scatter over it too */
  .hero { overflow: visible; }
  .hero.grain-up { z-index: 31; }
  .motion .intro {
    position: relative; z-index: 1;
    min-height: calc(100svh - var(--nav-h));
    display: flex; align-items: center;
    padding-block: 48px;
  }
  /* sideways swipes on the footer turn the logo; vertical swipes still scroll */
  .finale { touch-action: pan-y; }
}

@media (max-width: 640px) {
  .nav nav { gap: 14px; }
  .nav nav a { font-size: 0.88rem; }
}
@media (max-width: 380px) {
  .nav nav a[href="#achievements"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-name .in, .hero-name.replay .in, .portrait { animation: none; }
  .motion .statement .w { color: var(--text); }
  .copy.is-done .icon-check, .slip.is-reached .node::after { animation: none; }
  *, *::before, *::after { transition: none !important; }
}
