/* =====================================================================
   styles.css  —  ALL THE VISUAL DESIGN
   =====================================================================
   The look: an "immersive" page. Few boxes, large type, wide spacing.
   Each section is a "scene" with a big outlined number. Soft colour
   clouds drift behind everything.

   Contents
     1. Design tokens (colours, fonts, text sizes, motion) for light and dark mode
     2. Base styles (page, text, links, background clouds and web, progress line)
     3. Reusable pieces (card, label, button, tags, lists)
     4. Header and menu
     5. Sections (section heading and signal line, hero, process, projects,
        research and attention illustration, writing, background, contact)
     6. Motion (reveal on scroll, theme cross-fade)
     7. Tablets and phones
     8. Reduced motion
     9. Printing

   To change the look of the whole site, edit the tokens in part 1.
   ===================================================================== */

/* ---------- 1. DESIGN TOKENS ----------
   Every colour, font and text size on the site comes from these variables.
   LIGHT mode values are the default. */
:root {
  /* Colours */
  --bg: #f6f7f9;         /* page background */
  --surface: #ffffff;    /* card background */
  --border: #dfe3e8;     /* thin lines and borders */
  --text: #0f172a;       /* main text */
  --muted: #556070;      /* secondary text */
  --accent: #0f766e;     /* highlight colour */
  --on-accent: #ffffff;  /* text placed on top of the accent colour */
  --glow: rgba(15, 118, 110, 0.16);     /* soft accent halo for hover and effects (never for text) */
  --aurora-1: rgba(15, 118, 110, 0.16); /* first background cloud (teal) */
  --aurora-2: rgba(59, 130, 246, 0.11); /* second background cloud (blue) */
  --shadow: rgba(15, 23, 42, 0.16);     /* shadow under pictures */
  --glare: rgba(255, 255, 255, 0.34);   /* reflection that slides over a tilted picture */

  /* Fonts. To change the heading font, change --font-heading here
     AND the font name in the Google Fonts link in index.html. */
  --font-heading: "Space Grotesk", Inter, system-ui, sans-serif;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  /* Text sizes, smallest to largest. Use these instead of raw px values.
     The clamp() sizes grow with the screen: clamp(smallest, flexible, largest). */
  --text-xs: 13px;                          /* tags, dates, tiny labels */
  --text-sm: 14px;                          /* labels, menu */
  --text-base: 16px;                        /* normal reading text */
  --text-lg: 18px;                          /* lead paragraphs, small headings */
  --text-xl: clamp(21px, 2.4vw, 26px);      /* step and column headings */
  --text-2xl: clamp(26px, 3.6vw, 40px);     /* project titles, big statements */
  --text-3xl: clamp(32px, 5.2vw, 60px);     /* section titles */
  --text-hero: clamp(42px, 8.2vw, 104px);   /* the big headline */
  --text-num: clamp(72px, 13vw, 168px);     /* the outlined section numbers */

  /* Shapes and spacing */
  --radius: 22px;                           /* corner roundness of cards and pictures */
  --gap: 24px;                              /* standard small space */
  --scene-space: clamp(72px, 11vw, 150px);  /* empty space above and below every section */
  --page-max: 1200px;                       /* widest the content gets */
  --gutter: 24px;                           /* space at the left and right screen edges */

  /* Motion: how long animations take and how they ease */
  --dur-fast: 150ms;     /* hover changes */
  --dur: 800ms;          /* reveal on scroll */
  --ease: cubic-bezier(0.22, 1, 0.36, 1); /* starts quick, settles gently */
}

/* DARK mode values. main.js sets data-theme="dark" on the <html> tag. */
:root[data-theme="dark"] {
  --bg: #0a0e14;
  --surface: #131922;
  --border: #283241;
  --text: #e8eef5;
  --muted: #9aa6b4;
  --accent: #5eead4;
  --on-accent: #0a0e14;
  --glow: rgba(94, 234, 212, 0.15);
  --aurora-1: rgba(94, 234, 212, 0.13);
  --aurora-2: rgba(96, 165, 250, 0.11);
  --shadow: rgba(0, 0, 0, 0.55);
  --glare: rgba(255, 255, 255, 0.14);
}

/* ---------- 2. BASE ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased; /* crisper text on Mac */
  overflow-x: hidden;                  /* decoration may reach past the edge; never scroll sideways */
}
h1, h2, h3, p { margin: 0; }
/* Headings use the heading font; "balance" avoids one lonely word on the last line */
h1, h2, h3 { font-family: var(--font-heading); text-wrap: balance; }
p { text-wrap: pretty; }
a { color: var(--text); transition: color var(--dur-fast); }
a:hover { color: var(--accent); }
::selection { background: var(--accent); color: var(--on-accent); }
/* Clear outline for keyboard users */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
/* Menu links jump to a section: leave room so the floating header does not cover its title */
[id] { scroll-margin-top: 96px; }

