/* Colours are taken from the LATCH episode frames: the black caption bar, the pale simulator floor,
   and the yellow cubes the robot is asked to move. */
:root {
  --bg: #141414;
  --surface: #1f1f1e;
  --surface-2: #2a2a28;
  --ink: #ecebe6;
  --muted: #a8a7a1;
  --accent: #f4c20d;
  --accent-ink: #141414;
  --tile-2: #c9c8c1;
  --tile-3: #8f8e88;

  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-text: 'Barlow', system-ui, sans-serif;

  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-head: clamp(1.5rem, 1.1rem + 1.2vw, 2.25rem);
  --step-display: clamp(2rem, 0.9rem + 5vw, 5.5rem);

  --margin: clamp(1rem, 1.6vw, 1.5rem);
  --gap: 8px;
  --gutter: clamp(1rem, 2vw, 2rem);
  --section: clamp(7.5rem, 13vw, 14rem);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --t-press: 140ms;
  --t-hover: 180ms;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-text); font-size: var(--step-body); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
:target { scroll-margin-top: 2rem; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
.head { font-size: var(--step-head); line-height: 1.05; }
.display { font-size: var(--step-display); line-height: 0.98; letter-spacing: -0.02em; text-transform: uppercase; }
p { max-width: 62ch; text-wrap: pretty; }

main { position: relative; z-index: 1; background: var(--bg); padding-bottom: var(--section); }

/* ---------- hero: name band and rails ---------- */
.hero {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: auto 64px minmax(0, 1fr);
  gap: var(--gap);
  padding: var(--gap) var(--margin);
  height: 100svh;
  min-height: 720px;
  max-height: 1100px;
}
.band { grid-column: 1 / -1; background: var(--surface); overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 0.06em 0 0; }
.monument {
  font-size: 11.4vw; /* refined by main.js so the name fills the band exactly */
  line-height: 0.92;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  font-kerning: normal;
}
.monument span { display: inline-block; }
.links { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
.tile-link {
  display: block; padding: 12px 16px; background: var(--surface); text-decoration: none; font-weight: 500;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.tile-link:active { transform: scale(0.98); }

.rail-left { grid-column: 1 / 3; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: var(--gap); min-height: 0; }
.portrait { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.facts { background: var(--surface); padding: 14px 16px; font-size: var(--step-small); line-height: 1.4; display: flex; flex-direction: column; gap: 10px; overflow: auto; }

.hero-photo { grid-column: 3 / 11; position: relative; overflow: hidden; min-height: 0; background: var(--surface); }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; }
.statement {
  position: absolute; left: 0; bottom: 0; width: min(62%, 30rem);
  background: var(--bg); padding: 24px 28px 26px 24px;
  font-family: var(--font-display); font-weight: 500; font-size: var(--step-head); line-height: 1.08;
}

.rail-right { grid-column: 11 / 13; display: grid; grid-template-rows: repeat(5, minmax(0, 1fr)); gap: var(--gap); font-size: var(--step-small); line-height: 1.35; min-height: 0; }
.rail-right li { padding: 14px 16px; font-weight: 500; }
.t1 { background: var(--ink); color: var(--bg); }
.t2 { background: var(--tile-2); color: var(--bg); }
.t3 { background: var(--tile-3); color: var(--bg); }
.t4 { background: var(--surface-2); color: var(--ink); }
.t5 { background: var(--accent); color: var(--accent-ink); padding: 0 !important; }
.t5 a {
  display: flex; align-items: flex-end; height: 100%; padding: 14px 16px; text-decoration: none;
  font-weight: 500; font-size: var(--step-body); line-height: 1.2;
  transition: background-color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.t5 a:active { transform: scale(0.98); }

/* ---------- research: oversized visual, small cluster ---------- */
.research { padding-top: var(--section); }
.research-intro { padding-inline: var(--margin); display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); align-items: end; }
.research-intro h2 { grid-column: 1 / 5; }
.research-intro p { grid-column: 5 / 12; }

.project {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter);
  padding-inline: var(--margin); margin-top: 140px; align-items: end;
}
.project-visual { grid-column: 1 / 8; margin-left: calc(var(--margin) * -1); overflow: hidden; background: var(--surface); }
.project-visual img { width: 100%; height: 100%; object-fit: cover; }
.project--gridvad .project-visual { height: clamp(420px, 80svh, 860px); }
.project--latch .project-visual { height: auto; }
.project--thesis .project-visual img { height: auto; }
.plate-white { background: #fff; display: grid; place-items: center; padding: 3vw; }
.plate-white img { height: auto; object-fit: contain; }

.project-cluster { grid-column: 9 / 13; display: flex; flex-direction: column; gap: 18px; }
.cluster-image { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 6px; margin-bottom: 10px; }
.cite { color: var(--muted); font-size: var(--step-small); }
.cite strong { color: var(--ink); font-weight: 500; }
.project-links { display: flex; flex-wrap: wrap; gap: 8px; }
.project-links a, .cell {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; background: var(--surface);
  text-decoration: none; font-weight: 500;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.project-links a:active, .cell:active { transform: scale(0.97); }

/* LATCH episode: the frame and what the robot reported about it */
.episode-frame img { aspect-ratio: 4 / 3; height: auto; }
.episode-frame figcaption {
  padding: 18px 20px 20px var(--margin); background: var(--surface-2); min-height: 5.2em;
  display: flex; gap: 14px; align-items: baseline;
}
.verdict { flex: none; padding: 2px 10px; font-weight: 500; font-size: var(--step-small); background: var(--ink); color: var(--bg); }
.verdict--fail { background: var(--accent); color: var(--accent-ink); }
.command { color: var(--muted); }
.steps { display: grid; gap: 4px; }
.steps button {
  width: 100%; min-height: 44px; padding: 8px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface); text-align: left;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.steps button span { color: var(--muted); font-size: var(--step-small); }
.steps button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.steps button[aria-pressed="true"] span { color: var(--bg); }
.steps button:active { transform: scale(0.98); }

/* ---------- experience: statement, table pushed right ---------- */
.roles { padding: var(--section) var(--margin) 0; }
.roles h2 { text-indent: 3vw; }
.roles-body { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); margin-top: 96px; }
.roles-word { grid-column: 7; grid-row: 1; align-self: start; font-size: var(--step-small); color: var(--muted); padding-top: 2px; }
.rows { grid-column: 8 / 13; grid-row: 1; align-self: start; display: grid; gap: 26px; }
.rows li { display: grid; grid-template-columns: 28% 1fr auto; column-gap: 16px; align-items: baseline; }
.rows li.group { margin-top: 18px; }
.rows li span:first-child { color: var(--muted); }
.rows li span:last-child { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- apps: square plate, spare text ---------- */
.apps { margin-top: var(--section); background: var(--surface); display: grid; grid-template-columns: 1fr 1fr; min-height: 88svh; }
.apps-plate { display: grid; place-items: center; padding: 40px; }
.apps-plate img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: var(--surface-2); padding: 4% 0;
  transition: opacity 220ms ease;
}
.apps-plate img.is-swapping { opacity: 0; }
.apps-text { display: flex; flex-direction: column; justify-content: space-between; gap: 48px; padding: 40px var(--margin) 40px 40px; }
.tabs { display: flex; gap: 28px; margin-top: 20px; }
.tabs button { min-height: 44px; color: var(--muted); font-weight: 500; transition: color var(--t-hover) ease; }
.tabs button[aria-selected="true"] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 8px; text-decoration-color: var(--accent); }
.app { display: flex; flex-direction: column; gap: 20px; }
.app p { max-width: 34ch; }
.app + .app { margin-top: 64px; }
.js .app[hidden] { display: none; }
.js .app + .app { margin-top: 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); max-width: none !important; margin-top: 24px; }
.actions .cell { min-height: 72px; padding: 0 20px; background: var(--surface-2); }
.actions .cell--ink { background: var(--ink); color: var(--bg); }

/* ---------- community and honours: side facts, wide paragraph ---------- */
.record { padding: var(--section) var(--margin) 0; }
.record-row { display: grid; grid-template-columns: calc(34% - var(--margin)) minmax(0, 56%); margin-top: 48px; }
.side-facts { display: grid; gap: 20px; font-size: var(--step-small); align-content: start; }
.side-facts dt { color: var(--muted); }
.record-statement { font-weight: 500; max-width: 40ch; }
.record-row--lists { margin-top: 120px; grid-template-columns: calc(34% - var(--margin)) minmax(0, 1fr); }
.record-word { font-size: var(--step-small); color: var(--muted); padding-top: 4px; }
.record-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 23rem)); column-gap: 64px; row-gap: 48px; }
.record-lists h3 { font-family: var(--font-text); font-weight: 500; font-size: var(--step-body); letter-spacing: 0; margin-bottom: 14px; }
.record-lists li { display: flex; justify-content: space-between; gap: 16px; padding-block: 5px; }
.record-lists li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

