/* =========================================================
   Design tokens
   ========================================================= */
:root {
  /* Brand Guide Colors */
  --red-deep: #8B1A1A;
  --red-mid: #C0392B;
  --red-vivid: #E84040;
  --red-soft: #F5B7B1;
  --red-blush: #FDF0EF;
  --ink: #111111;
  --ink-muted: #444444;
  --ink-ghost: #888888;
  --paper: #FAFAFA;
  --paper-warm: #F7F3F0;
  --white: #FFFFFF;
  --rule: rgba(139, 26, 26, 0.15);

  /* Metaphor palette */
  --mf-bone: #F4F0E8;
  --mf-ink: #0E0D0F;
  --mf-ink-soft: #2E2A2C;
  --mf-panel: #141215;
  --mf-hairline: rgba(244, 240, 232, 0.5);
  --mf-rule-ink: rgba(14, 13, 15, 0.22);

  /* Section colors, in the order of the game's main menu (-ink = readable as text on paper) */
  --c-about: #E0338F;
  --c-about-ink: #A3175F;
  --c-skills: #E23B3B;
  --c-skills-ink: #A81B1B;
  --c-career: #F07A1F;
  --c-career-ink: #A94F08;
  --c-projects: #E8C21A;
  --c-projects-ink: #7F6500;
  --c-research: #3DBE5A;
  --c-research-ink: #1C7032;
  --c-articles: #1FAFB5;
  --c-articles-ink: #0C6A6F;

  /* Theme Mappings */
  --bg-color: var(--paper);
  --text-color: var(--mf-ink);
  --sidebar-width: 45%;
  --accent-color: var(--red-mid);
  --accent-hover: var(--red-vivid);
  --text-muted: var(--mf-ink-soft);
  --border-color: var(--rule);
  --font-main: 'Inter', sans-serif;
  --font-display: 'DM Serif Display', serif;
  --ease-snap: cubic-bezier(0.2, 0.9, 0.25, 1.1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --hepta: polygon(50% 0%, 89.1% 18.8%, 98.7% 61.1%, 71.7% 95%, 28.3% 95%, 1.3% 61.1%, 10.9% 18.8%);
}

/* Each section's color; body[data-active] (set by the scroll spy) exposes the current one */
body { --active-color: var(--c-about); }
body[data-active="skills"] { --active-color: var(--c-skills); }
body[data-active="cv"] { --active-color: var(--c-career); }
body[data-active="research"] { --active-color: var(--c-research); }
body[data-active="projects"] { --active-color: var(--c-projects); }
body[data-active="articles"] { --active-color: var(--c-articles); }

#about { --section-color: var(--c-about); --section-ink: var(--c-about-ink); }
#skills { --section-color: var(--c-skills); --section-ink: var(--c-skills-ink); }
#cv { --section-color: var(--c-career); --section-ink: var(--c-career-ink); }
#research { --section-color: var(--c-research); --section-ink: var(--c-research-ink); }
#projects { --section-color: var(--c-projects); --section-ink: var(--c-projects-ink); }
#articles { --section-color: var(--c-articles); --section-ink: var(--c-articles-ink); }

.meta-link[href="#about"] { --link-color: var(--c-about); }
.meta-link[href="#skills"] { --link-color: var(--c-skills); }
.meta-link[href="#cv"] { --link-color: var(--c-career); }
.meta-link[href="#research"] { --link-color: var(--c-research); }
.meta-link[href="#projects"] { --link-color: var(--c-projects); }
.meta-link[href="#articles"] { --link-color: var(--c-articles); }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* Base Layout */
.container {
  display: flex;
  min-height: 100vh;
}

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

/* =========================================================
   Metaphor primitives
   ========================================================= */

/* Split letters (see splitLetters() in script.js) */
.mf-w {
  display: inline-block;
  white-space: nowrap;
}

.mf-l {
  display: inline-block;
  font-size: calc(var(--s, 1) * 1em);
  transform: translateY(var(--y, 0)) rotate(var(--r, 0deg));
  transform-origin: 50% 80%;
}

/* Letters fly in and snap into place (transform + opacity only, so it stays on the GPU) */
@keyframes letterAssemble {
  0% {
    opacity: 0;
    translate: var(--dx, 0) var(--dy, 0);
    rotate: var(--dr, 0deg);
    scale: var(--ds, 1);
  }
  100% {
    opacity: 1;
    translate: 0 0;
    rotate: 0deg;
    scale: 1;
  }
}

@keyframes letterPop {
  0%, 100% { scale: 1; }
  45% { scale: 1.22; }
}

@keyframes ringSpin {
  to { transform: rotate(360deg); }
}

/* Italic caption, like the game's "Leader" / "Party" labels */
.mf-label {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* Button prompt pill (circle glyph + label), like the game's corner prompts */
.mf-prompt {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 1.2rem 0.45rem 0.45rem;
  border-radius: 999px;
  background: var(--mf-ink);
  color: var(--mf-bone);
  border: 1px solid var(--mf-ink);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s var(--ease-out);
}

.mf-prompt-key {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: radial-gradient(circle, currentColor 0 22%, transparent 26%);
  flex-shrink: 0;
  box-sizing: border-box;
  transition: transform 0.2s var(--ease-out);
}

.mf-prompt:hover,
.mf-prompt:focus-visible {
  background: var(--section-ink, var(--mf-ink-soft));
  color: var(--white);
  transform: translateY(-2px);
  outline: none;
}

.mf-prompt:hover .mf-prompt-key,
.mf-prompt:focus-visible .mf-prompt-key {
  transform: rotate(90deg);
}

.section-cta {
  text-align: center;
  margin-top: 2.4rem;
}

.mf-loading {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--mf-ink-soft);
}

.mf-fallback {
  grid-column: 1 / -1;
  width: 100%;
  text-align: center;
  padding: 2rem;
  box-sizing: border-box;
}

.mf-fallback p {
  margin: 0 0 1.2rem;
  color: var(--mf-ink-soft);
}

/* =========================================================
   Sidebar = the main menu
   ========================================================= */
.metaphor-sidebar {
  width: var(--sidebar-width);
  background: #0d0d0d;
  position: fixed;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: 100;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metaphor-bg-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #2a0823 0%, #0d0d0d 100%);
  opacity: 0.9;
  z-index: 1;
}

#dgc-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.moving-dgc {
  position: absolute;
  font-family: var(--font-display);
  color: transparent;
  -webkit-text-stroke: 2px rgba(255, 255, 255, 0.03);
  z-index: 0;
  user-select: none;
  white-space: nowrap;
  animation: moveRight linear infinite;
  pointer-events: none;
  font-weight: bold;
}

