/* ============================================================
   cebause.one redesign — design tokens, base, nav, hero
   Surface: Decide/Learn (portfolio). One idea per section.
   ============================================================ */

:root {
  /* palette — warm graphite neutrals + one moss accent */
  --bg: #0d0e0e;            /* page            */
  --bg-elev: #141515;       /* cards           */
  --bg-elev-2: #1b1d1c;     /* chips, inputs   */
  --bg-elev-3: #232524;     /* hover / pressed */
  --line: #272927;
  --line-strong: #3a3d3a;
  --ink: #f3f2ee;
  --ink-2: #c9c8c1;
  --ink-3: #9a9a93;         /* 6.5:1 on cards, 6.0:1 on chips */
  --accent: #a7d48f;
  --accent-ink: #0c1a0f;
  --accent-dim: rgba(167, 212, 143, 0.12);
  --accent-line: rgba(167, 212, 143, 0.35);
  --ok: #a7d48f;

  /* type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* fluid scale — floor 12px for mono labels, 13px for readable text */
  --fs-2xs: 0.75rem;                                      /* 12px — uppercase mono labels only */
  --fs-xs: 0.8125rem;                                     /* 13px — tags, buttons-sm, captions */
  --fs-sm: 0.9375rem;                                     /* 15px — card body, nav, filters */
  --fs-base: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);    /* 16–17px — body */
  --fs-lg: clamp(1.125rem, 1.07rem + 0.25vw, 1.25rem);    /* 18–20px — lead, card titles */
  --fs-xl: clamp(1.375rem, 1.2rem + 0.7vw, 1.75rem);       /* 22–28px — featured titles, roles */
  --fs-2xl: clamp(1.75rem, 1.45rem + 1.2vw, 2.375rem);    /* 28–38px — section titles */
  --fs-3xl: clamp(2.25rem, 1.7rem + 2.4vw, 3.5rem);        /* 36–56px — contact title */
  --fs-hero: clamp(2.75rem, 1.6rem + 4.6vw, 5rem);         /* 44–80px */

  /* rhythm */
  --s-1: .25rem;  --s-2: .5rem;   --s-3: .75rem;  --s-4: 1rem;
  --s-5: 1.5rem;  --s-6: 2rem;    --s-7: 3rem;    --s-8: 4rem;
  --s-9: clamp(4rem, 7vw, 7rem);
  --gutter: clamp(1.25rem, 3vw, 2rem);

  /* radius — three values + pill */
  --r-sm: 8px;      /* tags, small chips, inputs   */
  --r-md: 14px;     /* cards, skill groups, xp     */
  --r-lg: 20px;     /* featured media, contact card, portrait */

  --max: 1120px;
  --max-narrow: 760px;
  --nav-h: 64px;

  /* elevation */
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.03) inset;
  --shadow-md: 0 12px 32px -16px rgba(0,0,0,0.65), 0 1px 0 rgba(255,255,255,0.04) inset;
  --shadow-lg: 0 32px 80px -24px rgba(0,0,0,0.8);

  /* motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 160ms var(--ease);   /* colour, borders   */
  --t-med: 320ms var(--ease);    /* transform         */
  --t-reveal: 500ms var(--ease); /* reveal on scroll  */
  --t-slow: 600ms var(--ease);   /* image zoom only    */
}

