/* ============================================================
   Lahiru Supun — portfolio
   Pure CSS. Every visual decision is a custom property, so the
   tweaks panel can swap them at runtime through
   [data-theme] / [data-accent] / [data-font] / [data-bg] on <html>.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  /* Base palette (dark default) */
  --bg:            #09090b;
  --bg-elev:       #131316;
  --surface:       rgba(255, 255, 255, 0.03);
  --surface-2:     rgba(255, 255, 255, 0.06);
  --border:        rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --fg:            #d4d4d8;
  --fg-strong:     #fafafa;
  --fg-muted:      #a1a1aa;
  --fg-faint:      #80808a;
  --shadow:        0 28px 70px -28px rgba(0, 0, 0, 0.75);
  --shadow-nav:    0 10px 34px -16px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);

  /* Accent (lime default) */
  --accent:        #c6ff3d;
  --accent-2:      #3de8c0;          /* second hue for the hero glow */
  --accent-ink:    #0b0b0d;          /* text on accent fills */
  --accent-text:   var(--accent);    /* accent used as text */
  --accent-mark:   var(--accent);    /* dots, pips, rules */
  --accent-soft:   color-mix(in oklab, var(--accent) 14%, transparent);
  --glow:          16%;              /* strength of the accent glows */

  /* Type */
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-tracking: -0.045em;
  /* Hero name sizing, measured per font so the ink spans the container edge to
     edge: one line (wide screens), two lines (small screens), and a left shift
     that cancels the L's side bearing. Re-measure if the name or font changes. */
  --name-fit: 16.9cqi;
  --name-fit-stacked: 33.5cqi;
  --name-shift: -0.08em;

  --fs-xs: 12px;
  --fs-sm: 13.5px;
  --fs-md: 16px;
  --fs-lg: 18px;

  /* Layout */
  --container: 1120px;
  --gutter: clamp(20px, 4vw, 32px);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Grid bg */
  --grid-color: rgba(255, 255, 255, 0.045);
  --grid-size: 56px;
}