@keyframes moveRight {
  0% {
    transform: translateX(-150%);
  }

  100% {
    transform: translateX(100vw);
  }
}

/* Long diagonal hairlines and crosshair (static) */
.mf-hairlines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.mf-hairlines circle,
.mf-hairlines line,
.mf-hairlines path,
.mf-ring circle,
.mf-ring path {
  fill: none;
  stroke: var(--mf-hairline);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.mf-hairlines .mf-line-faint {
  opacity: 0.4;
}

/* Astrolabe ring: its own element so the rotation runs on the compositor */
.mf-ring {
  position: absolute;
  z-index: 1;
  left: 56%;
  top: 52%;
  width: calc(max(var(--sidebar-width), 100vh) * 0.9);
  aspect-ratio: 1;
  margin: calc(max(var(--sidebar-width), 100vh) * -0.45) 0 0 calc(max(var(--sidebar-width), 100vh) * -0.45);
  pointer-events: none;
  animation: ringSpin 220s linear infinite;
  will-change: transform;
}

.mf-ring svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.mf-ring .mf-ring-dash {
  stroke-dasharray: 2 12;
}

/* Section index dial, like the game's big "2 COMMAND" numeral */
.mf-dial {
  position: absolute;
  top: 1.6rem;
  right: 1.9rem;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  pointer-events: none;
  color: var(--mf-bone);
}

.mf-dial-ring {
  position: absolute;
  width: 8.6rem;
  height: 8.6rem;
  right: 1.1rem;
  top: -0.9rem;
  border-radius: 50%;
  border: 1px solid var(--mf-hairline);
}

.mf-dial-ring::after {
  content: '';
  position: absolute;
  inset: 0.55rem;
  border-radius: 50%;
  border: 1px dashed var(--mf-hairline);
  animation: ringSpin 85s linear infinite reverse;
}

.mf-dial-num {
  position: relative;
  display: inline-block;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 6.2rem;
  line-height: 0.95;
  color: var(--mf-bone);
  text-shadow: 4px 4px 0 var(--active-color);
  font-variant-numeric: lining-nums;
}

.mf-dial-num.flip {
  animation: dialFlip 0.65s var(--ease-out);
}

@keyframes dialFlip {
  0% {
    opacity: 0;
    transform: rotate(-50deg) scale(0.7);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

.mf-dial-cap {
  writing-mode: vertical-rl;
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-top: 0.7rem;
  opacity: 0.8;
}

/* Menu stack */
.metaphor-menu-wrapper {
  position: relative;
  z-index: 2;
  transform: rotate(-7deg);
  display: flex;
  flex-direction: column;
  width: 100%;
  padding-left: 9%;
  box-sizing: border-box;
}

.metaphor-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.meta-link {
  font-family: var(--font-display);
  font-weight: 400;
  text-decoration: none;
  color: var(--mf-bone);
  text-transform: uppercase;
  line-height: 0.95;
  margin-bottom: 0.1em;
  position: relative;
  display: inline-block;
  rotate: var(--fan, 0deg);
  text-shadow: 0.03em 0.03em 0 rgba(0, 0, 0, 0.9);
  z-index: 1;
  outline: none;
  transition: color 0.28s ease;
}

/* A slight fan down the stack, like the game's curved menu */
.meta-link:nth-child(1) { --fan: -3deg; }
.meta-link:nth-child(2) { --fan: -1deg; }
.meta-link:nth-child(3) { --fan: 1deg; }
.meta-link:nth-child(4) { --fan: 0deg; }
.meta-link:nth-child(5) { --fan: -3deg; }
.meta-link:nth-child(6) { --fan: -7deg; }

.meta-content {
  display: inline-block;
  position: relative;
  transform-origin: 15% 60%;
  transition: transform 0.48s var(--ease-out), translate 0.48s var(--ease-out);
}

.meta-link .meta-text {
  position: relative;
  z-index: 3;
  display: inline-block;
  pointer-events: none;
}

/* Letters fly in on load; the selected word pops letter by letter */
.meta-text .mf-l {
  animation: letterAssemble 1s var(--ease-out) calc(var(--i) * 20ms) both;
}

.meta-link.active .meta-text .mf-l {
  animation:
    letterAssemble 1s var(--ease-out) calc(var(--i) * 20ms) both,
    letterPop 0.6s ease-out calc(var(--j) * 40ms) both;
}

/* Selected item: ink letters on the section's brush stroke (the only brush on the site) */
.meta-link.active {
  color: var(--mf-ink);
  /* A light offset + glow keeps the dark letters legible over the brush's ragged edges */
  text-shadow: 0.03em 0.03em 0 rgba(255, 255, 255, 0.7), 0 0 0.08em rgba(255, 255, 255, 0.45);
  z-index: 10;
}

.meta-link.active .meta-content {
  transform: translateX(-0.08em) scale(1.12);
}

.meta-link.active + .meta-link .meta-content {
  translate: 0.35em 0.03em;
}

.meta-link:has(+ .meta-link.active) .meta-content {
  translate: 0.2em -0.03em;
}

/* Hover = a lighter "cursor" preview that doesn't compete with the scroll-driven selection */
.meta-link:hover:not(.active) .meta-content,
.meta-link:focus-visible:not(.active) .meta-content {
  transform: translateX(0.14em) scale(1.04);
}

.meta-splash {
  position: absolute;
  z-index: 2;
  /* Centered on the word, with enough overhang that the ragged edges clear the letters */
  left: -0.32em;
  right: -0.32em;
  top: -0.26em;
  bottom: -0.24em;
  background: var(--link-color);
  -webkit-mask: url('images/brush-b.webp') center / 100% 100% no-repeat;
  mask: url('images/brush-b.webp') center / 100% 100% no-repeat;
  opacity: 0;
  transform-origin: left center;
  pointer-events: none;
}

/* The stroke drags in from the left and leaves off to the right (scale only: GPU-friendly) */
@keyframes smearIn {
  from { scale: 0 1; }
  to { scale: 1 1; }
}

@keyframes smearOut {
  from { scale: 1 1; }
  to { scale: 0 1; }
}

.meta-link:hover:not(.active) .meta-splash,
.meta-link:focus-visible:not(.active) .meta-splash {
  opacity: 0.4;
  animation: smearIn 0.45s var(--ease-out) both;
}

.meta-link.leaving .meta-splash {
  opacity: 1;
  transform-origin: right center;
  animation: smearOut 0.42s ease-in both;
}

.meta-link.active .meta-splash {
  opacity: 1;
  animation: smearIn 0.6s var(--ease-out) both;
}

/* Font sizes (tied to the viewport so the widest word always fits the sidebar) */
.meta-huge {
  font-size: clamp(3rem, 5.3vw, 7rem);
  margin-left: 20px;
}

.meta-xl {
  font-size: clamp(2.7rem, 4.7vw, 6.2rem);
  margin-left: 40px;
}

.meta-large {
  font-size: clamp(2.4rem, 4.2vw, 5.5rem);
  margin-left: 10px;
}

.meta-medium {
  font-size: clamp(2rem, 3.4vw, 4.5rem);
  margin-left: 60px;
}

/* Status panel, like the game's MONEY / MAG readout */
.mf-status {
  position: absolute;
  right: 1.9rem;
  bottom: 2.2rem;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mf-status-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.mf-status-key {
  font-family: var(--font-main);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mf-bone);
}

.mf-status-val {
  min-width: 6.2rem;
  padding: 0.05rem 0.9rem 0.05rem 1.5rem;
  box-sizing: border-box;
  text-align: right;
  background: var(--mf-bone);
  color: var(--mf-ink);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.35;
  font-variant-numeric: lining-nums tabular-nums;
  clip-path: polygon(0.8rem 0, 100% 0, 100% 100%, 0 100%);
}

.sidebar-social-icons {
  position: absolute;
  bottom: 2.2rem;
  left: 1.9rem;
  display: flex;
  gap: 0.6rem;
  z-index: 10;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s var(--ease-out), opacity 0.2s ease;
  pointer-events: none;
}

.sidebar-social-icons.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.sidebar-social-icons a {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mf-bone);
  background: rgba(8, 4, 6, 0.6);
  border: 1.5px solid var(--mf-hairline);
  box-sizing: border-box;
  font-size: 1.05rem;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease-out);
}

.sidebar-social-icons a:hover,
.sidebar-social-icons a:focus-visible {
  background: var(--mf-bone);
  color: var(--mf-ink);
  border-color: var(--mf-bone);
  transform: translateY(-3px);
  outline: none;
}

/* =========================================================
   Content column
   ========================================================= */
.content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  padding: clamp(2.5rem, 4vh, 4.5rem) 4rem clamp(5rem, 7vh, 7rem) 4rem;
  box-sizing: border-box;
  min-height: 100vh;
  background: var(--bg-color);
  /* Title rules may run to the column edge, never past it */
  overflow-x: clip;
}