/* light theme — warm paper */
[data-theme="light"] {
  --bg: #f7f6f2;
  --bg-elev: #ffffff;
  --bg-elev-2: #efede6;
  --bg-elev-3: #e6e3da;
  --line: #e3e0d7;
  --line-strong: #c9c5ba;
  --ink: #15171a;
  --ink-2: #3f4347;         /* 9.2:1 */
  --ink-3: #5f6469;         /* 5.5:1 */
  --accent: #2f6f36;        /* 5.6:1 on paper — readable as text */
  --accent-ink: #ffffff;
  --accent-dim: rgba(47, 111, 54, 0.10);
  --accent-line: rgba(47, 111, 54, 0.35);
  --ok: #2f6f36;
  --shadow-sm: 0 1px 2px rgba(20,20,15,0.05);
  --shadow-md: 0 12px 32px -16px rgba(20,20,15,0.18), 0 1px 2px rgba(20,20,15,0.06);
  --shadow-lg: 0 32px 80px -24px rgba(20,20,15,0.35);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.08; letter-spacing: -0.022em; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.serif { font-family: var(--font-display); font-weight: 400; }
.mono { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.08em; text-transform: uppercase; }
.accent { color: var(--accent); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.container { width: min(var(--max), 100% - 2 * var(--gutter)); margin-inline: auto; }
.container.narrow { max-width: var(--max-narrow); }

section { position: relative; padding-block: var(--s-9); }

.skip {
  position: absolute; left: 1rem; top: -100px;
  background: var(--ink); color: var(--bg);
  padding: 0.6rem 1rem; border-radius: var(--r-sm);
  z-index: 100; font-weight: 600;
}
.skip:focus { top: 1rem; }

/* ---------- section headings ---------- */
/* number hangs in the left gutter; h2 and .sec-sub sit on the page's content edge (same edge as every grid) */
.sec-head {
  display: grid;
  grid-template-columns: 0 minmax(0, 1fr);
  gap: var(--s-2) 0;
  align-items: baseline;
  margin-bottom: var(--s-6);   /* heading → content: 32px */
}
.sec-num {
  grid-column: 1;
  justify-self: end;
  position: relative;
  left: calc(-1 * var(--s-5));  /* 24px of clear space between number and h2 */
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--accent);
  letter-spacing: 0.08em;
  padding-top: 0.4em;
  white-space: nowrap;
}
.sec-title { grid-column: 2; font-size: var(--fs-2xl); letter-spacing: -0.022em; }
.sec-title em {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-2);
}
.sec-sub {
  grid-column: 2;
  color: var(--ink-2);
  max-width: 56ch;
  font-size: var(--fs-lg);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  transition: transform var(--t-fast), background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); background: var(--bg-elev); }
.btn-sm { min-height: 44px; padding: 0.5rem 0.95rem; font-size: var(--fs-xs); }
.btn svg { width: 1em; height: 1em; flex: 0 0 auto; }

/* ---------- tags ---------- */
.tag {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  padding: 0.3rem 0.65rem;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
  cursor: default;
}
.skill-list { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; margin: 0; padding: 0; }

/* ---------- reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--t-reveal), transform var(--t-reveal);
}
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 60ms; }
.reveal[data-delay="2"] { transition-delay: 120ms; }
.reveal[data-delay="3"] { transition-delay: 180ms; }
.reveal[data-delay="4"] { transition-delay: 240ms; }
.reveal[data-delay="5"] { transition-delay: 300ms; }

/* ---------- nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; height: var(--nav-h);
  z-index: 50;
  display: flex; align-items: center;
  border-bottom: 1px solid transparent;
  transition: background var(--t-med), border-color var(--t-med);
}
.nav.scrolled {
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--line);
}
.nav-inner {
  width: min(var(--max), 100% - 2 * var(--gutter));
  max-width: calc(100vw - 2 * var(--gutter));
  margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
}
/* the <nav> wrapper holds the fixed-position drawer; it must not contribute min-content width to the bar */
.nav-inner > nav { min-width: 0; flex: 0 1 auto; }
.brand {
  font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 44px;
}
.brand-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.nav-links {
  display: flex; align-items: center; gap: var(--s-1);
  list-style: none; margin: 0; padding: 0;
}
.nav-links a {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2);
  transition: color var(--t-fast), background var(--t-fast);
}
/* hover: text only — visually distinct from the active pill */
.nav-links a:hover { color: var(--ink); background: transparent; }
/* active: filled pill + moss dot; exactly one link carries this */
.nav-links a.active { color: var(--ink); background: var(--bg-elev-2); }
.nav-links a.active::before {
  content: ""; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); margin-right: 0.5rem;
}
.nav-links a:focus-visible { background: var(--bg-elev-2); }
.nav-actions { display: flex; align-items: center; gap: var(--s-2); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--bg-elev-2); }
.icon-btn svg { width: 18px; height: 18px; }

