/* ==========================================================================
   Aliakbar Bhojani portfolio
   Plain CSS: tokens, base, layout, components, motion, print.
   ========================================================================== */

/* ------------------------------------------------------------------ Tokens */
:root {
  /* Dark theme (default): obsidian, electric purple, cyber blue, magenta */
  --bg: #090910;
  --bg-alt: #0e0e19;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-solid: #151523;
  --header-bg: rgba(9, 9, 16, 0.78);
  --border: rgba(255, 255, 255, 0.13);
  --control-border: #77749a;
  --text: #eeedf7;
  --muted: #b3b1cb;
  --accent: #a882ff;
  --accent-2: #5cc8ff;
  --magenta: #ff6ac1;
  --success: #6ee7a8;
  --error: #ff8fa3;
  --focus: #5cc8ff;
  --grid-line: rgba(168, 130, 255, 0.13);
  --glow-1: rgba(124, 58, 237, 0.34);
  --glow-2: rgba(36, 89, 224, 0.26);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --btn-from: #6d28d9;
  --btn-to: #2459e0;
  --floor-line: rgba(168, 130, 255, 0.24);
  --glare: rgba(168, 130, 255, 0.13);
  --card-solid: rgba(19, 19, 32, 0.9);
  --ring-opacity: 0.6;

  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --container: 1120px;
  --header-h: 68px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f4fb;
  --bg-alt: #eeecf8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --header-bg: rgba(245, 244, 251, 0.82);
  --border: rgba(22, 20, 42, 0.14);
  --control-border: #6f6c8c;
  --text: #16142a;
  --muted: #4f4c69;
  --accent: #6427d9;
  --accent-2: #0a5fa6;
  --magenta: #a81364;
  --success: #0c6b3d;
  --error: #b3193a;
  --focus: #0a5fa6;
  --grid-line: rgba(100, 39, 217, 0.1);
  --glow-1: rgba(124, 58, 237, 0.16);
  --glow-2: rgba(36, 89, 224, 0.13);
  --shadow: 0 14px 40px rgba(40, 30, 90, 0.12);
  --floor-line: rgba(100, 39, 217, 0.17);
  --glare: rgba(100, 39, 217, 0.07);
  --card-solid: rgba(255, 255, 255, 0.93);
  --ring-opacity: 0.5;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: clamp(2.6rem, 7.5vw, 4.75rem); font-weight: 800; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.8rem, 4.2vw, 2.6rem); font-weight: 750; }
h3 { font-size: 1.25rem; font-weight: 700; }

p { margin: 0 0 1em; }
ul { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }

a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { color: var(--accent-2); }

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

code { font-family: var(--font-mono); font-size: 0.92em; }

.container {
  width: min(100% - 2.5rem, var(--container));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  padding: 0.7rem 1rem;
  background: var(--surface-solid);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.eyebrow {
  margin: 0 0 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow);
}

.card {
  border-radius: var(--radius);
  padding: 1.6rem;
}