/* ---------- marquee ---------- */
.marquee { margin-top: var(--section); overflow: hidden; white-space: nowrap; background: var(--accent); color: var(--accent-ink); }
.marquee-track { display: inline-flex; padding-block: 0.18em 0.1em; font: 700 var(--step-display)/1 var(--font-display); text-transform: uppercase; letter-spacing: -0.02em; }
.marquee-track span { padding-right: 0.4em; }

/* ---------- contact: address in display rows ---------- */
.contact { padding-top: var(--section); }
.contact h2 { padding-inline: var(--margin); margin-bottom: 32px; }
.contact-rows li { font: 500 var(--step-display)/1 var(--font-display); letter-spacing: -0.01em; }
.contact-rows li:nth-child(odd) { background: var(--surface); }
.contact-rows a, .contact-rows li > span {
  display: flex; align-items: flex-end; gap: 0.3em; min-height: clamp(84px, 10vw, 150px); padding: 0 var(--margin) 0.3em calc(var(--margin) + 4px);
  text-decoration: none; overflow-wrap: anywhere;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease;
}
.round {
  display: inline-grid; place-items: center; width: 0.9em; height: 0.9em; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); align-self: center; margin-left: 0.2em;
  transition: transform var(--t-hover) var(--ease-out);
}
.round svg { width: 55%; height: 55%; }

