/* =========================================================
   Portfolio styles
   1. Tokens      2. Base       3. Nav        4. Hero
   5. Marquee     6. Sections   7. Work       8. About
   9. Experience  10. Résumé    11. Contact   12. Lightbox
   13. Small screens            14. Motion
   ========================================================= */


/* 1. Tokens: change colours, fonts and sizes here --------- */

/* Self-hosted web fonts (SIL Open Font License; the licences are in fonts/). Latin and Latin
   Extended subsets, as Google Fonts serves them; Inter Tight is one variable file for every weight. */
@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/inter-tight-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/inter-tight-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/instrument-serif-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/instrument-serif-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Metric-matched stand-ins: while the web fonts load, Arial and Times are resized to the
   same widths and heights, so the big type does not jump when the real fonts arrive.
   Arimo/Liberation Sans and Tinos/Liberation Serif share those metrics (Linux, ChromeOS). */
@font-face {
  font-family: "Inter Tight Fallback";
  src: local("Arial"), local("ArialMT"), local("Arimo"), local("Liberation Sans");
  font-weight: 400;
  size-adjust: 95.3%;
  ascent-override: 101.7%;
  descent-override: 25.3%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Inter Tight Fallback";
  src: local("Arial"), local("ArialMT"), local("Arimo"), local("Liberation Sans");
  font-weight: 500 700;
  size-adjust: 97.6%;
  ascent-override: 99.3%;
  descent-override: 24.7%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Instrument Serif Fallback";
  src: local("Times New Roman Italic"), local("TimesNewRomanPS-ItalicMT"), local("Tinos Italic"), local("Liberation Serif Italic");
  font-style: italic;
  size-adjust: 86.5%;
  ascent-override: 114.5%;
  descent-override: 35.8%;
  line-gap-override: 0%;
}

:root {
  --bg: #f4f3ef;
  --fg: #111110;
  --muted: #6b6a65;   /* small secondary text (4.9:1 on --bg) */
  --soft: #8a8983;    /* big grey headline text */
  --line: #dcdad3;
  --surface: #ebe9e3; /* cards and the preview frame */
  --accent: #ff5a1f;
  --ring: #c2410c;          /* focus ring: the accent, dark enough for 3:1 on --bg */
  --ring-inverse: #ff7a45;  /* focus ring on the inverted contact panel */

  /* Three families, each with one job */
  --font-sans: "Inter Tight", "Inter Tight Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;   /* everything */
  --font-serif: "Instrument Serif", "Instrument Serif Fallback", Georgia, serif;                            /* italic accents only */
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;                 /* labels and metadata */

  /* Type scale: every font size on the page comes from this list */
  --text-xs: 12px;                                         /* mono labels, tags, dates */
  --text-sm: 14px;                                         /* nav, meta, buttons, footer */
  --text-base: 17px;                                       /* body copy */
  --text-lg: clamp(18px, 1.4vw, 21px);                     /* intros */
  --text-xl: clamp(21px, 2vw, 28px);                       /* small headings */
  --text-marquee: clamp(26px, 3vw, 44px);                  /* the scrolling strip */
  --text-lead: clamp(27px, 3.3vw, 48px);                   /* lead sentences */
  --text-2xl: clamp(32px, 4vw, 60px);                      /* section titles */
  --text-3xl: clamp(40px, 5.8vw, 92px);                    /* project titles */
  --text-stat: clamp(52px, 7.2vw, 116px);                  /* numbers in About */
  --text-display: clamp(2.5rem, 12vw, 11rem);             /* hero headline (also capped by screen height below) */
  --text-giant: clamp(84px, 19vw, 300px);                  /* "Let's talk" */

  --tracking-display: -0.05em;    /* 3xl and display */
  --tracking-heading: -0.032em;   /* xl and 2xl */
  --tracking-label: 0.08em;       /* uppercase mono */

  --leading-tight: .97;
  --leading-snug: 1.1;
  --leading-body: 1.55;

  --pad: clamp(16px, 4vw, 56px);
  --radius: 14px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* Film grain for the hero and contact panel (inline SVG noise, no request).
     Grey noise in overlay mode: adds texture without shifting the colour underneath. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --grain-opacity: .2;

  color-scheme: light;
}

/* Short, wide screens: the headline also scales with the height, so the hero fits one screen */
@supports (height: 1svh) {
  :root { --text-display: clamp(2.5rem, min(12vw, 18.5svh), 11rem); }
}

:root[data-theme="dark"] {
  --bg: #0e0e0d;
  --fg: #f2f1ec;
  --muted: #8f8e88;
  --soft: #6b6a65;
  --line: #2a2a28;
  --surface: #181817;
  --ring: #ff7a45;
  --ring-inverse: #c2410c;
  --grain-opacity: .35;
  color-scheme: dark;
}


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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
  /* Font rendering: same everywhere, and never fake a bold or italic the fonts don't have */
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-body);
  overflow-x: clip;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}

h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
h1, h2, h3 { font-weight: 500; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
picture { display: contents; }   /* the <img> inside lays out as if the <picture> were not there */
button { font: inherit; color: inherit; }
strong { font-weight: 700; }   /* only 400, 500 and 700 are loaded */

/* Kerning and ligatures at their best for the big type only: on the whole page this setting
   makes the first layout noticeably slower on phones. */
.hero-title, .section-head h2, .p-title, .lead, .stats dd, .contact-mail, .case-title, .case-next-title {
  text-rendering: optimizeLegibility;
}

em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}

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

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