/* "Skip to content": hidden above the page until a keyboard user tabs to it */
.skip-link {
  position: absolute; left: 16px; top: -80px; z-index: 40;
  padding: 12px 16px;
  background: var(--accent); color: var(--on-accent);
  border-radius: 10px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--on-accent); }

/* Message shown when JavaScript is switched off */
.noscript { max-width: var(--page-max); margin: 24px auto; padding: 0 var(--gutter); }

/* Background clouds ("aurora"): two very large, very soft circles of
   colour, fixed behind the page, drifting slowly. Pure decoration. */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora span { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; }
.aurora span:first-child {
  top: -30vmax; right: -20vmax;
  background: radial-gradient(circle, var(--aurora-1), transparent 62%);
  animation: drift-a 28s ease-in-out infinite alternate;
}
.aurora span:last-child {
  bottom: -35vmax; left: -25vmax;
  background: radial-gradient(circle, var(--aurora-2), transparent 62%);
  animation: drift-b 34s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate(-14vmax, 12vmax) scale(1.15); } }
@keyframes drift-b { to { transform: translate(16vmax, -10vmax) scale(1.1); } }

/* Neural background: the canvas with the faint web of dots (js/effects.js).
   It stays fixed behind the page, above the colour clouds. */
.neural-bg { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }

/* Progress line: grows from left to right as the visitor scrolls.
   main.js keeps --scroll between 0 (top) and 1 (bottom). */
.progress {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: 3px;
  background: var(--accent);
  transform: scaleX(var(--scroll, 0));
  transform-origin: left;
}

/* The centred column that holds everything */
.page { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter) 40px; }

/* ---------- 3. REUSABLE PIECES ---------- */

/* Card: a frosted-glass box. Used sparingly (status box, article). */
.card {
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

/* Label: small monospace text such as "process" */
.label { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }

/* Lead: slightly larger grey paragraph */
.lead { font-size: clamp(17px, 1.6vw, 20px); color: var(--muted); max-width: 58ch; }

/* Buttons (pill shaped) */
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 12px 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 500;
  text-decoration: none;
  /* the next four lines make a <button> look the same as a link button */
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  color: var(--text);
  font-family: inherit; font-size: inherit;
  cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast), box-shadow 300ms, transform 300ms var(--ease);
}
.btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { color: var(--on-accent); box-shadow: 0 10px 34px -8px var(--accent); }
.btn-small { min-height: 44px; padding: 8px 16px; font-size: var(--text-sm); }

/* Round icon button (theme switch, menu) */
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Text link with an arrow */
.text-link { display: inline-block; padding: 12px 0; font-weight: 500; }

/* Key/value list: the status rows ("Open to ...") */
.kv-list { display: flex; flex-direction: column; gap: 16px; }
.kv-label { font-size: var(--text-sm); color: var(--muted); }
.kv-value { font-weight: 500; }

/* Row: one line of a plain list (the "more work" list) */
.row {
  display: flex; flex-wrap: wrap; gap: 4px 24px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
  text-decoration: none;
}
.row-date { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); }
.row-text { flex: 1 1 260px; }

/* Tag: small pill */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-family: var(--font-mono); font-size: var(--text-xs);
  padding: 5px 12px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted);
}

/* Spotlight: a soft light under the mouse. main.js keeps --spot-x and
   --spot-y up to date; this draws the light and shows it on hover. */
.spotlight { position: relative; overflow: hidden; }
.spotlight::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(420px circle at var(--spot-x, 50%) var(--spot-y, 0%), var(--glow), transparent 70%);
  opacity: 0;
  transition: opacity 300ms;
}
.spotlight:hover::before { opacity: 1; }
.spotlight > * { position: relative; } /* content stays above the light */

/* ---------- 4. HEADER AND MENU ----------
   A floating, rounded bar that stays near the top while scrolling.
   Its background is see-through with a blur of whatever passes behind. */