/* Section transition overlay (navigateTo() in script.js): a slanted panel slides across */
.mf-wipe {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: var(--sidebar-width);
  z-index: 95;
  pointer-events: none;
  overflow: hidden;
  visibility: hidden;
}

.mf-wipe.is-in,
.mf-wipe.is-out {
  visibility: visible;
}

.mf-wipe-layer,
.mf-wipe-stripe {
  position: absolute;
  will-change: transform;
}

.mf-wipe-layer {
  top: 0;
  bottom: 0;
  left: -10%;
  width: 120%;
  background: radial-gradient(circle at center, #2a0823 0%, #0d0d0d 100%);
  clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%);
  transform: translateX(-110%);
}

.mf-wipe-stripe {
  left: -10%;
  width: 120%;
  top: 46%;
  height: 9%;
  background: var(--wipe-color, var(--c-about));
  rotate: -7deg;
  transform: translateX(-120%);
}

.mf-wipe.is-in .mf-wipe-layer {
  animation: wipeIn 0.22s var(--ease-out) both;
}

.mf-wipe.is-in .mf-wipe-stripe {
  animation: wipeIn 0.22s var(--ease-out) 0.03s both;
}

.mf-wipe.is-out .mf-wipe-layer,
.mf-wipe.is-out .mf-wipe-stripe {
  animation: wipeOut 0.24s ease-in both;
}

@keyframes wipeIn {
  from { transform: translateX(-110%); }
  to { transform: translateX(0); }
}

@keyframes wipeOut {
  from { transform: translateX(0); }
  to { transform: translateX(110%); }
}

/* =========================================================
   Sections, titles and reveals
   ========================================================= */
.section {
  margin-bottom: 6rem;
  scroll-margin-top: 2rem;
}

/* Quick slide-in once each section enters the viewport (initScrollReveal) */
.reveal {
  opacity: 0;
}

.reveal.active {
  opacity: 1;
  animation: sectionEnter 0.4s var(--ease-out) backwards;
}

@keyframes sectionEnter {
  from {
    opacity: 0;
    translate: -1.5rem 0;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

.reveal.active .mf-split .mf-l {
  animation: letterAssemble 0.4s var(--ease-out) calc(var(--i) * 14ms) both;
}

/* Giant section title in clean ink; the drop cap carries the section color */
.mf-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3rem, 5vw, 5.4rem);
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--mf-ink);
  margin: 0 0 2.6rem;
  padding-bottom: 0.9rem;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.28em;
  row-gap: 0.25em;
}

/* Rule under the title, running to the column edge */
.mf-title::after {
  content: '';
  position: absolute;
  left: 0;
  right: -4rem;
  bottom: 0;
  height: 1px;
  background: var(--mf-rule-ink);
}

.mf-title::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 3.5rem;
  height: 3px;
  background: var(--section-color);
}

.mf-title .mf-l,
.hero-lockup .mf-l {
  font-size: 1em;
  transform: none;
}

.mf-title .mf-cap,
.hero-lockup .mf-cap {
  font-size: 1.15em;
}

.mf-title .mf-cap {
  color: var(--section-ink);
}

/* D, G and C: the initials behind the DGC monogram (same magenta as the .mf-hl phrases) */
.hero-lockup .mf-cap {
  font-size: 1.22em;
  color: var(--c-about-ink);
}

.mf-kicker {
  font-size: max(0.32em, 1.1rem);
  font-style: italic;
  font-weight: 400;
  text-transform: none;
  color: var(--mf-ink-soft);
}

/* Short narrative line under a section title */
.section-intro {
  max-width: 44rem;
  margin: -1.1rem 0 1.6rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--mf-ink-soft);
}

/* =========================================================
   Hero (About)
   ========================================================= */
