:root {
  --bg: #f4f3ee;
  --ink: #131311;
  --ink-soft: #5a5a55;
  --line: #d8d6cf;
  --card: #eceae3;
  --accent: #ff4a1c;
  --radius: 30px;
}
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; } /* reserve gutter so content doesn't shift, without a permanent empty track */
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }

/* page transitions — fade/slide in on load, fade out on navigation */
#root { animation: pageEnter 380ms cubic-bezier(.2, .7, .2, 1) backwards; }
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* client-side route swap fade (remounts via key={page}) */
.route-view { animation: routeFade 600ms ease both; }
@keyframes routeFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
body.page-leaving #root {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 240ms ease, transform 240ms ease;
}
@media (prefers-reduced-motion: reduce) {
  #root, .route-view { animation: none; }
  body.page-leaving #root { transition: none; transform: none; }
}

/* ── page-transition loader overlay ─────────────────────────────────────
   Painted from first frame (styles.css is render-blocking) so the one-time
   Babel compile on first load is covered — no blank flash. App hides it once
   React mounts; in-app navigation is client-side so it never shows again. */
#page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 380ms ease;
}
#page-loader.hide { opacity: 0; pointer-events: none; }

/* loader: equaliser bars (scaleY — compositor friendly, stays smooth while
   the main thread is busy compiling on first load) */
.ld-bars { display: flex; gap: 6px; align-items: center; height: 42px; }
.ld-bars i {
  width: 6px; height: 100%;
  background: var(--accent); border-radius: 3px;
  transform: scaleY(.3); transform-origin: center;
  animation: ldbars 1s ease-in-out infinite;
}
.ld-bars i:nth-child(2) { animation-delay: .15s; }
.ld-bars i:nth-child(3) { animation-delay: .30s; }
.ld-bars i:nth-child(4) { animation-delay: .45s; }
@keyframes ldbars { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
body {
  font-family: "Open Sans", system-ui, sans-serif;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.h1 { font-family: "Open Sans", sans-serif; font-weight: 600; font-size: 64px; line-height: 0.95; letter-spacing: -0.01em; margin: 0; }
.h2 { font-family: "Open Sans", sans-serif; font-weight: 400; font-size: 28px; line-height: 1.0; margin: 0; }
.body { font-family: "Open Sans", sans-serif; font-weight: 300; font-size: 16px; line-height: 1.55; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 400; font-size: 14px; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
::selection { background: var(--accent); color: var(--bg); }

.ph {
  background:
    repeating-linear-gradient(135deg,
      color-mix(in oklab, var(--ink) 6%, transparent) 0 1px,
      transparent 1px 14px),
    var(--card);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  color: var(--ink-soft);
}
.ph > img.ph-img,
.ph > video.ph-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .lbl {
  position: absolute;
  left: clamp(20px, 4%, 56px);
  bottom: clamp(20px, 4%, 56px);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 999px;
}
/* Variant for labels sitting on top of an image — transparent bg, white text,
   white pill outline. */
.ph .lbl.lbl--ghost {
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
  padding: 3px 9px; /* compensate for 1px border to keep size consistent */
}

.bigbtn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 0 5vw;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--bg);
  transition: background 200ms ease, color 200ms ease;
}
.bigbtn:hover { background: var(--ink); color: var(--bg); }
.bigbtn .arr { transition: transform 200ms ease; }
.bigbtn:hover .arr { transform: translateX(8px); }

header.site {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms;
}
header.site.scrolled { border-bottom-color: var(--line); }
header.site .row { display: flex; align-items: center; justify-content: space-between; padding: 18px 5vw; }

/* segmented pill nav with sliding highlight */
header.site nav.navseg {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
}
header.site nav.navseg .navseg-pill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  background: var(--ink);
  border-radius: 999px;
  z-index: 0;
  pointer-events: none;
  transition: transform 320ms cubic-bezier(.34, 1.2, .3, 1), width 320ms cubic-bezier(.34, 1.2, .3, 1), opacity 200ms ease, background-color 220ms ease;
  will-change: transform, width;
}
header.site nav.navseg a {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  color: var(--ink);
  padding: 8px 18px;
  border-radius: 999px;
  line-height: 1;
  transition: color 220ms ease;
}
header.site nav.navseg a.active { color: var(--bg); }

@media (max-width: 560px) {
  header.site nav.navseg a { padding: 8px 13px; }
}

section { padding: 0 5vw; }
.pad-y { padding-top: 96px; padding-bottom: 96px; }

.modal-back {
  position: fixed; inset: 0;
  background: color-mix(in oklab, var(--ink) 80%, transparent);
  z-index: 100;
  display: flex; justify-content: center;
  padding: 4vh 4vw;
  opacity: 0; pointer-events: none;
  transition: opacity 220ms ease;
}
.modal-back.open { opacity: 1; pointer-events: auto; }
.modal-card {
  background: var(--bg); border-radius: var(--radius);
  width: 100%; max-width: 1100px; max-height: 92vh;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 280ms cubic-bezier(.2,.8,.2,1);
}
.modal-back.open .modal-card { transform: translateY(0); }

/* The scroll happens on this inner element, inset from the card's rounded
   corners (margin top/bottom clears the 30px radius; small right gutter floats
   the bar inside) so the scrollbar never collides with the rounded corner —
   in every browser, not just webkit. */