.site-header {
  position: sticky; top: 14px; z-index: 20;
  margin-top: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 8px 8px 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.logo { font-family: var(--font-mono); font-size: var(--text-sm); text-decoration: none; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.site-nav { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--text-sm); }
.site-nav a { text-decoration: none; padding: 11px 12px; border-radius: 999px; color: var(--muted); }
.site-nav a:hover { color: var(--text); }
/* The section being read right now (main.js adds "is-current") */
.site-nav a.is-current { color: var(--accent); background: var(--glow); }
.site-nav .nav-cv { margin-left: 6px; padding: 10px 18px; border: 1px solid var(--accent); color: var(--accent); }
.site-nav .nav-cv:hover { background: var(--accent); color: var(--on-accent); }
.menu-btn { display: none; } /* shown only on phones, see part 7 */

/* Which theme icon is visible: moon in light mode, sun in dark mode */
#icon-sun { display: none; }
:root[data-theme="dark"] #icon-sun { display: block; }
:root[data-theme="dark"] #icon-moon { display: none; }

/* ---------- 5. SECTIONS ---------- */

/* A "scene": one section of the page, with generous empty space around it */
.scene { padding-top: var(--scene-space); display: flex; flex-direction: column; gap: clamp(36px, 5vw, 64px); }

/* Section heading: big outlined number, small label, large title */
.section-head { display: flex; flex-direction: column; gap: 10px; }
.section-head h2 { font-size: var(--text-3xl); font-weight: 600; letter-spacing: -0.03em; line-height: 1.08; max-width: 16em; }
.section-head .lead { margin-top: 8px; }
.scene-num {
  font-family: var(--font-heading); font-weight: 600;
  font-size: var(--text-num); line-height: 0.85; letter-spacing: -0.05em;
  margin-bottom: 8px;
  align-self: flex-start; /* only as wide as its digits, so the wipe below is tight */
  /* The digits are filled with a pattern of dots, like the portrait:
     a dotted background that is only visible inside the letter shapes. */
  color: transparent;
  background: radial-gradient(circle, var(--accent) 1.7px, transparent 2.2px) 0 0 / 7px 7px;
  -webkit-background-clip: text;
  background-clip: text;
  user-select: none;
  /* the number is wiped in from left to right when the signal light reaches it */
  clip-path: inset(0 0 0 0);
  transition: clip-path 900ms var(--ease), opacity 600ms;
}
/* Waiting for the light (main.js adds "signal-ready" to <main> and "is-lit" to the heading) */
.signal-ready .section-head:not(.is-lit) .scene-num { clip-path: inset(0 100% 0 0); opacity: 0; }

/* SIGNAL LINE: a thin line down the left edge that joins the section
   numbers. main.js sets its position and --signal-y, the distance the
   point of light has travelled. */
main { position: relative; }
.signal {
  position: absolute; left: calc(var(--gutter) * -0.55); /* in the empty strip beside the text */
  width: 2px; border-radius: 1px;
  background: var(--border);
  pointer-events: none;
}
@media (min-width: 1320px) { .signal { left: -44px; } } /* wide screens have room for it further out */
.signal-fill { /* the part the light has already travelled */
  position: absolute; top: 0; left: 0; right: 0;
  height: var(--signal-y, 0px);
  background: linear-gradient(to bottom, transparent, var(--accent));
}
.signal-dot { /* the point of light */
  position: absolute; left: 50%; top: var(--signal-y, 0px);
  width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--glow), 0 0 22px 2px var(--accent);
}
.signal-node { /* one small ring beside each section number */
  position: absolute; left: 50%;
  width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--border);
  transition: background-color 400ms, border-color 400ms, box-shadow 400ms;
}
.signal-node.is-lit { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 5px var(--glow); }