.label,
.stats dt {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
}

/* Numbers that sit in columns or tick over keep the same width */
.stats dd, .p-year, .t-when, #local-time { font-variant-numeric: tabular-nums; }
#local-time { white-space: nowrap; }

.nobr { white-space: nowrap; }   /* keeps "e-commerce" from breaking at its hyphen */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: var(--pad);
  top: 12px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
}

/* Buttons: a fill rises from below on hover; the solid one fills with the accent.
   --mx/--my are set by script.js for the magnetic pull. */
.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .9em 1.35em;
  border: 1px solid var(--fg);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transform: translate3d(var(--mx, 0px), calc(var(--my, 0px) + var(--lift, 0px)), 0);
  transition: transform .45s var(--ease), color .4s var(--ease), border-color .4s var(--ease), background-color .4s var(--ease);
}
.btn::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background: var(--fg);
  transform: translateY(102%);
  transition: transform .5s var(--ease);
}
.btn:hover { --lift: -2px; }
.btn:hover::before { transform: none; }

.btn-solid { background: var(--fg); color: var(--bg); }
.btn-solid::before { background: var(--accent); }
.btn-solid:hover { color: #111110; border-color: var(--accent); }
.btn-ghost:hover { color: var(--bg); }

.btn .arr { display: inline-block; transition: transform .5s var(--ease); }
.btn:hover .arr-se { transform: translate(2px, 2px); }
.btn:hover .arr-s  { transform: translateY(3px); }
.btn:hover .arr-ne { transform: translate(2px, -2px); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }


/* 3. Nav --------------------------------------------------- */
.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--pad);
  pointer-events: none;   /* clicks pass through the empty parts of the bar */
}
.nav > * { pointer-events: auto; }

/* Bar background appears once you scroll. It lives on a pseudo-element so the
   blur does not trap the fixed mobile pill inside the bar. */
.nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  opacity: 0;
  transition: opacity .3s;
}
.nav.scrolled::before { opacity: 1; }

.logo {
  padding: 4px 6px;
  margin: -4px -6px;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
}
.logo span {
  display: inline-block;
  color: var(--accent);
  transition: transform .5s var(--ease);
}
.logo:hover span { transform: translateY(-.18em); }

.nav-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.nav-pill a {
  position: relative;
  z-index: 1;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: var(--text-sm);
  transition: background-color .25s, color .3s var(--ease);
}

/* The dark pill that glides to the current or hovered link (positioned by script.js) */
.nav-glider {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: transform .55s var(--ease), width .55s var(--ease), opacity .25s;
}
.nav-pill a.lit { color: var(--bg); }

/* Without script.js: plain highlight on hover */
html:not(.js) .nav-pill a:hover { background: var(--fg); color: var(--bg); }

.nav-actions { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  --turn: 0deg;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  cursor: pointer;
}
.theme-toggle svg { transform: rotate(var(--turn)); transition: transform .7s var(--ease); }
.theme-toggle:hover svg { transform: rotate(calc(var(--turn) + 45deg)); }
[data-theme="dark"] .theme-toggle { --turn: 180deg; }

.nav-cta { padding: .78em 1.15em; }


/* 4. Hero -------------------------------------------------- */
.hero {
  position: relative;
  isolation: isolate;
  overflow: clip;   /* keeps the glow below from widening the page */
  background: var(--bg);   /* the grain blends with this */
  transition: background-color .4s var(--ease);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(24px, 4.5vh, 44px);
  gap: clamp(24px, 4.5svh, 44px);
  min-height: 100vh;     /* browsers without svh */
  min-height: 100svh;    /* the screen height with the phone's address bar showing, so nothing hides under it */
  padding: 100px var(--pad) clamp(32px, 5vh, 48px);
  padding: 100px var(--pad) clamp(32px, 5svh, 48px);
}

/* A soft glow in the accent colour drifts slowly behind the top right */
.hero::before {
  content: "";
  position: absolute;
  top: -25vmax;
  right: -20vmax;
  z-index: -1;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 22%, transparent), transparent);
  pointer-events: none;
}

/* Fine grain over the glow: stops gradient banding and gives the page some tooth */
.hero::after,
.contact::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--grain);
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* The 3D pipeline network (js/hero3d.js) sits between the glow and the grain, on the right.
   It is out of the layout, so nothing moves when it appears; it fades in once drawn. */
.hero-3d {
  position: absolute;
  inset: 0 0 0 38%;
  z-index: -1;
  opacity: 0;
  pointer-events: none;
}
.hero-3d.is-on { opacity: 1; }
.hero-3d canvas { display: block; width: 100%; height: 100%; }
@media (max-width: 899px) { .hero-3d { display: none; } }

.hero-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 32px;
  font-size: var(--text-sm);
}
.hero-meta p { display: grid; gap: 6px; align-content: start; }

.status { display: inline-flex; align-items: center; gap: 8px; }
.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.hero-title {
  align-self: end;
  font-size: var(--text-display);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
}
.hero-title .line {
  display: block;
  overflow: hidden;
  padding-bottom: .16em;    /* room for descenders (g, p, y) inside the mask */
  margin-bottom: -.16em;
  white-space: nowrap;
}
.hero-title .w { display: inline-block; }
/* The third line starts under "pipelines", so the three lines read as one block */
.hero-title .soft { color: var(--soft); padding-left: 1.934em; }
.hero-title em { letter-spacing: -0.02em; padding-right: .06em; }