.nav-burger {
  display: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  flex-direction: column; align-items: center; justify-content: center;
}
.nav-burger span {
  display: block; width: 18px; height: 2px; background: var(--ink);
  margin: 0; border-radius: 2px;
  transition: transform var(--t-med), opacity var(--t-med);
}
/* 2px bars, 5px apart: 3 bars + 2 gaps = 16px tall; each outer bar's centre is 7px from the middle */
.nav-burger span + span { margin-top: 5px; }
.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- hero ---------- */
.hero {
  min-height: 100svh;
  display: grid; align-items: center;
  padding-top: calc(var(--nav-h) + var(--s-6));
  padding-bottom: var(--s-7);
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: clamp(var(--s-6), 4vw, var(--s-8));
  align-items: center;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  margin-bottom: var(--s-5);
}
.hero-eyebrow::before { content: ""; width: 28px; height: 1px; background: var(--accent); }
.hero h1 {
  font-size: var(--fs-hero);
  letter-spacing: -0.035em;
  line-height: 1.0;
  font-weight: 650;
  margin-bottom: var(--s-5);
  text-wrap: initial;
}
.hero h1 em {
  font-family: var(--font-display);
  font-style: italic; font-weight: 400;
  color: var(--ink-2);
}
.hero-tagline {
  font-size: var(--fs-lg);
  color: var(--ink-2);
  max-width: 46ch;
  margin-bottom: var(--s-6);
  text-wrap: pretty;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-bottom: var(--s-7); }