/* HERO: fills the first screen. Text on the left, status card on the right. */
.hero {
  position: relative;
  min-height: calc(100svh - 90px);
  padding: clamp(40px, 7vw, 96px) 0;
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.62fr);
  align-items: center; gap: clamp(28px, 5vw, 72px);
}
.hero > * { position: relative; } /* text and card sit above the drawing */
.hero-main { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.hero-main h1 { font-size: var(--text-hero); font-weight: 600; line-height: 0.98; letter-spacing: -0.045em; }
.hero-main .lead { max-width: 46ch; }
.hero-main .btn-row { margin-top: 8px; }

/* Headline lines ("beats"): each on its own row. When the page opens they
   appear one after another in the accent colour, then settle to normal text.
   --beat-index (0, 1, 2 ...) is set by main.js. */
.beat {
  display: block;
  animation: beat-in 1000ms var(--ease) both;
  animation-delay: calc(250ms + var(--beat-index, 0) * 380ms);
}
@keyframes beat-in {
  from { opacity: 0; transform: translateY(24px); color: var(--accent); }
  55%  { opacity: 1; transform: none; color: var(--accent); }
  to   { opacity: 1; transform: none; color: var(--text); }
}

/* The 3D network: fills the right part of the hero, behind the status
   card, and fades out towards the text. Clicks pass through it. */
.hero > .hero-canvas {
  position: absolute; top: 0; right: 0;
  width: 62%; height: 100%;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 45%);
  mask-image: linear-gradient(to right, transparent, #000 45%);
}

/* Status card: portrait, name, then the status rows */
.status { display: flex; flex-direction: column; gap: 18px; }
.status h2 { font-weight: 500; }
.profile { display: flex; flex-direction: column; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.profile-name { font-family: var(--font-heading); font-size: var(--text-lg); font-weight: 600; }
.avatar {
  position: relative;
  width: 100%; max-width: 200px; aspect-ratio: 1;
  border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden;
}
.avatar img, .avatar canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* The real photo is invisible (but still there for screen readers)... */
.avatar img { object-fit: cover; opacity: 0; }
/* ...unless the dots could not be drawn: then it is shown in grey. */
.avatar.is-plain img { opacity: 1; filter: grayscale(1); }
.avatar.is-plain canvas { display: none; }

/* PROCESS CIRCUIT: the "how I work" steps as numbered points on a wavy
   path. Every second point sits lower, which makes the wave. The path,
   its travelling pulse and the dashed loop arrow are drawn into the
   <svg> by js/effects.js; this file only says how they look.

   A step can be:  "is-active" = the chosen one,  "is-done" = before it.
   The full text of the chosen step is shown in the panel underneath.
   Below 1040px all of this becomes a plain vertical list (see part 7). */
.circuit { position: relative; }
.circuit-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.circuit-track { fill: none; stroke: var(--border); stroke-width: 2px; }
.circuit-fill { /* the bright part of the path, up to the chosen step */
  fill: none; stroke: var(--accent); stroke-width: 2.5px; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  transition: stroke-dashoffset 700ms var(--ease);
}
.circuit-pulse { /* a short dash of light that runs along the whole path, again and again */
  fill: none; stroke: var(--accent); stroke-width: 4px; stroke-linecap: round;
  stroke-dasharray: 0.03 0.97; stroke-dashoffset: 1;
  animation: net-run 5s linear infinite;
}
.circuit-loop { fill: none; stroke: var(--accent); stroke-width: 1.5px; stroke-dasharray: 5 6; opacity: 0.75; }
.circuit-arrowhead { fill: var(--accent); }
.circuit-loop-label { /* the words on the loop arrow; effects.js sets its position */
  position: absolute; transform: translate(-50%, -150%);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent);
  white-space: nowrap;
}

.flow {
  list-style: none; margin: 0; padding: 0;
  position: relative;
  display: grid; grid-template-columns: repeat(var(--step-count, 5), minmax(0, 1fr));
  min-height: 340px;
}
.step { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 84px 8px 0; }
.step:nth-child(even) { padding-top: 184px; } /* every second step sits lower: this makes the wave */
.step-node { /* the numbered point */
  position: relative; /* stays above the drawn path */
  width: 58px; height: 58px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg); color: var(--muted);
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500;
  cursor: pointer;
  transition: background-color 300ms, color 300ms, border-color 300ms, box-shadow 300ms, transform 400ms var(--ease);
}
.step-node:hover { border-color: var(--accent); color: var(--accent); }
.step.is-done .step-node { border-color: var(--accent); color: var(--accent); }
.step.is-active .step-node {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 0 0 9px var(--glow), 0 0 44px -2px var(--accent);
  transform: scale(1.14);
}
.step-head { display: flex; flex-direction: column; gap: 2px; }
.step-head h3 { transition: color 300ms; }
.step-head .label { font-size: var(--text-xs); }
.step-head h3 { font-size: clamp(17px, 1.5vw, 21px); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
/* Steps not reached yet have a grey title. (Grey, not see-through: faded text would be too hard to read.) */
.step:not(.is-active):not(.is-done) .step-head h3 { color: var(--muted); }
.step-body { display: none; } /* on wide screens the text lives in the panel instead */

/* The "in practice" example of a step */
.step-example { display: flex; flex-direction: column; gap: 4px; padding-left: 20px; border-left: 2px solid var(--accent); }
.step-example .label { font-size: var(--text-xs); }
.step-example p { color: var(--text); }
.step-example .text-link { padding: 8px 0 0; align-self: flex-start; }

/* The panel: the chosen step in full */
.flow-panel { padding: clamp(24px, 3.2vw, 44px); }
.panel-content {
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  align-items: center; gap: clamp(20px, 4vw, 60px);
  animation: panel-in 500ms var(--ease);
}
@keyframes panel-in { from { opacity: 0; transform: translateY(10px); } }
.panel-num { font-family: var(--font-heading); font-weight: 600; font-size: clamp(56px, 7vw, 100px); line-height: 0.9; letter-spacing: -0.05em; color: var(--accent); }
.panel-main { display: flex; flex-direction: column; gap: 8px; }
.panel-main h3 { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.panel-main p { color: var(--muted); }

/* PROJECTS: each project is a wide row, picture on one side and text on
   the other. The sides swap on every second project. */
.projects { display: flex; flex-direction: column; gap: clamp(72px, 10vw, 130px); }
.project {
  display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  align-items: center; gap: clamp(28px, 5vw, 76px);
}
.project:nth-child(even) > :first-child { order: 2; } /* picture on the right */
.project:not(.has-media) { grid-template-columns: minmax(0, 760px); } /* no picture: one text column */
.project-body { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.project-num { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--accent); }
.project h3 { font-size: var(--text-2xl); font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; }
.project-meta { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); }

/* Picture frame: every project picture has the same shape (16:10), so
   the rows line up whatever the size of the original file. */
.media-frame {
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 40px 90px -50px var(--shadow), 0 0 0 8px var(--glow);
  background: var(--surface);
}
.media-frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 900ms var(--ease); }
/* Tilt: the picture leans towards the mouse. main.js sets --tilt-x and
   --tilt-y (the angles) and --glare-x / --glare-y (where the reflection is). */
