/* ═══════════════════════════════════════════════════════════════════════
   Concrete & Steel — clean, minimal, engineered.
   All colours live in the tokens below; the 3D scene reads the same
   hexes from js/scene.js (keep the two in sync if you re-theme).
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  --bg: #E8EBEE;            /* cool concrete */
  --ink: #10151C;
  --ink-soft: #46515E;      /* ~6.5:1 on --bg */
  --line: rgba(16, 21, 28, 0.14);
  --card: rgba(246, 248, 250, 0.9);

  --navy: #24364D;
  --steel: #8DA2B8;
  --mist: #C3CDD8;
  --teal: #4FA39A;
  --sand: #CDBE9F;
  --copper: #C47A45;
  --accent: #1D5C8A;        /* steel blue: AA contrast for small text on --bg */
  --ok: #2B7A5C;

  --display: 'Space Grotesk', system-ui, sans-serif;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 12px;
  --nav-h: 68px;
  --gutter: clamp(20px, 5vw, 64px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, p, dl, dd { margin: 0; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 6px; }

/* Lenis requirements */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

.skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; transition: top .2s; }
.skip:focus { top: 12px; }

/* ── Layers ───────────────────────────────────────────────────────────── */
#scene {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; display: none;
}
html.has-3d #scene { display: block; }

/* Static pastel backdrop: used when WebGL is missing or motion is reduced. */
.fallback-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40vmax 40vmax at 85% 8%, rgba(141,162,184,.45), transparent 60%),
    radial-gradient(38vmax 38vmax at 8% 45%, rgba(79,163,154,.22), transparent 60%),
    radial-gradient(42vmax 42vmax at 90% 80%, rgba(36,54,77,.18), transparent 60%),
    var(--bg);
}
html.has-3d .fallback-bg { display: none; }

