/* Contour — one 1040px column. The hero pairs the portrait with a topo-map
   field; a sticky section bar follows it; sections carry a left label rail
   on wide screens and stack on narrow ones. */
:root {
  --bg: #EEF1F2;
  --surface: #F8FAFA;
  --ink: #1B2730;
  --muted: #5B6A74;
  --line: #CCD5DA;
  --topo: #B5C3CA;
  --accent: #A8661A;
  --accent-soft: #F1E2CB;
  --scrim: rgba(12, 18, 22, .9);
  --on-scrim: #E3E9EC;
  --portrait-ground: #B9C4CC;

  --display: 'Familjen Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --body: 'Source Serif 4', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --col: 1040px;
  --nav-h: 56px;
  --ease: cubic-bezier(.32, .72, 0, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121A20; --surface: #18232B; --ink: #E3E9EC; --muted: #93A3AD;
    --line: #2A3842; --topo: #24333D; --accent: #E0A04A; --accent-soft: #3A2C17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121A20; --surface: #18232B; --ink: #E3E9EC; --muted: #93A3AD;
  --line: #2A3842; --topo: #24333D; --accent: #E0A04A; --accent-soft: #3A2C17;
  color-scheme: dark;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + env(safe-area-inset-top, 0px) + 8px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 var(--body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.wrap {
  max-width: var(--col);
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left, 0px), min(4vw, 40px));
}
img { max-width: 100%; }
a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.loading { color: var(--muted); font: 400 13px/1.4 var(--mono); margin: 0; }

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) 16px;
}
.mark { display: flex; align-items: center; gap: 10px; font: 700 18px/1 var(--display); letter-spacing: -.01em; text-decoration: none; }
.mark svg { width: 28px; height: 28px; color: var(--accent); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink); cursor: pointer; padding: 0; font-size: 16px;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 64px); align-items: end;
  padding-block: clamp(24px, 6vw, 72px) clamp(40px, 7vw, 88px);
}
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* z-index, not DOM order: the phone tier reorders the portrait ahead of the canvas. */
.hero > :not(canvas) { position: relative; z-index: 1; }
.hero-text { min-width: 0; }
h1 {
  font: 700 clamp(44px, 8.5vw, 96px)/.92 var(--display);
  letter-spacing: -.035em; margin: 0 0 20px; text-wrap: balance;
}
h1 span { color: var(--accent); }
.lede { font-size: clamp(18px, 2.1vw, 21px); max-width: 36ch; margin: 0 0 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.chips li {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px;
  font: 500 13px/1 var(--display); border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.chips svg { width: 15px; height: 15px; color: var(--accent); }

.portrait { margin: 0; justify-self: end; width: 100%; max-width: 380px; }
.portrait button {
  all: unset; cursor: pointer; position: relative; display: block; width: 100%; max-width: 100%; aspect-ratio: 4 / 5;
  border-radius: 6px; overflow: hidden; background: var(--portrait-ground);
  box-shadow: 0 30px 60px -30px rgba(10, 25, 35, .45);
}
.portrait button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.portrait img { display: block; width: 100%; height: 100%; object-fit: cover; }
.portrait figcaption {
  margin-top: 10px; font: 400 12px/1.4 var(--mono); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* The tap hint lives on the photo, so the caption keeps the full width and never wraps. */
.face-badge {
  position: absolute; right: 10px; bottom: 10px; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(10, 25, 35, .25);
  transition: transform .3s var(--ease);
}
.face-badge svg { width: 16px; height: 16px; }
.portrait button:hover .face-badge { transform: rotate(-90deg); }

/* ── Sticky section bar ─────────────────────────────────────────────────── */
.section-nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-block: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.section-nav-inner {
  display: flex; justify-content: center; gap: clamp(22px, 6vw, 48px);
  height: var(--nav-h); align-items: stretch;
  overflow-x: auto; scrollbar-width: none;
}
/* safe centering: if the tabs ever overflow, they scroll from the first tab instead of clipping it */
@supports (justify-content: safe center) { .section-nav-inner { justify-content: safe center; } }
.section-nav-inner::-webkit-scrollbar { display: none; }
.section-nav a {
  display: flex; align-items: center; flex: none;
  font: 600 17px/1 var(--display); color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.section-nav a:hover { color: var(--ink); }
.section-nav a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ── Sections ───────────────────────────────────────────────────────────── */
.section {
  display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px 40px;
  padding-block: clamp(40px, 6vw, 72px);
  border-top: 1px solid var(--line);
}
.section:first-child { border-top: 0; }
.label { font: 500 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.label b { display: block; margin-top: 6px; font: 700 22px/1.1 var(--display); letter-spacing: -.01em; text-transform: none; color: var(--ink); }
.dl {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; padding: 8px 12px;
  font: 500 13px/1 var(--display); letter-spacing: 0; text-transform: none; text-decoration: none;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 999px;
}
.dl:hover { background: var(--accent-soft); }
.dl svg { width: 15px; height: 15px; }

/* ── Photos ─────────────────────────────────────────────────────────────── */
.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.photo { margin: 0; min-width: 0; }
.photo button {
  all: unset; cursor: zoom-in; display: block; width: 100%; max-width: 100%; aspect-ratio: 3 / 4;
  border-radius: 4px; overflow: hidden; background: var(--topo);
}
.photo button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.photo button:hover img { transform: scale(1.03); }
.photo figcaption { margin-top: 8px; font: 400 12px/1.4 var(--mono); color: var(--muted); }
.photo .tag { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; margin-right: 6px; }

/* ── Resume ─────────────────────────────────────────────────────────────── */
.role { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding-bottom: 22px; }
.role h3 { margin: 0; font: 700 19px/1.25 var(--display); }
.role .org { color: var(--muted); font: italic 400 17px/1 var(--body); }
.role .yrs { font: 400 13px/1.5 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.role ul { grid-column: 1 / -1; margin: 6px 0 0; padding-left: 18px; max-width: 64ch; }
.role li { margin-bottom: 4px; }
.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px;
  margin-top: 12px; padding-top: 24px; border-top: 1px dashed var(--line);
}
.facts:empty { display: none; }
.facts h4 { margin: 0 0 10px; font: 500 12px/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.facts p { margin: 0; font-size: 15px; }

/* ── Projects ─────────────────────────────────────────────────────────── */
/* Brand plates: each card carries its app's own colours (from the vibelab
   landing page), fixed in both site themes. */
.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.proj {
  --p-bg: #1a1a24; --p-ink: #fff; --p-muted: rgba(255, 255, 255, .72); --p-line: rgba(255, 255, 255, .16);
  --p-cta-bg: #fff; --p-cta-ink: #000;
  position: relative; display: flex; flex-direction: column; gap: 18px; padding: 20px;
  background: var(--p-bg); color: var(--p-ink);
  border: 1px solid var(--p-line); border-radius: 16px;
  transition: transform .2s var(--ease), box-shadow .2s;
}
.proj:hover, .proj:focus-within { transform: translateY(-3px); box-shadow: 0 16px 36px -18px rgba(0, 0, 0, .55); }
.proj--bgb {
  --p-bg: linear-gradient(135deg, #2a1812 0%, #1a0f0b 100%);
  --p-ink: #F5E1B8; --p-muted: rgba(245, 225, 184, .74); --p-line: rgba(201, 146, 42, .35);
  --p-cta-bg: linear-gradient(135deg, #f59e0b, #f97316); --p-cta-ink: #1a0f0b;
}
.proj--bgb h3 { font-family: 'Crimson Text', Georgia, serif; font-weight: 600; font-size: 26px; letter-spacing: 0; }
.proj--vibelab {
  --p-bg: radial-gradient(120% 90% at 0% 0%, #2a2560 0%, #14122b 55%, #0a0a12 100%);
  --p-ink: #ECEBFF; --p-muted: rgba(236, 235, 255, .7); --p-line: rgba(140, 131, 255, .35);
  --p-cta-bg: #6c63ff; --p-cta-ink: #fff;
}
.proj--vibelab h3 { text-transform: lowercase; }
.proj-top { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 16px; align-items: center; }
.proj-art { width: 72px; height: 72px; }
.proj-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.proj h3 { margin: 0; font: 700 22px/1.1 var(--display); letter-spacing: -.01em; }
.proj h3 a { color: inherit; text-decoration: none; }
.proj h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.proj h3 a:focus-visible { outline: none; }
.proj:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.proj-tagline { margin: 0; font: 500 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--p-muted); }
.proj-blurb { margin: 4px 0 0; font-size: 15px; line-height: 1.5; color: var(--p-muted); }
.proj-apps { list-style: none; margin: 0; padding: 14px 0 0; border-top: 1px solid var(--p-line); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.proj-apps li { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.proj-app-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .14); }
.proj-app-icon img { width: 40px; height: 40px; }
.proj-app-icon--sb { background: linear-gradient(135deg, #E85D04, #8C3700); }
.proj-app-icon--dwp { background: linear-gradient(135deg, #F0EDE8, #DAD6CD); }
.proj-app-icon--tt { background: linear-gradient(135deg, #FFF6F2, #F9C5D1); }
.proj-app-icon--pp { background: linear-gradient(135deg, #FBF8F3, #E5DCC4); }
.proj-app-name { font: 500 11px/1.25 var(--display); color: var(--p-muted); text-align: center; overflow-wrap: anywhere; }
.proj-cta {
  align-self: flex-start; margin-top: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px;
  font: 600 14px/1 var(--display); border-radius: 999px; background: var(--p-cta-bg); color: var(--p-cta-ink);
}
.proj-cta svg { width: 16px; height: 16px; }

/* ── Contact ────────────────────────────────────────────────────────────── */
.contact { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.contact-lede { margin: 0; font-size: clamp(18px, 2.1vw, 21px); max-width: 40ch; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
  font: 600 15px/1 var(--display); text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  transition: border-color .2s, background .2s;
}
.btn:hover { border-color: var(--accent); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); }
.contact-address { margin: 0; font: 400 13px/1.4 var(--mono); color: var(--muted); user-select: all; overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .contact-actions .btn { flex: 1 1 100%; justify-content: center; }
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  padding-block: 28px 40px; border-top: 1px solid var(--line); text-align: center;
  font: 400 12px/1.5 var(--mono); color: var(--muted);
}

/* ── Lightbox ───────────────────────────────────────────────────────────── */
.lightbox {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; padding: 0; border: 0;
  background: transparent; color: var(--on-scrim);
}
.lightbox::backdrop { background: var(--scrim); }
.lightbox[open] { display: grid; place-items: center; }
.lightbox figure {
  margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: calc(64px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
  max-height: 100%;
}
.lightbox img { max-width: min(100%, 1200px); max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); object-fit: contain; border-radius: 4px; }
.lightbox figcaption { font: 400 13px/1.4 var(--mono); }
.lightbox-close { position: fixed; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; }

/* ── Tiers ──────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .photos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .portrait { justify-self: start; max-width: 300px; order: -1; }
  .section { grid-template-columns: 1fr; }
  /* Stacked sections: the label's action sits beside the heading instead of under it. */
  .label-with-action { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .label-with-action .dl { margin-top: 0; }
}
@media (max-width: 420px) {
  .role { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* 16px floor on anything focusable that takes text, so iOS never auto-zooms on focus. */
input, select, textarea { font-size: max(16px, 1em); }