.project > .media-frame {
  position: relative;
  transform: perspective(1100px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 500ms var(--ease);
}
.project > .media-frame::after { /* the reflection */
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at var(--glare-x, 50%) var(--glare-y, 50%), var(--glare), transparent 55%);
  opacity: 0; transition: opacity 400ms;
  pointer-events: none;
}
.project > .media-frame:hover::after { opacity: 1; }
.project:hover .media-frame img { transform: scale(1.04); } /* gentle zoom on hover */
/* Inside "How I built it" a screenshot is shown whole, not cropped */
.story .media-frame { aspect-ratio: auto; box-shadow: none; }
.story .media-frame img { height: auto; object-fit: contain; }

.project-facts { display: flex; flex-direction: column; gap: 14px; }
.fact { display: flex; flex-direction: column; gap: 2px; }
.fact-label { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent); }
.project-links { display: flex; flex-wrap: wrap; gap: 0 24px; }

/* "How I built it": the part of a project that opens on click.
   It is a <details> element, so it works with keyboard and without JavaScript. */
.story { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.story summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px;
  font-weight: 500; cursor: pointer;
  list-style: none; /* hide the browser's own triangle */
  transition: color var(--dur-fast);
}
.story summary::-webkit-details-marker { display: none; }
.story summary:hover { color: var(--accent); }
/* Our own marker: a plus that becomes a minus when open */
.story summary::after { content: "+"; font-family: var(--font-mono); font-size: var(--text-lg); color: var(--accent); }
.story[open] summary::after { content: "–"; }
.story-body { display: flex; flex-direction: column; gap: 16px; padding: 4px 0 20px; }
/* Smooth opening, in browsers that can animate to a natural height.
   Other browsers simply open it at once. */
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
  .story::details-content {
    block-size: 0; overflow: clip;
    transition: block-size 400ms var(--ease), content-visibility 400ms allow-discrete;
  }
  .story[open]::details-content { block-size: auto; }
}

/* Live demo inside a project row (the maze) */
.demo { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.demo-canvas {
  display: block; width: 100%; aspect-ratio: 16 / 9;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 40px 90px -50px var(--shadow), 0 0 0 8px var(--glow);
  cursor: pointer;
  touch-action: manipulation; /* taps respond at once on phones */
}
.demo-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 6px; }
.demo-stats { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); }
.demo-caption { font-size: var(--text-sm); color: var(--muted); }

/* More work: a plain list under the projects */
.more-work { display: flex; flex-direction: column; margin-top: clamp(24px, 4vw, 48px); }
.more-work h3 { font-weight: 500; margin-bottom: 14px; }
.more-work .row:last-child { border-bottom: 1px solid var(--border); }

/* RESEARCH: one big statement with tags, then three plain columns */
.info-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(28px, 4vw, 56px); }
.info-card { display: flex; flex-direction: column; gap: 8px; padding-top: 20px; border-top: 1px solid var(--border); }
.info-card h3 { font-size: var(--text-lg); font-weight: 600; }
.info-card p { color: var(--muted); }
.info-links { display: flex; flex-wrap: wrap; gap: 0 20px; }
/* The card marked wide: true becomes the big statement across the full row */
.info-wide { grid-column: 1 / -1; border-top: 0; padding-top: 0; gap: 20px; }
.info-wide h3 { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500; color: var(--muted); }
.info-wide p { font-family: var(--font-heading); font-size: var(--text-2xl); line-height: 1.2; letter-spacing: -0.02em; color: var(--text); max-width: 24em; }

/* ATTENTION ILLUSTRATION: a row of word buttons with curved lines above
   them (drawn by js/effects.js). Each word carries --weight (0 to 1):
   how strongly it is linked to the chosen word. */
