/* ============================
   SIGNAL — design system
   Warm dark monograph · Syne / DM Sans / Fraunces / Space Mono · one amber accent
   ============================ */

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

/* ============================
   TOKENS
   ============================ */
:root {
  /* Light — aged paper */
  --bg:         #F5F0E8;
  --bg-2:       #EDE8DE;
  --surface:    #EDE8DE;
  --text:       #0D0B08;
  --text-2:     #5E5244;
  --faint:      #D9D0C1;
  --line:       #D4CBBC;
  --line-2:     #B9AE9C;
  --accent:     #85590F;
  --accent-2:   #A06C14;
  --accent-rgb: 133, 89, 15;
  --plate:      #E6DFD2;
  --grain-op:   0.07;

  --font-display: 'Syne', 'Arial Black', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-serif:   'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono:    'Space Mono', ui-monospace, 'Courier New', monospace;
  --font-retro:   'VT323', 'Space Mono', ui-monospace, monospace;

  --nav-h:  64px;
  --max-w:  1440px;
  --px:     clamp(20px, 4.5vw, 72px);
  --col-gap: clamp(16px, 2.4vw, 40px);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io:  cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 0.3s;
  --t-med:  0.6s;
}

[data-theme="dark"] {
  --bg:         #0D0B08;
  --bg-2:       #141210;
  --surface:    #141210;
  --text:       #EAE5DC;
  --text-2:     #8F8576;
  --faint:      #1D1A15;
  --line:       #2A2520;
  --line-2:     #3D362D;
  --accent:     #C9943A;
  --accent-2:   #E3B965;
  --accent-rgb: 201, 148, 58;
  --plate:      #D9CFBE;
  --grain-op:   0.05;
}

/* ============================
   BASE
   ============================ */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: var(--nav-h);
}

html:not(.lenis) { scroll-behavior: smooth; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.5s var(--ease-out), color 0.5s var(--ease-out);
}

/* Film grain — fixed, never scrolls, never intercepts input */
body::after {
  content: '';
  position: fixed;
  inset: -50%;
  z-index: 3000;
  pointer-events: none;
  opacity: var(--grain-op);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
ul, ol { list-style: none; }

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

:focus { outline: none; }
:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 4px;
  border-radius: 1px;
}

/* Scrollbar */
html { scrollbar-color: var(--line-2) var(--bg); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 3px solid var(--bg); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 4000;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--t-fast) var(--ease-out);
}
.skip-link:focus-visible { transform: none; }

/* Mono micro-label, used everywhere for metadata */
.mono {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* Arrow link — underline draws in, arrow nudges */
.link-arrow {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  text-decoration: none;
  color: var(--text);
  padding-bottom: 2px;
  background: linear-gradient(currentColor, currentColor) no-repeat 100% 100% / 0% 1px;
  transition: background-size var(--t-med) var(--ease-out), color var(--t-fast) ease;
}
.link-arrow::after {
  content: '↗';
  font-family: var(--font-body);
  font-size: 0.85em;
  color: var(--accent);
  transition: transform var(--t-fast) var(--ease-out);
}
.link-arrow[href^="mailto"]::after { content: '→'; }
.link-arrow[href$=".pdf"]::after   { content: '↓'; }

@media (hover: hover) {
  .link-arrow:hover {
    color: var(--accent);
    background-position: 0 100%;
    background-size: 100% 1px;
  }
  .link-arrow:hover::after { transform: translate(2px, -2px); }
  .link-arrow[href^="mailto"]:hover::after { transform: translateX(4px); }
  .link-arrow[href$=".pdf"]:hover::after   { transform: translateY(3px); }
}

/* ============================
   LOADER — fast intro (≈1.1s, JS-driven)
   ============================ */
.loader { display: none; }

.motion .loader {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: var(--px);
  background: var(--bg);
  color: var(--text);
  pointer-events: none;
}

.loader-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1rem, 2vw, 1.25rem);
}
.loader-mark::after { content: '.'; color: var(--accent); }

.loader-count {
  font-family: var(--font-mono);
  font-size: clamp(3rem, 12vw, 9rem);
  line-height: 0.8;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ============================
   PROGRESS
   ============================ */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 1100;
}