.hero-meta {
  display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5);
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--ink-3); letter-spacing: 0.04em;
}
.hero-meta span { display: inline-flex; align-items: center; gap: 0.5rem; }
.hero-meta i {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px var(--accent-dim);
  animation: pulse 3s ease-in-out infinite;
}
@media (hover: hover) { .hero-meta i { animation: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.hero-portrait {
  position: relative;
  justify-self: center;
  width: min(100%, 400px);
}
.hero-portrait figure {
  margin: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.hero-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.portrait-glow {
  position: absolute; inset: -10% -6% auto auto;
  width: 60%; aspect-ratio: 1;
  background: radial-gradient(closest-side, var(--accent-dim), transparent);
  filter: blur(30px);
  pointer-events: none;
  /* decorative only: must never widen the layout viewport on narrow phones */
  right: 0; max-width: 60%;
}
.portrait-badge {
  position: absolute; left: 12px; bottom: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 0.5rem;
  box-shadow: var(--shadow-lg);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.portrait-badge b { color: var(--ok); font-weight: 600; }
.portrait-badge .sep { opacity: 0.5; }
/* never let the badge push the page wider than the viewport on narrow phones */
.portrait-badge { max-width: calc(100% - 8px); white-space: normal; line-height: 1.3; }

/* ---------- stats ---------- */
.stats {
  border-top: 1px solid var(--line);
  padding-block: var(--s-5);
}
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding-inline: var(--s-5);
  border-left: 1px solid var(--line);
}
.stat:first-child { border-left: 0; padding-left: 0; }
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 600; letter-spacing: -0.022em;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  line-height: 1.1;
}
.stat-label {
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase;
}

/* ---------- skills: ruled two-column index ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--s-8);
}
.skill-group {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
  padding: var(--s-4) 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  border-radius: 0;
  box-shadow: none;
  transition: border-color var(--t-med);
}
.skill-group:hover { border-top-color: var(--accent-line); }
.skill-title {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--accent);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin: 0; padding-top: 0.3em;
}

/* ---------- featured projects ---------- */
.featured { display: grid; gap: var(--s-6); }
.featured-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-6);
  align-items: start;          /* media top = text-column top */
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  overflow: hidden;
  transition: border-color var(--t-med);
}
.featured-item:hover { border-color: var(--line-strong); }
.featured-item:nth-child(even) .featured-media { order: 2; }
.featured-media {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  align-self: start;          /* media top = card inner top (matches the text column) */
  width: 100%;
  transition: border-color var(--t-fast);
}
.featured-media:hover { border-color: var(--line-strong); }
/* faux browser chrome: 3-dot bar */
.featured-media::before {
  content: "";
  flex: 0 0 28px;
  height: 28px;
  background:
    radial-gradient(circle at 14px 50%, #ff5f57 0 4px, transparent 4.5px),
    radial-gradient(circle at 30px 50%, #febc2e 0 4px, transparent 4.5px),
    radial-gradient(circle at 46px 50%, #28c840 0 4px, transparent 4.5px),
    var(--bg-elev-3);
  border-bottom: 1px solid var(--line);
  background-repeat: no-repeat;
}
.featured-media img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: top left;
  aspect-ratio: 600 / 304;
  transition: transform var(--t-slow);
}
.featured-media:hover img { transform: scale(1.02); }
.featured-body {
  display: flex; flex-direction: column; justify-content: flex-start;
  gap: var(--s-3);
}
.featured-eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
}
.featured-title { font-size: var(--fs-xl); letter-spacing: -0.022em; }
.featured-meta { font-size: var(--fs-xs); color: var(--ink-3); letter-spacing: 0.01em; }
.featured-desc { color: var(--ink-2); max-width: 52ch; text-wrap: pretty; }
.featured-outcome {
  padding: var(--s-3) var(--s-4);
  border-left: 2px solid var(--accent-line);
  background: var(--accent-dim);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: var(--fs-sm);
  color: var(--ink);
}
.featured-outcome b {
  display: block; font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 0.2rem;
}
.featured-stack { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.featured-links { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }

/* ---------- project grid ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: var(--s-2);
  margin-bottom: var(--s-6);
}
.filter {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2);
  background: transparent;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.filter:hover { border-color: var(--line-strong); color: var(--ink); }
.filter[aria-pressed="true"] {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.filter[aria-pressed="true"] .n { opacity: 0.8; }
.filter .n {
  margin-left: 0.35rem; font-family: var(--font-mono); font-size: var(--fs-2xs); opacity: 0.7;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
}
.card {
  position: relative;
  display: flex; flex-direction: column;
  padding: var(--s-4) var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-med), border-color var(--t-med), box-shadow var(--t-med);
  overflow: hidden;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
.card.hidden { display: none; }
/* negative margins cancel padding AND the 1px border so media is flush with the card edge */
.card-media, .card-noimg {
  margin: calc(-1 * (var(--s-4) + 1px)) calc(-1 * (var(--s-4) + 1px)) var(--s-4);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev-2);
}
.card-media img { width: 100%; height: 100%; object-fit: cover; object-position: top left; transition: transform var(--t-slow); }
.card:hover .card-media img { transform: scale(1.02); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.card-cat {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
}
.card-title {
  font-size: var(--fs-lg); letter-spacing: -0.022em; margin-bottom: var(--s-2);
  min-height: calc(2 * 1.35em);
}
.card-desc {
  color: var(--ink-2); font-size: var(--fs-sm); margin-bottom: var(--s-4); text-wrap: pretty;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 3lh;   /* reserve 3 lines so tags + links sit at the same y across a row */
}
/* tags sit directly under the (3-line-reserved) description so they align across a row; links pin to the card bottom */
.card-foot { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.card-links {
  display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4);
  margin-top: auto;                 /* pins the link row to the card bottom */
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}
.card-links a {
  min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-2);
  transition: color var(--t-fast);
}
.card-links a:hover { color: var(--accent); }
.card-links svg { width: 12px; height: 12px; }
/* monogram tile for projects without artwork */
.card-noimg {
  position: relative;
  display: grid; place-items: center;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(120% 120% at 100% 0%, var(--accent-dim), transparent 60%),
    var(--bg-elev-2);
  background-blend-mode: normal;
}
.card-noimg span {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.4rem 0.9rem;
  line-height: 1.1;
}
.grid-empty { display: none; padding: var(--s-7) 0; text-align: center; color: var(--ink-3); }
.grid-empty.show { display: block; }

/* ---------- education ---------- */
.edu-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.edu {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "head cgpa"
    "list cgpa";
  column-gap: var(--s-5);
  align-items: start;
  padding: var(--s-5) var(--s-6);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-med);
}
.edu:hover { border-color: var(--line-strong); }
.edu-head { grid-area: head; }
.edu-degree { font-size: var(--fs-lg); margin-bottom: 0.2rem; }
.edu-school { color: var(--ink-2); font-size: var(--fs-sm); margin-bottom: var(--s-2); }
.edu-period {
  display: inline-block; font-family: var(--font-mono); font-size: var(--fs-2xs);
  color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase;
}
.edu-cgpa {
  grid-area: cgpa;
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem;
  padding-left: var(--s-4);
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
.edu-cgpa b {
  font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.022em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.edu-cgpa span {
  font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--ink-3);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.edu-highlights { grid-area: list; list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: 0.5rem; }
.edu-highlights li {
  display: flex; gap: 0.7rem; font-size: var(--fs-sm); color: var(--ink-2);
}
.edu-highlights li::before {
  content: ""; flex: 0 0 auto; width: 12px; height: 1px; background: var(--accent-line);
  margin-top: 0.8em;
}

/* ---------- experience ---------- */
.xp { display: grid; gap: var(--s-4); }
.xp-item {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: var(--s-5);
  padding: var(--s-5) var(--s-6);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-med);
}
.xp-item:hover { border-color: var(--line-strong); }
.xp-item.current { border-color: var(--accent-line); background: linear-gradient(90deg, var(--accent-dim), transparent 40%), var(--bg-elev); }
.xp-logo {
  width: 44px; height: 44px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.4rem; line-height: 1;
  background: var(--bg-elev-2); color: var(--ink); border: 1px solid var(--line);
}
.xp-item.current .xp-logo { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.xp-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; margin-bottom: 0.15rem; }
.xp-role { font-size: var(--fs-xl); letter-spacing: -0.022em; }
.xp-company { color: var(--ink-2); font-size: var(--fs-lg); }
/* leading dot only makes sense beside the role; hide it once role and company stack */
.xp-company::before { content: "·"; margin-right: 0.5rem; color: var(--ink-3); }
.xp-loc { font-size: var(--fs-sm); color: var(--ink-3); margin-bottom: var(--s-4); display: flex; flex-wrap: wrap; gap: 0.3rem 0; align-items: center; }
/* dot separator sits at the END of each item (except the last), so it can never dangle at the start of a wrapped line */
.xp-loc span:not(:last-child)::after { content: "·"; margin-left: 0.6rem; color: var(--ink-3); opacity: 0.6; }
.xp-loc span + span { margin-left: 0.6rem; }
.xp-bullets { list-style: none; margin: 0 0 var(--s-4); padding: 0; display: grid; gap: 0.5rem; max-width: 60ch; }
.xp-bullets li { display: flex; gap: 0.7rem; color: var(--ink-2); font-size: var(--fs-sm); text-wrap: pretty; }
.xp-bullets li::before { content: ""; flex: 0 0 auto; width: 14px; height: 1px; background: var(--accent); margin-top: 0.85em; }
/* projects sub-block: linked chips + caption */
.xp-projects {
  margin: 0 0 var(--s-4); display: flex; flex-direction: column; gap: var(--s-2);
}
.xp-projects b {
  color: var(--ink-3); font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.08em;
  text-transform: uppercase; font-weight: 500;
}
.xp-project-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.xp-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 44px; padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev-2);
  color: var(--ink);
  font-weight: 600; font-size: var(--fs-sm);
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.xp-chip svg { width: 12px; height: 12px; transition: transform var(--t-fast); }
.xp-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.xp-chip:hover svg { transform: translateX(2px); }
.xp-chip-note { font-size: var(--fs-xs); color: var(--ink-3); }
.xp-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
/* period + badge chip, top-right at every breakpoint; right edge = card's inner edge */
.xp-period-wrap {
  position: absolute; top: var(--s-4); right: var(--s-6);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2);
  pointer-events: none;
}
.xp-period {
  font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--ink-3);
  text-align: right; letter-spacing: 0.04em; white-space: nowrap;
}
.xp-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.xp-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: pulse 3s ease-in-out infinite; }
/* reserve room for the top-right chip on the content column */
.xp-main { padding-right: 160px; }
@media (max-width: 1024px) { .xp-main { padding-right: 140px; } }