/* Accent overrides — kept in one place */
[data-accent="lime"]    { --accent: #c6ff3d; --accent-2: #3de8c0; }
[data-accent="cyan"]    { --accent: #5ee3ff; --accent-2: #7d8cff; }
[data-accent="amber"]   { --accent: #ffb454; --accent-2: #ff6f61; }
[data-accent="magenta"] { --accent: #ff5eaa; --accent-2: #a78bff; }
[data-accent="violet"]  { --accent: #a78bff; --accent-2: #5ee3ff; }

/* Light theme overrides */
[data-theme="light"] {
  color-scheme: light;
  --bg:            #f5f5f2;
  --bg-elev:       #ffffff;
  --surface:       rgba(255, 255, 255, 0.72);
  --surface-2:     #ffffff;
  --border:        rgba(12, 12, 16, 0.1);
  --border-strong: rgba(12, 12, 16, 0.22);
  --fg:            #3b3b43;
  --fg-strong:     #0c0c0f;
  --fg-muted:      #585862;
  --fg-faint:      #6b6b75;
  --shadow:        0 28px 70px -32px rgba(24, 24, 32, 0.3);
  --shadow-nav:    0 10px 34px -18px rgba(24, 24, 32, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.7);

  /* bright accents wash out on a light page, so text and marks use darker mixes */
  --accent-text:   color-mix(in oklab, var(--accent) 46%, #000);
  --accent-mark:   color-mix(in oklab, var(--accent) 64%, #000);
  --accent-soft:   color-mix(in oklab, var(--accent) 36%, transparent);
  --glow:          26%;

  --grid-color:    rgba(0, 0, 0, 0.055);
}

/* Font pairings (sans + mono). "mono" is the original all-monospace look. */
[data-font="geist"] {
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
[data-font="grotesk"] {
  --font-sans: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --name-fit: 16.65cqi;
  --name-fit-stacked: 32.7cqi;
  --name-shift: -0.07em;
}
[data-font="plex"] {
  --font-sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --name-fit: 17.3cqi;
  --name-fit-stacked: 34.2cqi;
  --name-shift: -0.082em;
}
[data-font="mono"] {
  --font-sans: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-tracking: -0.06em;
  --name-fit: 14.7cqi;
  --name-fit-stacked: 31.9cqi;
  --name-shift: -0.106em;
  --fs-md: 15px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 92px;   /* clear the floating nav on anchor jumps */
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.muted { color: var(--fg-muted); }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------- Focus ---------- */
:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-mark);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

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

/* ---------- Background FX layer ---------- */
.fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.fx > * {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .5s ease;
}

/* blueprint grid, fading out away from the top of the viewport */
.fx__grid {
  background-image:
    linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: center top;
  -webkit-mask-image: radial-gradient(ellipse 95% 80% at 50% 0%, #000 25%, transparent 80%);
          mask-image: radial-gradient(ellipse 95% 80% at 50% 0%, #000 25%, transparent 80%);
}

/* cursor-tracked spotlight — script.js moves it with a transform (compositor only) */
.fx > .fx__spot {
  inset: auto;
  left: -400px;
  top: -400px;
  width: 800px;
  height: 800px;
  border-radius: 50%;
  background: radial-gradient(
    closest-side,
    color-mix(in oklab, var(--accent) 11%, transparent) 0%,
    color-mix(in oklab, var(--accent) 4%, transparent) 45%,
    transparent 100%
  );
  transform: translate3d(50vw, 30vh, 0);
  will-change: transform;
}

/* scanlines + slow sweep — terminal CRT vibe */
.fx__scan {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    color-mix(in oklab, var(--fg-strong) 4%, transparent) 2px,
    color-mix(in oklab, var(--fg-strong) 4%, transparent) 3px
  );
}
.fx__scan::after {
  content: "";
  position: absolute;
  inset: -260px 0 auto 0;
  height: 260px;
  background: linear-gradient(
    to bottom,
    transparent,
    color-mix(in oklab, var(--accent) 9%, transparent) 50%,
    transparent
  );
  animation: scan-sweep 7s linear infinite;
}
@keyframes scan-sweep {
  to { transform: translateY(calc(100vh + 260px)); }
}

/* active mode toggles */
[data-bg="grid"]      .fx__grid { opacity: 1; }
[data-bg="spotlight"] .fx__grid { opacity: 0.8; }
[data-bg="spotlight"] .fx__spot { opacity: 1; }
[data-bg="scan"]      .fx__grid { opacity: 0.5; }
[data-bg="scan"]      .fx__scan { opacity: 1; }
[data-bg="off"]       .fx > *   { opacity: 0; }
@media (hover: none) {
  [data-bg="spotlight"] .fx__spot { opacity: 0.55; }
}

/* keep page content above the FX layer */
main, .footer { position: relative; z-index: 1; }

/* ---------- Floating nav ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 14px var(--gutter) 0;
  pointer-events: none;   /* only the capsule itself is interactive */
}
.topbar__inner {
  pointer-events: auto;
  width: min(100%, var(--container));
  height: 54px;
  margin-inline: auto;
  padding: 0 9px 0 18px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);   /* fallback without color-mix() */
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
          backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: var(--shadow-nav);
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-muted);
  white-space: nowrap;
}
.brand__prompt { color: var(--accent-text); }
.brand__path { color: var(--fg-strong); }
.brand__path-short { display: none; }
.brand__blink {
  color: var(--accent-text);
  animation: blink 1.1s steps(2, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  font-size: var(--fs-sm);
}
.nav a {
  position: relative;
  z-index: 1;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--fg-muted);
  white-space: nowrap;
  transition: color .2s ease;
}
.nav a:hover,
.nav a[aria-current="true"] { color: var(--fg-strong); }

/* sliding highlight — positioned by script.js */
.nav__pill {
  position: absolute;
  left: 0;
  top: 50%;
  width: var(--pill-w, 0px);
  height: 34px;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  opacity: 0;
  transform: translate3d(var(--pill-x, 0px), -50%, 0);
  transition: opacity .2s ease;
}
.nav.has-pill .nav__pill {
  opacity: 1;
  transition: transform .4s var(--ease), width .4s var(--ease), opacity .2s ease;
}

.topbar__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 6px;
}
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.icon-btn:hover {
  color: var(--fg-strong);
  background: var(--surface-2);
  border-color: var(--border);
}
.icon-btn .icon {
  grid-area: 1 / 1;
  transition: transform .5s var(--ease), opacity .25s ease;
}
/* dark shows the sun (switch to light), light shows the moon */
[data-theme="dark"]  .icon--moon,
[data-theme="light"] .icon--sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  isolation: isolate;
  padding: clamp(36px, 5.5vw, 76px) 0 0;
}

/* soft two-tone glow behind the hero (scrolls away with it) */
.hero__aurora {
  position: absolute;
  inset: -140px 0 auto 0;
  height: 820px;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(44% 58% at 16% 34%, color-mix(in oklab, var(--accent) var(--glow), transparent), transparent 72%),
    radial-gradient(40% 54% at 86% 14%, color-mix(in oklab, var(--accent-2) var(--glow), transparent), transparent 72%);
  transition: opacity .5s ease;
}
[data-bg="off"] .hero__aurora { opacity: 0; }

.hero__inner { container-type: inline-size; }

.hero__meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-muted);
  letter-spacing: 0.01em;
}
.hero__sep { color: var(--fg-faint); }
.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 13px 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg-strong);
}

