/* ==========================================================================
   Mohamed Hany Afifi, portfolio
   Plain CSS, no build step. Mobile-first; breakpoints at 640 / 900 / 1100.
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --step--1: clamp(0.8rem, 0.78rem + 0.1vw, 0.86rem);
  --step-0: clamp(0.95rem, 0.92rem + 0.15vw, 1.0625rem);
  --step-1: clamp(1.1rem, 1.04rem + 0.3vw, 1.3rem);
  --step-2: clamp(1.35rem, 1.2rem + 0.7vw, 1.8rem);
  --step-3: clamp(1.75rem, 1.4rem + 1.6vw, 2.75rem);
  --step-4: clamp(2.4rem, 1.7rem + 3.4vw, 4.6rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: clamp(4rem, 3rem + 5vw, 7rem);

  --gutter: clamp(1rem, 0.6rem + 2vw, 2rem);
  --max-width: 1120px;
  --header-h: 60px;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Dark is the default; light is opt-in via data-theme or the OS setting (see inline script). */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090b10;
  --bg-raised: #10141d;
  --surface: #121722;
  --surface-2: #1c2436;
  --line: rgba(248, 250, 252, 0.09);
  --line-strong: rgba(248, 250, 252, 0.24);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --on-accent: #090b10;
  --ok: #34d399;
  --wip: #fbbf24;
  --info: #38bdf8;
  --trace-2: #38bdf8;
  --grid-line: rgba(248, 250, 252, 0.04);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 20px 40px -20px rgba(0, 0, 0, 0.65);
  --scope-bg: #070a0f;
  --scope-grid: rgba(96, 165, 250, 0.1);
  --scope-trace: #38bdf8;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f8f9fb;
  --bg-raised: #ffffff;
  --surface: #ffffff;
  --surface-2: #edf1f7;
  --line: rgba(15, 23, 42, 0.09);
  --line-strong: rgba(15, 23, 42, 0.22);
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --on-accent: #ffffff;
  --ok: #059669;
  --wip: #d97706;
  --info: #0284c7;
  --trace-2: #0284c7;
  --grid-line: rgba(15, 23, 42, 0.045);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px -12px rgba(15, 23, 42, 0.08);
  --scope-bg: #090d14;
  --scope-grid: rgba(96, 165, 250, 0.12);
  --scope-trace: #38bdf8;
}

/* ---------- Base ---------- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

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

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

/* Subtle precision oscilloscope vector trace canvas */
.cursor-trail {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  opacity: 0.85;
}

/* Author display rules would otherwise beat the UA's [hidden] rule. */
[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
h4 {
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

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

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

.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
}

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-3);
}

.prose p + p {
  margin-top: var(--space-4);
}

.prose a {
  color: var(--accent);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 44px;
  padding: 0.6em 1.15em;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--step-0);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
  transition-duration: 0.08s;
}

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 4px 14px -3px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn .icon {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:hover .icon {
  transform: translateX(2.5px);
}

.btn--ghost {
  border-color: var(--line-strong);
  color: var(--text);
}

.play-badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  width: min(100%, 200px);
  border-radius: 8px;
  line-height: 0;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.play-badge:hover {
  transform: translateY(-1px);
}

.play-badge:active {
  transform: translateY(1px) scale(0.98);
  transition-duration: 0.08s;
}

.play-badge:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

.play-badge__image {
  width: 100%;
  height: auto;
}

.siraj-actions {
  display: flex;
  width: 100%;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.btn--ghost:hover {
  background: var(--surface-2);
}

.btn--small {
  min-height: 36px;
  padding: 0.4em 0.9em;
  font-size: var(--step--1);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: background-color 0.2s, color 0.2s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  transition: background-color 0.25s, border-color 0.25s;
}

.site-header.is-scrolled,
.site-header.is-open {
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border-bottom-color: var(--line);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-right: auto;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 28px;
  height: 28px;
  transform: none;
  transition: none;
}

:root[data-theme="dark"] .brand__mark {
  filter: invert(1);
}

.nav__list {
  display: flex;
  gap: var(--space-1);
}

.nav__list a {
  display: block;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.925rem;
  text-decoration: none;
  transition: color 0.2s, background-color 0.2s;
}

.nav__list a:hover {
  color: var(--text);
}

.nav__list a[aria-current="true"] {
  color: var(--text);
  background: var(--surface-2);
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon--moon {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  /* Runs each time the icon is swapped in */
  #theme-toggle .icon {
    animation: spin-in 0.5s var(--ease-out);
  }
}

@keyframes spin-in {
  from { opacity: 0; transform: rotate(-90deg) scale(0.6); }
}

:root[data-theme="light"] .icon--sun {
  display: none;
}

:root[data-theme="light"] .icon--moon {
  display: block;
}

.menu-btn {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  margin-right: -8px;
  border-radius: var(--radius);
}

.menu-btn span {
  position: absolute;
  left: 12px;
  right: 12px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.25s var(--ease-out), top 0.25s var(--ease-out);
}

.menu-btn span:first-child {
  top: 18px;
}

.menu-btn span:last-child {
  top: 25px;
}

.menu-btn[aria-expanded="true"] span:first-child {
  top: 21.5px;
  transform: rotate(45deg);
}

.menu-btn[aria-expanded="true"] span:last-child {
  top: 21.5px;
  transform: rotate(-45deg);
}

@media (max-width: 899px) {
  .menu-btn {
    display: block;
  }

  .site-header__cv {
    display: none;
  }

  .nav__list {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    gap: 0;
    padding: var(--space-3) var(--gutter) var(--space-6);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 24px 40px -20px rgba(0, 0, 0, 0.5);
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.25s var(--ease-out), visibility 0s 0.25s;
  }

  .site-header.is-open .nav__list {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity 0.2s, transform 0.25s var(--ease-out);
  }

  .nav__list li + li {
    border-top: 1px solid var(--line);
  }

  .nav__list a {
    padding: 0.95rem 0.25rem;
    font-size: 1.125rem;
    color: var(--text);
    border-radius: 0;
  }

  .nav__list a[aria-current="true"] {
    background: none;
    color: var(--accent);
  }

  body.menu-open {
    overflow: hidden;
  }
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  padding-block: clamp(2.5rem, 1rem + 7vw, 7rem) clamp(3rem, 2rem + 5vw, 6rem);
  isolation: isolate;
}

/* A warm glow behind the datasheet card */
.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 10%;
  right: max(0px, calc(50% - 640px));
  width: min(560px, 90vw);
  aspect-ratio: 1;
  background: radial-gradient(closest-side, var(--accent-soft), transparent);
  filter: blur(20px);
  pointer-events: none;
}

/* Graph-paper backdrop, faded at the edges */
.hero::before {
  content: "";
  position: absolute;
  inset: calc(var(--header-h) * -1) 0 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 30% 30%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 70% at 30% 30%, #000 30%, transparent 75%);
}

.hero__grid {
  display: grid;
  gap: var(--space-7);
  align-items: center;
}

@media (min-width: 900px) {
  .hero__grid {
    grid-template-columns: 1.25fr 1fr;
    gap: var(--space-8);
  }
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.35em 0.8em 0.35em 0.7em;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: var(--step--1);
}

.status-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

@media (prefers-reduced-motion: no-preference) {
  .status-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: inherit;
    animation: ping 2.4s var(--ease-out) infinite;
  }
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.6; }
  70%, 100% { transform: scale(2.6); opacity: 0; }
}