/* ---------- galleries: uniform 4:3 grid ---------- */
.masonry {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: var(--s-3);
}
.tile {
  position: relative; overflow: hidden;
  display: block; width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  cursor: zoom-in;
  color: inherit;
  transition: border-color var(--t-fast);
}
.tile:hover, .tile:focus-visible { border-color: var(--line-strong); }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--t-slow), filter var(--t-slow); }
.tile:hover img { transform: scale(1.02); }
/* persistent label on a bottom gradient */
.tile::after {
  content: "";
  position: absolute; inset: auto 0 0 0; height: 55%;
  background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0.45) 50%, transparent);
  pointer-events: none;
  transition: opacity var(--t-med);
}
.tile span {
  position: absolute; left: 14px; right: 14px; bottom: 12px; z-index: 1;
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.08em; text-transform: uppercase;
  color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,0.8);
  text-align: left; white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-label { opacity: 1; }
.tile-label::before {
  content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); margin-right: 0.5rem; vertical-align: middle;
}
.tile:hover::after, .tile:focus-visible::after { opacity: 0.85; }
/* wide lead tile: spans 2 columns and stretches to the row height defined by its 4:3 neighbour.
   The image is taken out of flow so it cannot inflate the row; the tile only ever fills what the neighbour sizes. */
.photo-masonry .tile:first-child { grid-column: span 2; aspect-ratio: auto; }
.photo-masonry .tile:first-child img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-masonry .tile::after { height: 0; }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.92);
  padding: 1.5rem;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); box-shadow: var(--shadow-lg); }