/* ============================
   NAV
   ============================ */
nav#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: var(--nav-h);
  padding: 0 var(--px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid transparent;
  transition: transform 0.5s var(--ease-out), background-color 0.4s ease, border-color 0.4s ease;
}

nav#navbar.scrolled {
  background: var(--bg);
  border-bottom-color: var(--line);
}

nav#navbar.hidden { transform: translateY(-100%); }

.logo {
  justify-self: start;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
}
.logo-dot { color: var(--accent); }

.nav-links {
  display: flex;
  gap: clamp(16px, 2.4vw, 40px);
}

.nav-links a {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  transition: color var(--t-fast) ease;
}

.nav-idx {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-2);
  transition: color var(--t-fast) ease;
}

.nav-links a:hover,
.nav-links a.active { color: var(--text); }
.nav-links a.active .nav-idx { color: var(--accent); }

.nav-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 18px;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.lang-btn {
  background: none;
  border: none;
  padding: 6px 2px;
  min-height: 32px;
  cursor: pointer;
  color: var(--text-2);
  letter-spacing: 0.04em;
  transition: color var(--t-fast) ease;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 5px;
  text-decoration-thickness: 1.5px;
}
.lang-sep { color: var(--line-2); }

.theme-toggle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  cursor: pointer;
}

.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text);
  background: linear-gradient(90deg, var(--text) 50%, transparent 50%);
  transition: transform 0.6s var(--ease-out);
}
[data-theme="light"] .theme-dot { transform: rotate(180deg); }
.theme-toggle:hover .theme-dot { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }

.menu-btn {
  display: none;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  min-height: 44px;
  padding: 0 0 0 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
}

.menu-lines {
  position: relative;
  width: 22px;
  height: 8px;
}
.menu-lines span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  transition: transform 0.45s var(--ease-out), top 0.45s var(--ease-out);
}
.menu-lines span:first-child { top: 0; }
.menu-lines span:last-child  { top: 6.5px; }
.menu-btn[aria-expanded="true"] .menu-lines span:first-child { top: 3.25px; transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-lines span:last-child  { top: 3.25px; transform: rotate(-45deg); }

/* ============================
   HERO
   ============================ */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + clamp(24px, 4vh, 48px)) var(--px) clamp(24px, 4vh, 40px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(28px, 4vh, 48px);
}

.hero-index {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: 8px clamp(24px, 5vw, 80px);
  font-size: 0.875rem;
  color: var(--text);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.hero-index li { display: flex; gap: 10px; align-items: baseline; }
.hero-index-n {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
}

.hero-stage {
  position: relative;
  --name-size: calc((min(100vw, var(--max-w)) - 2 * var(--px)) * 0.1344);
  --portrait-w: 22%;
  /* Reserve room for the portrait, which sits beside RAMI and above YOUNES */
  padding-top: max(0px, calc(var(--portrait-w) * 1.25 + 34px - var(--name-size) * 0.84));
}

.hero-name {
  position: relative;
  z-index: 2;
  font-family: var(--font-display);
  font-weight: 800;
  /* Pre-computed for Syne so the JS fit (after fonts load) barely moves anything */
  font-size: var(--name-size);
  line-height: 0.84;
  letter-spacing: -0.045em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
}

.hero-line { display: block; width: max-content; }


/* Split characters (built by JS) */
.ch { display: inline-block; }
.ch-i { display: inline-block; will-change: transform, clip-path; }

.motion .hero-name .ch-i,
.motion .footer-headline .ch-i { clip-path: inset(100% 0 0 0); transform: translateY(35%); }

/* Portrait — printed duotone plate. The white photo backdrop melts into the paper tone */
.hero-portrait {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: calc(var(--name-size) * 0.84 + 14px);
  width: var(--portrait-w);
  display: flex;
  flex-direction: column-reverse;
}

.plate {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--plate);
}

.plate img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
  filter: grayscale(1) contrast(1.12) brightness(1.02);
  mix-blend-mode: multiply;
}