.hero__title {
  margin-top: var(--space-5);
  font-size: var(--step-4);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.hero__role {
  margin-top: var(--space-4);
  max-width: 34ch;
  font-size: var(--step-2);
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--text);
}

.hero__lead {
  margin-top: var(--space-4);
  max-width: 56ch;
  color: var(--text-muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.hero__location {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-top: var(--space-5);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

@media (max-width: 479px) {
  .hero__actions .btn {
    flex: 1 1 100%;
  }
}

/* Datasheet card */

.datasheet {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
  transition: box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .datasheet {
    transform: perspective(1000px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  }

  .datasheet::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(
      480px circle at var(--sheen-x, 50%) var(--sheen-y, 50%),
      color-mix(in srgb, var(--accent) 14%, transparent),
      transparent 65%
    );
    opacity: var(--sheen-opacity, 0);
    transition: opacity 0.4s ease;
  }
}

.datasheet__head {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.schematic {
  padding: var(--space-5) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.schematic svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.schematic__wire {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.schematic__plate {
  stroke-width: 2.2;
}

.schematic__flow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 3 14;
  opacity: 0.9;
}

@media (prefers-reduced-motion: no-preference) {
  .schematic__flow {
    animation: flow 1.6s linear infinite;
  }
}

@keyframes flow {
  to { stroke-dashoffset: -34; }
}

/* The switch: drawn open, with the current it carries when it's open */
.schematic__blade {
  transform-box: view-box;
  transform-origin: 150px 58px;
  transform: rotate(-30deg);
}

.schematic__flow--on {
  opacity: 0;
}

/* Then it switches: closed for half of each period, open for the other half */
@media (prefers-reduced-motion: no-preference) {
  .schematic__blade {
    animation: sw-blade 2.4s 2s infinite;
  }

  .schematic__flow--off {
    animation: flow 1.6s linear infinite, sw-off 2.4s 2s steps(1) infinite;
  }

  .schematic__flow--on {
    animation: flow 1.6s linear infinite, sw-on 2.4s 2s steps(1) infinite;
  }
}

@keyframes sw-blade {
  0%, 46% { transform: rotate(-30deg); animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
  49%, 96% { transform: rotate(0deg); animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
  100% { transform: rotate(-30deg); }
}

@keyframes sw-off {
  0% { opacity: 0.9; }
  50% { opacity: 0; }
}

@keyframes sw-on {
  0% { opacity: 0; }
  50% { opacity: 0.9; }
}

.schematic__node {
  fill: var(--text-muted);
}

.schematic__node circle {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), fill 0.2s ease, filter 0.25s ease;
  transform-origin: center;
  transform-box: fill-box;
  cursor: crosshair;
}

@media (hover: hover) and (pointer: fine) {
  .schematic__node circle:hover {
    fill: var(--accent);
    transform: scale(1.6);
    filter: drop-shadow(0 0 5px var(--accent));
  }
}

.schematic__label {
  fill: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
}

.schematic figcaption {
  margin-top: var(--space-2);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.datasheet__table {
  padding: var(--space-2) var(--space-4) var(--space-3);
}

.datasheet__table div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: var(--space-3);
  padding-block: 0.55rem;
  font-size: 0.9rem;
}

.datasheet__table div + div {
  border-top: 1px dashed var(--line);
}

.datasheet__table dt {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding-top: 0.1em;
}

.datasheet__now dt {
  color: var(--accent);
}

.datasheet__now a {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent);
  text-underline-offset: 3px;
}

.datasheet__now a:hover {
  color: var(--accent);
}

/* ---------- Sections ---------- */

.section {
  padding-block: var(--space-8) 0;
}

.section:last-of-type {
  padding-bottom: var(--space-8);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.section-head h2 {
  font-size: var(--step-3);
  letter-spacing: -0.03em;
}

.section-head__num {
  order: 2;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--text-faint);
}

.section-head::after {
  content: "";
  order: 1;
  flex: 1;
  height: 1px;
  background: var(--line);
  align-self: center;
}

.section-lead {
  max-width: 60ch;
  margin: calc(var(--space-5) * -1) 0 var(--space-6);
  color: var(--text-muted);
}

/* ---------- About ---------- */

.about {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 900px) {
  .about {
    grid-template-columns: 1.4fr 1fr;
    gap: var(--space-8);
  }
}

.about__text {
  font-size: var(--step-1);
  line-height: 1.65;
  color: var(--text-muted);
}

.about__text p:first-child {
  color: var(--text);
}

.facts {
  border-top: 1px solid var(--line);
}

.facts__row {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: var(--space-4);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.facts dt {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding-top: 0.15em;
}

.langs li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.langs__level {
  color: var(--text-faint);
}

/* ---------- Chips & tags ---------- */

.chips,
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.3em 0.7em;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--text-muted);
  background: var(--surface);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s ease,
              background-color 0.2s ease,
              color 0.2s ease,
              box-shadow 0.22s ease;
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    color: var(--text);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.12);
  }

  .chip--core:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 14px -2px color-mix(in srgb, var(--accent) 25%, transparent);
  }
}

.chip--core {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
  color: var(--text);
}

.tags li {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
}

.tags li:not(:last-child)::after {
  content: "·";
  margin-left: 0.4rem;
}

/* ---------- Skills ---------- */

.skills {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .skills {
    grid-template-columns: repeat(2, 1fr);
  }
}

.skill-group {
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
}

.skill-group__title {
  margin-bottom: var(--space-4);
  font-size: var(--step-0);
  font-weight: 600;
}

/* ---------- Experience ---------- */

.timeline {
  position: relative;
}

.timeline__item {
  display: grid;
  gap: var(--space-2) var(--space-6);
  padding-block: var(--space-5);
  border-top: 1px solid var(--line);
  transition: background-color 0.25s ease, padding 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.timeline__item:last-child {
  border-bottom: 1px solid var(--line);
}

@media (min-width: 900px) {
  .timeline__item {
    grid-template-columns: 11rem 1fr;
    padding-block: var(--space-6);
  }
}

@media (hover: hover) and (pointer: fine) {
  .timeline__item {
    padding-inline: var(--space-3);
    margin-inline: calc(var(--space-3) * -1);
    border-radius: var(--radius);
  }

  .timeline__item:hover {
    background-color: color-mix(in srgb, var(--surface) 40%, transparent);
  }

  .timeline__item:hover .timeline__title {
    color: var(--accent);
  }

  .timeline__item:hover .timeline__points li::before {
    transform: scaleX(1.5);
    background: var(--accent-strong);
  }
}

.timeline__when {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--text-faint);
  padding-top: 0.25em;
}

.timeline__title {
  font-size: var(--step-1);
  transition: color 0.2s ease;
}

.timeline__org {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.timeline__points {
  display: grid;
  gap: var(--space-2);
  margin-block: var(--space-4);
  max-width: 68ch;
  color: var(--text-muted);
}

.timeline__points li {
  position: relative;
  padding-left: 1.1rem;
}

.timeline__points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 6px;
  height: 1px;
  background: var(--accent);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease;
  transform-origin: left center;
}

/* ---------- Projects ---------- */

.featured {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 760px) {
  .featured {
    grid-template-columns: repeat(2, 1fr);
  }
}

.project {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background-color: var(--bg-raised);
  transition: border-color 0.25s ease,
              background-color 0.25s ease,
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.project:hover {
  border-color: var(--line-strong);
  background-color: var(--surface);
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.25);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .project:hover {
    transform: translateY(-3px);
  }
}

.project:focus-within {
  border-color: var(--accent);
}

.project--featured {
  padding: var(--space-6) var(--space-5);
}

/* Two featured cards side by side share their row lines, so the stats and
   tags line up across the pair however long each summary is */
@supports (grid-template-rows: subgrid) {
  @media (min-width: 760px) {
    .featured > .project:not(.project--siraj) {
      display: grid;
      grid-template-rows: subgrid;
      grid-row: span 7;
      row-gap: var(--space-3);
    }
  }
}

.project__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.project__domain {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

.project__title--logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.project__logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.project__title {
  font-size: var(--step-1);
  letter-spacing: -0.015em;
}

.project--featured .project__title {
  font-size: var(--step-2);
}

/* The title button stretches over the whole card so the card is one big target */
.project__open {
  text-align: left;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
}

.project__open::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.project__open:focus-visible {
  outline: none;
}

.project__summary {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.project .tags {
  margin-top: auto;
  padding-top: var(--space-2);
}

.project__link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  align-self: flex-start;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
}

.project__link:hover {
  text-decoration: underline;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: var(--space-2);
  margin-block: var(--space-2);
  padding-block: var(--space-3);
  border-block: 1px dashed var(--line);
}

.metrics dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.metrics dd {
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status--done::before { background: var(--ok); }
.status--wip::before { background: var(--wip); }
.status--proto::before { background: var(--info); }
.status--soon::before { background: var(--text-faint); }

/* ---------- Siraj: the wide featured card ---------- */

.project--siraj {
  --brand: #1f9d6c;
  --brand-gold: #d4af37;
  --card-glow: radial-gradient(90% 80% at 85% 70%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%);
  overflow: hidden;
  background-image: var(--card-glow);
}

:root[data-theme="light"] .project--siraj {
  --brand: #0f7a55;
  --brand-gold: #8a6a16;
  --card-glow: radial-gradient(90% 80% at 85% 70%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 70%);
}

/* Thin gold rule along the top, like the app's emblem */
.project--siraj::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-gold) 30%, var(--brand-gold) 70%, transparent);
  opacity: 0.7;
}