.hero-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 24px 40px;
}
.hero-intro { max-width: 40ch; font-size: var(--text-lg); line-height: 1.45; }
/* One line of proof above the buttons (it sits beside the introduction, so the first screen is no
   taller): the green dot matches the "CI passing" dots below */
.hero-cta { display: grid; gap: 14px; }
.hero-proof {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
}
.hero-proof::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin-top: .55em;
  border-radius: 50%;
  background: #22c55e;
}


/* 5. Marquee ---------------------------------------------- */
.marquee {
  overflow: hidden;
  padding: clamp(18px, 2.2vw, 28px) 0;
  border-block: 1px solid var(--line);
}
.marquee-track { display: flex; width: max-content; will-change: transform; }
.marquee-group { display: flex; }
.marquee span {
  display: inline-flex;
  align-items: center;
  gap: .7em;
  padding-right: .7em;
  font-size: var(--text-marquee);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: var(--tracking-heading);
  white-space: nowrap;
}
/* Every second word in the serif italic, echoing "applied ML." */
.marquee span:nth-child(even) {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: calc(var(--text-marquee) * 1.12);
  letter-spacing: -0.01em;
}
.marquee span::after {
  content: "✦";
  font-family: var(--font-sans);
  font-style: normal;
  color: var(--accent);
  font-size: .45em;
}


/* 6. Sections ---------------------------------------------- */
.section { padding: clamp(96px, 13vw, 176px) var(--pad) 0; }

.section-head {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(8px, 2vw, 24px);
  padding-bottom: 22px;
}
/* The rule under each heading (drawn in from the left when it scrolls into view) */
.section-head::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: var(--line);
  transform-origin: left center;
}
.section-head h2 {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: var(--text-2xl);
  line-height: 1;
  letter-spacing: var(--tracking-heading);
}
.section-head h2 .label { padding-top: .2em; }
/* Wide screens: the (01) label hangs in the same column as the project numbers,
   so section titles start on the same line as the project titles below them */
@media (min-width: 900px) {
  .section-head h2 .label { flex: none; width: calc(4.5rem + 12px); }
}

/* Text that rises out of a mask (section titles, "Let's talk") */
.h-mask, .cm-mask {
  display: block;
  overflow: hidden;
  padding-bottom: .14em;
  margin-bottom: -.14em;
}
.h-mask > span, .cm-mask > span { display: block; }

/* Big lead sentences in About and Résumé */
.lead {
  font-size: var(--text-lead);
  font-weight: 500;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-heading);
  text-wrap: pretty;
}


/* 7. Work -------------------------------------------------- */
.project {
  position: relative;
  display: grid;
  gap: 20px;
  padding: 28px 0 30px;
}
/* Hairline under each project, and a line in the project's colour that sweeps in on hover */
.project::after,
.project::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: var(--line);
  transform-origin: left center;
}
.project::before {
  z-index: 1;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .7s var(--ease);
}
.project:hover::before,
.project:focus-within::before { transform: none; }

/* The screenshot (phones and tablets; tap to enlarge) */
.p-shot {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background:
    radial-gradient(110% 90% at 18% 12%, color-mix(in srgb, var(--accent) 40%, transparent), transparent 60%),
    var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  cursor: zoom-in;
}
.p-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform .9s var(--ease);
}
.p-shot:hover img { transform: scale(1.025); }
.p-shot:focus-visible { outline-offset: 4px; border-radius: var(--radius); }
.p-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--line), 0 6px 18px -8px rgb(0 0 0 / .4);
  transition: transform .5s var(--ease);
}
.p-shot:hover .p-zoom { transform: scale(1.08); }

/* Phones: stacked card, text under the image */
.p-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "index title arrow"
    "desc  desc  desc"
    "tags  tags  year";
  gap: 8px 14px;
  align-content: center;
  transition: opacity .4s var(--ease);
}

.p-index, .p-tags, .p-year {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.p-index {
  grid-area: index;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: start;
  padding-top: .7em;
  color: var(--muted);
}
.p-index::before {   /* the project's colour, as a small dot */
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.p-title {
  grid-area: title;
  font-size: var(--text-3xl);
  font-weight: 500;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
  transition: transform .6s var(--ease);
}
.p-desc { grid-area: desc; max-width: 58ch; margin-top: 4px; color: var(--muted); }
.p-tags { grid-area: tags; margin-top: 6px; }
.p-year { grid-area: year; margin-top: 6px; justify-self: end; color: var(--muted); }
.p-arrow {
  grid-area: arrow;
  align-self: center;
  font-size: var(--text-xl);
  line-height: 1;
  transition: transform .5s var(--ease), color .3s;
}
.p-link:hover .p-arrow,
.p-link:focus-visible .p-arrow { transform: rotate(45deg); color: var(--accent); }

/* Under each project: its proof line, then the code and live-demo links (outside the row's
   main link, which opens the case study) */
.p-body { display: grid; gap: 16px; min-width: 0; }
.p-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  transition: opacity .4s var(--ease);
}
.p-proof { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.p-proof::before {   /* green, like the status dot: the CI run is passing */
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}
.p-stat { color: var(--muted); }   /* one measured number, linked to the case study */
/* The test count and the number each take a line, so Code and Live demo always start a line of
   their own (wide desktop rows put all of it on one line, below) */
.p-proof, .p-stat { flex-basis: 100%; }
.case-facts .p-proof { flex-basis: auto; }
.p-ext {
  display: inline-block;
  padding-block: 4px;   /* at least a 24 px tap target */
  border-bottom: 1px solid var(--line);
  line-height: 1.3;
  transition: border-color .3s;
}
.p-ext:hover { border-color: currentColor; }
/* Bigger tap area without changing how the links look. */
.p-ext { position: relative; }
.p-ext::after { content: ""; position: absolute; inset: -8px -6px; }
.p-wake {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}
/* "live now": the demo answered the wake-up ping (script.js) */
[data-demo-note].is-live { display: inline-flex; align-items: center; gap: 6px; }
[data-demo-note].is-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: live-pulse 2s ease-out infinite;
}
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); } 70%, 100% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); } }
@media (prefers-reduced-motion: reduce) { [data-demo-note].is-live::before { animation: none; } }
.p-more [hidden] { display: none; }