.metaphor-hero {
  min-height: calc(100vh - clamp(6.5rem, 9.5vh, 10rem));
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  margin-bottom: 0;
  padding-bottom: 0;
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: clamp(1.5rem, 3vh, 3rem);
  width: 100%;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.hero-grid-container {
  display: grid;
  grid-template-columns: min-content 1fr;
  gap: clamp(2.4rem, 4.2vw, 4.2rem);
  align-items: center;
  width: 100%;
  margin-bottom: clamp(2.2rem, 4.2vh, 3.4rem);
}

.hero-grid-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

/* Portrait: shard-cut frame inside an astrolabe ring */
.hero-portrait-frame {
  position: relative;
  width: clamp(170px, 22vh, 230px);
  aspect-ratio: 1;
  isolation: isolate;
}

.hero-ring {
  position: absolute;
  z-index: -1;
  width: 130%;
  aspect-ratio: 1;
  left: -15%;
  top: -15%;
  border-radius: 50%;
  border: 1px solid var(--mf-rule-ink);
}

.hero-ring::after {
  content: '';
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  border: 1px dashed rgba(14, 13, 15, 0.3);
  animation: ringSpin 90s linear infinite;
}

.hero-portrait-shape {
  display: block;
  width: 100%;
  height: 100%;
  padding: 4px;
  box-sizing: border-box;
  background: var(--mf-ink);
  clip-path: polygon(8% 0, 100% 5%, 93% 100%, 0 91%);
  cursor: pointer;
  transition: transform 0.2s var(--ease-out);
}

.hero-portrait {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: polygon(8% 0, 100% 5%, 93% 100%, 0 91%);
}

.hero-portrait-frame:hover .hero-portrait-shape {
  transform: rotate(-2deg) scale(1.04);
}

.hero-grid-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

/* Logo-style name lockup */
.hero-lockup {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.92;
  text-transform: uppercase;
  color: var(--mf-ink);
}

.lockup-line {
  display: block;
}

.lockup-first {
  font-size: clamp(2.9rem, 5.4vh, 4.3rem);
}

.lockup-mid {
  font-size: clamp(2.3rem, 4.2vh, 3.4rem);
}

.lockup-last {
  font-size: clamp(2.6rem, 4.8vh, 3.85rem);
}

.hero-archetype {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin: 1.1rem 0 1.5rem;
  color: var(--mf-ink);
}

.hero-archetype::before {
  content: '';
  width: 2.2rem;
  height: 1px;
  align-self: center;
  background: var(--mf-ink);
}

.hero-archetype-name {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.social-icons {
  display: flex;
  gap: 0.7rem;
}

.social-icons a {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mf-ink);
  color: var(--mf-bone);
  font-size: 1.05rem;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.15s var(--ease-out);
}

.social-icons a:hover,
.social-icons a:focus-visible {
  background: var(--c-about-ink);
  transform: translateY(-3px);
  outline: none;
}

.hero-punchline {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 3.2vh, 2.2rem);
  color: var(--mf-ink);
  margin: clamp(2.6rem, 4.8vh, 4rem) auto;
  line-height: 1.45;
  text-align: center;
  max-width: 800px;
}

.mf-hl {
  font-style: italic;
  font-weight: 400;
  color: var(--section-ink);
}

/* Research pipeline: three heptagon emblems (the game's rank badges) on one connected track.
   One shared clock (--pipe-cycle) runs the whole sequence: Data lights up, the line fills while a
   pulse travels to Human Biology, which lights up, then on to Clinical Practice; all three hold,
   then reset together. Arrivals are at 0%, 33% and 66% of the cycle; the reset runs 85-100%.
   The base (non-animated) state is "all lit", which is what reduced motion shows. */
.hero-pipeline {
  --pipe-cycle: 6.5s;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  width: 100%;
  max-width: 720px;
  margin: clamp(1rem, 2vh, 2rem) auto 0;
  padding: 0;
  list-style: none;
}

/* Runs from the first emblem's center to the last one's */
.pipeline-track {
  position: absolute;
  top: 2.3rem;
  left: calc(100% / 6);
  right: calc(100% / 6);
  height: 3px;
  border-radius: 2px;
  background: var(--mf-rule-ink);
}

.pipeline-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--c-about), color-mix(in srgb, var(--c-about) 50%, var(--c-articles)), var(--c-articles));
  transform-origin: left center;
  animation: pipeFill var(--pipe-cycle) linear infinite;
}

@keyframes pipeFill {
  0% { transform: scaleX(0); opacity: 1; }
  66% { transform: scaleX(1); opacity: 1; }
  85% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

.pipeline-pulse {
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: pipePulse var(--pipe-cycle) linear infinite;
}

.pipeline-pulse::after {
  content: '';
  position: absolute;
  right: -7px;
  top: -5.5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-about) 50%, var(--c-articles)), 0 0 14px rgba(0, 0, 0, 0.2);
}

@keyframes pipePulse {
  0% { transform: translateX(-100%); opacity: 0; }
  3% { transform: translateX(-95.5%); opacity: 1; }
  63% { opacity: 1; }
  66% { transform: translateX(0); opacity: 0; }
  100% { transform: translateX(0); opacity: 0; }
}

.pipeline-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  cursor: default;
  user-select: none;
}

/* Unlit rim is a quiet grey; .node-ring fades the step color in when the pulse arrives */
.node-emblem {
  position: relative;
  width: 4.6rem;
  height: 4.6rem;
  display: grid;
  place-items: center;
  background: rgba(14, 13, 15, 0.22);
  clip-path: var(--hepta);
  color: var(--mf-bone);
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
  transition: rotate 0.2s var(--ease-out);
}

.node-ring,
.node-emblem::before,
.node-emblem::after {
  position: absolute;
  clip-path: var(--hepta);
}

.node-ring {
  inset: 0;
  z-index: 0;
  background: var(--step-color);
}

.node-emblem::before,
.node-emblem::after {
  content: '';
}

.node-emblem::before {
  inset: 3px;
  z-index: 1;
  background: var(--bg-color);
}

.node-emblem::after {
  inset: 7px;
  z-index: 2;
  background: var(--mf-ink);
  transition: background-color 0.15s ease;
}

.node-emblem i {
  position: relative;
  z-index: 3;
  transition: color 0.15s ease;
}