.project--siraj .project__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.project--siraj .project__logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.project__native {
  font-size: 0.8em;
  font-weight: 500;
  color: var(--brand-gold);
  line-height: 1;
}

.project--siraj .metrics {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 480px) {
  .project--siraj .metrics {
    grid-template-columns: repeat(4, 1fr);
  }
}

.project--siraj .project__link {
  color: var(--brand-gold);
}

.project--siraj .siraj-actions {
  width: min(100%, 200px);
  align-items: center;
  margin-top: var(--space-2);
}

.project--siraj .siraj-actions .project__link {
  align-self: center;
}

.project--siraj .tags {
  margin-top: 0;
}

@media (max-width: 899px) {
  .project--siraj .project__summary {
    text-align: center;
  }

  .project--siraj .siraj-actions {
    margin-inline: auto;
  }
}

@media (min-width: 760px) {
  .project--siraj {
    grid-column: 1 / -1;
  }
}

@media (min-width: 900px) {
  .project--siraj {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-6);
  }
}

/* Three phones, fanned. The middle one sits on top. */
.phones {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2.75rem 0 var(--space-2);
  pointer-events: none;
}

.phone {
  width: 33%;
  max-width: 214px;
  height: auto;
  aspect-ratio: 480 / 1069;
  border: 3px solid #0b0b0d;
  border-radius: clamp(14px, 3.4vw, 24px);
  background: #fff;
  box-shadow: 0 24px 40px -20px rgba(0, 0, 0, 0.7);
  transition: transform 0.45s var(--ease-out);
}