.more { margin-top: 32px; color: var(--muted); }
.more-tail { margin-top: 12px; }
.more a { color: var(--fg); border-bottom: 1px solid var(--line); transition: border-color .3s; }
.more a:hover { border-color: currentColor; }

/* Tablets and narrow windows: image beside the text */
@media (min-width: 700px) {
  .project {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    align-items: center;
    gap: clamp(28px, 4vw, 56px);
    padding: 36px 0;
  }
}

/* The cursor preview only exists on desktops with a mouse */
.preview { display: none; }

@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .project { display: block; padding: 0; }
  .p-shot { display: none; }
  .p-link {
    grid-template-columns: 4.5rem minmax(0, 1fr) minmax(0, 18rem) 4rem 2.5rem;
    grid-template-areas:
      "index title tags year arrow"
      "index desc  tags year arrow";
    align-items: center;
    column-gap: 24px;
    row-gap: 12px;
    padding-top: 44px;
  }
  .p-body { gap: 0; }
  .p-more { padding: 14px 0 40px calc(4.5rem + 24px); }
  .p-proof, .p-stat { flex-basis: auto; }
  .p-desc, .p-tags, .p-year { margin-top: 0; }
  .p-arrow { justify-self: end; }
  .p-link:hover .p-title,
  .p-link:focus-visible .p-title { transform: translateX(16px); }
  .projects:hover .project:not(:hover) :is(.p-link, .p-more) { opacity: .3; }

  .preview {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    width: clamp(360px, 34vw, 560px);
    pointer-events: none;
    transform: translate3d(-200vw, 0, 0);
  }
  .preview-tilt { transform-origin: 50% 0; scale: var(--fit, 1); }   /* --fit: shrinks to fit beside a focused row */
  .preview-card {
    overflow: hidden;
    border-radius: 12px;
    background: var(--surface);
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--fg) 12%, transparent),
      0 50px 90px -40px rgb(0 0 0 / .55);
    opacity: 0;
    transform: scale(.35);
    transform-origin: var(--origin-x, 0%) 50%;
    transition: transform .65s var(--ease-out), opacity .35s var(--ease);
  }
  .preview.show .preview-card { opacity: 1; transform: none; }

  .preview-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
  }
  .preview-bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
  .preview-bar i:first-child { background: var(--accent); transition: background-color .4s; }
  .preview-name {
    margin-left: 8px;
    font: 11px/1 var(--font-mono);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--fg);
  }
  .preview-window { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #fff; }
  .preview-reel {
    transform: translate3d(0, calc(var(--i, 0) * -100% / var(--n, 3)), 0);
    transition: transform .8s var(--ease-out);
  }
  .preview-reel img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top center; }
}

/* Narrow desktops (900 to 1100 px): the tags and year move under the description and the
   text column is capped, so the (smaller) floating preview fits to the right of everything
   in the row instead of covering the tags and year. script.js keeps it right of all of it. */
@media (hover: hover) and (pointer: fine) and (min-width: 900px) and (max-width: 1100px) {
  .p-link {
    grid-template-columns: 4.5rem max-content minmax(0, 1fr) 2.5rem;
    grid-template-areas:
      "index title title arrow"
      "index desc  desc  arrow"
      "index tags  year  arrow";
    column-gap: 24px;
  }
  .p-desc { max-width: 38ch; }
  .p-year { justify-self: start; }
  .p-more { max-width: calc(4.5rem + 24px + 400px); }
  .p-proof, .p-stat { flex-basis: 100%; }
  .preview { width: clamp(260px, calc(100vw - 620px), 420px); }
}


/* 8. About ------------------------------------------------- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(32px, 6vw, 96px);
  padding-top: clamp(16px, 3vw, 32px);
}
.about-body { display: grid; gap: 18px; max-width: 52ch; }

.stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: clamp(64px, 9vw, 128px);
}
.stats::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: var(--line);
  transform-origin: left center;
}
.stats div {
  display: flex;
  flex-direction: column-reverse;   /* number above its label */
  justify-content: flex-end;
  gap: 14px;
  padding: 30px 24px 0 0;
}
.stats div + div { padding-left: clamp(16px, 2vw, 28px); border-left: 1px solid var(--line); }
.stats dd {
  font-size: var(--text-stat);
  font-weight: 500;
  line-height: .95;
  letter-spacing: var(--tracking-display);
}

.skills {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 36px 24px;
  margin-top: clamp(64px, 9vw, 128px);
}
.skills h3 { margin-bottom: 10px; }
.skills li {
  padding: 11px 0;
  background: linear-gradient(var(--line), var(--line)) 0 100% / 100% 1px no-repeat;
}