/* Faint blueprint grid between the canvas and the content */
body::after { content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(rgba(16,21,28,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(16,21,28,.045) 1px, transparent 1px);
  background-size: 56px 56px; }
main { position: relative; z-index: 1; }
/* Content sits above the canvas but lets empty areas pass pointer events
   through, so the 3D scene can still be hovered/clicked. Real content opts
   back in below. */
main, .wrap, .col, .stop { pointer-events: none; }
html:not(.has-3d) main, html:not(.has-3d) .wrap, html:not(.has-3d) .col, html:not(.has-3d) .stop { pointer-events: auto; }
main :is(a, button, input, textarea, label, .card, .note, .skill, .tl-item, .services li, h1, h2, h3, p, dl, ul, .portrait, .contact-form) { pointer-events: auto; }
/* …except wrappers that are big and would block the scene */
html.has-3d .tags, html.has-3d .pills, html.has-3d .about-top, html.has-3d .note-grid, html.has-3d .skills, html.has-3d .timeline, html.has-3d .services { pointer-events: none; }
html.has-3d :is(.tags, .pills) li { pointer-events: auto; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }
.stop { min-height: 100vh; min-height: 100svh; display: flex; align-items: center; padding: 14vh 0; }
.stop > .wrap { width: 100%; }
.col { max-width: 600px; }
.col-right { margin-left: auto; }

/* ── Type ─────────────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
h1 { font-size: clamp(2.5rem, 6vw, 4.8rem); }
h2 { font-size: clamp(2rem, 4.4vw, 3.3rem); }
h3 { font-size: 1.4rem; line-height: 1.2; }
em { font-style: normal; color: var(--accent); }
.hl { background: linear-gradient(transparent 66%, rgba(196,122,69,.55) 66%, rgba(196,122,69,.55) 92%, transparent 92%); padding: 0 .08em; }
.eyebrow { font-family: var(--mono); font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 500; color: var(--accent); margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(47,122,87,.18); }
.lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 34em; }
.hint { margin-top: 12px; color: var(--ink-soft); font-size: .95rem; }
.sec-head { margin-bottom: 36px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 14px 24px; border-radius: 10px; font: 600 .95rem var(--sans); text-decoration: none; cursor: pointer; border: 1.5px solid transparent; transition: transform .3s var(--ease), background .3s, box-shadow .3s; }
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 10px 24px -12px rgba(16,21,28,.6); }
.btn-primary:hover { background: var(--navy); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn:disabled { opacity: .6; cursor: progress; transform: none; }

/* ── Nav ──────────────────────────────────────────────────────────────── */
#nav { position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: var(--nav-h); padding: 0 var(--gutter); display: flex; align-items: center; justify-content: space-between; transition: background .4s, box-shadow .4s; }
#nav.scrolled { background: rgba(232,235,238,.9); box-shadow: 0 1px 0 var(--line); }
.logo { font: 700 1.35rem var(--display); letter-spacing: -.04em; text-decoration: none; }
.logo span, .loader-name span { color: var(--accent); }
#navLinks { display: flex; gap: 6px; }
#navLinks a { display: block; padding: 8px 14px; border-radius: 8px; font-family: var(--mono); font-size: .82rem !important; text-decoration: none; font-weight: 500; font-size: .95rem; color: var(--ink-soft); transition: background .3s, color .3s; }
#navLinks a:hover { color: var(--ink); background: rgba(255,255,255,.7); }
#navLinks a[aria-current="true"] { color: var(--ink); background: var(--mist); }
.menu-btn { display: none; width: 44px; height: 44px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; cursor: pointer; position: relative; }
.menu-btn span { position: absolute; left: 13px; right: 13px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .3s var(--ease); }
.menu-btn span:first-child { top: 18px; } .menu-btn span:last-child { top: 24px; }
.menu-btn[aria-expanded="true"] span:first-child { transform: translateY(3px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:last-child { transform: translateY(-3px) rotate(-45deg); }

/* Scroll-progress rail */
#rail { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); height: 120px; width: 4px; border-radius: 4px; background: var(--line); z-index: 20; overflow: hidden; }
#railFill { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: top; transform: scaleY(0); border-radius: 4px; }

/* Orb tooltip */
#orbLabel { position: fixed; left: 0; top: 0; z-index: 25; pointer-events: none; padding: 7px 12px; border-radius: 6px; background: var(--ink); color: #fff; font: 500 .8rem var(--mono); opacity: 0; transform: translate(-50%, -140%); transition: opacity .2s; white-space: nowrap; }
#orbLabel.on { opacity: 1; }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero-copy { max-width: 600px; }
.hero-copy h1 { margin-bottom: 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.stats { display: flex; gap: clamp(20px, 4vw, 44px); margin-top: 44px; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dd { font: 600 2.2rem var(--display); }
.stats dt { font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.scroll-cue { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; text-decoration: none; color: var(--ink-soft); pointer-events: auto; }
.scroll-cue i { width: 1.5px; height: 42px; background: var(--line); position: relative; overflow: hidden; }
.scroll-cue i::after { content: ''; position: absolute; left: 0; top: -50%; width: 100%; height: 50%; background: var(--ink); animation: cue 2s var(--ease) infinite; }
@keyframes cue { to { top: 110%; } }
.stop-hero { position: relative; }

/* ── About ────────────────────────────────────────────────────────────── */
.about-top { display: grid; grid-template-columns: 120px 1fr; gap: 24px; align-items: start; margin-bottom: 28px; }
.portrait { width: 120px; height: 120px; border-radius: 14px; object-fit: cover; object-position: 50% 15%; border: 3px solid #fff; box-shadow: 0 10px 30px -14px rgba(16,21,28,.45); }
.prose p + p { margin-top: 14px; }
.prose { color: var(--ink-soft); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 28px; }
.facts div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.facts dt { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.facts dd { font-weight: 500; overflow-wrap: anywhere; font-size: .95rem; }
.facts .ok { color: var(--ok); }
.note-grid { display: grid; gap: 16px; }
.note { border-radius: var(--radius); padding: 22px 24px; }
.note.steel { background: var(--mist); } .note.sand { background: var(--sand); }
.note h3 { margin-bottom: 8px; }
.note p { font-size: .98rem; }
.tags, .pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tags li, .pills li { font-family: var(--mono); font-size: .72rem; font-weight: 500; padding: 4px 10px; border-radius: 6px; background: rgba(255,255,255,.7); border: 1px solid var(--line); }

/* ── Skills ───────────────────────────────────────────────────────────── */
.skills { display: grid; gap: 12px; }
.skill { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; cursor: default; transition: transform .35s var(--ease), border-color .3s, box-shadow .3s; }
.skill:hover, .skill:focus-visible, .skill.on { transform: translateX(6px); border-color: var(--ink); box-shadow: 0 12px 28px -16px rgba(16,21,28,.45); }
.skill h3 { font-size: 1.1rem; }
.skill .pills { margin-top: 10px; }
.skill .pills li { font-size: .7rem; padding: 2px 8px; }

/* ── Projects ─────────────────────────────────────────────────────────── */
#projects { padding-top: 14vh; }
.projects-head { display: flex; flex-direction: column; align-items: flex-start; gap: 0; margin-bottom: 0; }
.projects-head .btn { margin-top: 20px; }
.project { min-height: 88vh; min-height: 88svh; padding: 8vh 0; }
.project .card { width: min(100%, 520px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: 0 1px 0 rgba(16,21,28,.05), 0 24px 50px -28px rgba(16,21,28,.5); transform-style: preserve-3d; will-change: transform; transition: box-shadow .3s; }
.project .card:hover { box-shadow: 0 1px 0 rgba(16,21,28,.05), 0 34px 60px -26px rgba(16,21,28,.55); }
.project:nth-of-type(even) .card { margin-left: auto; } /* alternate sides; the 3D card takes the opposite side */
.project h3 { font-size: 1.7rem; margin-bottom: 10px; }
.project p:not(.eyebrow) { color: var(--ink-soft); font-size: 1rem; }
.thumb { width: 100%; max-height: 190px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; background: var(--bg); }
.thumb-contain { object-fit: contain; padding: 14px; max-height: 150px; }
.links { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.links a { font-weight: 600; text-decoration: none; border-bottom: 2px solid var(--copper); padding-bottom: 2px; transition: border-color .3s; }
.links a:hover { border-color: var(--ink); }
.links a.live { background: var(--ink); color: #fff; border: 0; border-radius: 8px; padding: 6px 14px; }
.links a.live:hover { background: var(--navy); }
.facts .wide { grid-column: 1 / -1; }
.tl-item p a { color: var(--accent); }
.edu li p { margin-top: 2px; }

/* ── Experience ───────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 30px; display: grid; gap: 22px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; transition: border-color .4s, background .4s; }
.tl-item::before { content: ''; position: absolute; left: -29px; top: 24px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line); transition: background .4s, border-color .4s, box-shadow .4s; }
.tl-item.lit { border-color: rgba(79,163,154,.8); }
.tl-item.lit::before { background: var(--teal); border-color: var(--teal); box-shadow: 0 0 0 6px rgba(79,163,154,.25); }
.tl-date { font-family: var(--mono); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 500; color: var(--accent); }
.tl-item h3 { font-size: 1.2rem; margin: 4px 0 2px; }
.tl-co { font-weight: 600; font-size: .95rem; margin-bottom: 6px; }
.tl-item p:last-child { color: var(--ink-soft); font-size: .96rem; }
.sub-h { margin: 48px 0 16px; }
.services { display: grid; gap: 12px; }
.services li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 20px; }
.services h4 { font: 600 1rem var(--sans); }
.services p { color: var(--ink-soft); font-size: .93rem; }

/* ── Contact ──────────────────────────────────────────────────────────── */
#contact { align-items: flex-start; padding-top: 22vh; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 5vw, 64px); align-items: start; }
.contact-info, .contact-form { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: clamp(24px, 3.5vw, 40px); box-shadow: 0 1px 0 rgba(16,21,28,.05), 0 24px 50px -30px rgba(16,21,28,.45); }
.contact-info h2 { margin-bottom: 16px; }
.contact-list { margin: 24px 0; display: grid; gap: 10px; }
.contact-list li { display: flex; flex-direction: column; }
.contact-list span { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.contact-list a { font-weight: 500; overflow-wrap: anywhere; }
.socials { display: flex; gap: 10px; flex-wrap: wrap; }
.contact-form { display: grid; gap: 16px; }
.contact-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.contact-form label { display: grid; gap: 6px; font-weight: 600; font-size: .88rem; }
.contact-form input, .contact-form textarea { font: 400 1rem var(--sans); color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 8px; padding: 12px 14px; width: 100%; transition: border-color .25s, box-shadow .25s; }
.contact-form textarea { resize: vertical; }
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgba(141,162,184,.4); }
.contact-form .btn { justify-content: center; }
.form-note { font-size: .88rem; color: var(--ink-soft); }
.form-note.err { color: #A33A3A; } .form-note.good { color: var(--ok); }
.foot { margin-top: 64px; padding: 22px 0 28px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: .9rem; color: var(--ink-soft); pointer-events: auto; }

/* ── Loader ───────────────────────────────────────────────────────────── */
#loader { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; place-items: center; transition: opacity .7s var(--ease), visibility .7s; }
#loader.done { opacity: 0; visibility: hidden; }
.loader-inner { width: min(280px, 70vw); text-align: center; }
.loader-name { font: 700 2rem var(--display); letter-spacing: -.04em; margin-bottom: 22px; }
.loader-bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--steel), var(--teal)); border-radius: 6px; transition: transform .25s var(--ease); }
.loader-pct { margin-top: 12px; font-family: var(--mono); font-size: .8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ── Reveal (only hidden once JS confirms it can reveal them again) ──── */
html.js-reveal [data-reveal], html.js-reveal [data-hero] { opacity: 0; transform: translateY(26px); }
html.static { scroll-padding-top: 80px; scroll-behavior: smooth; }
/* Static mode: plain CSS fade-ins, no GSAP */
html.static.js-reveal [data-reveal], html.static.js-reveal [data-hero] { transition: opacity .8s var(--ease), transform .8s var(--ease); }
html.static.js-reveal .in { opacity: 1; transform: none; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .contact-grid { grid-template-columns: 1fr; }
  .col, .col-right { max-width: none; margin-left: 0; }
  #rail { display: none; }
}
@media (max-width: 760px) {
  #navLinks { position: fixed; inset: 0 0 auto 0; top: var(--nav-h); flex-direction: column; gap: 0; padding: 12px var(--gutter) 24px; background: rgba(232,235,238,.98); box-shadow: 0 20px 40px -20px rgba(16,21,28,.35); transform: translateY(-120%); visibility: hidden; transition: transform .45s var(--ease), visibility .45s; }
  #navLinks.open { transform: none; visibility: visible; }
  #navLinks a { padding: 14px 6px; font-size: 1.1rem; border-radius: 12px; }
  .menu-btn { display: block; }
  .stop { padding: 12vh 0; }
  /* On phones the 3D object sits in the top half (see scene.js), text in the bottom half. */
  .stop-hero { align-items: flex-end; padding-bottom: 14vh; }
  .project { align-items: flex-end; min-height: 100svh; }
  .project .card { margin-left: 0 !important; padding: 22px; }
  .project h3 { font-size: 1.45rem; }
  .thumb { max-height: 120px; }
  .about-top { grid-template-columns: 1fr; }
  .contact-form .row { grid-template-columns: 1fr; }
  .stats dd { font-size: 1.8rem; }
  .scroll-cue { display: none; }
  /* With the scene behind, give text on mobile a soft backing for contrast. */
  html.has-3d .hero-copy, html.has-3d .col > .sec-head { background: rgba(232,235,238,.8); border-radius: 12px; padding: 18px; margin-left: -18px; margin-right: -18px; }
}

/* ── Reduced motion: no scroll hijack, plain fades ───────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