/* Amber tone layer: multiplies warmth into the mid-tones */
.plate::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(var(--accent-rgb), 0.28);
  mix-blend-mode: multiply;
  pointer-events: none;
  transition: opacity 0.8s var(--ease-out);
}
@media (hover: hover) {
  .hero-portrait:hover .plate::after { opacity: 0; }
}

.hero-portrait figcaption {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-2);
}

.hero-foot {
  display: grid;
  /* The typed line takes every pixel the social links don't need */
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: var(--col-gap);
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.hero-statement {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.35rem, 2.5vw, 2.1rem);
  line-height: 1.15;
  color: var(--text-2);
  min-width: 0;
}

.hero-greeting { display: block; color: var(--text); }

/* Typewriter — CRT terminal type. JS sizes it so the longest sentence fits one line */
.typer {
  display: block;
  max-width: 100%;
  margin-top: 0.2em;
  font-family: var(--font-retro);
  font-style: normal;
  font-weight: 400;
  font-size: clamp(1.5rem, 3.4vw, 3rem);
  line-height: 1;
  white-space: nowrap;
  text-align: left;
  color: var(--accent);
  text-shadow: 0 0 0.3em rgba(var(--accent-rgb), 0.45);
}

.typer-cursor {
  display: inline-block;
  width: 0.55em;
  height: 0.95em;
  margin-left: 0.06em;
  vertical-align: -0.1em;
  background: var(--accent);
  box-shadow: 0 0 0.35em rgba(var(--accent-rgb), 0.6);
  animation: cursorBlink 1s steps(1) infinite;
}
/* Solid while characters are landing, blinking while idle — like a real terminal */
.typer.is-typing .typer-cursor { animation: none; }

@keyframes cursorBlink { 50% { opacity: 0; } }

.hero-social {
  grid-column: 3;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-size: 0.9375rem;
}

.hero-scroll {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-2);
}

.hero-scroll-line {
  width: 1px;
  height: 40px;
  background: var(--line-2);
  position: relative;
  overflow: hidden;
}
.hero-scroll-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateY(-100%);
  animation: scrollDrop 2.2s var(--ease-io) infinite;
}

@keyframes scrollDrop {
  0%   { transform: translateY(-100%); }
  55%  { transform: translateY(0); }
  100% { transform: translateY(100%); }
}

/* ============================
   SECTIONS — shared
   ============================ */
main { overflow-x: clip; }

.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(96px, 16vh, 200px) var(--px) 0;
}

.section-head {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  align-items: end;
  margin-bottom: clamp(48px, 9vh, 112px);
  border-bottom: 1px solid var(--line);
  padding-bottom: clamp(16px, 2vh, 24px);
}

.section-num {
  grid-column: 1 / span 4;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: clamp(0.75rem, 1vw, 0.875rem);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  align-self: start;
  padding-top: 0.5em;
}

.section-title {
  grid-column: 5 / -1;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 6.6vw, 6.6rem);
  line-height: 0.88;
  letter-spacing: -0.045em;
  color: var(--text);
}

/* Huge ghost numeral behind each heading */
.section-head::before {
  content: attr(data-ghost);
  position: absolute;
  left: -0.04em;
  bottom: -0.16em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(8rem, 19vw, 17rem);
  line-height: 0.75;
  letter-spacing: -0.06em;
  color: var(--faint);
  z-index: -1;
  pointer-events: none;
  user-select: none;
}

.sub-head {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  align-items: baseline;
  margin: clamp(80px, 12vh, 144px) 0 clamp(24px, 4vh, 40px);
}

.sub-head h3 {
  grid-column: 5 / -1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.sub-head .mono {
  grid-column: 1 / span 4;
  color: var(--text-2);
}

/* ============================
   ABOUT
   ============================ */
.about-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  row-gap: 48px;
}

.about-intro {
  grid-column: 5 / span 8;
  font-size: clamp(1.3rem, 2.15vw, 1.95rem);
  line-height: 1.38;
  letter-spacing: -0.012em;
  color: var(--text);
  max-width: 38ch;
  text-indent: 3.5em;
  hanging-punctuation: first;
}