/* 9. Experience -------------------------------------------- */
.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) minmax(0, 1.6fr);
  gap: 12px 32px;
  padding: 34px 0;
}
.timeline li::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: var(--line);
  transform-origin: left center;
}
.t-when {
  padding-top: 8px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .02em;
  color: var(--muted);
}
.t-what h3 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
}
.t-what p { margin-top: 6px; color: var(--muted); }
.t-desc { max-width: 60ch; }


/* 10. Résumé ----------------------------------------------- */
.resume {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(40px, 6vw, 96px);
  padding-top: clamp(16px, 3vw, 32px);
}
.resume-note { margin: 20px 0 28px; color: var(--muted); }
.resume-note a { color: var(--fg); border-bottom: 1px solid var(--line); transition: border-color .3s; }
.resume-note a:hover { border-color: currentColor; }

.resume-visual { justify-self: end; width: min(100%, 500px); margin-right: 1.5%; }
.resume-paper {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line), 0 40px 80px -30px rgb(0 0 0 / .45);
  transform: rotate(2.5deg);
  transition: transform .7s var(--ease), box-shadow .7s var(--ease);
}
.resume-paper:hover { transform: rotate(0) translateY(-6px); box-shadow: 0 0 0 1px var(--line), 0 56px 90px -34px rgb(0 0 0 / .5); }
.resume-paper img { width: 100%; height: auto; }


/* 11. Contact (inverted colours) --------------------------- */
.contact {
  --ring: var(--ring-inverse);
  position: relative;
  isolation: isolate;
  overflow: clip;
  margin-top: clamp(110px, 15vw, 200px);
  padding: clamp(80px, 11vw, 150px) var(--pad) 32px;
  border-radius: clamp(20px, 2.5vw, 32px) clamp(20px, 2.5vw, 32px) 0 0;
  background: var(--fg);
  color: var(--bg);
}
/* The hero's glow, echoed at the bottom of the page */
.contact::before {
  content: "";
  position: absolute;
  right: -18vmax;
  bottom: -40vmax;
  z-index: -1;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 16%, transparent), transparent);
  pointer-events: none;
}
.contact .label { color: inherit; opacity: .7; }
.contact-kicker {
  margin-top: 24px;
  font-size: var(--text-lg);
  opacity: .78;
}
.contact-mail {
  display: inline-flex;
  align-items: flex-start;
  gap: .1em;
  margin: 8px 0 clamp(72px, 11vw, 150px);
  font-family: var(--font-serif);
  font-size: var(--text-giant);
  font-style: italic;
  line-height: .95;
  letter-spacing: -0.02em;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat;
  transition: background-size .8s var(--ease);
}
.contact-mail:hover { background-size: 100% 2px; }
/* Italic letters lean past their box, so the mask gets a little room on both sides */
.cm-mask { padding-inline: .06em .1em; margin-inline: -.06em -.1em; }
.cm-arrow {
  font-family: var(--font-sans);
  font-size: .35em;
  font-style: normal;
  transition: transform .6s var(--ease), color .3s;
}
.contact-mail:hover .cm-arrow,
.contact-mail:focus-visible .cm-arrow { transform: rotate(45deg); color: var(--accent); }

.contact-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  padding-top: 24px;
  border-top: 1px solid color-mix(in srgb, var(--bg) 20%, transparent);
  font-size: var(--text-sm);
}
.socials { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.contact-foot a { position: relative; border-bottom: 1px solid transparent; transition: border-color .3s; }
.contact-foot a::after { content: ""; position: absolute; inset: -9px -4px; }
.contact-foot a:hover { border-color: currentColor; }


/* 12. Lightbox (tap a project screenshot) ------------------ */
/* Lock the page behind the dialog; the gutter keeps the page from jumping sideways
   where the scrollbar it hides took up space */
html:has(.lightbox[open]) { overflow: hidden; scrollbar-gutter: stable; }

.lightbox {
  width: min(100% - 24px, 1200px);
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--line), 0 40px 120px -20px rgb(0 0 0 / .6);
}
.lightbox::backdrop { background: rgb(10 10 9 / .74); }
.lightbox-inner { display: flex; flex-direction: column; max-height: inherit; }

/* Phones: the screenshot keeps a readable size and pans sideways */
.lightbox-media { position: relative; min-height: 0; }
.lightbox-scroller {
  overflow: auto;
  overscroll-behavior: contain;
  background: #fff;
  scrollbar-width: thin;
}
.lightbox-img {
  width: auto;
  max-width: none;
  height: min(calc(100dvh - 110px), 750px);
  margin-inline: auto;
}
.lightbox-hint {
  position: absolute;
  left: 12px;
  bottom: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgb(17 17 16 / .82);
  color: #f4f3ef;
  font: 11px/1 var(--font-mono);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  transition: opacity .4s;
  pointer-events: none;
}
.lightbox-hint[hidden] { display: none; }
.lightbox-media.panned .lightbox-hint { opacity: 0; }

.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 10px 10px 20px;
  border-top: 1px solid var(--line);
}
.lightbox-title {
  flex: 1;
  min-width: 0;
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: var(--tracking-heading);
}
.lightbox-link { font-size: var(--text-sm); font-weight: 500; border-bottom: 1px solid var(--line); }
.lightbox-link:hover { border-color: currentColor; }
.lightbox-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color .3s, color .3s;
}
.lightbox-close:hover { background: var(--fg); color: var(--bg); }