/* ------------------------------------------------------------------ Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

/* At the top of the page the header is clear and the hero shows through it */
.js .site-header:not(.is-scrolled) {
  background: transparent;
  border-bottom-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.sprite { position: absolute; width: 0; height: 0; }

/* ------------------------------------------------------- Opening screen */
/* Profile selector + loading state. Fixed dark colours on purpose: this
   screen looks the same in the light and dark themes. */
.gate { display: none; }
html.gate-open { overflow: hidden; }
.gate-open .gate {
  --focus: #5cc8ff;
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: auto;
  background: #090910;
  color: #eeedf7;
}
.gate:focus { outline: none; }

.gate-pick {
  display: grid;
  justify-items: center;
  gap: clamp(1.6rem, 5vh, 2.8rem);
  text-align: center;
}
.gate-title {
  font-size: clamp(1.9rem, 6vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.profile-tile {
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 0.5rem;
  border: 0;
  border-radius: 14px;
  background: none;
  color: #b3b1cb;
  font: inherit;
  font-size: clamp(1.05rem, 2.6vw, 1.35rem);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.profile-avatar {
  display: grid;
  place-items: center;
  width: clamp(9rem, 30vw, 12.5rem);
  aspect-ratio: 1;
  border: 3px solid rgba(168, 130, 255, 0.4);
  border-radius: 14px;
  background: linear-gradient(140deg, #1b1340, #0d0b1a 55%, #0b1c33);
}
.profile-avatar svg { width: 68%; height: 68%; }
/* Hover, keyboard focus and touch press: white ring and brighter name */
.profile-tile:hover .profile-avatar,
.profile-tile:focus-visible .profile-avatar,
.profile-tile:active .profile-avatar { border-color: #eeedf7; }
.profile-tile:hover,
.profile-tile:focus-visible,
.profile-tile:active { color: #ffffff; }

/* Loading state sits on top of the selector and is shown by .is-loading */
.gate-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.5rem;
  opacity: 0;
  pointer-events: none;
}
/* The loader shows twice: while the site opens (.is-booting) and after a
   profile is chosen (.is-loading). The selector is hidden for both, which
   also keeps the tile out of reach of the keyboard. */
.gate.is-booting .gate-pick,
.gate.is-loading .gate-pick { visibility: hidden; }
.gate.is-booting .gate-loading,
.gate.is-loading .gate-loading { opacity: 1; }
.loader {
  position: relative;
  display: grid;
  place-items: center;
  width: 7.5rem;
  aspect-ratio: 1;
}
.loader svg { width: 58%; height: 58%; }
/* Progress ring around the mark */
.loader::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #a882ff;
  border-right-color: #5cc8ff;
  border-radius: 50%;
}
.gate-status { margin: 0; min-height: 1.6em; color: #b3b1cb; font-size: 1.05rem; font-weight: 600; }

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  margin-right: auto;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}
.brand:hover { color: var(--text); }

.brand-mark {
  display: block;
  flex: none;
  width: 40px;
  height: 40px;
}

.site-nav ul { display: flex; gap: 0.25rem; }

.site-nav a {
  display: block;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.97rem;
  font-weight: 600;
  text-decoration: none;
}
.site-nav a:hover { color: var(--text); background: var(--surface); }
/* Current section: brighter text AND an underline bar (not colour alone) */
.site-nav a { position: relative; }
.site-nav a[aria-current] { color: var(--text); }
.site-nav a[aria-current]::after {
  content: "";
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: 0.2rem;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.scroll-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  pointer-events: none;
}
.scroll-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.3rem 0.5rem;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle-track {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 2px solid var(--control-border);
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
}

[aria-checked="true"] .theme-toggle-thumb { transform: translateX(22px); }
[aria-checked="true"] .icon-sun,
[aria-checked="false"] .icon-moon { display: none; }
.theme-toggle-text { min-width: 2.6em; text-align: left; }

/* -------------------------------------------------------------------- Hero */
.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: min(100vh, 54rem);
  /* Pull the hero up behind the header so it reads as one billboard */
  margin-top: calc((var(--header-h) + 1px) * -1);
  padding: calc(clamp(3rem, 7vw, 5rem) + var(--header-h)) 0 clamp(3rem, 7vw, 5.5rem);
  overflow: hidden;
}

.hero-grid {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(42rem 26rem at 12% 0%, var(--glow-1), transparent 70%),
    radial-gradient(36rem 24rem at 92% 18%, var(--glow-2), transparent 70%);
}

/* 3D grid floor: a flat grid tipped back in perspective so it recedes to a
   horizon. Faded at the top (horizon) and bottom so it never fights the text. */
.hero-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 62%;
  z-index: -1;
  overflow: hidden;
  perspective: 600px;
  perspective-origin: 50% 0;
  -webkit-mask-image: linear-gradient(to bottom, transparent 4%, #000 46%, #000 72%, transparent);
  mask-image: linear-gradient(to bottom, transparent 4%, #000 46%, #000 72%, transparent);
}
.hero-floor span {
  position: absolute;
  left: -60%;
  right: -60%;
  top: 0;
  height: 150%;
  transform-origin: 50% 0;
  transform: rotateX(70deg);
  background-image:
    linear-gradient(var(--floor-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--floor-line) 1px, transparent 1px);
  background-size: 56px 56px;
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.9fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.hero-value {
  max-width: 34em;
  margin: 1.4rem 0 2rem;
  font-size: clamp(1.1rem, 2.1vw, 1.32rem);
  line-height: 1.55;
  color: var(--text);
}

.actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 48px;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(120deg, var(--btn-from), var(--btn-to));
  background-color: var(--btn-from);
  color: #fff;
  box-shadow: 0 8px 26px var(--glow-1);
}
.btn-primary:hover { color: #fff; filter: brightness(1.12); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--control-border);
  color: var(--text);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.btn-icon { flex: none; }
.btn-small { min-height: 44px; padding: 0.4rem 1.1rem; font-size: 0.95rem; }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.4rem;
  margin-top: 2.6rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border);
}
.fact dt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.fact dd { font-weight: 650; }

.hero-visual { position: relative; }

/* Three rings tilted on different axes, peeking out from behind the card */
.orbit {
  position: absolute;
  top: -6.5rem;
  right: -5rem;
  width: clamp(10rem, 18vw, 14.5rem);
  aspect-ratio: 1;
  perspective: 700px;
  pointer-events: none;
  opacity: var(--ring-opacity);
}
.orbit i {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  transform: rotateX(72deg);
}
.orbit i:nth-child(2) { border-color: var(--accent-2); transform: rotateY(70deg); }
.orbit i:nth-child(3) { inset: 14%; border-color: var(--magenta); transform: rotateX(48deg) rotateY(42deg); }
/* A small satellite riding each ring */
.orbit i::after {
  content: "";
  position: absolute;
  top: -4px;
  left: calc(50% - 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.orbit i:nth-child(1) { color: var(--accent); }
.orbit i:nth-child(2) { color: var(--accent-2); }
.orbit i:nth-child(3) { color: var(--magenta); }

.hero-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  /* More solid than other glass cards so the rings never show through the code */
  background: var(--card-solid);
}
.hero-card-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.hero-card-bar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--control-border);
}
.hero-card-bar b { margin-left: 0.5rem; font-weight: 500; }
/* pre-wrap lets a long line wrap on narrow cards instead of scrolling sideways */
.hero-card pre { margin: 0; padding: 1.2rem 1.25rem 1.4rem; overflow-x: auto; white-space: pre-wrap; line-height: 1.75; }
.c-key { color: var(--accent); }
.c-str { color: var(--accent-2); }

/* ---------------------------------------------------------------- Sections */
.section { padding: clamp(3.5rem, 8vw, 6rem) 0; }
.section:nth-of-type(odd) { background: var(--bg-alt); }
.hero.hero { background: none; }

.section h2 { margin-bottom: 1.2rem; max-width: 22em; }
.section-lead { max-width: 40em; color: var(--muted); margin-bottom: 2rem; }

/* About */
.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  margin-top: 2rem;
}
.about-bio p { max-width: 36em; }
.approach { display: grid; gap: 1rem; }
.approach h3 { margin-bottom: 0.45rem; font-size: 1.1rem; }
.approach p { margin: 0; color: var(--muted); font-size: 0.98rem; }
.approach .card { padding: 1.25rem 1.4rem; border-left: 3px solid var(--accent); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.45rem 1.05rem;
  border-radius: 999px;
  border: 2px solid var(--control-border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.filter-btn:hover { border-color: var(--accent); }
.filter-btn .check { display: none; }
/* Selected state: filled background, heavier text AND a check mark (not colour alone) */
.filter-btn[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 750;
}
.filter-btn[aria-pressed="true"] .check { display: block; }

.filter-status { margin: 0.9rem 0 1.6rem; color: var(--muted); font-size: 0.95rem; }

/* Projects: a sideways-scrolling row of title cards */
.row-wrap { position: relative; }

.title-row {
  display: flex;
  gap: 1rem;
  margin: 0 -0.5rem;
  padding: 0.9rem 0.5rem 1.2rem;   /* room for the hover zoom and focus ring */
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--control-border) transparent;
}
.title-row .project { flex: 0 0 clamp(14rem, 23vw, 17rem); scroll-snap-align: start; }

.poster {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.poster-art,
.dialog-art {
  position: relative;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  color: #fff;
}
.poster-art {
  aspect-ratio: 16 / 9;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
/* Darken the lower part of the artwork so the white title always reads */
.poster-art::before,
.dialog-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(5, 5, 14, 0.62), transparent 62%),
    radial-gradient(60% 80% at 85% 10%, rgba(255, 255, 255, 0.16), transparent 70%);
}
/* Artwork gradients: fixed dark tones so white text works in both themes */
.poster-0 { background: linear-gradient(135deg, #4c1d95, #1e3a8a); }
.poster-1 { background: linear-gradient(135deg, #1e3a8a, #0e7490); }
.poster-2 { background: linear-gradient(135deg, #6d28d9, #9d174d); }
.poster-3 { background: linear-gradient(135deg, #155e75, #4c1d95); }
.poster-4 { background: linear-gradient(135deg, #831843, #4c1d95); }
.poster-5 { background: linear-gradient(135deg, #312e81, #0e7490); }

.poster-mark { position: absolute; top: 0.6rem; left: 0.6rem; width: 24px; height: 24px; }
.poster-flag {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(5, 5, 14, 0.62);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.poster-title {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.poster-meta {
  display: block;
  margin-top: 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--muted);
}
.poster:hover .poster-art,
.poster:focus-visible .poster-art { border-color: var(--accent); }

.row-arrow {
  position: absolute;
  top: calc(0.9rem + (clamp(14rem, 23vw, 17rem) * 9 / 32) - 22px);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--control-border);
  border-radius: 50%;
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
}
.row-prev { left: -1.1rem; }
.row-next { right: -1.1rem; }
.row-arrow:hover { border-color: var(--accent); }
.row-arrow[disabled] { opacity: 0.35; cursor: default; }

/* Detail dialog */
html:has(.project-dialog[open]) { overflow: hidden; }
.project-dialog {
  width: min(46rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
}
.project-dialog::backdrop {
  background: rgba(4, 4, 10, 0.74);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.dialog-art { aspect-ratio: 16 / 5; padding: 1.4rem 1.6rem; }
.dialog-art .poster-title { font-size: clamp(1.6rem, 5vw, 2.4rem); }
.dialog-art .poster-mark { top: 1rem; left: 1.6rem; width: 28px; height: 28px; }
.dialog-close-form { position: absolute; top: 0.8rem; right: 0.8rem; margin: 0; }
.dialog-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(5, 5, 14, 0.7);
  color: #fff;
  cursor: pointer;
}
.dialog-close:hover { border-color: #fff; }
.dialog-body { padding: 1.5rem 1.6rem 1.8rem; }
.dialog-note { margin-bottom: 0; color: var(--muted); }
/* Visually hidden while the artwork title is on screen, still read aloud */
.js .dialog-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Without JavaScript the dialogs cannot open, so list the details instead */
html:not(.js) .row-wrap,
html:not(.js) .filters,
html:not(.js) .filter-status,
html:not(.js) .dialog-close-form { display: none; }
html:not(.js) .project-dialog {
  position: static;
  display: block;
  width: auto;
  max-height: none;
  margin: 0 0 1.2rem;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.3rem 1rem;
  margin-bottom: 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.project-kind { color: var(--muted); }
.project-dialog h3 { font-size: 1.6rem; }
.project-summary { margin: 0.6rem 0 1.3rem; font-size: 1.05rem; }

.project-story { display: grid; gap: 0.9rem; margin-bottom: 1.4rem; }
.project-story dt {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.project-story dd { color: var(--muted); font-size: 0.98rem; line-height: 1.55; }

.tags { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tags li {
  padding: 0.22rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 550;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  margin: auto 0 0;
  padding-top: 1.4rem;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 650;
}
.link-arrow::after { content: "\2197"; margin-left: 0.35em; text-decoration: none; display: inline-block; }

/* Skills */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.2rem;
  margin-top: 2rem;
}
.skill-type {
  margin: 0 0 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.skill-group h3 { margin-bottom: 1rem; }
.skill-evidence { margin: 1.1rem 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.skill-evidence strong { color: var(--text); }

/* Experience */
.timeline { display: grid; gap: 1.2rem; margin: 2rem 0 0; padding: 0; list-style: none; }
/* Episode-list look: a large outlined number beside each role */
.timeline { counter-reset: episode; }
.role {
  counter-increment: episode;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: clamp(0.9rem, 3vw, 1.8rem);
}
.role::before {
  content: counter(episode);
  grid-row: 1 / span 3;
  min-width: 1.1ch;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 5rem);
  font-weight: 800;
  line-height: 0.9;
  text-align: center;
  color: transparent;
  -webkit-text-stroke: 2px var(--accent);
}
.role > * { grid-column: 2; }

.role-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem 1.5rem;
  margin-bottom: 1.1rem;
}
.role-head h3 { font-size: 1.35rem; }
.role-org { margin: 0.3rem 0 0; font-weight: 650; color: var(--accent-2); }
.role-about { color: var(--muted); font-weight: 500; }
.role-meta {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.bullets {
  display: grid;
  gap: 0.5rem;
  padding-left: 1.2rem;
  list-style: disc;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}
.bullets li::marker { color: var(--accent); }
.achievement {
  margin: 1.2rem 0 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--magenta);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface);
  font-size: 0.98rem;
}
.subhead { margin: 2.6rem 0 1.2rem; }
.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.2rem;
}
.activity h4 { margin: 0; font-family: var(--font-display); font-size: 1.1rem; line-height: 1.2; }
.activity .role-meta { margin-top: 0.35rem; }
.activity-text { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.95rem; line-height: 1.55; }

/* Education and certifications */
.education-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 1.2rem;
  margin-top: 2rem;
  align-items: start;
}
.mini-head {
  margin: 1.3rem 0 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.course-list { display: grid; gap: 0.35rem; font-size: 0.98rem; }
.course-code { display: inline-block; min-width: 5.2em; font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); }
.course-focus { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.55; }
.cert-list { display: grid; gap: 0.9rem; margin-top: 1rem; }
.cert-name { display: block; font-weight: 650; line-height: 1.35; }
.cert-meta { display: block; color: var(--muted); font-size: 0.9rem; }
.cert-subhead { margin-top: 1.8rem; }

/* Contact */
.contact-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: start;
}
.contact-intro p { max-width: 30em; }
.contact-details { display: grid; gap: 1.2rem; }
.contact-row + .contact-row { padding-top: 1.2rem; border-top: 1px solid var(--border); }
.contact-row dt {
  margin-bottom: 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.contact-row dd { font-weight: 600; }
.contact-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 1.1rem; }
.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.2rem; }
.email-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 1.1rem; overflow-wrap: anywhere; }
.copy-status { margin: 0.2rem 0 0; color: var(--success); font-size: 0.95rem; }
.social { display: flex; flex-wrap: wrap; gap: 0 1.6rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 2rem 0; color: var(--muted); font-size: 0.95rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.6rem 2rem; }
.footer-inner p { margin: 0; }
.footer-inner ul { display: flex; flex-wrap: wrap; gap: 0.2rem 1.4rem; }
.footer-inner a { display: inline-flex; align-items: center; min-height: 44px; }

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

  .hero-floor span { animation: floor-drift 9s linear infinite; }
  .hero-card { animation: card-float 8s ease-in-out infinite; }
  .orbit i:nth-child(1) { animation: orbit-a 20s linear infinite; }
  .orbit i:nth-child(2) { animation: orbit-b 26s linear infinite; }
  .orbit i:nth-child(3) { animation: orbit-c 32s linear infinite; }

  /* Scroll parallax: --sy is the scroll distance, set by main.js */
  .hero-visual { translate: 0 calc(var(--sy, 0) * 0.05px); transition: transform 0.5s ease; }
  .orbit { translate: 0 calc(var(--sy, 0) * -0.12px); }
  .hero-visual.is-tilting { transition-duration: 0.12s; }

  .btn,
  .filter-btn,
  .site-nav a,
  .tags li { transition: background-color 0.2s, border-color 0.2s, color 0.2s, filter 0.2s, transform 0.2s; }
  .btn:hover { transform: translateY(-2px); }
  .theme-toggle-thumb { transition: transform 0.25s ease; }

  .site-header { transition: background-color 0.3s ease, border-color 0.3s ease; }

  /* Title cards zoom a little on hover or keyboard focus */
  .poster-art { transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease; }
  .poster:hover .poster-art,
  .poster:focus-visible .poster-art { transform: scale(1.05); box-shadow: var(--shadow), 0 0 30px var(--glow-1); }
  .row-arrow { transition: border-color 0.2s, opacity 0.2s; }
  .project-dialog[open] { animation: dialog-in 0.28s cubic-bezier(0.2, 0.7, 0.2, 1); }

  /* Opening screen motion */
  .profile-avatar { transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease; }
  .profile-tile { transition: color 0.2s ease; }
  .profile-tile:hover .profile-avatar,
  .profile-tile:focus-visible .profile-avatar { transform: scale(1.05); box-shadow: 0 0 40px rgba(124, 58, 237, 0.35); }
  .profile-tile:active .profile-avatar { transform: scale(0.98); }
  /* Runs when the opening loader hands over to the profile screen */
  .gate:not(.is-booting):not(.is-loading) .gate-pick { animation: gate-in 0.45s ease 0.2s both; }
  .gate-loading { transition: opacity 0.25s ease; }
  .loader::after { animation: loader-spin 0.85s linear infinite; }
  .loader svg { animation: loader-pulse 1.1s ease-in-out infinite; }
  .gate.is-leaving { opacity: 0; transition: opacity 0.35s ease; }

  /* Scroll reveal only applies when JavaScript is running */
  /* Elements tip up into place, like a card being stood upright */
  .js .reveal {
    opacity: 0;
    /* Negative angle tips the element away from the viewer, so it is never
       drawn wider than its box and cannot cause sideways overflow */
    transform: perspective(1000px) translateY(26px) rotateX(-9deg);
    transform-origin: 50% 0;
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .js .reveal.is-visible { opacity: 1; transform: none; }
}

@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes gate-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes loader-spin {
  to { transform: rotate(360deg); }
}
@keyframes loader-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.94); opacity: 0.8; }
}
@keyframes floor-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 56px, 0 56px; }
}
@keyframes card-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes orbit-a {
  from { transform: rotateX(72deg) rotateZ(0deg); }
  to { transform: rotateX(72deg) rotateZ(360deg); }
}
@keyframes orbit-b {
  from { transform: rotateY(70deg) rotateZ(360deg); }
  to { transform: rotateY(70deg) rotateZ(0deg); }
}
@keyframes orbit-c {
  from { transform: rotateX(48deg) rotateY(42deg) rotateZ(0deg); }
  to { transform: rotateX(48deg) rotateY(42deg) rotateZ(360deg); }
}

/* -------------------------------------------------------------- Responsive */
@media (max-width: 900px) {
  .hero-inner,
  .about-layout,
  .contact-layout,
  .education-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Header: brand and theme switch on one row, nav on its own row. 800px leaves
   a safe margin above the width where a single-row header stops fitting. */
@media (max-width: 800px) {
  :root { --header-h: 112px; }
  .header-inner { flex-wrap: wrap; gap: 0 0.5rem; padding-top: 0.5rem; }
  .site-nav { order: 3; width: 100%; }
  .site-nav ul { justify-content: space-between; max-width: 28rem; }
  .site-nav a { padding: 0.7rem 0.3rem; font-size: 0.92rem; }
  .site-nav a[aria-current]::after { left: 0.3rem; right: 0.3rem; bottom: 0.35rem; }
  .row-prev { left: -0.4rem; }
  .row-next { right: -0.4rem; }
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .card { padding: 1.25rem; }
  .actions .btn { flex: 1 1 auto; }
  .hero-card { font-size: 0.78rem; }
  /* Smaller rings on phones so they stay clear of the text beside them */
  .orbit { top: -4.25rem; right: -3.5rem; width: 8.5rem; }
  .title-row .project { flex-basis: 72vw; }
  .row-arrow { top: calc(0.9rem + (72vw * 9 / 32) - 22px); }
  .dialog-art { aspect-ratio: 16 / 7; padding: 1.1rem 1.25rem; }
  .dialog-body { padding: 1.25rem 1.25rem 1.5rem; }
}

/* Very narrow phones: drop the switch's text so the header stays two rows */
@media (max-width: 360px) {
  .theme-toggle-text { display: none; }
}

/* ------------------------------------------------------------------- Print */
@media print {
  :root,
  :root[data-theme="light"],
  :root[data-theme="dark"] {
    --bg: #fff; --bg-alt: #fff; --surface: #fff; --surface-solid: #fff;
    --text: #000; --muted: #333; --accent: #3b1a8a; --accent-2: #0a3f70; --magenta: #7a0e49;
    --border: #bbb; --control-border: #888; --shadow: none;
    color-scheme: light;
  }
  body { font-size: 11pt; line-height: 1.45; }
  .site-header, .skip-link, .hero-grid, .hero-floor, .hero-visual, .actions, .filters, .filter-status,
  #copy-email, .copy-status, .site-footer ul, .sprite, .gate, .scroll-progress,
  .row-wrap, .dialog-close-form, .dialog-art { display: none !important; }
  /* Print every project's details as a plain list */
  .project-dialog { position: static; display: block !important; width: auto; max-height: none; margin: 0 0 0.4cm; border: 1px solid #bbb; }
  html.gate-open { overflow: visible; }
  .hero { min-height: 0; margin-top: 0; display: block; }
  .js .dialog-title { position: static; width: auto; height: auto; clip-path: none; white-space: normal; }
  .role::before { -webkit-text-stroke: 1px #3b1a8a; }
  .glass { -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .section, .hero { padding: 0.6cm 0; background: none !important; }
  .container { width: 100%; }
  .hero-inner, .about-layout, .contact-layout, .education-layout { grid-template-columns: 1fr; }
  h1 { font-size: 26pt; }
  h2 { font-size: 17pt; }
  .card { padding: 0.4cm; break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  a { color: #000; }
  a[href^="http"]::after,
  a[href^="mailto:"]::after { content: " (" attr(href) ")"; font-weight: 400; font-size: 9pt; word-break: break-all; }
  .link-arrow::after { margin-left: 0; }
}