/* Each step lights up and pings exactly when the pulse reaches it */
.pipeline-node:nth-child(2) .node-ring { animation: nodeOn1 var(--pipe-cycle) linear infinite; }
.pipeline-node:nth-child(3) .node-ring { animation: nodeOn2 var(--pipe-cycle) linear infinite; }
.pipeline-node:nth-child(4) .node-ring { animation: nodeOn3 var(--pipe-cycle) linear infinite; }
.pipeline-node:nth-child(2) .node-emblem { animation: nodePing1 var(--pipe-cycle) ease-out infinite; }
.pipeline-node:nth-child(3) .node-emblem { animation: nodePing2 var(--pipe-cycle) ease-out infinite; }
.pipeline-node:nth-child(4) .node-emblem { animation: nodePing3 var(--pipe-cycle) ease-out infinite; }

@keyframes nodeOn1 {
  0% { opacity: 0; }
  3%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes nodeOn2 {
  0%, 32% { opacity: 0; }
  35%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes nodeOn3 {
  0%, 65% { opacity: 0; }
  68%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes nodePing1 {
  0%, 12%, 100% { scale: 1; }
  4% { scale: 1.12; }
}

@keyframes nodePing2 {
  0%, 33%, 45%, 100% { scale: 1; }
  37% { scale: 1.12; }
}

@keyframes nodePing3 {
  0%, 66%, 78%, 100% { scale: 1; }
  70% { scale: 1.12; }
}

.node-label {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.05rem, 1.6vh, 1.25rem);
  letter-spacing: 0.03em;
  line-height: 1.15;
  text-transform: uppercase;
  color: var(--mf-ink);
}

.node-desc {
  max-width: 12rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--mf-ink-soft);
}

.pipeline-node:hover .node-emblem {
  rotate: -8deg;
}

.pipeline-node:hover .node-emblem::after {
  background: var(--step-color);
}

.pipeline-node:hover .node-emblem i {
  color: var(--mf-ink);
}

.scroll-indicator {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s var(--ease-out),
              transform 0.3s var(--ease-out),
              visibility 0.3s ease,
              background-color 0.15s ease,
              color 0.15s ease;
  animation: bounceCTA 2.5s infinite;
}

.scroll-badge {
  white-space: nowrap;
}

.scroll-arrow {
  font-size: 0.85rem;
}

.scroll-indicator:hover,
.scroll-indicator:focus-visible {
  transform: translateX(-50%) translateY(-3px);
}

.scroll-indicator.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(14px);
  pointer-events: none;
  animation: none;
}

@keyframes bounceCTA {
  0%, 20%, 50%, 80%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  40% {
    transform: translateX(-50%) translateY(-8px);
  }
  60% {
    transform: translateX(-50%) translateY(-4px);
  }
}

/* Horizontal Skill Tree Section */
#horizontal-skill-tree-section {
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  --tree-accent: rgba(255, 255, 255, 0.1);
  /* default */
  background-color: #0d1117;
  transition: border-color 0.4s ease;
  display: flex;
  gap: 2rem;
  height: 65vh;
  min-height: 550px;
  max-height: 800px;
  overflow: hidden;
}

#horizontal-skill-tree-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, var(--tree-accent, transparent) 0%, transparent 80%);
  opacity: 0.10;
  pointer-events: none;
  z-index: 0;
  transition: background 0.4s ease;
}

.skills-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.skills-sidebar {
  width: 220px;
  flex-shrink: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding-right: 1.5rem;
}

.skills-selector {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.skills-selector li {
  position: relative;
  padding: 1rem 1.5rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.75);
  font-family: 'DM Mono', monospace;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  overflow: hidden;
}

.skills-selector li:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
  transform: translateX(5px);
}

.skills-selector li.active {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.05);
  border-left: 4px solid var(--cat-color, #fff);
  transform: translateX(10px);
}

.skills-content-wrapper {
  flex: 1;
  min-width: 0;
  /* allows flex item to shrink properly */
  position: relative;
  z-index: 5;
  display: flex;
}

.skills-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.skills-content::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.skills-content::-webkit-scrollbar-track {
  background: transparent;
}

.skills-content::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.horizontal-tree-container {
  position: relative;
  height: 100%;
  min-width: 100%;
  /* Will expand based on JS layout */
  transform-origin: top left;
}

.horizontal-tree-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

@media (max-width: 900px) {
  #horizontal-skill-tree-section {
    flex-direction: column;
    min-height: 750px;
  }

  .skills-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-right: 0;
    padding-bottom: 1.5rem;
  }

  .skills-selector {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .skills-selector li.active {
    transform: translateY(-5px) translateX(0);
  }
}

/* Horizontal Node */
.horizontal-node {
  position: absolute;
  width: calc(56px * var(--scale-factor, 1));
  height: calc(56px * var(--scale-factor, 1));
  background: rgba(20, 25, 30, 0.95);
  border: calc(2px * var(--scale-factor, 1)) solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  cursor: pointer;
  z-index: 4;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.horizontal-node.root-node {
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.2), 0 4px 10px rgba(0, 0, 0, 0.5);
}

.horizontal-node i {
  font-size: calc(1.4rem * var(--scale-factor, 1));
  transition: all 0.3s ease;
}

.horizontal-node:hover,
.horizontal-node.glow {
  border-color: var(--node-color, var(--tree-accent));
  background: rgba(30, 35, 40, 0.95);
  color: var(--node-color, var(--tree-accent));
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: inset 0 0 20px var(--node-color, var(--tree-accent)), 0 6px 15px rgba(0, 0, 0, 0.6);
}

.horizontal-node-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: calc(10px * var(--scale-factor, 1));
  font-family: 'DM Mono', monospace;
  font-size: calc(0.85rem * var(--scale-factor, 1));
  font-weight: 500;
  letter-spacing: 0.5px;
  white-space: pre-wrap;
  word-break: break-word;
  width: max-content;
  max-width: calc(140px * var(--scale-factor, 1));
  text-align: center;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.75);
  pointer-events: none;
  transition: all 0.3s ease;
  text-transform: uppercase;
}

.horizontal-node.root-node .horizontal-node-label {
  color: #fff;
}

.horizontal-node:hover .horizontal-node-label,
.horizontal-node.glow .horizontal-node-label {
  color: #fff;
  transform: translateX(-50%) translateY(3px);
}

/* Lines */
.horizontal-tree-line {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 3;
  fill: none;
  transition: stroke 0.4s ease, stroke-width 0.4s ease, opacity 0.4s ease;
  stroke-linecap: round;
}

.horizontal-tree-line.glow {
  stroke: var(--node-color, var(--tree-accent));
  stroke-width: 4;
}