.dot {
  position: relative;
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-mark);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes ping {
  70%, 100% { transform: scale(2.8); opacity: 0; }
}

.hero__name {
  margin: clamp(18px, 2.6vw, 30px) 0 0 var(--name-shift);
  font-size: clamp(56px, calc((100vw - 64px) * 0.169), 189px);   /* fallback without cq units */
  font-size: clamp(56px, var(--name-fit), 200px);
  font-weight: 600;
  line-height: 0.92;
  letter-spacing: var(--display-tracking);
  color: var(--fg-strong);
  white-space: nowrap;
}
.hero__name-visual { display: block; }
.hero__word {
  display: inline-block;
  /* padding keeps descenders inside the clipped gradient; the margin cancels it out */
  padding-block: 0.16em;
  margin-block: -0.16em;
  background: linear-gradient(
    180deg,
    var(--fg-strong) 40%,
    color-mix(in oklab, var(--fg-strong) 50%, transparent) 100%
  );
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero__caret {
  -webkit-text-fill-color: var(--accent-mark);
  color: var(--accent-mark);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
  margin-top: clamp(26px, 3.6vw, 44px);
  padding-top: clamp(24px, 3vw, 36px);
  border-top: 1px solid var(--border);
}

.hero__role {
  margin: 0 0 14px;
  font-size: clamp(13px, 4.55vw, 22px);   /* fluid so the three parts share a line on phones */
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--fg-strong);
}
.hero__role span { white-space: nowrap; }
.hero__role span + span::before {
  content: "/";
  content: "/" / "";   /* decorative: no alt text for screen readers */
  margin-inline: 0.2em 0.45em;
  color: var(--accent-text);
}

.hero__intro {
  max-width: 54ch;
  margin: 0 0 30px;
  font-size: 17px;
  color: var(--fg-muted);
  text-wrap: pretty;
}
.hero__intro em {
  padding: 0 2px;
  font-style: normal;
  color: var(--fg-strong);
  background: linear-gradient(transparent 62%, var(--accent-soft) 0);
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.socials {
  display: flex;
  gap: 8px;
  margin: 0 0 0 6px;
  padding: 0;
  list-style: none;
}
.socials a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--fg-muted);
  transition: color .2s ease, border-color .2s ease, background .2s ease, transform .25s var(--ease);
}
.socials a:hover {
  color: var(--fg-strong);
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-2px);
}
.socials .icon { width: 17px; height: 17px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 20px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg-strong);
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .25s var(--ease), background .2s ease, border-color .2s ease, box-shadow .3s ease;
}
.btn:hover {
  transform: translateY(-2px);
  background: var(--surface-2);
}
.btn:active { transform: translateY(0); }
.btn .icon { transition: transform .3s var(--ease); }
.btn:hover .icon { transform: translate(2px, 2px); }
.btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 12px 32px -12px color-mix(in oklab, var(--accent) 70%, transparent);
}
.btn--primary:hover {
  background: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 18px 40px -10px color-mix(in oklab, var(--accent) 85%, transparent);
}
.btn--ghost { background: transparent; }

/* ---------- Cards ---------- */
.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: background .3s ease;
}
[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(24, 24, 32, 0.04); }