.attention {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; gap: 10px;
  padding: clamp(20px, 3vw, 36px);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.attention h3 { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500; color: var(--muted); }
.attention-stage { position: relative; padding-top: 70px; } /* empty room above the words for the curves */
.attention-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.attention-stage path {
  fill: none; stroke: var(--accent); stroke-linecap: round;
  /* the line is drawn from the chosen word outwards */
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: draw-link 600ms var(--ease) forwards;
}
@keyframes draw-link { to { stroke-dashoffset: 0; } }
.attention-tokens { display: flex; flex-wrap: wrap; gap: 30px 8px; }
.token {
  position: relative; overflow: hidden;
  min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: transparent; color: var(--text);
  font-family: var(--font-mono); font-size: var(--text-base);
  cursor: pointer;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.token::before { /* accent tint: stronger for strongly linked words */
  content: "";
  position: absolute; inset: 0;
  background: var(--accent);
  opacity: calc(var(--weight, 0) * 0.3);
  transition: opacity 300ms;
}
.token.is-source { border-color: var(--accent); color: var(--accent); }
.attention-note { font-size: var(--text-sm); color: var(--muted); max-width: 64ch; }

/* WRITING: article cards. The whole card is one link.
   Several articles share the row; a single article becomes a wide card
   with the cover beside the text. */
.article-list { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.article {
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; /* keeps the cover inside the rounded corners */
  text-decoration: none;
  box-shadow: 0 40px 90px -60px var(--shadow);
  transition: border-color var(--dur-fast);
}
.article:hover { color: var(--text); border-color: var(--accent); }
.article-cover { aspect-ratio: 16 / 9; overflow: hidden; }
.article-cover img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 900ms var(--ease); }
.article:hover .article-cover img { transform: scale(1.04); } /* the cover zooms in a little on hover */
.article-text { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 24px; }
.article h3 { font-size: var(--text-xl); font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; transition: color var(--dur-fast); }
.article:hover h3 { color: var(--accent); }
.article-more { margin-top: auto; padding-top: 8px; color: var(--accent); font-weight: 500; }
@media (min-width: 761px) {
  .article:only-child { flex-direction: row; align-items: stretch; }
  .article:only-child .article-cover { flex: 0 0 56%; aspect-ratio: auto; min-height: 320px; }
  .article:only-child .article-text { justify-content: center; padding: clamp(28px, 4vw, 56px); gap: 14px; }
  .article:only-child h3 { font-size: var(--text-2xl); }
  .article:only-child .article-more { margin-top: 8px; }
}

/* BACKGROUND: achievements on the left, education and skills on the right */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(36px, 6vw, 96px); }
.split-col { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.split-col > h3 { font-weight: 500; }

/* Timeline: a line down the left with one dot per achievement.
   The newest entry (the first one) has a filled, glowing dot. */
.timeline {
  list-style: none; margin: 0; padding: 0;
  position: relative;
  display: flex; flex-direction: column; gap: 24px;
}
.timeline::before { /* the line */
  content: "";
  position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-left: 34px; display: flex; flex-direction: column; gap: 2px; }
.timeline-item::before { /* the dot */
  content: "";
  position: absolute; left: 0; top: 7px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.timeline-item:first-child::before { background: var(--accent); box-shadow: 0 0 0 6px var(--glow); }
.timeline-date { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); }

/* Education block and skill groups */
.edu-list, .skill-list { display: flex; flex-direction: column; gap: 20px; }
.edu-list { padding-bottom: 28px; border-bottom: 1px solid var(--border); }
.edu { display: flex; flex-direction: column; gap: 6px; }
.edu-title { font-family: var(--font-heading); font-size: var(--text-xl); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.edu-meta { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); }
.edu p { color: var(--muted); }
.skill-group { display: flex; flex-direction: column; gap: 10px; }

/* CONTACT: the closing scene. Left: the invitation and buttons.
   Right: a small network joining one glowing point to every contact link.
   The border is a ring of light that slowly travels around the card. */
.site-footer { display: flex; flex-direction: column; gap: var(--gap); margin-top: var(--scene-space); }
/* --ring-angle is the position of the light on the border. Declaring it
   with @property lets the browser animate it smoothly; browsers that
   cannot simply show a still ring. */
@property --ring-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.contact {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center; gap: clamp(28px, 4vw, 56px);
  padding: clamp(36px, 6vw, 84px) clamp(22px, 4.5vw, 64px);
  border: 1.5px solid transparent;
  border-radius: clamp(24px, 4vw, 40px);
  /* three layers: a glow in the corner, the card colour, and (showing
     only in the border) the travelling ring of light */
  background:
    radial-gradient(60% 90% at 100% 0%, var(--glow), transparent 70%) padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    conic-gradient(from var(--ring-angle), var(--accent), var(--border) 22%, var(--border) 78%, var(--accent)) border-box;
  animation: ring-turn 9s linear infinite;
}
@keyframes ring-turn { to { --ring-angle: 360deg; } }
.contact-main { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; min-width: 0; }
.contact h2 { font-size: var(--text-3xl); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; }
.contact .btn-row { margin-top: 8px; }

/* "Open to new roles · Dhaka · 14:32" with a softly pulsing green dot */
.contact-now { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-family: var(--font-mono); font-size: var(--text-sm); }
.now-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: now-pulse 2.2s ease-out infinite; }
@keyframes now-pulse { to { box-shadow: 0 0 0 12px transparent; } }
.now-place { color: var(--muted); }
.now-place::before { content: "· "; }

/* The network: hub on the left, the links stacked on the right,
   the <svg> with the lines stretched behind both. */
.contact-net { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: clamp(36px, 4.5vw, 64px); min-width: 0; }
.contact-net svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.contact-hub {
  position: relative;
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 10px var(--glow), 0 0 44px -4px var(--accent);
  font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 500; color: var(--accent);
}
.net-line { fill: none; stroke: var(--accent); stroke-width: 1.2px; opacity: 0.3; transition: opacity 250ms, stroke-width 250ms; }
.net-line.is-hot { opacity: 1; stroke-width: 2.2px; }
.net-pulse { /* a short bright dash that runs from the hub to the link, again and again */
  fill: none; stroke: var(--accent); stroke-width: 3px; stroke-linecap: round;
  stroke-dasharray: 0.07 0.93; stroke-dashoffset: 1;
  animation: net-run 2.8s linear infinite;
}
@keyframes net-run { to { stroke-dashoffset: 0; } }
.contact-links { position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.channel {
  display: flex; flex-direction: column; gap: 0;
  min-height: 56px; justify-content: center;
  padding: 8px 18px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg);
  text-decoration: none;
  transition: border-color var(--dur-fast), transform 300ms var(--ease);
}
.channel:hover { border-color: var(--accent); transform: translateX(6px); }
.channel-name { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent); }
.channel-value { font-size: var(--text-sm); color: var(--text); overflow-wrap: anywhere; }