.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.15);
  display: grid; place-items: center;
  transition: background var(--t-fast), transform var(--t-fast);
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,0.18); }
.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-prev:hover { transform: translateY(-50%) translateX(-2px); }
.lightbox-next:hover { transform: translateY(-50%) translateX(2px); }
.lightbox-close svg, .lightbox-prev svg, .lightbox-next svg { width: 20px; height: 20px; }
.lightbox-count {
  position: absolute; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: var(--fs-2xs); color: rgba(255,255,255,0.7); letter-spacing: 0.1em;
}

/* ---------- contact ---------- */
.contact { padding-block: var(--s-9); }
.contact-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: var(--s-7);
  align-items: end;
  padding: clamp(var(--s-6), 5vw, var(--s-7));
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-dim), transparent 55%),
    var(--bg-elev);
  overflow: hidden;
}
.contact-main { min-width: 0; }
/* inside the card there is no gutter: the "08" sits on the card's inner edge, directly above the title */
.contact-main .sec-num { justify-self: start; position: static; left: auto; display: block; margin-bottom: var(--s-3); padding: 0; }
.contact-title {
  font-size: var(--fs-3xl);
  letter-spacing: -0.03em;
  margin-bottom: var(--s-4);
  max-width: 18ch;
}
.contact-title em { font-family: var(--font-display); font-style: italic; font-weight: 400; color: var(--accent); }
.contact-body { color: var(--ink-2); max-width: 46ch; margin-bottom: var(--s-6); font-size: var(--fs-lg); }
.contact-row { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.contact-links {
  display: flex; flex-direction: column; gap: var(--s-1);
  margin-top: 0; padding-top: 0; border-top: 0;
}
.contact-links-title {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: var(--s-2);
}
.contact-detail {
  display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: var(--s-3);
  min-height: 44px;
  border-top: 1px solid var(--line);
}
.contact-detail dt {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3);
}
.contact-detail dd { margin: 0; min-width: 0; }
.contact-detail dd span, .contact-links a {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px;
  font-family: var(--font-mono); font-size: var(--fs-sm); letter-spacing: 0.01em;
  color: var(--ink);
  white-space: normal; overflow-wrap: anywhere;
  transition: color var(--t-fast);
}
.contact-links a:hover { color: var(--accent); }
.contact-links svg { width: 14px; height: 14px; flex: 0 0 auto; opacity: 0.6; }
.contact-links a:hover svg { opacity: 1; }