/* Wider screens: the whole screenshot fits */
@media (min-width: 700px) {
  .lightbox-scroller { overflow: hidden; display: grid; place-items: center; }
  .lightbox-img { width: auto; max-width: 100%; height: auto; max-height: calc(100dvh - 110px); }
  .lightbox-hint { display: none; }
}


/* 13. Small screens ---------------------------------------- */
@media (max-width: 900px) {
  .hero-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-meta p:first-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  /* The section links become a pill at the bottom of the screen; it tucks away while you scroll down */
  .nav-pill {
    position: fixed;
    bottom: max(14px, env(safe-area-inset-bottom));
    box-shadow: 0 10px 30px -10px rgb(0 0 0 / .3);
    transition: transform .5s var(--ease);
  }
  .nav.tucked .nav-pill:not(:focus-within) { transform: translate(-50%, calc(100% + 40px)); }
  .nav-cta { display: none; }

  .hero { padding-bottom: 104px; }   /* room for the bottom pill */
  .about, .resume { grid-template-columns: 1fr; }
  .skills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline li { grid-template-columns: 1fr; gap: 8px; padding: 28px 0; }
  .t-when { padding-top: 0; }
  .resume-visual { justify-self: stretch; width: 100%; margin: 0; }
  .resume-paper { transform: none; }
  .contact { padding-bottom: 104px; }   /* room for the bottom pill */
}

@media (max-width: 560px) {
  /* The three facts become a compact label / value list */
  .hero-meta { grid-template-columns: 1fr; gap: 10px; }
  .hero-meta p { grid-template-columns: 6.75rem minmax(0, 1fr); align-items: baseline; gap: 12px; }
  .hero-meta p:first-child { grid-column: auto; }

  .stats { grid-template-columns: 1fr; }
  .stats div,
  .stats div + div {
    align-items: flex-start;          /* number above its label, as on desktop */
    gap: 10px;
    padding: 22px 0;
    border-left: 0;
  }
  .stats div + div { border-top: 1px solid var(--line); }
}

@media (max-width: 380px) {
  .nav-pill a { padding: 9px 10px; }
}

/* Touch screens: everything you can tap is at least 44 × 44 px. Buttons and nav links grow a
   little; text links keep their look and get a larger, invisible tap area (::after), and rows
   of them get a little more room so those areas do not overlap. */
@media (pointer: coarse) {
  .logo { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; }
  .nav-pill a { display: inline-flex; align-items: center; min-height: 44px; }
  .theme-toggle { width: 44px; height: 44px; }
  .btn { min-height: 44px; }
  .btn, .theme-toggle, .p-shot, .nav-pill a, .logo { -webkit-tap-highlight-color: transparent; }

  .p-more { row-gap: 20px; }
  .p-ext::after { inset: -10px -6px; }
  .p-proof a, .p-stat a { position: relative; }
  .p-proof a::after, .p-stat a::after { content: ""; position: absolute; inset: -13px -4px; }
  .contact-foot a[href="#top"] { position: relative; }
  .contact-foot a[href="#top"]::after { content: ""; position: absolute; inset: -10px -6px; }

  .socials { row-gap: 26px; }   /* the tap areas below reach 13 px each way, so rows of them don't overlap */
  .contact-foot a::after { inset: -13px -6px; }
  .cm-options a, .cm-options button, .lightbox-link { position: relative; }
  .cm-options a::after, .cm-options button::after { content: ""; position: absolute; inset: 0 -6px; }
  .lightbox-link::after { content: ""; position: absolute; inset: -13px -6px; }
  /* Links inside sentences ("More on GitHub", "CI runs", the email under the résumé): a taller tap area, same look */
  .more a, .proof-note a, .resume-note a { position: relative; }
  .more a::after, .proof-note a::after, .resume-note a::after { content: ""; position: absolute; inset: -12px -4px; }
}

/* Touch screens have no hover: a tapped button would otherwise stay filled (and the theme
   icon stay turned) after the tap. The fill shows while the finger is down instead. */