/* The small line at the very bottom of the page */
.site-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 24px;
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted);
}
.site-foot a { padding: 14px 0; color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

/* ---------- 6. MOTION ---------- */

/* Reveal on scroll.
   main.js adds the class "reveal" to the main blocks, then adds
   "is-visible" when they scroll into view. If JavaScript does not run,
   the class is never added, so nothing stays hidden.
   --reveal-delay is set by main.js so neighbours appear one after another. */
.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* Theme cross-fade: main.js asks the browser to fade between the light and
   dark picture of the page. This sets how long that fade takes. */
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 300ms; }

/* ---------- 7. TABLETS AND PHONES ---------- */

/* Below 1040px the process steps no longer fit on a wave: they become a
   vertical list. Each step shows its own text, and there is no panel. */
@media (max-width: 1040px) {
  .circuit-lines, .flow-panel { display: none; }
  .flow { display: flex; flex-direction: column; min-height: 0; }
  .step, .step:nth-child(even) {
    position: relative;
    display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 18px; row-gap: 8px;
    align-items: start; text-align: left;
    padding: 0 0 34px;
  }
  .step:last-child { padding-bottom: 0; }
  .step-node { width: 48px; height: 48px; grid-row: 1 / span 2; }
  .step.is-active .step-node { transform: none; }
  /* the line from this point down to the next one */
  .step::after { content: ""; position: absolute; left: 23px; top: 54px; bottom: 6px; width: 2px; border-radius: 1px; background: var(--border); transition: background-color 300ms; }
  .step.is-done::after { background: var(--accent); }
  .step:last-child::after { display: none; }
  .step-head { padding-top: 2px; }
  .step-body { display: flex; flex-direction: column; gap: 12px; grid-column: 2; }
  .step-body > p { color: var(--muted); }
  /* the loop note becomes a plain line under the list */
  .circuit-loop-label { position: static; transform: none; white-space: normal; margin: 22px 0 0 66px; }
  .circuit-loop-label::before { content: "↺ "; }
}