/* ---------- footer ---------- */
.footer {
  padding-block: var(--s-5);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--ink-3);
}
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2) var(--s-5); align-items: center; }
.footer a { color: var(--ink-2); }
.footer a:hover { color: var(--ink); }
.footer-dev { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.08em; text-transform: uppercase; }
.footer-top {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px;
  font-weight: 600;
}
.footer-top svg { width: 14px; height: 14px; transition: transform var(--t-fast); }
.footer-top:hover svg { transform: translateY(-2px); }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .reveal { opacity: 1; transform: none; }
  .tile img, .featured-media img, .card-media img { transition: none !important; }
  .tile:hover img, .featured-media:hover img, .card:hover .card-media img,
  .card:hover, .btn:active, .footer-top:hover svg, .xp-chip:hover svg { transform: none; }
  .card-noimg { background-attachment: scroll; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-card { grid-template-columns: minmax(0, 1fr) 260px; gap: var(--s-6); }
}

@media (max-width: 860px) {
  :root { --nav-h: 60px; }
  .nav-links {
    position: fixed; inset: var(--nav-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: var(--s-3) var(--gutter) var(--s-4);
    transform: translateY(-110%);
    visibility: hidden;
    transition: transform var(--t-med), visibility var(--t-med);
    z-index: 49;
  }
  .nav-links.open { transform: none; visibility: visible; box-shadow: 0 16px 40px -20px rgba(0,0,0,0.7); }
  /* scrim so the open drawer never visually merges with the page below it */
  .nav-links.open::after {
    content: ""; position: fixed; inset: 0; z-index: -1;
    background: rgba(0,0,0,0.45); pointer-events: none;
  }
  .nav-links li { list-style: none; }
  .nav-links a { min-height: 48px; border-radius: var(--r-sm); font-size: var(--fs-base); padding: 0.6rem 0.9rem; }
  .nav-links a:hover { background: var(--bg-elev-2); }
  .nav-burger { display: flex; flex: 0 0 auto; }
  /* uniform 8px between Resume / theme / burger; kill the space-between gap before the burger */
  .nav-inner { gap: var(--s-2); justify-content: flex-start; }
  .nav-inner > nav { display: contents; }
  .brand { margin-right: auto; }
  .hero { min-height: auto; padding-top: calc(var(--nav-h) + var(--s-7)); }
  .hero-grid { grid-template-columns: 1fr; gap: var(--s-7); }
  .hero-portrait { width: 100%; max-width: 420px; justify-self: center; }
  .hero h1 { font-size: clamp(2.4rem, 10vw, 3.6rem); }
  .hero-cta .btn { flex: 1 1 auto; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5) 0; }
  .stat:nth-child(3) { border-left: 0; padding-left: 0; }
  .featured-item { grid-template-columns: 1fr; }
  .featured-item:nth-child(even) .featured-media { order: 0; }
  .edu-list { grid-template-columns: 1fr; }
  .sec-head { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  /* no gutter to hang the number into on phones: stack it above the title, on the content edge */
  .sec-num { grid-column: 1; justify-self: start; position: static; left: auto; padding-top: 0; }
  .sec-title, .sec-sub { grid-column: 1; }
  .masonry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* in 2 columns the wide tile owns its row alone (no 4:3 neighbour to size it): give it its own ratio */
  .photo-masonry .tile:first-child { grid-column: span 2; aspect-ratio: 2 / 1; }
  .photo-masonry .tile:first-child img { position: absolute; inset: 0; width: 100%; height: 100%; }
  .skills-grid { grid-template-columns: 1fr; }
  .skill-group { grid-template-columns: 1fr; gap: var(--s-2); }
  .skill-title { padding-top: 0; }
  .contact-card { grid-template-columns: 1fr; align-items: start; gap: var(--s-6); }
  .contact-links { border-top: 1px solid var(--line); padding-top: var(--s-4); }
  .footer-inner { justify-content: center; text-align: center; }
}

@media (max-width: 600px) {
  .container { width: min(var(--max), 100% - 2rem); }
  section { padding-block: var(--s-8); }
  .grid { grid-template-columns: 1fr; }
  .filters { gap: 0.4rem; }
  .filter { min-height: 44px; padding: 0.5rem 0.9rem; font-size: var(--fs-xs); }
  /* touch targets: every small control reaches 44px */
  .btn-sm, .nav-resume, .xp-chip { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding-inline: var(--s-3); }
  .stat:nth-child(odd) { padding-left: 0; border-left: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .xp-item { grid-template-columns: 1fr; padding: var(--s-4); gap: var(--s-3); }
  .xp-logo { width: 40px; height: 40px; font-size: 1.25rem; }
  .xp-company::before { content: none; }
  .xp-main { padding-right: 0; padding-top: var(--s-3); }
  .xp-item.current .xp-main { padding-top: 48px; }
  .xp-period-wrap { top: var(--s-4); right: var(--s-4); align-items: flex-start; }
  .edu { grid-template-columns: 1fr; grid-template-areas: "head" "cgpa" "list"; padding: var(--s-4); row-gap: var(--s-3); }
  .edu-cgpa { flex-direction: row; align-items: baseline; gap: var(--s-2); border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: var(--s-3); }
  .edu-highlights { margin-top: 0; }
  .hero-meta { gap: var(--s-2) var(--s-3); }
  .portrait-badge { left: 12px; bottom: 12px; }
  .contact-title { font-size: clamp(2rem, 9vw, 2.8rem); }
  .lightbox-prev, .lightbox-next { width: 44px; height: 44px; }
  .nav-actions .icon-btn { display: none; }
  .nav-actions .icon-btn.theme-toggle { display: inline-grid; }
  /* nav resume collapses to an icon-only 44px button; aria-label keeps it named */
  .nav-resume { padding: 0; width: 44px; }
  .nav-resume span { display: none; }
  .nav-resume svg { width: 16px; height: 16px; }
  .contact-detail { grid-template-columns: 80px minmax(0, 1fr); }
  .featured-item { padding: var(--s-4); }
}

/* very small */
@media (max-width: 380px) {
  .hero h1 { font-size: 2.2rem; }
  .stat-value { font-size: var(--fs-xl); }
  /* nav must fit brand + 3 × 44px buttons in 280px: tighten the brand, never the tap targets */
  .nav-inner { gap: var(--s-2); }
  .brand { font-size: 0.75rem; letter-spacing: 0.02em; gap: 0.4rem; min-width: 0; }
  .brand-dot { flex: 0 0 auto; }
  .nav-actions { gap: 6px; }
}
/* scrim is dark-only; keep it light in the light theme */
[data-theme="light"] .nav-links.open::after { background: rgba(0,0,0,0.18); }