.modal-scroll {
  max-height: calc(92vh - 36px);
  overflow-y: auto;
  margin: 18px 7px 18px 0;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklab, var(--ink) 26%, transparent) transparent;
}
.modal-scroll::-webkit-scrollbar { width: 8px; }
.modal-scroll::-webkit-scrollbar-track { background: transparent; }
.modal-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--ink) 26%, transparent);
  border-radius: 999px;
}
.modal-scroll::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklab, var(--ink) 42%, transparent);
}

footer.site { background: var(--ink); color: var(--bg); padding: 72px 5vw 36px; }
footer.site .grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; align-items: start; }
footer.site .mark { font-family: "Open Sans", sans-serif; font-weight: 600; font-size: 96px; line-height: 0.85; letter-spacing: -0.02em; }
footer.site .meta {
  display: flex; justify-content: space-between;
  border-top: 1px solid color-mix(in oklab, var(--bg) 20%, transparent);
  margin-top: 64px; padding-top: 20px;
  font-family: "IBM Plex Mono", monospace; font-size: 12px;
  color: color-mix(in oklab, var(--bg) 60%, transparent);
}
footer.site h4 {
  font-family: "IBM Plex Mono", monospace; font-weight: 400; font-size: 14px;
  margin: 0 0 14px;
  color: color-mix(in oklab, var(--bg) 50%, transparent);
}
footer.site ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
footer.site a:hover { color: var(--accent); }

/* half/half section — picture left, three text blocks right on desktop;
   picture moves between p1 and p2 on mobile (see mobile breakpoint below). */
.hh {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto auto auto 1fr;
  grid-template-areas:
    "pic ."
    "pic label"
    "pic p1"
    "pic p2"
    "pic .";
  column-gap: 48px;
  height: min(66vh, 700px);
  align-items: stretch;
}
.hh-pic   { grid-area: pic; }
.hh-label { grid-area: label; color: var(--ink-soft); margin: 0 0 20px; max-width: 520px; }
.hh-p1    { grid-area: p1; font-size: 22px; line-height: 1.4; font-weight: 400; margin: 0 0 16px; max-width: 520px; }
.hh-p2    { grid-area: p2; font-size: 16px; line-height: 1.65; color: var(--ink-soft); margin: 0; max-width: 520px; }

.work-card { transition: transform 220ms ease; }
.work-card:hover { transform: translateY(-4px); }
.work-card:hover .ph { filter: brightness(0.96); }

@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(4px) } }
.scroll-cue { transition: color 180ms ease; }
.scroll-cue:hover { color: var(--ink); }
@keyframes nameFade {
  0%   { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}
/* Word-by-word reveal used by the hero H1. Each word span gets its own
   animation-delay set inline. */
.word-reveal {
  display: inline-block;
  opacity: 0;
  animation: wordReveal 520ms cubic-bezier(.2,.8,.2,1) forwards;
  will-change: opacity, transform;
}
@keyframes wordReveal {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .h1 { font-size: 40px; } .h2 { font-size: 22px; }
  .pad-y { padding-top: 64px; padding-bottom: 64px; }
  footer.site .grid { grid-template-columns: 1fr 1fr; }
  footer.site .mark { font-size: 56px; }
}
@media (max-width: 800px) {
  .duo { grid-template-columns: 1fr !important; height: auto !important; }
  .duo > .ph { aspect-ratio: 4 / 3; }
  .duo-right { height: auto !important; }
  .duo-right > div:first-child { flex: 0 0 auto !important; }
  .duo-right > .ph { aspect-ratio: 4 / 3 !important; flex: 0 0 auto !important; min-height: 0; }
  .hh {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    grid-template-areas:
      "label"
      "p1"
      "pic"
      "p2" !important;
    height: auto !important;
    row-gap: 16px;
  }
  .hh-pic { aspect-ratio: 4 / 3; }
  .proj-canvas { min-height: 78vh !important; }
  /* Mobile project overlay — left-aligned column. Everything (logo, title,
     outcome, button) stacks with equal 18px gaps. The overlay is bottom-
     anchored well above the .lbl line so the button never collides with the
     "haptia · render…" caption. */
  .proj-overlay {
    flex-direction: column !important;
    align-items: flex-start !important;
    left: 50% !important;
    right: auto !important;
    bottom: 96px !important;
    top: auto !important;
    width: calc(100% - clamp(40px, 8%, 112px)) !important;
    transform: translateX(-50%) !important;
    gap: 18px !important;
  }
  .proj-overlay .view-work { align-self: flex-start !important; }
  .about { grid-template-columns: 1fr !important; gap: 24px !important; padding: 80px 5vw !important; }
  .hero-grid { grid-template-columns: 1fr !important; gap: 24px !important; }
  /* Hide the sub-label inside big buttons on mobile so the main label has
     room to fit on one line. */
  .bigbtn .mono { display: none; }
  .about-hero { grid-template-columns: 1fr !important; gap: 24px !important; }
  .about-row { grid-template-columns: 1fr !important; gap: 16px !important; }
  .exp-item { grid-template-columns: 1fr !important; gap: 8px !important; }
}