/* accent ring that follows the cursor (script.js writes --cx / --cy) */
.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: inherit;
  background: radial-gradient(
    280px circle at var(--cx, -999px) var(--cy, -999px),
    var(--accent-mark),
    transparent 70%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
@media (hover: hover) {
  [data-glow]:hover .card::before { opacity: 1; }
  .card:hover { background: var(--surface-2); }
}

.card__label {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--accent-text);
}

/* ---------- Chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chips li {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  transition: border-color .2s ease, color .2s ease;
}
@media (hover: hover) {
  .chips li:hover {
    border-color: color-mix(in oklab, var(--accent-mark) 55%, transparent);
    color: var(--fg-strong);
  }
}
.chips--sm { gap: 6px; }
.chips--sm li {
  padding: 3px 9px;
  font-size: 11.5px;
  color: var(--fg-muted);
}

/* ---------- At-a-glance panel (hero) ---------- */
.panel {
  overflow: hidden;
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-faint);
}
.panel__dots {
  display: inline-flex;
  gap: 6px;
}
.panel__dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}
.panel__dots i:last-child { background: var(--accent-mark); }
.panel__list {
  margin: 0;
  padding: 4px 18px 8px;
}
.panel__list > div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14.5px;
  line-height: 1.45;
}
.panel__list > div:last-child { border-bottom: 0; }
.panel__list dt {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-faint);
}
.panel__list dd {
  margin: 0;
  color: var(--fg-strong);
}
[data-clock] { font-variant-numeric: tabular-nums; }
[data-clock]:not([hidden])::after {
  content: "·";
  margin: 0 0.45em;
  color: var(--fg-muted);
}

/* ---------- Section scaffolding ---------- */
.section { margin-top: clamp(72px, 10vw, 132px); }
.section__inner {
  position: relative;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  column-gap: clamp(32px, 5vw, 64px);
  padding-top: 34px;
  border-top: 1px solid var(--border);
}
/* short accent tick on each section rule */
.section__inner::before {
  content: "";
  position: absolute;
  left: 0;
  top: -1px;
  width: 44px;
  height: 1px;
  background: var(--accent-mark);
}
.section__head {
  position: sticky;
  top: 104px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.section__index {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  color: var(--accent-text);
}
.section__title {
  margin: 0;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--fg-strong);
}

/* ---------- About ---------- */
.lead {
  max-width: 27em;
  margin: 0 0 clamp(28px, 4vw, 44px);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 500;
  line-height: 1.32;
  letter-spacing: -0.022em;
  color: var(--fg-strong);
  text-wrap: balance;
}
.about__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 48px);
  align-items: start;
}
.about__body p {
  max-width: 62ch;
  margin: 0 0 1.05em;
  text-wrap: pretty;
}
.about__body p:last-child { margin-bottom: 0; }
.about__body strong {
  font-weight: 600;
  color: var(--fg-strong);
}
.about__body em {
  font-style: normal;
  color: var(--fg-strong);
  border-bottom: 1px dashed var(--fg-faint);
}
.about__side {
  display: grid;
  gap: 14px;
}

.facts {
  display: grid;
  margin: 0;
  padding: 6px 20px;
}
.fact {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  padding: 11px 0;
  font-size: 14.5px;
}
.fact + .fact { border-top: 1px dashed var(--border); }
.fact dt {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--fg-faint);
}
.fact dd {
  margin: 0;
  color: var(--fg-strong);
}
.interests { padding: 18px 20px 20px; }

/* ---------- Timeline (experience + education) ---------- */
.timeline {
  margin: -26px 0;   /* rows carry their own padding; pull the list flush with the section head */
  padding: 0;
  list-style: none;
}
.job {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  column-gap: 28px;
  padding: 26px 0;
  border-top: 1px solid var(--border);
  transition: opacity .3s ease, border-color .3s ease;
}
.job:first-child { border-top-color: transparent; }
/* hover card that sits behind the row */
.job::before {
  content: "";
  position: absolute;
  inset: 0 -20px;
  z-index: -1;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  opacity: 0;
  transition: opacity .3s ease;
}
@media (hover: hover) and (min-width: 721px) {
  .timeline:hover .job:not(:hover) { opacity: 0.5; }
  .job:hover::before { opacity: 1; }
  .job:hover,
  .job:hover + .job { border-top-color: transparent; }
}