/* Tooltip Styles */
.horizontal-tree-tooltip {
  position: fixed;
  background: rgba(15, 20, 25, 0.95);
  border: 1px solid var(--tree-accent);
  border-radius: 12px;
  padding: 1.5rem;
  color: #fff;
  width: 320px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9) translateY(10px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(255, 255, 255, 0.05);
  border-left: 4px solid var(--tree-accent);
}

.horizontal-tree-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

.horizontal-tree-tooltip h4 {
  margin: 0 0 0.5rem 0;
  color: #fff;
  font-family: 'DM Mono', monospace;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.horizontal-tree-tooltip p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #d1d5db;
  font-family: 'DM Mono', monospace;
}

.horizontal-tree-tooltip .st-tooltip-exp {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
  font-size: 0.85rem;
  color: #a0aab5;
  font-style: italic;
  display: none;
}

.horizontal-tree-tooltip .st-tooltip-exp.has-content {
  display: block;
}


/* =========================================================
   Experience timeline: progress track, milestones and pixel walker
   ========================================================= */
/* The track runs down --track-x, lined up with the section title's left edge */
.cv-roadmap {
  --track-x: 20px;
  position: relative;
  padding-left: 3.6rem;
  margin-top: 1rem;
}

.cv-line,
.cv-line-fill {
  position: absolute;
  width: 6px;
  border-radius: 3px;
}

.cv-line {
  background: color-mix(in srgb, var(--c-career) 18%, transparent);
  z-index: 0;
}

.cv-line-fill {
  top: 0;
  left: 0;
  height: 0;
  background: linear-gradient(to top, var(--c-career-ink), var(--c-career));
  box-shadow: 0 0 10px color-mix(in srgb, var(--c-career) 45%, transparent);
  /* No z-index here: the fill must not form a stacking context, or the walker inside it
     (z-index 10) would sink below the milestones (z-index 2) */
}

.cv-item {
  position: relative;
  margin-bottom: 3.5rem;
}

.cv-item:last-child {
  margin-bottom: 0;
}

/* Milestones: open diamonds ahead of the walker, filled once passed */
.cv-dot {
  position: absolute;
  left: calc(var(--track-x) - 3.6rem - 11px);
  top: 1.2rem;
  width: 16px;
  height: 16px;
  background: var(--bg-color);
  border: 3px solid color-mix(in srgb, var(--c-career) 50%, transparent);
  border-radius: 3px;
  transform: rotate(45deg);
  transition: transform 0.3s var(--ease-out), background-color 0.3s ease, border-color 0.3s ease;
  z-index: 2;
}

.cv-item.completed .cv-dot {
  background: var(--c-career);
  border-color: var(--c-career-ink);
}

/* The entry being read gets a larger milestone with a pulsing "you are here" ring */
.cv-item.current .cv-dot {
  transform: rotate(45deg) scale(1.3);
  border-color: var(--c-career-ink);
}

.cv-dot::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 5px;
  border: 2px solid var(--c-career);
  opacity: 0;
  pointer-events: none;
}

.cv-item.current .cv-dot::after {
  animation: milestonePulse 1.8s ease-out infinite;
}