/* Tablets and small laptops (900px and below) */
@media (max-width: 900px) {
  /* Hero: one column. The status card goes under the text. */
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .hero > .hero-canvas { right: 0; width: 100%; height: 62%; opacity: 0.4; -webkit-mask-image: none; mask-image: none; }
  /* Status card: portrait beside the name and rows */
  .status { display: grid; grid-template-columns: 148px minmax(0, 1fr); column-gap: 24px; row-gap: 14px; align-items: start; }
  .profile { grid-row: 1 / span 2; border-bottom: 0; padding-bottom: 0; }

  /* Contact: the network goes under the text */
  .contact { grid-template-columns: minmax(0, 1fr); }

  /* Projects: picture on top, text below, for every project */
  .project { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .project:nth-child(even) > :first-child { order: 0; }

  .info-list { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .split { grid-template-columns: minmax(0, 1fr); gap: 56px; }
}

/* Narrow screens (860px and below): the menu no longer fits in the bar,
   so it becomes a drop-down panel opened by the menu button */
@media (max-width: 860px) {
  .site-header { top: 10px; margin-top: 10px; padding: 6px 6px 6px 18px; }
  .menu-btn { display: inline-flex; }
  .site-nav {
    display: none;
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 10;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: 20px;
    padding: 8px 20px;
    box-shadow: 0 30px 60px -30px var(--shadow);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 14px 0; border-radius: 0; border-bottom: 1px solid var(--border); }
  .site-nav a.is-current { background: none; }
  .site-nav a:last-child { border-bottom: 0; }
  .site-nav .nav-cv { margin-left: 0; border: 0; padding: 14px 0; }
  .site-nav .nav-cv:hover { background: none; color: var(--accent); }
}

/* Phones (760px and below) */
@media (max-width: 760px) {
  :root { --gutter: 18px; --radius: 18px; }
  .card { padding: 22px; }

  .hero { padding: 36px 0 12px; gap: 32px; }
  .hero-main { gap: 18px; }
  .hero-main .btn-row .btn { flex: 1 1 auto; } /* the two buttons share the row */
  /* Status card: small portrait beside the name, the rows underneath */
  .status { display: flex; align-items: stretch; }
  .profile { flex-direction: row; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); padding-bottom: 18px; }
  .avatar { width: 84px; flex: none; }

  .contact .btn-row { width: 100%; }
  .contact .btn-row .btn { flex: 1 1 100%; } /* full-width buttons are easy to tap */
  /* Contact network: no hub and no lines on phones, just the list of links */
  .contact-net { grid-template-columns: minmax(0, 1fr); }
  .contact-hub, .contact-net svg { display: none; }
  /* The city and time go on their own line, without the leading dot */
  .now-place { flex-basis: 100%; }
  .now-place::before { content: none; }
  .channel:hover { transform: none; }
  .site-foot { justify-content: center; text-align: center; }
}

/* ---------- 8. REDUCED MOTION ----------
   Respect visitors who turn off animations in their system settings:
   nothing drifts, slides, zooms or fades in. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .aurora span { animation: none; }
  .contact, .now-dot { animation: none; }
  .net-pulse { animation: none; opacity: 0; }
  .channel, .net-line { transition: none; }
  .channel:hover { transform: none; }
  .scene-num, .signal-node, .token::before { transition: none; }
  .attention-stage path { animation: none; stroke-dashoffset: 0; }
  .project > .media-frame { transform: none; transition: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  a, .btn, .icon-btn { transition: none; }
  .btn:hover { transform: none; }
  .beat { animation: none; }
  .step-node, .step-head h3, .step::after, .circuit-fill { transition: none; }
  .step.is-active .step-node { transform: none; }
  .circuit-pulse { animation: none; opacity: 0; }
  .panel-content { animation: none; }
  .spotlight::before, .story summary, .story::details-content { transition: none; }
  .article, .article h3, .article-cover img, .media-frame img { transition: none; }
  .article:hover .article-cover img, .project:hover .media-frame img { transform: none; }
}

/* ---------- 9. PRINTING ----------
   When the page is printed or saved as PDF: always use the light colours,
   show everything, and leave out the parts that only make sense on a
   screen (menu, buttons, moving drawings). main.js also opens every
   "How I built it" part just before printing. */
@media print {
  :root, :root[data-theme="dark"] {
    --bg: #ffffff; --surface: #ffffff; --border: #c9cfd6;
    --text: #0f172a; --muted: #44505f; --accent: #0f766e; --on-accent: #ffffff;
    --glow: transparent; --shadow: transparent;
    --scene-space: 40px;
  }
  .reveal { opacity: 1; transform: none; }
  /* Process: print it as the plain list with every step's text */
  .circuit-lines, .flow-panel, .circuit-loop-label { display: none !important; }
  .flow { display: block; min-height: 0; }
  .step, .step:nth-child(even) { display: block; text-align: left; padding: 0 0 16px; }
  .step-node { display: none; }
  .step-body { display: block; }
  .beat { animation: none; }

  .site-header { position: static; border: 0; padding: 0; background: none; }
  .aurora, .neural-bg, .signal, .progress, .site-nav, .icon-btn, .skip-link, .btn-row, .hero-canvas, .avatar, .demo, .scene-num, .site-foot a { display: none !important; }
  .hero { min-height: 0; padding: 24px 0; }
  .profile { border-bottom: 0; padding-bottom: 0; }
  .contact { background: none; border-color: var(--border); animation: none; }
  .contact-hub, .contact-net svg { display: none !important; }

  /* Do not cut a block in half between two pages when it can be avoided */
  .card, .step, .project, .timeline-item, .article, .contact { break-inside: avoid; }
  .page { max-width: none; padding: 0; }
  a { text-decoration: none; }
}
