/* Home page. Visual system taken from the cube: flat sticker colours, hard
   edges, hairline rules, one sans plus a mono. The only atmosphere is a faint
   dusk sky behind the hero. Spacing is one 8px scale (--s1 … --s7).
   The case study page uses styles.css. */

@font-face { font-family: "Host Grotesk"; font-weight: 400; font-display: swap; src: url("assets/fonts/host-grotesk-400.ttf") format("truetype"); }
@font-face { font-family: "Host Grotesk"; font-weight: 500; font-display: swap; src: url("assets/fonts/host-grotesk-500.ttf") format("truetype"); }
@font-face { font-family: "Atkinson Mono"; font-weight: 400; font-display: swap; src: url("assets/fonts/atkinson-mono-400.ttf") format("truetype"); }
@font-face { font-family: "Atkinson Mono"; font-weight: 500; font-display: swap; src: url("assets/fonts/atkinson-mono-500.ttf") format("truetype"); }

:root {
  --bg: #f3f1ea;
  --panel: #e7e4d9;
  --ink: #111111;
  --ink-2: #2e2d2a;
  --muted: #5c5a53;
  --rule: #cdc9bc;
  --link: #1f4fd1;
  --foot-bg: #111111;
  --foot-ink: #f3f1ea;
  --foot-muted: #a9a69d;

  /* dusk, kept faint */
  --sky-top: #ebe2ea;
  --sky-mid: #f4e2d3;
  --sun: rgb(255 176 120 / .32);
  --waves: rgb(176 104 84 / .10);

  --red: #e63946; --orange: #ff8c1a; --yellow: #ffd23f;
  --green: #1fae5b; --blue: #2f6bff; --white: #f5f5f0;

  --sans: "Host Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Atkinson Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px; --s6: 64px; --s7: 96px;
  --wrap: 1200px;
  --gutter: 32px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0e; --panel: #1a1a18; --ink: #f3f1ea; --ink-2: #dcd9cf; --muted: #a9a69d; --rule: #34332f;
    --link: #8fb0ff; --foot-bg: #1a1a18;
    --sky-top: #191632; --sky-mid: #22192c; --sun: rgb(255 140 100 / .13); --waves: rgb(255 190 150 / .06);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0e; --panel: #1a1a18; --ink: #f3f1ea; --ink-2: #dcd9cf; --muted: #a9a69d; --rule: #34332f;
  --link: #8fb0ff; --foot-bg: #1a1a18;
  --sky-top: #191632; --sky-mid: #22192c; --sun: rgb(255 140 100 / .13); --waves: rgb(255 190 150 / .06);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 80px; }
body {
  position: relative;
  isolation: isolate;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--link); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
strong { font-weight: 500; color: var(--ink); }
button { font: inherit; color: inherit; }
::selection { background: var(--yellow); color: #111; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.skip { position: absolute; left: var(--s2); top: -100px; padding: var(--s1) var(--s2); background: var(--ink); color: var(--bg); z-index: 100; }
.skip:focus { top: var(--s2); }
.label { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- Faint dusk behind the hero ---------- */
.sky {
  position: absolute; inset: 0 0 auto; z-index: -1;
  height: 980px;
  pointer-events: none;
  background:
    radial-gradient(38% 42% at 80% 58%, var(--sun), transparent 70%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 38%, transparent 92%);
}
.sky::after {
  /* water lines on the horizon */
  content: ""; position: absolute; inset: auto 0 4% 40%; height: 30%;
  background: repeating-linear-gradient(180deg, var(--waves) 0 1px, transparent 1px 10px);
  mask-image: radial-gradient(closest-side, #000 30%, transparent);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 var(--s3);
  border: 1.5px solid var(--ink); border-radius: 4px;
  background: transparent; color: var(--ink);
  font-size: .95rem; font-weight: 500; text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--bg); text-decoration: none; }
.btn--solid { background: var(--ink); color: var(--bg); }
.btn--solid:hover { background: var(--link); border-color: var(--link); color: #fff; }
:root[data-theme="dark"] .btn--solid:hover { color: #111; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn--solid:hover { color: #111; } }
.btn--sm { height: 36px; padding: 0 var(--s2); font-size: .875rem; }
.btn[disabled] { opacity: .4; cursor: not-allowed; background: transparent; color: var(--ink); }
.btn--solid[disabled] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Header ---------- */
.top { position: sticky; top: 0; z-index: 40; border-bottom: 1px solid transparent; }
.top.scrolled { background: var(--bg); border-bottom-color: var(--rule); }
.top-inner { display: flex; align-items: center; gap: var(--s3); min-height: 64px; }
.mark { display: inline-flex; align-items: center; gap: 12px; margin-right: auto; font-weight: 500; text-decoration: none; white-space: nowrap; }
.mark:hover { color: inherit; }
.mark-cube { width: 22px; height: 22px; color: var(--rule); }
.nav { display: flex; gap: var(--s3); font-size: .925rem; }
.nav a { text-decoration: none; }
.nav a:hover { text-decoration: underline; color: var(--ink); }
.tool {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--rule); border-radius: 4px; background: transparent;
  cursor: pointer;
}
.tool:hover { border-color: var(--ink); }
.theme-dot { width: 14px; height: 14px; border: 1.5px solid var(--ink); border-radius: 50%; background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: var(--s6); align-items: center;
  padding-block: var(--s6) var(--s7);
}
.hero h1 {
  font-size: clamp(3rem, 6.4vw, 6rem);
  font-weight: 500;
  line-height: .88;
  letter-spacing: -.05em;
}
.lede { margin-top: var(--s4); max-width: 40ch; font-size: clamp(1.125rem, 1.6vw, 1.3rem); line-height: 1.5; color: var(--ink-2); }
.facts { margin-top: var(--s4); max-width: 560px; border-top: 1px solid var(--ink); }
.facts div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--s2); padding: 12px 0; border-bottom: 1px solid var(--rule); }
.facts dt { font-family: var(--mono); font-size: .8rem; color: var(--muted); padding-top: 3px; }
.facts dd { color: var(--ink); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: var(--s4); }
.inline-links { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); margin-top: var(--s3); font-size: .95rem; }

.id { display: flex; align-items: flex-end; gap: var(--s3); }
.id-photo {
  flex: none;
  width: clamp(130px, 15vw, 200px); aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid var(--ink); border-radius: 3px;
  background: var(--panel);
}
.id-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 47% 0%; transform: scale(1.6); transform-origin: 47% 8%; }