:root[data-theme="light"] .phone {
  box-shadow: 0 24px 40px -22px rgba(24, 22, 18, 0.45);
}

.phone--c {
  position: relative;
  z-index: 1;
}

.phone--l {
  transform: translateX(22%) rotate(-7deg) scale(0.86);
}

.phone--r {
  transform: translateX(-22%) rotate(7deg) scale(0.86);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .project--siraj:hover .phone--l { transform: translateX(12%) rotate(-10deg) scale(0.88); }
  .project--siraj:hover .phone--r { transform: translateX(-12%) rotate(10deg) scale(0.88); }
  .project--siraj:hover .phone--c { transform: translateY(-4px); }
}

/* Screenshot strip inside the dialog: swipe on phones, scroll on desktop */
.shots {
  display: flex;
  gap: var(--space-3);
  margin: 0 calc(var(--space-5) * -1) var(--space-5);
  padding: 0 var(--space-5) var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--space-5);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.shots li {
  flex: none;
  width: clamp(132px, 38vw, 176px);
  scroll-snap-align: start;
}

.shots img {
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 1069;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface-2);
}

.shots figcaption {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
}

.projects-toolbar {
  margin-bottom: var(--space-5);
}

.projects-subhead {
  margin: var(--space-7) 0 var(--space-4);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.featured[hidden] + .projects-subhead {
  margin-top: 0;
}

.filters {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  scroll-padding-inline: var(--gutter);
}

.filters::-webkit-scrollbar {
  display: none;
}

@media (min-width: 640px) {
  .filters {
    flex-wrap: wrap;
    margin-inline: 0;
    padding-inline: 0;
  }
}

.filter {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 36px;
  padding: 0.35em 0.85em;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.filter:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.filter.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.filter__count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  opacity: 0.6;
}

.project-grid {
  display: grid;
  gap: var(--space-4);
}

/* Twice as many tracks as cards per row, each card spanning two, so a short last
   row can sit in the middle (js/projects.js marks it) */
@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .project-grid > .project {
    grid-column: span 2;
  }

  .project-grid[data-rem2="1"] > .is-last {
    grid-column: 2 / span 2;
  }
}

@media (min-width: 1100px) {
  .project-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .project-grid[data-rem2="1"] > .is-last {
    grid-column: span 2;
  }

  .project-grid[data-rem3="1"] > .is-last {
    grid-column: 3 / span 2;
  }

  .project-grid[data-rem3="2"] > .is-penult {
    grid-column: 2 / span 2;
  }
}

.project.is-entering {
  animation: fade-up 0.35s var(--ease-out) both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
}

.project-grid__empty {
  color: var(--text-muted);
  padding: var(--space-6) 0;
}

/* "A few more": smaller projects as rows, like the timeline, no preview */
.project-rows {
  border-top: 1px solid var(--line);
}

.project--row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
  padding: var(--space-5) 2.75rem var(--space-5) var(--space-3);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
}

.project--row .tags {
  margin-top: var(--space-1);
  padding: 0;
}

.project--row::after {
  top: 50%;
  right: var(--space-2);
  bottom: auto;
  margin-top: -9px;
}

@media (min-width: 760px) {
  .project--row {
    grid-template-columns: 13rem minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: var(--space-6);
    row-gap: var(--space-2);
  }

  .project--row .project__meta {
    grid-row: 1 / -1;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: var(--space-2);
    padding-top: 0.3em;
  }
}

.project--row:hover,
.project--row:focus-within {
  background-color: color-mix(in srgb, var(--surface) 55%, transparent);
  border-color: var(--line);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .project--row:hover {
    transform: none;
  }
}

.project--row:focus-within {
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ---------- Modal ---------- */

.modal {
  width: min(100% - 2rem, 760px);
  max-height: min(88dvh, 900px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.6);
  overscroll-behavior: contain;
}

.modal::backdrop {
  background: rgba(8, 8, 10, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal[open] {
  display: flex;
  flex-direction: column;
}

@media (prefers-reduced-motion: no-preference) {
  .modal[open] {
    animation: modal-in 0.28s var(--ease-out);
  }

  .modal[open]::backdrop {
    animation: fade-in 0.28s ease;
  }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

.modal__inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--line);
}

.modal__head .icon-btn {
  margin: -6px -8px 0 0;
}

.modal__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
}

.modal__title {
  margin-top: var(--space-2);
  font-size: var(--step-2);
}

.modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-5);
  color: var(--text-muted);
}

.modal__body .prose {
  color: var(--text);
  max-width: 65ch;
}

.modal__body h4 {
  margin: var(--space-6) 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.modal__body > p:last-child {
  margin-top: var(--space-5);
}

.modal__foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--line);
}

.modal__foot:empty {
  display: none;
}

/* Bottom sheet on phones */
@media (max-width: 639px) {
  .modal {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal__head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 2px;
    background: var(--line-strong);
  }

  @media (prefers-reduced-motion: no-preference) {
    .modal[open] {
      animation: sheet-in 0.32s var(--ease-out);
    }
  }
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
}

body.modal-open {
  overflow: hidden;
}

.spec-table {
  border-top: 1px solid var(--line);
}

.spec-table div {
  display: grid;
  grid-template-columns: minmax(8rem, 40%) 1fr;
  gap: var(--space-4);
  padding-block: 0.55rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.925rem;
}

.spec-table dt {
  color: var(--text-faint);
}