@keyframes milestonePulse {
  0% {
    opacity: 0.7;
    transform: scale(0.8);
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

.cv-spark {
  position: absolute;
  box-sizing: border-box;
  width: 36px;
  height: 56px;
  background-image: url('images/walk_1.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  border: none;
  border-radius: 0;
  transform: translate(-50%, -50%);
  left: 3px;
  top: 0;
  box-shadow: none;
  opacity: 1;
  z-index: 10;
  animation: walk 2s infinite;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
  transition: opacity 0.3s ease;
  image-rendering: pixelated; /* high resolution pixel art rendering */
}

@keyframes walk {
  0%, 49.99% { background-image: url('images/walk_1.png'); }
  50%, 100% { background-image: url('images/walk_2.png'); }
}

/* Quest-log rows */
.cv-header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 1rem;
  padding: 0.85rem 1.2rem 0.85rem 0.9rem;
  margin-bottom: 0.8rem;
  background-color: var(--mf-panel);
  border: 1px solid var(--mf-ink);
  box-shadow: inset 0 0 0 3px var(--mf-panel), inset 0 0 0 4px var(--mf-hairline);
  color: var(--mf-bone);
  transition: box-shadow 0.15s ease, translate 0.2s var(--ease-out);
}

/* The entry nearest the viewport center (checkCVScroll) gets the orange selection bar */
.cv-item.current .cv-header {
  box-shadow: inset 5px 0 0 var(--c-career), inset 0 0 0 3px var(--mf-panel), inset 0 0 0 4px var(--mf-hairline);
  translate: 6px 0;
}

.cv-glyph {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cv-item.current .cv-glyph {
  background: var(--c-career);
  border-color: var(--c-career);
  color: var(--mf-ink);
}

.cv-heading {
  min-width: 0;
}

.cv-info h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.2;
  color: inherit;
}

.cv-institution {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(244, 240, 232, 0.82);
}

.cv-date {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: rgba(244, 240, 232, 0.9);
}

.cv-tag {
  position: absolute;
  top: -0.7rem;
  left: 3.4rem;
  padding: 0.26rem 0.55rem;
  background: var(--c-career);
  color: var(--mf-ink);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.cv-learned {
  margin: 0 0 0 0.4rem;
  max-width: 68ch;
  color: var(--mf-ink-soft);
  font-size: 1rem;
  line-height: 1.65;
}

/* =========================================================
   Research: Journal list
   ========================================================= */
.journal-panel {
  background-color: var(--mf-panel);
  color: var(--mf-bone);
  border: 1px solid var(--mf-ink);
  box-shadow: inset 0 0 0 3px var(--mf-panel), inset 0 0 0 4px var(--mf-hairline);
  padding: 1rem 0 0.7rem;
}

.journal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0.7rem;
  padding: 0 0.9rem 0.6rem;
  border-bottom: 1px solid var(--mf-hairline);
}

.journal-head .mf-label {
  font-size: 1.05rem;
}

.journal-count {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1;
  font-variant-numeric: lining-nums;
}

.journal-list {
  list-style: none;
  margin: 0;
  padding: 0.3rem 0.7rem 0;
}

.journal-row + .journal-row {
  border-top: 1px solid rgba(244, 240, 232, 0.14);
}

.journal-link {
  display: grid;
  grid-template-columns: 3.6rem 1fr auto;
  align-items: center;
  column-gap: 1rem;
  padding: 0.9rem 0.9rem;
  color: var(--mf-bone);
  text-decoration: none;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.journal-link:hover,
.journal-link:focus-visible {
  background-color: rgba(244, 240, 232, 0.08);
  box-shadow: inset 4px 0 0 var(--c-research);
  outline: none;
}

.journal-year {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.4rem;
  line-height: 1;
  font-variant-numeric: lining-nums;
  color: var(--c-research);
}

.journal-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.journal-title {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.4;
}

.journal-venue {
  font-size: 0.86rem;
  font-weight: 500;
  color: rgba(244, 240, 232, 0.75);
}

.journal-arrow {
  font-size: 0.8rem;
  opacity: 0.5;
  transition: translate 0.15s var(--ease-out), opacity 0.15s ease;
}

.journal-link:hover .journal-arrow,
.journal-link:focus-visible .journal-arrow {
  opacity: 1;
  translate: 4px 0;
}

/* =========================================================
   Projects: Equipment plates
   ========================================================= */
.equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.2rem 1.3rem;
}

.equip-plate {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 0.9rem;
  row-gap: 0.4rem;
  padding: 1.05rem 1.15rem 0.9rem 1rem;
  background-color: var(--mf-panel);
  border: 1px solid var(--mf-ink);
  box-shadow: inset 0 0 0 3px var(--mf-panel), inset 0 0 0 4px var(--mf-hairline);
  clip-path: polygon(1.1rem 0, 100% 0, 100% 100%, 0 100%, 0 1.1rem);
  color: var(--mf-bone);
  text-decoration: none;
  transition: box-shadow 0.15s ease, transform 0.15s var(--ease-out);
}

.equip-plate:hover,
.equip-plate:focus-visible {
  box-shadow: inset 0 0 0 3px var(--mf-panel), inset 0 0 0 4px var(--c-projects);
  transform: translateY(-3px);
  outline: none;
}

.equip-emblem {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.equip-plate:hover .equip-emblem,
.equip-plate:focus-visible .equip-emblem {
  background: var(--c-projects);
  border-color: var(--c-projects);
  color: var(--mf-ink);
}

.equip-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.2rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.equip-desc {
  grid-column: 1 / -1;
  font-size: 0.92rem;
  line-height: 1.5;
  color: rgba(244, 240, 232, 0.85);
}

.equip-foot {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.35rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(244, 240, 232, 0.18);
}

.equip-lang {
  font-size: 1rem;
  color: var(--c-projects);
}

.equip-stats {
  display: flex;
  gap: 0.9rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  font-variant-numeric: lining-nums;
}

.equip-stats i {
  font-size: 0.72rem;
  margin-right: 0.3rem;
  opacity: 0.75;
}

/* =========================================================
   Medium articles (own look)
   ========================================================= */
/* Trading Card Game (TCG) Deck Carousel
   A 3D stage (initDeckCarousel): the active card faces front, neighbors fan out behind it and the
   deck wraps around. Cards are placed with inline transform/opacity only. */
.tcg-deck {
  --deck: var(--c-articles);
  --deck-deep: var(--c-articles-ink);
}

.tcg-deck-wrapper {
  position: relative;
  width: 100%;
  margin: 1rem 0 0;
}

.tcg-stage {
  position: relative;
  height: 480px;
  perspective: 1400px;
  perspective-origin: 50% 40%;
  touch-action: pan-y;
  user-select: none;
  outline: none;
  cursor: grab;
}

.tcg-stage:focus-visible {
  outline: 2px dashed var(--deck-deep);
  outline-offset: 6px;
}

.tcg-stage.dragging {
  cursor: grabbing;
}

.tcg-stage > .mf-fallback,
.tcg-stage > .mf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Deck nav arrows */
.deck-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--mf-ink);
  border: 2px solid var(--deck);
  color: var(--mf-bone);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-out), opacity 0.25s ease;
}

.deck-nav:hover,
.deck-nav:focus-visible {
  background: var(--deck);
  color: var(--mf-ink);
  transform: translateY(-50%) scale(1.08);
  outline: none;
}

.deck-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.deck-nav.prev {
  left: 0;
}

.deck-nav.next {
  right: 0;
}

/* Pips + counter under the deck */
.tcg-deck-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 0.4rem;
}

.tcg-pips {
  display: flex;
  gap: 0.5rem;
}

.tcg-pip {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  rotate: 45deg;
  background: rgba(14, 13, 15, 0.18);
  cursor: pointer;
  transition: background-color 0.25s ease, scale 0.25s var(--ease-out);
}

.tcg-pip:hover {
  background: rgba(14, 13, 15, 0.4);
}

.tcg-pip[aria-current="true"] {
  background: var(--deck);
  scale: 1.35;
}

.tcg-counter {
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  color: var(--mf-ink-soft);
  font-variant-numeric: tabular-nums;
}

/* TCG Card Frame: the whole card is the link to the article */
.tcg-card {
  position: absolute;
  left: 50%;
  top: 16px;
  width: 300px;
  height: 440px;
  display: block;
  color: #ffffff;
  text-decoration: none;
  outline: none;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.6s var(--ease-out), opacity 0.5s ease;
}

.tcg-stage.dragging .tcg-card {
  transition: none;
}

/* Cards behind the front one are shaded */
.tcg-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: #050507;
  opacity: var(--dim, 0);
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.tcg-stage.dragging .tcg-card::after {
  transition: none;
}

.tcg-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--deck) 28%, #121216) 0%, #101013 45%, #0b0b0e 100%);
  border: 3px solid #0a0a0c;
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--deck) 75%, transparent),
    inset 0 0 0 5px rgba(0, 0, 0, 0.55),
    0 18px 40px rgba(0, 0, 0, 0.28);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s ease;
}

.tcg-card.is-front .tcg-card-inner {
  box-shadow:
    inset 0 0 0 2px var(--deck),
    inset 0 0 0 5px rgba(0, 0, 0, 0.55),
    0 22px 48px rgba(12, 106, 111, 0.35);
}