/* ---------- Cube section ---------- */
.how { padding: 12px var(--s3); border-top: 1px solid var(--rule); font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.cube-panel { justify-self: end; width: 100%; max-width: 400px; border: 1px solid var(--ink); border-radius: 4px; background: var(--panel); }
.stage { position: relative; aspect-ratio: 1; cursor: grab; touch-action: none; }
.stage.over-cube { cursor: pointer; }
.stage.grabbing { cursor: grabbing; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage-fallback { position: absolute; inset: 18%; width: 64%; height: 64%; }
.stage.live .stage-fallback { display: none; }
.timer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px var(--s2); padding: var(--s2) var(--s3); border-top: 1px solid var(--ink); }
.timer-read { display: grid; }
.timer-time { font-family: var(--mono); font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer-state { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.timer-btns { display: flex; gap: var(--s1); }

/* ---------- Sections ---------- */
.block { padding-top: var(--s7); }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); padding-bottom: var(--s2); border-bottom: 1px solid var(--ink); }
.block-head h2 { display: flex; align-items: center; gap: .3em; font-size: clamp(2rem, 4.5vw, 3.25rem); font-weight: 500; line-height: 1; letter-spacing: -.04em; }
.block-head h2::before { content: ""; flex: none; width: .42em; height: .42em; border-radius: 2px; background: var(--c, var(--ink)); }

/* ---------- Work + Research: compact rows ---------- */
.projects { display: grid; }
.proj {
  --face: var(--ink);
  display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: var(--s3);
  padding-block: var(--s3);
  border-bottom: 1px solid var(--rule);
}
.thumb {
  display: block; align-self: start;
  aspect-ratio: 16 / 10; overflow: hidden;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--panel);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.thumb--light { background: #fafafa; }
.thumb--light img { object-fit: contain; object-position: center; }
.thumb--tile { display: grid; place-items: center; }
.thumb--tile span {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 3px;
  background: var(--face); color: #111;
  font-family: var(--mono); font-size: .9rem; font-weight: 500;
}
#room .thumb--tile span { border: 1px solid var(--ink); }
.proj-body { display: grid; gap: 6px; align-content: start; min-width: 0; }
.proj h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 1.2rem; font-weight: 500; line-height: 1.3; letter-spacing: -.015em; text-wrap: balance; }
.tag { padding: 1px 8px; border: 1px solid var(--rule); border-radius: 4px; font-family: var(--mono); font-size: .72rem; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.proj-meta { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.proj-body > p:not(.proj-meta):not(.tech):not(.actions) { max-width: 64ch; color: var(--ink-2); line-height: 1.55; }
.num { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.tech { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 4px var(--s3); font-weight: 500; font-size: .95rem; }

/* ---------- About ---------- */
.about { padding-top: var(--s5); }
.about-copy { display: grid; gap: var(--s2); color: var(--ink-2); max-width: 760px; }
.about-copy .big { font-size: clamp(1.25rem, 2vw, 1.5rem); line-height: 1.4; letter-spacing: -.01em; color: var(--ink); }
.about-copy .sub { margin-top: var(--s3); }
.rows { margin-top: var(--s2); border-top: 1px solid var(--ink); }
.rows div { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: var(--s2); padding: var(--s2) 0; border-bottom: 1px solid var(--rule); }
.rows dt { font-family: var(--mono); font-size: .8rem; color: var(--muted); padding-top: 3px; }
.rows dd { color: var(--ink-2); }
.rows--wide { margin-top: 0; border-top: 0; }
.rows--wide div { grid-template-columns: 200px minmax(0, 1fr); gap: var(--s4); padding-block: var(--s3); }
.ledger { border-top: 1px solid var(--ink); }
.ledger li { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: var(--s2); padding: 12px 0; border-bottom: 1px solid var(--rule); }
.ledger span { font-family: var(--mono); font-size: .8rem; color: var(--muted); padding-top: 3px; font-variant-numeric: tabular-nums; }
.ledger strong { margin-right: var(--s1); }

/* ---------- Footer ---------- */
.foot { margin-top: var(--s7); background: var(--foot-bg); color: var(--foot-ink); }
.foot-stripe { display: grid; grid-template-columns: repeat(6, 1fr); height: 8px; }
.foot-stripe i:nth-child(1) { background: var(--red); }
.foot-stripe i:nth-child(2) { background: var(--orange); }
.foot-stripe i:nth-child(3) { background: var(--yellow); }
.foot-stripe i:nth-child(4) { background: var(--green); }
.foot-stripe i:nth-child(5) { background: var(--blue); }
.foot-stripe i:nth-child(6) { background: var(--white); }
.foot-inner { display: grid; gap: var(--s3); padding-block: var(--s7) var(--s6); }
.foot h2 { font-size: clamp(2rem, 4.5vw, 3.25rem); font-weight: 500; line-height: 1; letter-spacing: -.04em; }
.foot-note { color: var(--foot-muted); }
.foot-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.mail { font-size: clamp(1.4rem, 4.2vw, 3rem); font-weight: 500; letter-spacing: -.035em; line-height: 1.1; overflow-wrap: anywhere; text-decoration-thickness: 2px; text-underline-offset: .15em; }
.mail:hover { color: var(--yellow); }
.foot .inline-links { margin-top: 0; }
.foot .inline-links a:hover { color: var(--yellow); }
.btn--inverse { border-color: var(--foot-ink); color: var(--foot-ink); }
.btn--inverse:hover { background: var(--foot-ink); color: var(--foot-bg); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: var(--s5); }
  .hero { padding-top: var(--s5); }
  .cube-panel { justify-self: start; }
}
@media (max-width: 760px) {
  :root { --gutter: 20px; }
  .nav { gap: var(--s2); font-size: .875rem; }
  .proj { grid-template-columns: 112px minmax(0, 1fr); gap: var(--s2); }
  .rows div, .rows--wide div { grid-template-columns: 1fr; gap: 4px; }
  .block { padding-top: var(--s6); }
}
@media (max-width: 520px) {
  .proj { grid-template-columns: 1fr; gap: 12px; }
  .thumb { max-width: 220px; }
  .thumb--tile { display: none; }
  :root { --gutter: 16px; }
  .top-inner { gap: 12px; }
  .mark span { display: none; }
  .nav { gap: 14px; }
  .facts div { grid-template-columns: 1fr; gap: 0; }
  .id { gap: var(--s2); }
  .id-photo { width: 120px; }
  .timer { padding: var(--s2); }
  .timer-time { font-size: 1.6rem; }
}