.about-aside {
  grid-column: 1 / span 4;
  grid-row: 1;
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cv-link {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  letter-spacing: -0.02em;
  width: fit-content;
}

/* Education index — a typeset table, not cards */
.edu-list { border-top: 1px solid var(--line); }

.edu-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  padding: clamp(20px, 3vh, 32px) 0;
  border-bottom: 1px solid var(--line);
}

.edu-row::before {
  content: '';
  position: absolute;
  left: 0; top: -1px;
  height: 1px;
  width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.7s var(--ease-out);
}
@media (hover: hover) {
  .edu-row:hover::before { transform: scaleX(1); }
  .edu-row:hover .edu-idx { color: var(--accent); }
}

.edu-idx {
  grid-column: 1 / span 1;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-2);
  padding-top: 0.45em;
  transition: color var(--t-fast) ease;
}

.edu-org {
  grid-column: 2 / span 3;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--text-2);
  padding-top: 0.15em;
}

.edu-main { grid-column: 5 / -1; }

.edu-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.15rem, 1.7vw, 1.5rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.edu-desc {
  color: var(--text-2);
  font-size: 1rem;
  max-width: 62ch;
}

.edu-cert { margin-top: 10px; font-size: 0.9375rem; }

/* Skills — two typographic columns */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  row-gap: clamp(40px, 6vh, 64px);
}

.skill-cat:nth-child(odd)  { grid-column: 5 / span 4; }
.skill-cat:nth-child(even) { grid-column: 9 / span 4; }

.skill-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--accent);
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.skill-label span:last-child { color: var(--text-2); }

.skill-items {
  font-size: clamp(1.05rem, 1.35vw, 1.25rem);
  line-height: 1.55;
  color: var(--text);
}

.skill-items li { display: inline; }
.skill-items li:not(:last-child)::after { content: ', '; color: var(--text-2); }

/* ============================
   EXPERIENCE — editorial timeline
   ============================ */
.timeline { border-top: 1px solid var(--line); }

.job {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  padding: clamp(40px, 7vh, 80px) 0;
  border-bottom: 1px solid var(--line);
}

.job-meta {
  grid-column: 1 / span 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: start;
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}

.job-n {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 4.5vw, 4rem);
  line-height: 0.9;
  letter-spacing: -0.05em;
  color: var(--faint);
  /* Fill painted over the stroke hides the seams where the glyph's contours overlap (Syne's 4).
     The fill covers the stroke's inner half, so it's drawn at twice the visible width */
  -webkit-text-stroke: 2px var(--line-2);
  paint-order: stroke fill;
  margin-bottom: 10px;
  transition: color 0.6s var(--ease-out), -webkit-text-stroke-color 0.6s var(--ease-out);
}
.job.is-active .job-n { color: var(--accent); -webkit-text-stroke-color: var(--accent); }

.job-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
}

.job-loc {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-2);
}

.job-body { grid-column: 5 / -1; }

.job-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 3.4vw, 3.1rem);
  line-height: 1;
  letter-spacing: -0.035em;
  max-width: 18ch;
}

.job-company {
  margin-top: 12px;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.15rem, 1.6vw, 1.45rem);
  color: var(--accent);
}

.job-role {
  margin-top: clamp(24px, 4vh, 36px);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-2);
}

.job-desc {
  margin-top: 8px;
  max-width: 64ch;
  font-size: clamp(1rem, 1.15vw, 1.1rem);
}

.job-specs {
  margin-top: clamp(28px, 4vh, 40px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px var(--col-gap);
}

.job-specs > div { border-top: 1px solid var(--line); padding-top: 12px; }
.job-specs > .spec-wide { grid-column: 1 / -1; }

.job-specs dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-2);
  margin-bottom: 8px;
}

.job-specs dd { font-size: 0.9375rem; line-height: 1.65; }

.inline-list li { display: inline; }
.inline-list li:not(:last-child)::after { content: ' / '; color: var(--accent); opacity: 0.7; }

.dot-list li { display: inline; color: var(--text-2); }
.dot-list li:not(:last-child)::after { content: ' · '; }