.spec-table dd {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.code {
  position: relative;
  padding: var(--space-4);
  padding-top: calc(var(--space-4) + 1.2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
  tab-size: 4;
  -webkit-overflow-scrolling: touch;
}

.code::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.55rem;
  left: var(--space-4);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.code__copy {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
}

.code__copy:hover {
  background: var(--surface);
  color: var(--text);
}

/* ---------- Lab ---------- */

.lab {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  overflow: hidden;
}

.lab__tabs {
  position: relative;
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.lab__tabs::-webkit-scrollbar {
  display: none;
}

.lab__tabs [role="tab"] {
  flex: none;
  min-height: 40px;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.925rem;
  transition: background-color 0.2s, color 0.2s;
}

.lab__tabs [role="tab"]:hover {
  color: var(--text);
}

.lab__tabs [aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
}

/* Five tabs don't fit on a phone: the row scrolls sideways, and fades at whichever
   edge has more tabs past it (lab.js sets data-more) */
.lab__tabs [role="tab"] {
  white-space: nowrap;
}

.lab__tabs[data-more~="left"] {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 2.5rem);
  mask-image: linear-gradient(90deg, transparent, #000 2.5rem);
}

.lab__tabs[data-more~="right"] {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 2.5rem), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 2.5rem), transparent);
}

.lab__tabs[data-more~="left"][data-more~="right"] {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent);
}

@media (max-width: 479px) {
  .lab__tabs [role="tab"] {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* Once lab.js has measured the tabs, a single pill slides between them instead */
.lab__tabs.has-pill::before {
  content: "";
  position: absolute;
  top: var(--space-2);
  bottom: var(--space-2);
  left: 0;
  width: var(--pill-w, 0);
  border-radius: var(--radius);
  background: var(--surface-2);
  transform: translateX(var(--pill-x, 0));
  transition: transform 0.4s var(--ease-out), width 0.4s var(--ease-out);
}

.lab__tabs.has-pill [role="tab"] {
  position: relative;
}

.lab__tabs.has-pill [aria-selected="true"] {
  background: none;
}

.lab__panel {
  padding: var(--space-5);
}

@media (max-width: 479px) {
  .lab__panel {
    padding: var(--space-4);
  }
}

/* Segmented radio control */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  border: 0;
  padding: 0;
  min-width: 0;
}

.segmented legend,
.field__label,
.slider__label {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.segmented span {
  display: block;
  min-height: 36px;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.segmented input:checked + span {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.slider {
  display: block;
}

.slider output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
}

input[type="range"] {
  width: 100%;
  height: 28px;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-raised);
  box-shadow: 0 0 0 1px var(--accent);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-raised);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
}

.readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--space-3);
}

.readout div {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.readout dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.readout dd {
  margin-top: 0.15rem;
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.readout--stack {
  grid-template-columns: 1fr;
}

/* Scope */

.scope {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 900px) {
  .scope {
    grid-template-columns: 1fr 280px;
  }
}

.scope__screen {
  position: relative;
  border-radius: var(--radius);
  background: var(--scope-bg);
  border: 1px solid #000;
  box-shadow: 0 0 0 4px var(--surface-2), inset 0 0 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  margin: 4px;
}

.scope__screen canvas {
  width: 100%;
  aspect-ratio: 10 / 7;
}

@media (max-width: 639px) {
  .scope__screen canvas {
    aspect-ratio: 4 / 3;
  }
}

.scope__readout {
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--scope-trace) 85%, #ffffff);
  pointer-events: none;
}

/* A dark backing, so the numbers stay readable over the FFT's noise floor */
.scope__readout span {
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: rgb(0 0 0 / 0.6);
}

.scope__controls {
  display: grid;
  gap: var(--space-4);
  align-content: start;
}

.scope__btns {
  display: flex;
  gap: var(--space-2);
}

.lab .btn[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-soft);
  color: var(--text);
}

/* Resistor */

.resistor {
  display: grid;
  gap: var(--space-5);
}

.resistor__art {
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
}

.resistor__lead {
  stroke: #9a9a9a;
  stroke-width: 5;
  stroke-linecap: round;
}

.resistor__body {
  fill: #d9c08e;
  stroke: rgba(0, 0, 0, 0.25);
  stroke-width: 1;
}

:root[data-theme="dark"] .resistor__body {
  fill: #c8ad78;
}

.resistor__band {
  stroke: rgba(0, 0, 0, 0.18);
  stroke-width: 0.5;
  transition: fill 0.2s;
}

.resistor__selects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.band-select {
  display: grid;
  gap: 0.35rem;
}

.band-select__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.band-select__control {
  position: relative;
}

.band-select__swatch {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--line);
  pointer-events: none;
}

select,
input[type="number"],
input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1rem; /* 16px stops iOS from zooming on focus */
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%), linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 1rem) 55%, calc(100% - 0.7rem) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.band-select select {
  padding-left: 2.1rem;
}

/* Type a value, get the bands */
.resistor__find {
  max-width: 22rem;
  margin-top: var(--space-4);
}

.resistor__find input {
  font-family: var(--font-mono);
}

.resistor__note {
  min-height: 1.4em;
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* LC */

.lc {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 900px) {
  .lc {
    grid-template-columns: 300px 1fr;
    align-items: start;
  }
}

.lc__form {
  display: grid;
  gap: var(--space-4);
}

.field {
  display: block;
}

.field__row {
  display: grid;
  grid-template-columns: 1fr 5.5rem;
  gap: var(--space-2);
}

.lc__plot svg,
.tool__plot svg {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.lc__plot figcaption,
.tool__plot figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 2px;
  margin-right: 0.45em;
  vertical-align: middle;
  background: currentColor;
}

.legend--l { color: var(--accent); }
.legend--c { color: var(--trace-2); }
.legend--z { color: var(--text); }
.legend--gate { color: var(--text-faint); }

.legend--set::before {
  background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px);
}

.legend--set { color: var(--text-muted); }

.lc__note {
  color: var(--text-faint);
  margin-left: auto;
}