@media (hover: none) {
  .btn:hover { --lift: 0px; }
  .btn:hover::before { transform: translateY(102%); }
  .btn-solid:hover { color: var(--bg); border-color: var(--fg); }
  .btn-ghost:hover { color: inherit; }
  .btn:hover .arr { transform: none; }
  .btn:active::before { transform: none; }
  .btn-solid:active { color: #111110; border-color: var(--accent); }
  .btn-ghost:active { color: var(--bg); }
  .theme-toggle:hover svg { transform: rotate(var(--turn)); }
  .p-shot:hover img, .p-shot:hover .p-zoom { transform: none; }
}


/* 14. Motion ----------------------------------------------- */
/* Everything here is off for people who ask for reduced motion. */
@media (prefers-reduced-motion: no-preference) {

  /* Entrance: the headline words rise out of their masks one after another while the
     facts and buttons settle in. It plays on the first page view of a visit only (the
     script in <head> adds .intro; repeat views in the same tab session show everything at
     once). It waits for the fonts for 250 ms at most and has landed under a second later.
     The nav and the intro text are there from the first paint, so there is always
     something to read. */
  html.intro .hero-title .w { transform: translateY(112%); }
  html.intro.ready .hero-title .w { animation: rise .85s var(--ease-out) forwards; }
  html.intro.ready .hero-title .line:nth-child(1) .w:nth-child(2) { animation-delay: .05s; }
  html.intro.ready .hero-title .line:nth-child(2) .w:nth-child(1) { animation-delay: .1s; }
  html.intro.ready .hero-title .line:nth-child(2) .w:nth-child(2) { animation-delay: .15s; }
  html.intro.ready .hero-title .line:nth-child(3) .w { animation-delay: .2s; }
  html.intro.ready .hero-title .line:nth-child(3) em .w { animation-delay: .24s; }
  html.intro.ready .hero-title .line:nth-child(3) em .w + .w { animation-delay: .28s; }
  @keyframes rise { to { transform: none; } }

  html.intro .hero-meta p,
  html.intro .hero-proof,
  html.intro .hero-foot .btn { opacity: 0; }
  html.intro.ready .hero-meta p,
  html.intro.ready .hero-proof,
  html.intro.ready .hero-foot .btn { animation: fade-up .6s var(--ease-out) forwards; }
  html.intro.ready .hero-proof { animation-delay: .27s; }
  html.intro.ready .hero-meta p:nth-child(1) { animation-delay: .15s; }
  html.intro.ready .hero-meta p:nth-child(2) { animation-delay: .2s; }
  html.intro.ready .hero-meta p:nth-child(3) { animation-delay: .25s; }
  html.intro.ready .hero-foot .btn:nth-child(1) { animation-delay: .3s; }
  html.intro.ready .hero-foot .btn:nth-child(2) { animation-delay: .34s; }
  html.intro.ready .hero-foot .btn:nth-child(3) { animation-delay: .38s; }
  @keyframes fade-up { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }

  html.intro .hero-intro { translate: 0 14px; }
  html.intro.ready .hero-intro { animation: slide-up .8s var(--ease-out) .2s forwards; }
  @keyframes slide-up { to { translate: 0 0; } }

  html.intro .hero::before { opacity: 0; }
  html.intro.ready .hero::before { animation: glow-in 2.4s var(--ease) forwards, drift 20s ease-in-out 2.4s infinite alternate; }
  html:not(.intro) .hero::before { animation: drift 20s ease-in-out infinite alternate; }
  @keyframes glow-in { from { opacity: 0; scale: .7; } to { opacity: 1; scale: 1; } }
  @keyframes drift { from { opacity: 1; } to { opacity: 1; transform: translate(-12vmax, 10vmax) scale(1.15); } }

  .status::before { animation: ping 2.2s infinite; }
  @keyframes ping {
    0%   { box-shadow: 0 0 0 0 rgb(34 197 94 / .55); }
    80%, 100% { box-shadow: 0 0 0 9px rgb(34 197 94 / 0); }
  }

  .hero-3d { transition: opacity 2s var(--ease); }

  /* Nothing in the hero keeps animating once it is scrolled away (script.js sets .hero-off) */
  html.hero-off .hero::before,
  html.hero-off .status::before { animation-play-state: paused; }

  /* CSS fallback for the strip; script.js takes over and ties its speed to scrolling */
  html.js .marquee:not(.is-live) .marquee-track { animation: marquee 40s linear infinite; }
  .marquee:not(.is-live):hover .marquee-track { animation-play-state: paused; }
  @keyframes marquee { to { transform: translateX(-50%); } }

  /* Blocks fade up as they scroll into view (script.js adds .in) */
  html.js .reveal {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 1s var(--ease), transform 1.1s var(--ease-out);
  }
  html.js .reveal.in { opacity: 1; transform: none; }
  html.js .about-body.reveal { transition-delay: .12s; }

  /* Section heads: the title rises out of its mask and the rule draws in */
  html.js .section-head.reveal { opacity: 1; transform: none; }
  html.js .section-head .h-mask > span { transform: translateY(108%); transition: transform 1.1s var(--ease-out); }
  html.js .section-head::after { transform: scaleX(0); transition: transform 1.5s var(--ease-out) .1s; }
  html.js .section-head > .label,
  html.js .section-head h2 > .label { opacity: 0; transition: opacity .8s var(--ease) .35s; }
  html.js .section-head.in .h-mask > span,
  html.js .section-head.in::after { transform: none; }
  html.js .section-head.in > .label,
  html.js .section-head.in h2 > .label { opacity: 1; }

  /* Hairlines draw in from the left */
  html.js .project.reveal::after,
  html.js .timeline .reveal::after,
  html.js .stats.reveal::before { transform: scaleX(0); transition: transform 1.4s var(--ease-out) .15s; }
  html.js .project.reveal.in::after,
  html.js .timeline .reveal.in::after,
  html.js .stats.reveal.in::before { transform: none; }

  html.js .skills li { background-size: 0 1px; transition: background-size 1.2s var(--ease-out); }
  html.js .skills.in li { background-size: 100% 1px; }
  html.js .skills.in div:nth-child(2) li { transition-delay: .08s; }
  html.js .skills.in div:nth-child(3) li { transition-delay: .16s; }
  html.js .skills.in div:nth-child(4) li { transition-delay: .24s; }

  html.js .stats.reveal { opacity: 1; transform: none; }
  html.js .stats.reveal div { opacity: 0; translate: 0 24px; transition: opacity .9s var(--ease), translate 1s var(--ease-out); }
  html.js .stats.reveal.in div { opacity: 1; translate: 0 0; }
  html.js .stats.reveal.in div:nth-child(2) { transition-delay: .1s; }
  html.js .stats.reveal.in div:nth-child(3) { transition-delay: .2s; }

  /* "Let's talk" rises like the headline at the top of the page */
  html.js .contact-mail.reveal { opacity: 1; transform: none; }
  html.js .contact-mail .cm-mask > span { transform: translateY(105%); transition: transform 1.2s var(--ease-out); }
  html.js .contact-mail .cm-arrow { opacity: 0; transition: opacity .8s var(--ease) .5s, transform .6s var(--ease), color .3s; }
  html.js .contact-mail.in .cm-mask > span { transform: none; }
  html.js .contact-mail.in .cm-arrow { opacity: 1; }

  /* The résumé page straightens as it scrolls up into place (where supported) */
  @supports (animation-timeline: view()) {
    @media (min-width: 761px) {
      .resume-visual { animation: settle linear both; animation-timeline: view(); animation-range: entry 0% cover 45%; }
      @keyframes settle { from { rotate: 4deg; translate: 0 40px; } to { rotate: 0deg; translate: 0 0; } }
    }
  }

  /* Theme switch: a circle grows from the toggle (View Transitions, where supported) */
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
  ::view-transition-new(root) { z-index: 2; }

  /* Lightbox opens with a short scale and fade */
  .lightbox[open] { animation: lightbox-in .5s var(--ease-out); }
  .lightbox[open]::backdrop { animation: fade-in-backdrop .4s var(--ease); }
  .lightbox.closing { animation: lightbox-out .25s var(--ease) forwards; }
  .lightbox.closing::backdrop { animation: fade-out-backdrop .25s var(--ease) forwards; }
  @keyframes lightbox-in { from { opacity: 0; transform: translateY(18px) scale(.96); } }
  @keyframes lightbox-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
  @keyframes fade-in-backdrop { from { opacity: 0; } }
  @keyframes fade-out-backdrop { to { opacity: 0; } }
}

/* While the theme switches, colours change at once (the circle does the animating) */
html.theme-switching,
html.theme-switching * { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
  html { scroll-behavior: auto; }
}

/* Proof lines link to the CI runs without looking like extra buttons. */
.p-proof a,.p-stat a{color:inherit;text-decoration:underline;text-decoration-color:color-mix(in srgb,currentColor 35%,transparent);text-underline-offset:3px}
.p-proof a:hover,.p-stat a:hover{text-decoration-color:currentColor}

/* Centre the copyright on the page, not between the unequal side groups. */
@media (min-width: 1200px) {
  .contact-foot { display: grid; grid-template-columns: 1fr auto 1fr; }
  .contact-foot > a { justify-self: end; }
}


/* ===== Contact reel ==========================================
   "Let's ship something." headline, the row of contact options under it and the
   "Email copied" toast (js/contact.js). The slot-machine spin is in js/reel.js. */
.contact-mail {
  margin-bottom: 0;
  /* Same giant size; only screens under ~390 px shrink it so "something." still fits */
  font-size: min(var(--text-giant), calc((100vw - 2 * var(--pad)) / 4.35));
}
.contact-mail .cm-mask { max-width: 3.95em; }   /* "Let's ship" / "something." on two lines */
.contact-mail .cm-arrow { color: var(--accent); }
[data-theme="dark"] .contact-mail .cm-arrow { color: #e4500f; }   /* 3.4:1 on the light panel */

/* The headline's mask and reel windows reach about .2em below its box (room for the italic descenders), over the
   top of this row. The row sits above them, so "LinkedIn" opens LinkedIn instead of the headline's email link. */
.cm-options {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0 28px;
  margin: 20px 0 clamp(72px, 11vw, 150px);
  font-size: var(--text-base);
}
.cm-options a,
.cm-options button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-color .3s;
}
.cm-options a:hover,
.cm-options button:hover { text-decoration-color: currentColor; }

.cm-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 18px 12px 14px;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--line), 0 18px 40px -14px rgb(0 0 0 / .45);
  font-size: var(--text-sm);
  line-height: 1.35;
  overflow-wrap: anywhere;
  opacity: 0;
  translate: -50% 12px;
  pointer-events: none;
  transition: opacity .3s var(--ease), translate .45s var(--ease-out);
}
.cm-toast:empty { padding: 0; box-shadow: none; }
.cm-toast.show { opacity: 1; translate: -50% 0; }
.cm-toast svg { flex: none; color: var(--accent); }
@media (max-width: 760px) {
  .cm-toast { bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px)); }   /* above the bottom nav pill */
}

/* Contact reel (js/reel.js): each reel is a window the size of its final word, and the strip of
   words scrolls inside it. The window is taller than the .95 line height so descenders show,
   and gets a little side room for the italic lean. */
.reel {
  position: relative;
  display: inline-block;
  vertical-align: top;
  height: 1.12em;
  margin: 0 -.08em -.17em;
  padding: 0 .08em;
  overflow: hidden;
}
.reel-sizer { display: block; visibility: hidden; white-space: nowrap; }
.reel-strip { position: absolute; top: 0; left: .08em; display: flex; flex-direction: column; white-space: nowrap; will-change: transform; }
.reel-strip > span, .reel-sizer { height: 1.12em; }
@keyframes cm-jackpot { 0% { transform: scale(1); } 40% { transform: scale(1.2) rotate(20deg); } 100% { transform: scale(1); } }
.contact-mail.jackpot { background-size: 100% 2px; }
.contact-mail.jackpot .cm-arrow { animation: cm-jackpot 1.1s cubic-bezier(.45, 0, .55, 1); }