.course-list { columns: 2; column-gap: var(--col-gap); }
.course-list li { break-inside: avoid; padding: 2px 0; }
.course-list li::before {
  content: counter(list-item, decimal-leading-zero) '  ';
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
  white-space: pre;
}

.pub-list li + li { margin-top: 10px; }
.pub-list a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  text-decoration: none;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  transition: border-color var(--t-fast) ease;
}
.pub-source {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-2);
}
.pub-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.35;
}
.pub-arrow { color: var(--accent); transition: transform var(--t-fast) var(--ease-out); }
@media (hover: hover) {
  .pub-list a:hover { border-bottom-color: var(--accent); }
  .pub-list a:hover .pub-arrow { transform: translate(3px, -3px); }
}

/* ============================
   PROJECTS — staggered case files
   ============================ */
.projects {
  display: flex;
  flex-direction: column;
  gap: clamp(72px, 14vh, 168px);
}

.project {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  align-items: start;
}

.project-num {
  grid-column: 1 / span 4;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(5rem, 14vw, 13rem);
  line-height: 0.78;
  letter-spacing: -0.06em;
  /* Outline-only look without the overlap seams: an opaque page-coloured fill painted over a doubled stroke */
  color: var(--bg);
  -webkit-text-stroke: 3px var(--line-2);
  paint-order: stroke fill;
  transition: color 0.7s var(--ease-out), -webkit-text-stroke-color 0.7s var(--ease-out);
  user-select: none;
}

.project-body {
  grid-column: 5 / span 8;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

/* Alternate: number moves to the right edge, body to the left */
.project:nth-child(even) .project-num  { grid-column: 9 / span 4; grid-row: 1; text-align: right; }
.project:nth-child(even) .project-body { grid-column: 1 / span 8; grid-row: 1; }

.project-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-2);
  margin-bottom: clamp(20px, 3vh, 32px);
}

.project-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 4.6vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  max-width: 16ch;
}

.project-title a {
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 92% / 0% 0.07em;
  transition: background-size 0.7s var(--ease-out), color 0.4s ease;
}

.project-desc {
  margin-top: clamp(20px, 3vh, 32px);
  max-width: 62ch;
  color: var(--text-2);
  font-size: clamp(1rem, 1.1vw, 1.0625rem);
}

.project-stack {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.9;
  color: var(--text);
}
.project-stack span { white-space: nowrap; }
.project-stack .sep { color: var(--accent); }

.project-links {
  margin-top: clamp(24px, 4vh, 36px);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  font-size: 1rem;
  font-weight: 500;
}

@media (hover: hover) {
  .project:hover .project-num { color: var(--accent); -webkit-text-stroke-color: var(--accent); }
  .project-title a:hover { background-size: 100% 0.07em; }
}

/* ============================
   FOOTER — the closing statement
   ============================ */
.site-footer {
  position: relative;
  max-width: var(--max-w);
  margin: clamp(120px, 22vh, 260px) auto 0;
  padding: 0 var(--px) clamp(24px, 4vh, 40px);
  overflow: hidden;
}

.footer-num {
  display: block;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-bottom: clamp(32px, 6vh, 64px);
}

.footer-headline {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.4rem, 13.5vw, 13rem);
  line-height: 0.86;
  letter-spacing: -0.05em;
  color: var(--text);
}
.footer-headline .ch.is-last .ch-i { color: var(--accent); }

.footer-email {
  display: inline-block;
  margin-top: clamp(28px, 5vh, 56px);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.4rem, 3.6vw, 3.25rem);
  line-height: 1.1;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / 100% 1px;
  padding-bottom: 6px;
  transition: color var(--t-fast) ease, background-size 0.7s var(--ease-out);
}
@media (hover: hover) {
  .footer-email:hover { color: var(--accent); background-size: 100% 3px; }
}

.footer-bottom {
  margin-top: clamp(80px, 14vh, 160px);
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 20px;
  font-size: 0.9375rem;
}

.footer-links { display: flex; flex-wrap: wrap; gap: 6px 22px; }

.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-2);
}

.footer-top {
  justify-self: end;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text);
  text-decoration: none;
}
.footer-top:hover { color: var(--accent); }