.job__when {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding-top: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--fg-faint);
  white-space: nowrap;
}
.job__now {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding-left: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.job__role {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--fg-strong);
}
.job__role-note {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--fg-faint);
}
.job__org {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin: 5px 0 0;
  font-size: 14.5px;
  color: var(--fg-muted);
}
.job__org span + span::before {
  content: "·";
  margin: 0 0.6em;
  color: var(--fg-faint);
}
.job__company {
  font-weight: 500;
  color: var(--fg-strong);
}
.job__points {
  display: grid;
  gap: 6px;
  max-width: 62ch;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  text-wrap: pretty;
}
.job__points li {
  position: relative;
  padding-left: 18px;
}
.job__points li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.8em;
  width: 8px;
  height: 1px;
  background: var(--accent-mark);
}
.job .chips { margin-top: 14px; }

/* ---------- Stack (bento) ---------- */
.bento {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-areas:
    "web   web   web   web   lvl   lvl"
    "cloud cloud cloud cloud lvl   lvl"
    "robo  robo  robo  emb   emb   emb"
    "data  data  games games also  also";
  gap: 14px;
}
.bento > .card { padding: 18px 20px 20px; }
.bento__web      { grid-area: web; }
.bento__levels   { grid-area: lvl; }
.bento__cloud    { grid-area: cloud; }
.bento__robo     { grid-area: robo; }
.bento__embedded { grid-area: emb; }
.bento__data     { grid-area: data; }
.bento__games    { grid-area: games; }
.bento__also     { grid-area: also; }

.bento__levels {
  display: flex;
  flex-direction: column;
}
.levels {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.level {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--fg-strong);
}
.pips {
  display: inline-flex;
  flex: none;
  gap: 4px;
}
.pips i {
  width: 16px;
  height: 6px;
  border-radius: 3px;
  background: var(--border-strong);
}
.pips i.on {
  background: var(--accent-mark);
  transform-origin: left center;
  transition: transform .5s var(--ease);
}
.pips i:nth-child(1) { --p: 0; }
.pips i:nth-child(2) { --p: 1; }
.pips i:nth-child(3) { --p: 2; }
.pips i:nth-child(4) { --p: 3; }
.pips i:nth-child(5) { --p: 4; }

/* ---------- Selected work (currently commented out in index.html) ---------- */
.work {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.work__item {
  display: flex;
  flex-direction: column;
  padding: 22px 24px;
}
.work__head {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.work__title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--fg-strong);
}
.work__tags {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  color: var(--fg-faint);
}
.work__desc {
  margin: 0 0 18px;
  font-size: 15px;
  color: var(--fg);
}
.work__links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.work__links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-muted);
  transition: color .2s ease;
}
.work__links a:hover { color: var(--accent-text); }

/* ---------- Contact ---------- */
.contact {
  container-type: inline-size;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(22px, 4vw, 40px);
  border-radius: var(--r-xl);
}
/* glow rising from the bottom-right corner */
.contact::after {
  content: "";
  position: absolute;
  right: -18%;
  bottom: -72%;
  z-index: -1;
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(
    closest-side,
    color-mix(in oklab, var(--accent) var(--glow), transparent),
    transparent
  );
  pointer-events: none;
}
[data-bg="off"] .contact::after { display: none; }
/* the card is a container here, not a hover target */
@media (hover: hover) {
  .contact.card:hover { background: var(--surface); }
}