/* Name bar: the article title, like a card's name */
.tcg-name {
  margin: 0;
  padding: 8px 10px;
  flex-shrink: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.3;
  background: linear-gradient(90deg, color-mix(in srgb, var(--deck) 30%, #1a1a1f), #1a1a1f 80%);
  border: 1px solid color-mix(in srgb, var(--deck) 55%, transparent);
  border-radius: 8px;
}

/* Long titles stop at three lines (clamped on the inner span so the bar's padding stays clean) */
.tcg-name span {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tcg-art-frame {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  height: 150px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #050507;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--deck) 60%, transparent), inset 0 0 18px rgba(0, 0, 0, 0.6);
  background: #000;
}

.tcg-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
}

.tcg-art-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, #2c2c30 0%, #18181b 100%);
  color: var(--deck);
  font-size: 3rem;
}

/* Type line: the article's tags, like "Creature — Elf Warrior" */
.tcg-type {
  margin: 0;
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #e6f4f4;
  background: color-mix(in srgb, var(--deck) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--deck) 45%, transparent);
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Text box with the subtitle as flavor text */
.tcg-textbox {
  flex: 1;
  min-height: 0;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  overflow: hidden;
}

.tcg-flavor {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.98rem;
  line-height: 1.4;
  color: #d6d6dc;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Set line: where it was published, when, and its number in the deck */
.tcg-set {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 2px 4px 0;
  font-size: 0.72rem;
  color: #b4b4bc;
}

.tcg-set-name {
  font-weight: 600;
  color: #e6e6ea;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tcg-set-meta {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Soft glare that follows the pointer on the front card (moved with transform only) */
.tcg-glare {
  position: absolute;
  left: -50%;
  top: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.025) 18%, transparent 36%);
  opacity: 0;
  transform: translate(var(--gx, 0%), var(--gy, 0%));
  transition: opacity 0.3s ease;
}

.tcg-card.is-front.is-tilting .tcg-glare {
  opacity: 1;
}

@media (max-width: 600px) {
  .tcg-stage {
    height: 450px;
  }

  .tcg-card {
    width: 260px;
    height: 410px;
  }

  .tcg-art-frame {
    height: 120px;
  }

  .tcg-flavor {
    -webkit-line-clamp: 3;
  }

  .deck-nav {
    width: 40px;
    height: 40px;
  }
}
/* =========================================================
   Coda: "..." and the DGC signature (the C is a hidden door to Atlas)
   ========================================================= */
.mf-coda {
  text-align: center;
  padding: 2rem 0 1rem;
  color: var(--mf-ink);
  font-family: var(--font-display);
  font-weight: 400;
  user-select: none;
}

.coda-dots {
  margin: 0 0 1.5rem;
  font-size: 2.2rem;
  line-height: 1;
  letter-spacing: 0.35em;
  color: var(--mf-ink-soft);
}

.coda-sign {
  margin: 0;
  font-size: clamp(4rem, 8vw, 7rem);
  line-height: 1;
  letter-spacing: 0.02em;
}

.coda-door {
  position: relative;
  display: inline-block;
  color: inherit;
  text-decoration: none;
  outline: none;
  cursor: pointer;
}

/* While the pixel canvas is showing, the real glyph steps aside */
.coda-door.is-pixel .coda-c {
  visibility: hidden;
}

.coda-pixels {
  position: absolute;
  pointer-events: none;
  image-rendering: pixelated;
}

.coda-door:focus-visible {
  outline: 2px dashed var(--mf-ink-soft);
  outline-offset: 6px;
}

/* Full-screen pixel dissolve before leaving for Atlas */
.mf-teleport {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
  display: none;
  image-rendering: pixelated;
}

.mf-teleport.is-active {
  display: block;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1400px) {
  .mf-dial-num {
    font-size: 5rem;
  }

  .mf-dial-ring {
    width: 7rem;
    height: 7rem;
  }
}

/* Narrow sidebar: the status panel moves to the top-left corner, clear of the social icons */
@media (max-width: 1300px) {
  .mf-status {
    top: 1.8rem;
    left: 1.9rem;
    right: auto;
    bottom: auto;
  }

  .mf-status-row {
    justify-content: flex-start;
  }
}

@media (max-width: 1000px) {
  :root {
    --sidebar-width: 0px;
  }

  /* The menu becomes a static title screen above the content */
  .metaphor-sidebar {
    width: 100%;
    position: relative;
    height: auto;
    padding: 5rem 0 5.5rem;
  }

  .mf-ring {
    width: 90vw;
    margin: -45vw 0 0 -45vw;
  }

  .metaphor-menu-wrapper {
    transform: rotate(-5deg);
    padding-left: 0;
    align-items: center;
  }

  .metaphor-nav {
    align-items: center;
  }

  .meta-link {
    rotate: calc(var(--fan, 0deg) * 0.5);
  }

  .meta-huge,
  .meta-xl,
  .meta-large,
  .meta-medium {
    margin-left: 0;
    font-size: clamp(2.6rem, 11vw, 4rem);
    text-align: center;
  }

  .mf-dial,
  .mf-status,
  .sidebar-social-icons {
    display: none !important;
  }
}

@media (max-height: 820px) {
  .content {
    padding-top: 1.5rem;
    padding-bottom: 4.5rem;
  }

  .hero-content {
    margin-bottom: 1.2rem;
  }

  .hero-portrait-frame {
    width: 150px;
  }

  .hero-pipeline {
    margin: 0.6rem 0 1.2rem 0;
  }
}

@media (max-width: 900px) {
  .container {
    flex-direction: column;
  }

  .content {
    padding: 3rem 1.5rem;
  }

  .hero-grid-container {
    grid-template-columns: 1fr;
    gap: 2rem;
    justify-items: center;
  }

  .hero-grid-right {
    align-items: center;
    text-align: center;
  }

  .hero-lockup {
    align-items: center;
  }

  .cv-header {
    grid-template-columns: auto 1fr;
  }

  .cv-date {
    grid-column: 2;
  }
}

@media (max-width: 600px) {
  .mf-title {
    font-size: clamp(2.4rem, 12vw, 3.4rem);
  }

  .hero-archetype {
    flex-wrap: wrap;
    justify-content: center;
  }

  .hero-archetype-name {
    font-size: 0.82rem;
    letter-spacing: 0.16em;
  }

  .hero-pipeline {
    gap: 0.5rem;
  }

  .node-emblem {
    width: 3.8rem;
    height: 3.8rem;
    font-size: 1.1rem;
  }

  .pipeline-track {
    top: 1.9rem;
  }

  .node-label {
    font-size: 0.95rem;
  }

  .node-desc {
    font-size: 0.8rem;
  }

  .journal-link {
    grid-template-columns: 2.9rem 1fr;
    column-gap: 0.75rem;
  }

  .journal-arrow {
    display: none;
  }

  .journal-year {
    font-size: 1.2rem;
  }
}

/* =========================================================
   Reduced motion: no fly-ins, slides or spinning rings
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

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