/* ============================
   TABLET
   ============================ */
@media (max-width: 1024px) {
  .section-num { grid-column: 1 / span 3; }
  .section-title { grid-column: 4 / -1; }
  .about-intro, .edu-main, .job-body { grid-column: 4 / -1; }
  .about-aside, .job-meta { grid-column: 1 / span 3; }
  .edu-org { grid-column: 2 / span 2; }
  .sub-head h3 { grid-column: 4 / -1; }
  .sub-head .mono { grid-column: 1 / span 3; }
  .skill-cat:nth-child(odd)  { grid-column: 1 / span 6; }
  .skill-cat:nth-child(even) { grid-column: 7 / span 6; }
  .project-num { grid-column: 1 / span 3; font-size: 9vw; }
  .project-body { grid-column: 4 / -1; }
  .project:nth-child(even) .project-num  { grid-column: 10 / span 3; }
  .project:nth-child(even) .project-body { grid-column: 1 / span 9; }
}

/* ============================
   PHONE — its own layout, not a shrunk desktop
   ============================ */
@media (max-width: 768px) {
  :root { --nav-h: 56px; }
  body { font-size: 1rem; }

  nav#navbar { grid-template-columns: auto 1fr; }
  .nav-right { gap: 12px; }
  .menu-btn { display: inline-flex; }

  /* Full-screen menu */
  .nav-links {
    position: fixed;
    inset: 0;
    z-index: -1;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0;
    padding: calc(var(--nav-h) + 24px) var(--px) 48px;
    background: var(--bg);
    clip-path: inset(0 0 100% 0);
    visibility: hidden;
    transition: clip-path 0.7s var(--ease-io), visibility 0s linear 0.7s;
  }
  .nav-links.open {
    clip-path: inset(0 0 0 0);
    visibility: visible;
    transition: clip-path 0.7s var(--ease-io), visibility 0s;
  }
  .nav-links li { border-top: 1px solid var(--line); overflow: hidden; }
  .nav-links li:last-child { border-bottom: 1px solid var(--line); }
  .nav-links a {
    width: 100%;
    justify-content: space-between;
    flex-direction: row-reverse;
    padding: 14px 0;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: min(9vw, 3.25rem);
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--text);
    transform: translateY(100%);
    transition: transform 0.6s var(--ease-out);
  }
  .nav-links a .nav-idx { font-size: 0.75rem; letter-spacing: 0; }
  .nav-links.open a { transform: none; }
  .nav-links.open li:nth-child(1) a { transition-delay: 0.18s; }
  .nav-links.open li:nth-child(2) a { transition-delay: 0.24s; }
  .nav-links.open li:nth-child(3) a { transition-delay: 0.30s; }
  .nav-links.open li:nth-child(4) a { transition-delay: 0.36s; }

  /* Hero — composed on the centre axis */
  .hero {
    padding-top: calc(var(--nav-h) + 20px);
    gap: 28px;
    text-align: center;
  }
  .hero-index {
    grid-template-columns: auto;
    justify-content: center;
    justify-items: start;
    gap: 4px;
    font-size: 0.8125rem;
  }
  .hero-stage {
    margin-top: auto;
    padding-top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .hero-portrait {
    position: relative;
    order: -1;
    bottom: auto;
    width: min(62%, 300px);
    margin: 0 auto 20px;
  }
  .hero-line { margin-inline: auto; }
  .hero-foot {
    grid-template-columns: 1fr;
    justify-items: center;
    row-gap: 24px;
  }
  .hero-statement { grid-column: 1; width: 100%; font-size: clamp(1.5rem, 7vw, 2rem); }
  .typer { margin-inline: auto; }
  .hero-social { grid-column: 1; grid-row: 2; justify-self: center; justify-content: center; gap: 0 22px; }
  .hero-scroll { grid-column: 1; grid-row: 3; }
  .hero-scroll-line { height: 28px; }

  /* Sections: centred heads, readable left-aligned body copy */
  .section { padding-top: 112px; }
  .section-head { grid-template-columns: 1fr; justify-items: center; row-gap: 16px; text-align: center; }
  .section-num, .section-title { grid-column: 1; }
  .section-num { align-self: center; padding-top: 0; }
  .section-title { font-size: clamp(2.2rem, 10.4vw, 4rem); min-width: 0; max-width: 100%; }
  .section-head::before { font-size: 44vw; left: 50%; right: auto; bottom: -0.08em; transform: translateX(-50%); }

  .about-grid { grid-template-columns: 1fr; row-gap: 36px; }
  .about-intro { grid-column: 1; margin-inline: auto; text-indent: 2em; font-size: clamp(1.2rem, 5.4vw, 1.45rem); }
  .about-aside { grid-column: 1; grid-row: 2; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 12px 28px; }

  .sub-head { grid-template-columns: 1fr; justify-items: center; text-align: center; row-gap: 8px; margin-top: 88px; }
  .sub-head h3, .sub-head .mono { grid-column: 1; }

  .edu-row { grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem; row-gap: 4px; }
  .edu-idx { grid-column: 1; grid-row: 1 / span 2; }
  .edu-main { grid-column: 2; grid-row: 1; text-align: center; }
  .edu-org { grid-column: 2; grid-row: 2; padding-top: 4px; text-align: center; }
  .edu-org:empty { display: none; }
  .edu-desc { margin-inline: auto; }

  .skills-grid { grid-template-columns: 1fr; row-gap: 40px; }
  .skill-cat:nth-child(odd), .skill-cat:nth-child(even) { grid-column: 1; }
  .skill-items { text-align: center; }

  .job { grid-template-columns: 1fr; row-gap: 24px; padding: 48px 0; }
  .job-meta {
    grid-column: 1;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 4px 14px;
  }
  .job-n { flex-basis: 100%; text-align: center; font-size: 3rem; margin: 0 0 6px; }
  .job-body { grid-column: 1; }
  .job-title, .job-company, .job-role { text-align: center; margin-inline: auto; }
  .job-specs { grid-template-columns: 1fr; }
  .course-list { columns: 1; }

  .projects { gap: 88px; }
  .project, .project:nth-child(even) { grid-template-columns: 1fr; }
  .project-num,
  .project:nth-child(even) .project-num {
    grid-column: 1;
    grid-row: 1;
    font-size: 34vw;
    text-align: center;
    margin-bottom: 0.08em;
  }
  .project-body,
  .project:nth-child(even) .project-body { grid-column: 1; grid-row: 2; }
  .project-title { text-align: center; margin-inline: auto; }
  .project-stack, .project-links { justify-content: center; }
  .project-links a { min-height: 44px; align-items: center; }

  .footer-num, .footer-headline, .site-footer { text-align: center; }
  .footer-headline { font-size: clamp(3rem, 17vw, 6rem); }
  .footer-bottom { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 24px; }
  .footer-links { justify-content: center; gap: 0 22px; }
  .footer-links a, .hero-social a { min-height: 44px; display: inline-flex; align-items: center; }
  .footer-top { justify-self: center; }
}

/* ============================
   TOUCH — what hover does on desktop, scrolling into the centre (or a tap) does here
   ============================ */
@media (hover: none) {
  .edu-row.is-active::before { transform: scaleX(1); }
  .edu-row.is-active .edu-idx { color: var(--accent); }
  .job.is-active .job-n,
  .project.is-active .project-num { color: var(--accent); -webkit-text-stroke-color: var(--accent); }
  .project.is-active .project-title a { background-size: 100% 0.07em; }
  .hero-portrait.is-revealed .plate::after { opacity: 0; }
  .hero-portrait { cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .link-arrow:active {
    color: var(--accent);
    background-position: 0 100%;
    background-size: 100% 1px;
  }
  .footer-email:active { color: var(--accent); background-size: 100% 3px; }
}

@media (max-width: 380px) {
  .lang-toggle { font-size: 0.7rem; }
  .menu-label { display: none; }
}

/* Short landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { min-height: auto; }
  .hero-portrait { display: none; }
}

/* ============================
   REDUCED MOTION — everything resolves instantly
   ============================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