/* ---------- footer: columns above, wordmark below ---------- */
.site-footer {
  position: sticky; bottom: 0; z-index: 0;
  min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto auto;
  background: var(--ink); color: var(--bg); padding: 40px var(--margin) 20px;
}
.footer-cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gutter); }
.footer-cols li { color: #4a4945; padding-block: 3px; }
.footer-cols li:first-child { color: var(--bg); font-weight: 500; }
.footer-cols a { text-decoration: none; transition: color var(--t-hover) ease; }
.wordmark { grid-row: 3; }
.wordmark svg { width: 100%; height: auto; overflow: visible; }
.wordmark text { font: 700 100px var(--font-display); fill: currentColor; }
.wm-stack { display: none; }
.legal { margin-top: 20px; font-size: var(--step-small); color: #4a4945; }

/* ---------- hover only where a pointer hovers ---------- */
@media (hover: hover) and (pointer: fine) {
  .tile-link:hover { background: var(--accent); color: var(--accent-ink); }
  .t5 a:hover { background: var(--ink); }
  .project-links a:hover, .cell:is(a):hover { background: var(--accent); color: var(--accent-ink); }
  .steps button:hover:not([aria-pressed="true"]) { background: var(--surface-2); }
  .tabs button:hover { color: var(--ink); }
  .contact-rows a:hover { background: var(--accent); color: var(--accent-ink); }
  .contact-rows a:hover .round { transform: translateX(6px); background: var(--accent-ink); color: var(--accent); }
  .footer-cols a:hover { color: var(--bg); text-decoration: underline; }
  .marquee:hover .marquee-track { animation-play-state: paused; }
}

/* ---------- motion (content stays visible without JavaScript) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js [data-rise] { opacity: 0; transform: translateY(18px); animation: rise 800ms var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 90ms + 120ms); }
  .js [data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-out); transition-delay: calc(var(--i, 0) * 75ms); }
  .js [data-reveal].is-in { opacity: 1; transform: none; }
  .hero-photo img { animation: drift 22s var(--ease-soft) infinite alternate; transform-origin: 60% 40%; }
  .marquee-track { animation: marquee 38s linear infinite; }
  .episode-frame img { transition: opacity 200ms ease; }
  .episode-frame img.is-swapping { opacity: 0.25; }
}
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes drift { from { transform: scale(1.02); } to { transform: scale(1.1) translate(-1.5%, 1%); } }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- tablet and phone ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr 1fr; grid-template-rows: none; gap: 6px; height: auto; min-height: 0; max-height: none; }
  .band { padding: 0.08em 0 0.02em; }
  .monument { font-size: 19vw; line-height: 0.9; white-space: normal; text-align: left; width: 100%; padding-inline: 0.06em; }
  .monument span { display: block; }
  .links { grid-template-columns: 1fr 1fr; gap: 6px; }
  .tile-link { min-height: 56px; }
  .hero-photo { grid-column: 1 / -1; order: 1; background: none; }
  .hero-photo img { aspect-ratio: 4 / 3; height: auto; }
  .statement { position: static; width: auto; padding: 18px 0 8px; }
  .rail-left { grid-column: 1 / -1; order: 2; grid-template-columns: 1fr 1fr; grid-template-rows: none; gap: 6px; }
  .rail-right { grid-column: 1 / -1; order: 3; grid-template-columns: 1fr 1fr; grid-template-rows: none; gap: 6px; }
  .rail-right li { min-height: 88px; }
  .t5 { grid-column: 1 / -1; }

  .research-intro { display: block; }
  .research-intro p { margin-top: 20px; }
  .project { display: block; margin-top: 88px; }
  .project-visual { margin-left: calc(var(--margin) * -1); margin-right: calc(var(--margin) * -1); }
  .project--gridvad .project-visual, .project--thesis .project-visual { height: auto; }
  .project--thesis .project-visual img { aspect-ratio: 4 / 5; }
  .plate-white { padding: 4vw; }
  .project-cluster { margin-top: 28px; }
  .cluster-image { width: 70%; margin-left: auto; order: 9; margin-top: 10px; margin-bottom: 0; }
  .episode-frame figcaption { padding-left: var(--margin); }

  .roles h2 { text-indent: 0; }
  .roles-body { display: flex; flex-direction: column; margin-top: 48px; }
  .roles-word { display: none; }
  .rows li { grid-template-columns: 1fr auto; row-gap: 2px; }
  .rows li span:first-child { grid-column: 1; grid-row: 1; }
  .rows li span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .rows li span:last-child { grid-column: 2; grid-row: 1; }

  .apps { grid-template-columns: 1fr; min-height: 0; }
  .apps-plate { padding: 16px var(--margin) 0; order: 2; }
  .apps-text { display: contents; }
  .apps-text > div:first-child { order: 1; padding: 40px var(--margin) 0; }
  .tabs { gap: 22px; }
  .tabs button { font-size: 1.0625rem; }
  .app { order: 3; padding: 28px var(--margin) 48px; }
  .actions { grid-template-columns: 1fr; }
  .actions .cell { min-height: 60px; }

  .record-row { display: flex; flex-direction: column; gap: 28px; }
  .record-statement { order: -1; }
  .side-facts { grid-template-columns: 1fr 1fr; }
  .record-row--lists { display: block; margin-top: 64px; }
  .record-word { display: none; }
  .record-lists { grid-template-columns: 1fr; }

  .contact-rows li:last-child { background: var(--accent); color: var(--accent-ink); }
  .greeting a { justify-content: space-between; }
  .greeting .round { width: 56px; height: 56px; background: var(--accent-ink); color: var(--accent); }
  .contact-rows .arrow { display: none; }

  .footer-cols { grid-template-columns: 1fr 1fr; row-gap: 32px; }
  .wm-wide { display: none; }
  .wm-stack { display: block; }
}