/* Lab charts. js/lab/plot.js keeps their viewBox in real pixels, so these sizes are what you see. */
.plot-grid { stroke: var(--line); stroke-width: 1; }
.plot-frame { fill: none; stroke: var(--line-strong); }
.plot-axis { fill: var(--text-faint); font-family: var(--font-mono); font-size: 11px; }
.plot-unit { fill: var(--text-muted); }
.plot-xl { fill: none; stroke: var(--accent); stroke-width: 2; }
.plot-xc { fill: none; stroke: var(--trace-2); stroke-width: 2; }
.plot-z { fill: none; stroke: var(--text); stroke-width: 2.8; stroke-linejoin: round; }
.plot-f0 { stroke: var(--text-faint); stroke-dasharray: 3 4; }
.plot-dot { fill: var(--text); }
.plot-dot--z { fill: var(--surface); stroke: var(--text); stroke-width: 1.5; }
.plot-f0-label { fill: var(--text); font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.plot-gate { fill: none; stroke: var(--text-faint); stroke-width: 1.4; stroke-linejoin: round; }
.plot-avg { stroke: var(--text-faint); stroke-dasharray: 4 4; }
.plot-il { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.plot-tag { fill: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }
.plot-tag--il { fill: var(--accent); }
.plot-speed { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.plot-set { fill: none; stroke: var(--text-muted); stroke-width: 1.2; stroke-dasharray: 5 4; }
.plot-duty { fill: none; stroke: var(--trace-2); stroke-width: 1.2; opacity: 0.85; }

/* The four RLC numbers sit two by two */
.readout--pairs {
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.readout--pairs div,
.readout--compact div {
  padding: var(--space-2) var(--space-3);
}

.readout--pairs dd,
.readout--compact dd {
  font-size: 1.05rem;
}

.readout dd small {
  font-size: 0.75em;
  font-weight: 500;
  color: var(--text-muted);
}

/* Boost converter and PID tuner: controls on the left, numbers and the plot on the right */
.tool {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 900px) {
  .tool {
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
  }
}

.tool__controls {
  display: grid;
  gap: var(--space-4);
  align-content: start;
}

.tool__controls .btn {
  justify-self: start;
}

.tool__out {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.readout--compact {
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: var(--space-2);
}

/* Six numbers read better as 3 × 2 than 4 + 2 */
@media (min-width: 560px) {
  .readout--3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tool__eq {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-faint);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 36px;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ---------- Education ---------- */

.education {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 900px) {
  .education {
    grid-template-columns: 1.1fr 1fr;
    gap: var(--space-7);
    align-items: start;
  }
}

.schools {
  display: grid;
}

.school {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: var(--space-4);
  padding-block: var(--space-5);
  border-top: 1px solid var(--line);
}

.school:last-child {
  border-bottom: 1px solid var(--line);
}

.school__logo {
  width: 56px;
  height: 56px;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
}

.school__name {
  font-size: var(--step-1);
}

.school__meta {
  margin-top: 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
}

.school__note {
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.education__side {
  display: grid;
  gap: var(--space-4);
}

.card {
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
}

.card__title {
  margin-bottom: var(--space-3);
  font-size: var(--step-0);
}

.courses {
  border-top: 1px solid var(--line);
}

.courses summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
}

.courses summary::-webkit-details-marker {
  display: none;
}

.courses summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: 0.25rem;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.2s;
}

.courses[open] summary::after {
  transform: rotate(225deg) translate(-2px, -1px);
}

.courses__count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
}

.courses ul {
  display: grid;
  gap: 0.35rem;
  padding: 0 0 var(--space-4) 1.1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (min-width: 480px) {
  .courses ul {
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-4);
  }
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.dot--done { background: var(--ok); }
.dot--now { background: var(--accent); }
.dot--next { background: var(--text-faint); }

.creds li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.15rem var(--space-4);
  padding-block: 0.6rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}

.creds__by {
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* ---------- Hobbies ---------- */

.hobbies {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--line);
  overflow: hidden;
}

@media (min-width: 640px) {
  .hobbies {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .hobbies {
    grid-template-columns: repeat(3, 1fr);
  }
}

.hobby {
  padding: var(--space-5);
  background: var(--bg-raised);
}

.hobby h3 {
  font-size: var(--step-0);
}

.hobby__icon {
  width: 38px;
  height: 38px;
  margin-bottom: var(--space-3);
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* Each icon does its own little thing on hover */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .hobby:hover .hobby__icon:has([href="#i-knight"]) { animation: knight-hop 0.7s var(--ease-out); }
  .hobby:hover .hobby__icon:has([href="#i-gamepad"]) { animation: wiggle 0.5s ease-in-out; }
  .hobby:hover .hobby__icon:has([href="#i-quill"]) { animation: scribble 0.9s ease-in-out; }
  .hobby:hover .hobby__icon:has([href="#i-chip"]) { animation: power-up 0.9s ease-out; }
  .hobby:hover .hobby__icon:has([href="#i-cube"]) { animation: flip 0.8s var(--ease-out); }
  .hobby:hover .hobby__icon:has([href="#i-compass"]) { animation: needle 1.2s ease-out; }
}

/* A knight moves in an L */
@keyframes knight-hop {
  35% { translate: 0 -9px; }
  60% { translate: 7px -9px; }
  85% { translate: 7px 0; scale: 1.06 0.94; }
  100% { translate: 0 0; }
}

@keyframes wiggle {
  25% { rotate: -9deg; }
  50% { rotate: 7deg; }
  75% { rotate: -4deg; }
}

@keyframes scribble {
  20% { translate: 2px -1px; rotate: -6deg; }
  40% { translate: -1px 1px; rotate: 2deg; }
  60% { translate: 2px 0; rotate: -5deg; }
  80% { translate: 0 1px; rotate: 1deg; }
}

@keyframes power-up {
  40% { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 16px color-mix(in srgb, var(--accent) 45%, transparent); scale: 1.06; }
}

@keyframes flip {
  from { transform: perspective(120px) rotateY(0); }
  to { transform: perspective(120px) rotateY(360deg); }
}

/* Swings past north and settles, like a real needle */
@keyframes needle {
  20% { rotate: -24deg; }
  45% { rotate: 14deg; }
  65% { rotate: -7deg; }
  85% { rotate: 3deg; }
}

.hobby p {
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Contact ---------- */

.contact__grid {
  display: grid;
  gap: var(--space-7);
}

@media (min-width: 900px) {
  .contact__grid {
    grid-template-columns: 1.3fr 1fr;
    align-items: start;
  }
}

.contact__lead {
  max-width: 52ch;
  font-size: var(--step-1);
  color: var(--text-muted);
}

.contact__email {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.contact__address {
  min-width: 0;
  font-size: clamp(1.05rem, 0.6rem + 2.8vw, 1.8rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 2px no-repeat;
  transition: background-size 0.3s var(--ease-out);
}

.contact__address:hover {
  background-size: 100% 2px;
}

.contact__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

@media (max-width: 479px) {
  .contact__actions .btn {
    flex: 1 1 100%;
  }
}

.socials {
  border-top: 1px solid var(--line);
}

.socials a,
.socials button {
  display: grid;
  grid-template-columns: 1.25rem 1fr auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 52px;
  padding-inline: var(--space-1);
  border-bottom: 1px solid var(--line);
  text-align: left;
  text-decoration: none;
  transition: color 0.2s, padding 0.25s var(--ease-out);
}

.socials .icon {
  color: var(--text-faint);
  transition: color 0.2s;
}

.socials a:hover,
.socials button:hover {
  padding-left: var(--space-3);
}

.socials a:hover .icon,
.socials button:hover .icon {
  color: var(--accent);
}

.socials__handle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom));
  color: var(--text-faint);
  font-size: 0.875rem;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-footer__top {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  text-decoration: none;
}

.site-footer__top:hover {
  color: var(--text);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  z-index: 200;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s var(--ease-out);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Hand-written notes ---------- */

/* Caveat is loaded with only the letters these notes use, so it costs a few KB. */
.hand {
  font-family: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
}

.hand-arrow {
  flex: none;
  width: 42px;
  height: 32px;
}

.hero__hello {
  width: max-content;
  margin-top: var(--space-6);
  font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem);
  transform: rotate(-4deg);
  transform-origin: left bottom;
}

.hero__hello + .hero__title {
  margin-top: var(--space-2);
}

.phones__note {
  position: absolute;
  top: 0;
  left: 2%;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 2px;
  font-size: 1.4rem;
  color: var(--brand-gold);
  transform: rotate(-5deg);
}

.phones__note .hand-arrow {
  margin-top: 0.55em;
}

.lab__note {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 2px;
  margin: calc(var(--space-5) * -1) var(--space-4) var(--space-1) 0;
  font-size: 1.45rem;
  transform: rotate(-3deg);
}

.lab__note .hand-arrow {
  margin-top: 0.5em;
}

.signoff {
  width: max-content;
  margin-top: var(--space-7);
  font-size: clamp(2rem, 1.6rem + 1.5vw, 2.6rem);
  line-height: 1.05;
  transform: rotate(-3deg);
  transform-origin: left;
}

/* "Written" left to right once the contact block scrolls in */
@media (prefers-reduced-motion: no-preference) {
  .js .signoff {
    clip-path: inset(-30% 100% -30% -10%);
    transition: clip-path 1.8s 0.5s cubic-bezier(0.45, 0, 0.3, 1);
  }

  .js .is-visible > .signoff {
    /* negative insets: the rotated handwriting spills past its box */
    clip-path: inset(-30% -20% -30% -10%);
  }
}

/* ---------- Motion ---------- */

/* Hero: a short staggered entrance on load */
@media (prefers-reduced-motion: no-preference) {
  .js .hero__copy > *,
  .js .datasheet {
    animation: rise 0.8s var(--ease-out) both;
  }

  .js .hero__copy > :nth-child(2) { animation-delay: 0.06s; }
  .js .hero__copy > :nth-child(3) { animation-delay: 0.12s; }
  .js .hero__copy > :nth-child(4) { animation-delay: 0.2s; }
  .js .hero__copy > :nth-child(5) { animation-delay: 0.28s; }
  .js .hero__copy > :nth-child(6) { animation-delay: 0.36s; }
  .js .hero__copy > :nth-child(7) { animation-delay: 0.44s; }
  .js .datasheet { animation-delay: 0.3s; }

  /* "hey there, I'm" gets written out, the same way the sign-off at the bottom does */
  .js .hero__copy > .hero__hello {
    animation: rise 0.8s 0.06s var(--ease-out) both, write 1.3s 0.35s cubic-bezier(0.45, 0, 0.3, 1) both;
  }
}

/* Uses translate (not transform) so it doesn't fight the hand-written note's rotation */
@keyframes rise {
  from { opacity: 0; translate: 0 18px; }
}

/* Negative insets: the rotated handwriting spills past its box */
@keyframes write {
  from { clip-path: inset(-30% 100% -30% -10%); }
  to { clip-path: inset(-30% -20% -30% -10%); }
}

/* Theme change: the new theme grows out of the toggle (see ui.js) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* Reading progress along the bottom of the header */
.scroll-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 40%, transparent), var(--accent));
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

@supports (animation-timeline: scroll()) {
  .scroll-progress {
    animation: grow-x linear both;
    animation-timeline: scroll(root block);
  }
}

@keyframes grow-x {
  to { transform: scaleX(1); }
}

/* Section headings: the rule draws itself in */
@media (prefers-reduced-motion: no-preference) {
  .js .section-head[data-reveal]::after {
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 1.1s 0.15s var(--ease-out);
  }

  .js .section-head.is-visible::after {
    transform: scaleX(1);
  }
}

/* Experience: a rail with a dot per role. It fills as you scroll where the browser can do that in CSS. */
.timeline {
  padding-left: 1.75rem;
}

.timeline::before,
.timeline::after {
  content: "";
  position: absolute;
  top: var(--space-6);
  bottom: var(--space-6);
  left: 5px;
  width: 2px;
  border-radius: 1px;
  background: var(--line-strong);
}

.timeline::after {
  background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 25%, transparent));
  transform-origin: top;
}

@supports (animation-timeline: view()) {
  .timeline::after {
    animation: grow-y linear both;
    animation-timeline: view();
    animation-range: entry 40% cover 65%;
  }
}

@keyframes grow-y {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

.timeline__item {
  position: relative;
}

.timeline__item::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: calc(-1.75rem + 1px);
  top: calc(var(--space-5) + 0.35em);
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
}

@media (min-width: 900px) {
  .timeline__item::before {
    top: calc(var(--space-6) + 0.35em);
  }
}

/* Roles that are still going get a filled dot */
.timeline__item--now::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* Roles that are still going breathe, slowly */
@media (prefers-reduced-motion: no-preference) {
  .timeline__item--now::before {
    animation: breathe 2.8s ease-in-out infinite;
  }

  .timeline__item--now + .timeline__item--now::before {
    animation-delay: -1.4s;
  }
}

@keyframes breathe {
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 6%, transparent); }
}