.contact__lede {
  max-width: 46ch;
  margin: 0 0 clamp(18px, 3cqi, 28px);
  color: var(--fg-muted);
}
.contact__email-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}
.contact__email {
  display: inline-flex;
  align-items: center;
  gap: 0.22em;
  font-size: clamp(24px, 4.6vw, 58px);   /* fallback without cq units */
  font-size: clamp(24px, 7.2cqi, 58px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.035em;
  color: var(--fg-strong);
}
.contact__email-value {
  background: linear-gradient(var(--accent-mark), var(--accent-mark)) no-repeat 0 100% / 0 2px;
  transition: background-size .45s var(--ease);
}
.contact__email:hover .contact__email-value,
.contact__email:focus-visible .contact__email-value { background-size: 100% 2px; }
.contact__email .icon {
  width: 0.62em;
  height: 0.62em;
  color: var(--accent-text);
  transition: transform .3s var(--ease);
}
.contact__email:hover .icon { transform: translate(3px, -3px); }

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}
.copy-btn:hover {
  color: var(--fg-strong);
  border-color: var(--border-strong);
}
.copy-btn .icon { width: 14px; height: 14px; }
.copy-btn .icon--check { display: none; }
.copy-btn.is-copied {
  color: var(--accent-text);
  border-color: color-mix(in oklab, var(--accent-mark) 55%, transparent);
}
.copy-btn.is-copied .icon--copy { display: none; }
.copy-btn.is-copied .icon--check { display: block; }

.links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: clamp(24px, 4.5cqi, 40px) 0 0;
  padding: 0;
  list-style: none;
}
.links a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg-muted);
  transition: border-color .2s ease, background .2s ease, color .2s ease, transform .25s var(--ease);
}
.links a:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--fg-strong);
  transform: translateY(-2px);
}
.links__text {
  display: grid;
  line-height: 1.35;
}
.links__key {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--fg-faint);
}
.links__val {
  overflow: hidden;
  font-size: 14.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-strong);
}
.links__arrow {
  width: 15px;
  height: 15px;
  color: var(--accent-text);
  transition: transform .25s var(--ease);
}
.links a:hover .links__arrow { transform: translate(2px, -2px); }

.contact__where {
  margin: clamp(18px, 3cqi, 26px) 0 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-faint);
}

/* ---------- Footer ---------- */
.footer {
  margin-top: clamp(72px, 10vw, 132px);
  padding: 26px 0 44px;
  border-top: 1px solid var(--border);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-faint);
}
.footer__top {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  color: var(--fg-muted);
  transition: color .2s ease;
}
.footer__top:hover { color: var(--fg-strong); }
.footer__top .icon {
  width: 14px;
  height: 14px;
  transition: transform .25s var(--ease);
}
.footer__top:hover .icon { transform: translateY(-2px); }

/* ---------- Tweaks toggle button ---------- */
.tweaks-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 49;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg-elev) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform .2s var(--ease), border-color .2s ease, color .2s ease;
}
.tweaks-toggle:hover {
  border-color: color-mix(in oklab, var(--accent-mark) 60%, transparent);
  color: var(--fg-strong);
  transform: translateY(-2px);
}
.tweaks-toggle:active { transform: translateY(0); }
.tweaks-toggle__icon {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
}
.tweaks-toggle__icon span {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-mark);
}
.tweaks-toggle__icon span:nth-child(2) { width: 10px; }
.tweaks-toggle__icon span:nth-child(3) { width: 6px; }
.tweaks-toggle[aria-expanded="true"] { display: none; }