/* Cards: a soft light that follows the cursor (set in motion.js). Mouse only. */
@media (hover: hover) and (pointer: fine) {
  .project:hover,
  .skill-group:hover,
  .hobby:hover {
    background-image:
      radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
      var(--card-glow, none);
  }

  .skill-group,
  .hobby {
    transition: border-color 0.2s, background-color 0.2s;
  }

  .skill-group:hover {
    border-color: var(--line-strong);
  }
}

/* Contact: a warm glow in the corner to close the page */
.contact {
  position: relative;
  isolation: isolate;
}

.contact::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -10%;
  bottom: 0;
  width: min(640px, 100%);
  aspect-ratio: 1;
  background: radial-gradient(closest-side, var(--accent-soft), transparent);
  pointer-events: none;
}

/* Phone menu: links slide in one after another */
@media (max-width: 899px) and (prefers-reduced-motion: no-preference) {
  .site-header.is-open .nav__list li {
    animation: slide-in 0.4s var(--ease-out) both;
  }

  .site-header.is-open .nav__list li:nth-child(2) { animation-delay: 0.03s; }
  .site-header.is-open .nav__list li:nth-child(3) { animation-delay: 0.06s; }
  .site-header.is-open .nav__list li:nth-child(4) { animation-delay: 0.09s; }
  .site-header.is-open .nav__list li:nth-child(5) { animation-delay: 0.12s; }
  .site-header.is-open .nav__list li:nth-child(6) { animation-delay: 0.15s; }
  .site-header.is-open .nav__list li:nth-child(7) { animation-delay: 0.18s; }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-14px); }
}

/* Hero schematic: wires draw themselves in on load, then labels and current flow fade up */
@media (prefers-reduced-motion: no-preference) {
  .js .schematic__wire path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 1.5s 0.45s var(--ease-out) forwards;
  }

  .js .schematic__node,
  .js .schematic__label,
  .js .schematic figcaption {
    animation: fade-in 0.6s 1.5s both;
  }

  .js .schematic__flow--off {
    animation: fade-in 0.6s 1.5s both, flow 1.6s linear infinite, sw-off 2.4s 2s steps(1) infinite;
  }

  .js .schematic__flow--on {
    animation: flow 1.6s linear infinite, sw-on 2.4s 2s steps(1) infinite;
  }
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

/* Project cards: a small arrow says "this opens". On phones it's the only hint, since there's no hover. */
.project::after {
  content: "";
  position: absolute;
  right: var(--space-5);
  bottom: var(--space-5);
  width: 18px;
  height: 18px;
  background: currentColor;
  color: var(--text-faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
  transition: transform 0.25s var(--ease-out), color 0.2s;
}

.project:hover::after,
.project:focus-within::after {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.project .tags {
  padding-right: 28px;
}

/* Siraj's corner belongs to the phones */
.project--siraj::after {
  display: none;
}

/* Touch: a small press so taps feel physical */
html {
  -webkit-tap-highlight-color: transparent;
}

@media (hover: none) {
  .project:active {
    transform: scale(0.985);
    border-color: var(--line-strong);
  }

  .btn:active {
    transform: scale(0.97);
  }
}

.contact__cv {
  margin-top: var(--space-4);
  font-size: 0.95rem;
}

.contact__cv a {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
}

.contact__cv a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* Floating back-to-top, with a ring that fills as you read (set in motion.js) */
.to-top {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg-raised) 85%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.9);
  transition: opacity 0.25s,
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.2s ease,
              visibility 0s 0.3s;
}

.to-top.is-shown {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.25s, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.to-top:hover {
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -10px color-mix(in srgb, var(--accent) 30%, rgba(0, 0, 0, 0.5));
}

.to-top:active {
  transform: translateY(1px) scale(0.96);
}

.to-top__ring {
  position: absolute;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  max-width: none;
  transform: rotate(-90deg);
}

.to-top__ring circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--p, 0));
}

body.modal-open .to-top,
body.menu-open .to-top {
  opacity: 0;
  visibility: hidden;
}

/* Filtering projects: cards glide to their new places (see projects.js) */
html.is-filtering::view-transition-group(*) {
  animation-duration: 0.45s;
  animation-timing-function: var(--ease-out);
}

html.is-filtering::view-transition-old(*):only-child {
  animation: fade-out 0.2s ease both;
}

html.is-filtering::view-transition-new(*):only-child {
  animation: fade-in 0.35s 0.1s ease both;
}

@keyframes fade-out {
  to { opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  /* Lab tabs: the new panel settles in instead of snapping */
  .lab__panel:not([hidden]) {
    animation: fade-up 0.35s var(--ease-out);
  }

  /* Project dialog: the content arrives in a short cascade */
  .modal[open] .modal__body > * {
    animation: settle 0.5s var(--ease-out) both;
  }

  .modal[open] .modal__body > :nth-child(2) { animation-delay: 0.06s; }
  .modal[open] .modal__body > :nth-child(3) { animation-delay: 0.12s; }
  .modal[open] .modal__body > :nth-child(4) { animation-delay: 0.18s; }
  .modal[open] .modal__body > :nth-child(n + 5) { animation-delay: 0.24s; }

  /* Screenshots in the Siraj dialog drift in one by one */
  .modal[open] .shots li {
    animation: settle 0.5s var(--ease-out) both;
  }

  .modal[open] .shots li:nth-child(2) { animation-delay: 0.05s; }
  .modal[open] .shots li:nth-child(3) { animation-delay: 0.1s; }
  .modal[open] .shots li:nth-child(4) { animation-delay: 0.15s; }
  .modal[open] .shots li:nth-child(n + 5) { animation-delay: 0.2s; }
}

@keyframes settle {
  from { opacity: 0; transform: translateY(10px); }
}

/* ---------- Scroll reveal ---------- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1), transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Print ---------- */

@media print {
  .site-header,
  .lab,
  #lab,
  .hero::before,
  .schematic,
  .site-footer__top,
  .toast {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .js [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