/* ---------- Tweaks panel ---------- */
.tweaks {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  width: 268px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: color-mix(in oklab, var(--bg-elev) 88%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
          backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.tweaks[hidden] { display: none; }
.tweaks__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.tweaks__title {
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--fg-strong);
}
.tweaks__close {
  appearance: none;
  padding: 2px 7px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.tweaks__close:hover {
  background: var(--surface-2);
  color: var(--fg-strong);
}

.tweaks__section { margin-bottom: 14px; }
.tweaks__section:last-child { margin-bottom: 0; }
.tweaks__label {
  margin-bottom: 7px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.tweaks__row {
  display: flex;
  gap: 6px;
}
.tweaks__row--col { flex-direction: column; }
.tweaks__row--swatches {
  flex-wrap: wrap;
  gap: 10px;
  padding: 2px;
}
.tweaks__row--grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.tweaks__row--grid2 .seg { text-align: center; }

.seg {
  appearance: none;
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-align: center;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.seg:hover {
  border-color: var(--border-strong);
  color: var(--fg-strong);
}
.seg.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.seg--wide {
  font-size: 13px;
  text-align: left;
}

.swatch {
  --sw: #fff;
  appearance: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--sw);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--sw); }

/* ---------- Motion: load + scroll reveals ---------- */
@keyframes blur-rise {
  from { opacity: 0; transform: translateY(0.14em); filter: blur(14px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes fade-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  /* hero entrance (pure CSS, plays on load) */
  .hero__word {
    animation: blur-rise .9s var(--ease) both;
    animation-delay: calc(var(--w, 0) * 110ms + 80ms);
  }
  .hero__meta,
  .hero__copy,
  .hero__grid > .panel { animation: fade-rise .8s var(--ease) both; }
  .hero__copy { animation-delay: 280ms; }
  .hero__grid > .panel { animation-delay: 400ms; }

  /* scroll reveals — script.js "arms" elements that start below the fold, adds
     .is-in when they scroll into view, then drops the attribute when done.
     Nothing is hidden unless the script armed it. */
  [data-reveal="armed"] {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s var(--ease), transform .7s var(--ease);
    transition-delay: calc(var(--i, 0) * 70ms);
  }
  [data-reveal="armed"].is-in {
    opacity: 1;
    transform: none;
  }
  [data-reveal="armed"]:not(.is-in) .pips i.on { transform: scaleX(0); }
  [data-reveal="armed"] .pips i.on {
    transition-delay: calc(var(--i, 0) * 70ms + var(--r, 0) * 45ms + var(--p, 0) * 55ms + 150ms);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* theme switch: script.js runs a circular reveal on the new snapshot */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero__grid { grid-template-columns: minmax(0, 1fr); }

  .section__inner {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 28px;
    padding-top: 26px;
  }
  .section__head {
    position: static;
    flex-direction: row;
    align-items: baseline;
    gap: 14px;
  }
}

@media (max-width: 860px) {
  .bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "web   web"
      "lvl   cloud"
      "lvl   robo"
      "emb   data"
      "games also";
  }
}

@media (max-width: 720px) {
  .topbar { padding-top: 10px; }
  .topbar__inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    height: 50px;
    gap: 6px;
    padding: 0 7px 0 14px;
  }
  .brand { gap: 6px; }
  .brand__path-full { display: none; }
  .brand__path-short { display: inline; }
  .nav {
    justify-self: center;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 7px 10px; }
  .nav__optional { display: none; }

  .about__grid { grid-template-columns: minmax(0, 1fr); }

  .job {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 10px;
  }
  .job__when {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding-top: 0;
  }
  .job__company { flex: 0 0 100%; }
  .job__org .job__company + span::before { content: none; }

  .work { grid-template-columns: minmax(0, 1fr); }
  .links { grid-template-columns: minmax(0, 1fr); }

  .tweaks-toggle { right: 12px; bottom: 12px; }
  .tweaks {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
}

@media (max-width: 600px) {
  /* stack the name on two lines so it stays big */
  .hero__name {
    font-size: clamp(56px, calc((100vw - 40px) * 0.335), 150px);
    font-size: clamp(56px, var(--name-fit-stacked), 150px);
    line-height: 0.9;
  }
  .hero__word { display: block; width: fit-content; }
  .hero__sep { display: none; }
  .hero__intro { font-size: var(--fs-md); }
  .socials { margin-left: 0; }

  .bento {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "web" "lvl" "cloud" "robo" "emb" "data" "games" "also";
  }
  .levels { gap: 14px; }
}

@media (max-width: 480px) {
  /* trim the brand to "~/ls" so all four links fit without scrolling */
  .brand__prompt,
  .brand__blink { display: none; }
  .nav {
    gap: 0;
    font-size: 12.5px;
  }
  .nav a { padding: 7px; }
  .footer__top { margin-left: 0; }
}

@media (max-width: 374px) {
  .nav { font-size: 12px; }
  .nav a { padding: 7px 5px; }
}

@media (max-width: 340px) {
  /* smallest phones: drop the brand so the links still fit */
  .topbar__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-left: 8px;
  }
  .brand { display: none; }
}

/* short laptop screens: tighten the hero so the panel stays above the fold */
@media (min-width: 961px) and (max-height: 780px) {
  .hero { padding-top: 32px; }
  .hero__name { margin-top: 18px; }
  .hero__grid {
    margin-top: 28px;
    padding-top: 28px;
  }
}

/* ---------- Print ---------- */
@media print {
  .fx, .topbar, .tweaks, .tweaks-toggle, .hero__aurora, .skip-link { display: none !important; }
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
  .section { margin-top: 40px; }
}
