/* =========================================================================
   BASE — warm dark palette, rounded friendly type, restrained red/blue
   ========================================================================= */

:root {
  --bg: #12100e;
  --bg-elevated: #191613;
  --bg-soft: #1d1916;
  --text: #f0ebe3;
  --muted: #a89f95;
  --dim: #7f776e;
  --accent: #b4574b;
  --accent-bright: #d17a6b;
  --accent-soft: rgba(180, 87, 75, 0.14);
  --blue: #93b1dc;
  --blue-soft: rgba(147, 177, 220, 0.13);
  --warm: #dfb079;
  /* One link colour everywhere — the warm accent used for Epitome. */
  --link: #dfb079;
  --link-hover: #f0c894;
  --link-soft: rgba(223, 176, 121, 0.34);
  --line: rgba(240, 235, 227, 0.09);
  --line-strong: rgba(240, 235, 227, 0.18);
  --nav-h: 68px;
  --game-band: 48px;
  --header-h: calc(var(--nav-h) + var(--game-band));
  --gutter: clamp(20px, 4vw, 40px);
  --max: 1120px;
  --sans: "Nunito Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    "Courier New", monospace;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  overscroll-behavior-y: auto;
}

html.scroll-locked,
html.scroll-locked body {
  overflow-y: hidden;
}

html.scroll-locked body {
  padding-right: var(--scrollbar-comp, 0px);
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(58rem 36rem at 82% -12%, rgba(180, 87, 75, 0.1), transparent 62%),
    radial-gradient(46rem 30rem at 4% 34%, rgba(147, 177, 220, 0.035), transparent 65%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  overscroll-behavior-y: auto;
}

p {
  margin: 0 0 1em;
  color: var(--muted);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  color: var(--text);
  font-family: var(--sans);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.012em;
}

img {
  max-width: 100%;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  transform: translateY(-200%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Shared icon technique so the supplied SVGs follow the theme colour. */
.icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.icon-github {
  -webkit-mask-image: url("./assets/icons/github.svg");
  mask-image: url("./assets/icons/github.svg");
}

.icon-linkedin {
  -webkit-mask-image: url("./assets/icons/linkedin.svg");
  mask-image: url("./assets/icons/linkedin.svg");
}

.icon-email {
  -webkit-mask-image: url("./assets/icons/email.svg");
  mask-image: url("./assets/icons/email.svg");
}

.icon-game {
  -webkit-mask-image: url("./assets/icons/game.svg");
  mask-image: url("./assets/icons/game.svg");
}

/* Crossfade icons with subtle blur that clears as the incoming icon appears. */
.icon-swap {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--swap-size, 16px);
  height: var(--swap-size, 16px);
  flex: 0 0 auto;
}

.icon-swap-layer {
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition:
    opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.icon-swap-layer.is-default {
  opacity: 1;
  filter: blur(0px);
  transform: scale(1);
}

.icon-swap-layer.is-active {
  opacity: 0;
  filter: blur(3px);
  transform: scale(0.86);
  pointer-events: none;
}

.game-toggle.is-active .icon-swap-layer.is-default,
.game-info-toggle[aria-expanded="true"] .icon-swap-layer.is-default,
.hero-cta-secondary.is-copied .icon-swap-layer.is-default,
.chapter-toggle[aria-expanded="true"] .icon-swap-layer.is-default {
  opacity: 0;
  filter: blur(3px);
  transform: scale(0.86);
  pointer-events: none;
}

.game-toggle.is-active .icon-swap-layer.is-active,
.game-info-toggle[aria-expanded="true"] .icon-swap-layer.is-active,
.hero-cta-secondary.is-copied .icon-swap-layer.is-active,
.chapter-toggle[aria-expanded="true"] .icon-swap-layer.is-active {
  opacity: 1;
  filter: blur(0px);
  transform: scale(1);
}

/* =========================================================================
   HEADER / NAVBAR
   ========================================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(18, 16, 14, 0.88);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  border-bottom: 1px solid var(--line);
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  width: 100%;
  max-width: var(--max);
  height: var(--nav-h);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
}

.nav-links a {
  position: relative;
  padding-block: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.18s ease;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text);
}

.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after {
  transform: scaleX(1);
}

.nav-social {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  transition: color 0.18s ease, background-color 0.18s ease;
}

.icon-link .icon {
  width: 17px;
  height: 17px;
}

.icon-link:hover {
  color: var(--text);
  background: rgba(240, 235, 227, 0.06);
}

/* --- Game Mode launcher: independent of the navbar, sits below it on the
   left. It owns its stacking context and has no inherited border/background. */

.game-launch {
  position: sticky;
  top: var(--nav-h);
  z-index: 59;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: var(--max);
  height: var(--game-band);
  margin: 0 auto;
  padding-inline: var(--gutter);
  background: transparent;
  pointer-events: none;
}

/* Icon-only control: no label, transparent idle chrome, red glow when active. */
.game-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 32px;
  padding: 0;
  color: #d9a396;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.18s ease, border-color 0.18s ease,
    background-color 0.18s ease, box-shadow 0.25s ease;
}

.game-toggle .icon {
  width: 19px;
  height: 19px;
}

.game-toggle:hover {
  color: var(--text);
  border-color: rgba(209, 122, 107, 0.5);
  background: rgba(180, 87, 75, 0.14);
}

.game-toggle:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
  color: var(--text);
}

/* Active: same footprint, subtle red illumination. */
.game-toggle.is-active {
  color: var(--accent-bright);
  border-color: rgba(209, 122, 107, 0.75);
  background: rgba(180, 87, 75, 0.16);
  box-shadow: 0 0 14px rgba(180, 87, 75, 0.45),
    inset 0 0 8px rgba(180, 87, 75, 0.2);
}

.game-toggle.is-active .icon {
  color: var(--accent-bright);
}

/* Info control: hidden until Web Rush is running. */
.game-info-toggle {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  background: rgba(25, 22, 19, 0.92);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-6px) scale(0.9);
  transition: color 0.18s ease, border-color 0.18s ease,
    background-color 0.18s ease, opacity 0.2s ease, transform 0.2s ease,
    visibility 0.2s ease;
}

.game-launch.is-active .game-info-toggle {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  transform: none;
}

.game-info-toggle:hover,
.game-info-toggle[aria-expanded="true"] {
  color: var(--text);
  border-color: rgba(209, 122, 107, 0.65);
  background: rgba(180, 87, 75, 0.16);
}

/* Cleared below the HUD row so the score readout stays readable. */
.game-controls-panel {
  position: absolute;
  top: calc(100% + 64px);
  left: var(--gutter);
  z-index: 3;
  width: min(290px, calc(100vw - var(--gutter) * 2));
  max-height: calc(100svh - var(--header-h) - 72px);
  overflow-y: auto;
  padding: 14px 16px 15px;
  pointer-events: auto;
  background: rgba(22, 19, 16, 0.98);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
}

.game-controls-panel[hidden] {
  display: none;
}

.game-controls-title {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.game-controls-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.game-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.game-control-row dt {
  font-family: var(--mono);
  font-size: 0.67rem;
  white-space: nowrap;
  color: var(--text);
}

.game-control-row dd {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: right;
  color: var(--muted);
}

.game-control-row kbd {
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 0.63rem;
  color: var(--text);
  background: rgba(240, 235, 227, 0.06);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}

body.is-grabbing,
body.is-grabbing * {
  user-select: none;
  -webkit-user-select: none;
}

/* =========================================================================
   GAME DRAWER
   ========================================================================= */

/* =========================== GAME DRAWER =========================== */
.game-drawer {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.38s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.28s ease,
              border-color 0.28s ease;
  border-bottom: 1px solid transparent;
  background: rgba(18, 16, 14, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.game-drawer.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  border-bottom-color: rgba(148, 163, 184, 0.14);
}

.game-drawer-inner {
  overflow: hidden;
  min-height: 0;
  background: transparent;
}

.shooter-stage {
  position: relative;
  width: 100%;
  max-width: 1120px;
  height: clamp(430px, 58vh, 560px);
  margin: 0 auto;
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.shooter-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

/* The canvas takes focus for keyboard play; it is a surface, not a control. */
.shooter-canvas:focus,
.shooter-canvas:focus-visible {
  outline: none;
}

.shooter-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 0.78rem;
  color: #8892b0;
  /* Above the full-stage overlays so HUD controls stay clickable while the
     start, pause and game-over screens are visible. */
  z-index: 5;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  pointer-events: auto;
}

.hud-stat span.val {
  color: #f1f5f9;
  font-weight: 500;
}

.hud-stat.accent span.val {
  color: #b4574b;
}

.hud-lives {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.life-pip {
  width: 12px;
  height: 12px;
  display: inline-block;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.life-pip.lost {
  opacity: 0.22;
  transform: scale(0.85);
}

.hud-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.hud-btn:hover {
  color: #f1f5f9;
  border-color: rgba(241, 245, 249, 0.45);
}

.hud-btn[aria-pressed="false"] {
  color: #64748b;
  opacity: 0.72;
}

.hud-btn[aria-pressed="false"]:hover {
  color: #94a3b8;
  opacity: 1;
}

.hud-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

.hud-btn:disabled:hover {
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.22);
}

.hud-btn-icon {
  padding: 0.25rem 0.4rem;
}

.hud-btn-icon svg {
  display: block;
}

.hud-powerups {
  position: absolute;
  bottom: 0.75rem;
  left: 1.25rem;
  display: flex;
  gap: 0.6rem;
  pointer-events: none;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  z-index: 2;
}

.powerup-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  border: 1px solid rgba(180, 87, 75, 0.35);
  color: #b4574b;
  background: rgba(15, 14, 13, 0.45);
}

.shooter-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  z-index: 3;
  background: transparent;
  transition: opacity 0.2s ease;
}

.shooter-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-kicker {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #b4574b;
  margin-bottom: 0.45rem;
}

.overlay-title {
  font-size: clamp(1.5rem, 3vw, 2.05rem);
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.overlay-sub {
  font-size: 0.9rem;
  color: #8892b0;
  max-width: 420px;
  margin-bottom: 1.25rem;
}

.overlay-stats {
  display: flex;
  gap: 1.5rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  color: #94a3b8;
  margin-bottom: 1.35rem;
}

.overlay-stats strong {
  color: #f1f5f9;
  font-weight: 500;
}

.overlay-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.btn-arcade-primary {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  color: #f1f5f9;
  background: rgba(180, 87, 75, 0.14);
  border: 1px solid rgba(180, 87, 75, 0.55);
  padding: 0.55rem 1.35rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.btn-arcade-primary:hover {
  background: rgba(180, 87, 75, 0.24);
  border-color: #b4574b;
  transform: translateY(-1px);
}

.btn-arcade-secondary {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  color: #8892b0;
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.24);
  padding: 0.55rem 1.1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.btn-arcade-secondary:hover {
  color: #f1f5f9;
  border-color: rgba(241, 245, 249, 0.45);
}

.controls-hint {
  margin-top: 1.1rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  color: #64748b;
}

.touch-controls {
  display: none;
  position: absolute;
  bottom: 0.85rem;
  left: 1rem;
  right: 1rem;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 6;
}

@media (hover: none) and (pointer: coarse), (max-width: 720px) {
  .touch-controls.active {
    display: flex;
  }
  .hud-powerups {
    bottom: 4.1rem;
  }
}

.touch-dpad {
  display: flex;
  gap: 0.65rem;
  pointer-events: auto;
}

.touch-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 14, 13, 0.35);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.85rem;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn:active,
.touch-btn.pressed {
  border-color: #b4574b;
  background: rgba(180, 87, 75, 0.2);
}

.touch-btn.fire-btn {
  width: 54px;
  height: 54px;
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.touch-btn.fire-btn:active,
.touch-btn.fire-btn.pressed {
  border-color: #b4574b;
  background: rgba(180, 87, 75, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  .game-drawer {
    transition: none;
  }
}



/* =========================================================================
   HERO
   ========================================================================= */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  align-items: center;
  gap: 40px;
  width: 100%;
  max-width: var(--max);
  min-height: clamp(620px, 82vh, 840px);
  margin: 0 auto;
  padding: clamp(56px, 9vh, 96px) var(--gutter) clamp(110px, 16vh, 180px);
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 560px;
}

.hero-heading {
  margin: 0 0 22px;
  font-size: clamp(2.7rem, 5.6vw, 4.5rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 0.82em;
  margin-left: 0.1em;
  vertical-align: -0.02em;
  background: var(--accent-bright);
  animation: cursor-blink 1.15s steps(1, end) infinite;
}

@keyframes cursor-blink {
  0%,
  46% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

.hero-lead {
  max-width: 46ch;
  font-size: 1.06rem;
  line-height: 1.72;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 9px 15px 9px 13px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--accent-bright);
  background: transparent;
  border: 1px solid rgba(209, 122, 107, 0.55);
  border-radius: 4px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease,
    color 0.2s ease, transform 0.2s ease;
}

.hero-cta-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 13px;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  background: rgba(25, 22, 19, 0.65);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.18s ease, border-color 0.18s ease,
    background-color 0.18s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.hero-cta-secondary:hover {
  color: var(--text);
  border-color: rgba(240, 235, 227, 0.34);
  background: rgba(240, 235, 227, 0.06);
}

.hero-cta-secondary:active {
  transform: scale(0.97);
  transition-duration: 0.07s;
}

.hero-cta-secondary.is-copied {
  color: var(--text);
  border-color: rgba(147, 177, 220, 0.55);
  background: rgba(147, 177, 220, 0.1);
}

.hero-cta .icon {
  width: 16px;
  height: 16px;
  color: var(--accent-bright);
  transition: color 0.2s ease;
}

.hero-cta-text {
  letter-spacing: 0.002em;
}

.hero-cta-arrow {
  font-size: 0.92em;
  color: rgba(209, 122, 107, 0.75);
  transition: color 0.2s ease, transform 0.2s ease;
}

.hero-cta:hover {
  color: var(--text);
  background: rgba(180, 87, 75, 0.16);
  border-color: var(--accent-bright);
  transform: translateY(-1px);
}

.hero-cta:hover .icon,
.hero-cta:hover .hero-cta-arrow {
  color: var(--text);
}

.hero-cta:hover .hero-cta-arrow {
  transform: translate(2px, -2px);
}

.hero-cta:active {
  color: var(--text);
  background: rgba(180, 87, 75, 0.26);
  border-color: var(--accent-bright);
  transform: translateY(0);
}

.hero-cta:active .icon,
.hero-cta:active .hero-cta-arrow {
  color: var(--text);
}

/* Spider-Man lives on this transparent, floating stage. */
.spider-stage {
  position: absolute;
  inset: 0;
  /* The hero starts one game-band below the header, plus the 1px transparent
     border of the closed game drawer. Pulling the stage up by both puts its top
     edge — the canvas origin, and therefore the web's apex — flush with the
     navbar's bottom edge. */
  top: calc((var(--game-band) + 1px) * -1);
  z-index: 1;
  pointer-events: none;
  background: transparent;
}

.spider-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

/* Keep the hero spiderweb confined below the game drawer while it is open or closing. */
body.game-open .spider-stage,
body.game-closing .spider-stage {
  top: 0;
}

body.game-open .pixel-signature {
  opacity: 0;
}

/* =========================================================================
   EXTERNAL LINKS — one colour for every highlighted link, weight + underline
   carry the emphasis instead of separate hues.
   ========================================================================= */

.link,
.text-link {
  color: var(--link);
  font-weight: 600;
  border-bottom: 1px solid var(--link-soft);
  transition: color 0.18s ease, border-color 0.18s ease;
}

.link:hover,
.link:focus-visible,
.text-link:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

/* =========================================================================
   SECTIONS — folder / file visual language
   ========================================================================= */

.section {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(68px, 10vh, 104px) var(--gutter);
  border-top: 1px solid var(--line);
}

.section-head {
  margin-bottom: clamp(32px, 4.5vw, 48px);
}

.section-path {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.section-path .sep {
  color: rgba(240, 235, 227, 0.28);
}

.section-folder {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(1.5rem, 3.2vw, 2.15rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

.section-folder .slash {
  color: var(--accent-bright);
}

.section-sub {
  margin: 12px 0 0;
  padding-left: 2px;
  font-size: 0.98rem;
  color: var(--muted);
}

/* Generic file-like label */
.file-tab {
  display: inline-block;
  margin: 0 0 16px;
  padding: 3px 10px;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(240, 235, 227, 0.03);
  border: 1px solid var(--line);
  border-bottom-color: rgba(240, 235, 227, 0.18);
  border-radius: 6px 6px 3px 3px;
}

/* About */

.about-body {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
  align-items: center;
  gap: clamp(30px, 5vw, 60px);
}

.about-photo {
  position: relative;
  margin: 0;
  width: 100%;
  max-width: 320px;
  justify-self: end;
  padding: 7px 7px 30px;
  background-color: var(--bg-elevated);
  background-image: linear-gradient(
    150deg,
    rgba(240, 235, 227, 0.045),
    transparent 58%
  );
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.34);
}

.about-photo::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 7px;
  right: 7px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: 0.65;
  border-radius: 2px;
  pointer-events: none;
}

.about-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1084 / 1224;
  object-fit: cover;
  object-position: 50% 24%;
  border-radius: 9px;
  filter: saturate(0.95) contrast(1.02);
}

.about-photo-caption {
  position: absolute;
  left: 16px;
  bottom: 5px;
}

.about-photo-caption .file-tab {
  margin: 0;
  padding: 2px 8px;
  font-size: 0.62rem;
  border-color: transparent;
  color: var(--muted);
}

.about-copy {
  padding-left: clamp(0px, 2vw, 24px);
  border-left: 1px solid var(--line);
}

.about-lead {
  font-size: 1.08rem;
  line-height: 1.72;
  color: var(--text);
}

.about-body p + p {
  margin-top: 1.05em;
}

.interest-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.interest-list li {
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

/* Journey */

.journey-ribbon {
  position: relative;
  width: 100%;
  overflow: hidden;
  margin: -10px 0 28px;
  padding-block: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.journey-ribbon-track {
  display: flex;
  align-items: center;
  gap: 18px;
  width: max-content;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
  will-change: transform;
  animation: journey-marquee 26s linear infinite;
}

.journey-ribbon-track .ribbon-sep {
  color: var(--accent-bright);
  opacity: 0.75;
}

@keyframes journey-marquee {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

.journey-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.journey-card {
  position: relative;
  padding: clamp(22px, 3vw, 30px);
  background-color: var(--bg-elevated);
  background-image: linear-gradient(
    155deg,
    rgba(240, 235, 227, 0.035),
    transparent 55%
  );
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.25s ease,
    background-color 0.25s ease,
    box-shadow 0.28s ease;
}

/* No fixed viewport takeover — Achievements expand in-place within .chapter-ladder */

.journey-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 22px;
  width: 46px;
  height: 2px;
  background: var(--accent);
  opacity: 0.7;
  transition: width 0.3s ease, opacity 0.25s ease;
}

.journey-card:hover,
.journey-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(209, 122, 107, 0.4);
  background-color: var(--bg-soft);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24);
}

.journey-card:hover::before,
.journey-card:focus-visible::before {
  width: 72px;
  opacity: 1;
}

.journey-card:focus-visible {
  outline-offset: 3px;
}

.journey-step {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-bright);
}

.js .journey-fill-title {
  color: transparent;
  -webkit-text-stroke: 0.85px rgba(240, 235, 227, 0.72);
  background-image: linear-gradient(
    90deg,
    var(--text) 0%,
    var(--text) 50%,
    transparent 50%
  );
  background-size: 200% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  transition: background-position 2.2s cubic-bezier(0.22, 1, 0.36, 1) 0.15s,
    -webkit-text-stroke-color 1.2s ease 0.95s;
}

.js .journey-fill-title.is-filled {
  background-position: 0% 0;
  -webkit-text-stroke-color: rgba(240, 235, 227, 0.12);
}

.js .journey-card.fade-in {
  transition: opacity 1.15s ease,
    transform 1.15s cubic-bezier(0.22, 1, 0.36, 1);
}

.js .journey-card:not(.is-tracked) .file-tab {
  letter-spacing: 0em;
}

.js .journey-card:not(.is-tracked) p:not(.journey-step) {
  letter-spacing: -0.018em;
}

.js .journey-card .file-tab,
.js .journey-card p:not(.journey-step) {
  transition: letter-spacing 2.1s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}

.js .journey-card.is-tracked .file-tab {
  letter-spacing: 0.04em;
}

.js .journey-card.is-tracked p:not(.journey-step) {
  letter-spacing: 0em;
}

.journey-card h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  line-height: 1.35;
}

.journey-card p {
  font-size: 0.93rem;
  line-height: 1.65;
}

/* Projects */

.tree-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 24px;
  margin: -22px 0 26px;
  padding-left: 16px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--dim);
}

.tree-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tree-item::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 0.72em;
  width: 7px;
  height: 1px;
  background: rgba(240, 235, 227, 0.22);
}

.tree-folder {
  color: var(--muted);
}

.tree-branch {
  color: rgba(240, 235, 227, 0.3);
}

.tree-leaf {
  color: var(--text);
  opacity: 0.72;
}

.project-stack {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.project-card {
  position: sticky;
  top: calc(var(--header-h) + 28px);
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  align-items: center;
  gap: clamp(22px, 3vw, 36px);
  padding: clamp(22px, 2.8vw, 32px);
  background-color: var(--bg-elevated);
  background-image: linear-gradient(
    135deg,
    rgba(240, 235, 227, 0.03),
    transparent 48%
  );
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.34),
    0 28px 60px rgba(0, 0, 0, 0.26);
  transform-origin: center top;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.28s ease;
}

.project-card.is-stacked {
  transform: scale(var(--stack-scale, 1));
  filter: brightness(var(--stack-brightness, 1));
}

.project-card:nth-child(2) {
  top: calc(var(--header-h) + 40px);
}

.project-card:nth-child(3) {
  top: calc(var(--header-h) + 52px);
}

.project-info {
  min-width: 0;
}

/* Path line: projects/<name> — keeps the file-explorer language. */
.project-path {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  color: var(--dim);
}

.path-num {
  padding-right: 9px;
  margin-right: 3px;
  color: var(--accent-bright);
  border-right: 1px solid var(--line-strong);
}

.path-seg {
  color: var(--dim);
}

.path-file {
  color: var(--muted);
  font-weight: 500;
}

/* Folder hierarchy chip — CodeAIs/ └─ engano/ */
.project-tree {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  margin: 0 0 14px;
  padding: 7px 13px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.01em;
  background: rgba(240, 235, 227, 0.035);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tree-root {
  color: var(--muted);
}

.tree-elbow {
  color: var(--accent-bright);
}

.tree-current {
  color: var(--text);
  font-weight: 500;
}

/* OJAS contributions sit together inside one project. */
.project-contrib {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 16px;
}

.contrib {
  min-width: 0;
  padding-left: 12px;
  border-left: 1px solid var(--line-strong);
}

.contrib-label {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  color: var(--accent-bright);
}

.contrib p:last-child {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
}

.project-card h3 {
  margin: 0 0 8px;
  font-size: clamp(1.28rem, 2.2vw, 1.55rem);
  line-height: 1.24;
}

.project-role {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.project-points {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.project-points li {
  position: relative;
  padding-left: 18px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--muted);
}

.project-points li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.project-copy {
  max-width: 56ch;
  margin-bottom: 16px;
  font-size: 0.93rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
}

.tag-list li {
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.01em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-bottom: 2px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--link);
  border-bottom: 1px solid var(--link-soft);
  transition: color 0.18s ease, border-color 0.18s ease;
}

.project-link:hover,
.project-link:focus-visible {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

/* Reserved, fixed-ratio image area — identical on every card. */
.project-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  margin: 0;
  overflow: hidden;
  background-color: #161311;
  background-image: radial-gradient(
      circle at 78% 18%,
      rgba(180, 87, 75, 0.2),
      transparent 52%
    ),
    linear-gradient(155deg, rgba(240, 235, 227, 0.05), transparent 60%);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.project-media::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: repeating-linear-gradient(
    115deg,
    rgba(240, 235, 227, 0.05) 0,
    rgba(240, 235, 227, 0.05) 1px,
    transparent 1px,
    transparent 22px
  );
  opacity: 0.45;
  pointer-events: none;
}

.project-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(16px, 2.4vw, 24px);
  transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.project-mark {
  width: 64px;
  height: 64px;
  margin-bottom: auto;
  object-fit: contain;
  opacity: 0.9;
}

.fallback-kicker {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: var(--accent-bright);
}

.fallback-title {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: rgba(240, 235, 227, 0.88);
}

.fallback-rule {
  width: 40px;
  height: 1px;
  margin-top: 14px;
  background: var(--accent);
}

/* Dedicated cover region: the real project visual fills it, cropped to the
   card's fixed ratio so OJAS and Engano always match. */
.project-cover {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 45%;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.project-card:hover .project-cover,
.project-card:focus-within .project-cover,
.project-card:active .project-cover,
.project-card:hover .project-fallback,
.project-card:focus-within .project-fallback,
.project-card:active .project-fallback {
  transform: scale(1.015);
}

.project-stack.has-focus .project-card:not(:focus-within):not(.is-touch-focused) {
  opacity: 0.8;
  filter: blur(0.8px);
}

/* The Engano mark is on a pale field; a soft inner shade keeps it from
   glaring against the dark card. */
.project-media--light::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(18, 16, 14, 0.06),
    transparent 40%,
    rgba(18, 16, 14, 0.14)
  );
  pointer-events: none;
}

.media-caption {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 4;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: rgba(240, 235, 227, 0.55);
  background: rgba(18, 16, 14, 0.42);
  border-radius: 4px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* =========================================================================
   ACHIEVEMENTS — chapter ladder
   ========================================================================= */

.chapter-ladder {
  position: relative;
  border-top: 1px solid var(--line);
}

.chapter {
  position: relative;
  border-bottom: 1px solid var(--line);
  border-radius: 12px;
  transition: background-color 0.36s ease,
    border-color 0.36s ease,
    box-shadow 0.36s ease,
    margin 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    padding 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.38s ease,
    filter 0.38s ease;
}

.chapter.is-open {
  margin-block: 18px;
  padding: 6px 10px 10px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.3);
}

.chapter.is-open::before {
  opacity: 0.35;
}

/* No blur or opacity reduction inside the Achievements section —
   every card, number, icon and label stays fully sharp regardless of
   which chapter is expanded. Only content outside the section is dimmed. */

/* When any Achievement is open, blur/dim page sections (navbar stays sharp) */
#home,
#about,
#journey,
#projects,
.site-footer {
  transition: filter 0.4s ease, opacity 0.4s ease;
}

body.chapter-open #home,
body.chapter-open #about,
body.chapter-open #journey,
body.chapter-open #projects,
body.chapter-open .site-footer {
  opacity: 0.6;
  filter: blur(2.5px);
}

/* subtle ladder spine */
.chapter::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 26px;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(240, 235, 227, 0.14) 12%,
    rgba(240, 235, 227, 0.14) 88%,
    transparent
  );
  pointer-events: none;
}

.chapter-toggle {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 22px 20px 22px 0;
  font-family: inherit;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.chapter-toggle:hover {
  background: rgba(240, 235, 227, 0.025);
}

.chapter-num {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: 9px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent-bright);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transition: border-color 0.2s ease, background-color 0.2s ease,
    opacity 0.38s ease, filter 0.38s ease;
}

.chapter-toggle[aria-expanded="true"] .chapter-num {
  color: var(--bg);
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}

.chapter-title {
  font-size: 1.14rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.chapter-hint {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  color: var(--dim);
  white-space: nowrap;
  transition: opacity 0.38s ease, filter 0.38s ease;
}

.chapter-mark {
  position: relative;
  width: 14px;
  height: 14px;
  justify-self: end;
  margin-right: 4px;
  color: var(--muted);
  transition: color 0.2s ease, opacity 0.38s ease, filter 0.38s ease;
}

.chapter-toggle[aria-expanded="true"] .chapter-mark {
  color: var(--accent-bright);
}

.chapter-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.46s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.36s ease;
}

.chapter-panel.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
}

.chapter-panel-inner {
  min-height: 0;
  overflow: hidden;
}

.chapter-body {
  max-width: 78ch;
  margin: 0 0 32px;
  padding: 8px 20px 28px 68px;
  border-left: 1px solid transparent;
}

.chapter-kicker {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  color: var(--accent-bright);
}

.chapter-body h4 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.chapter-body p {
  font-size: 0.94rem;
  line-height: 1.68;
}

.chapter-subhead {
  margin-top: 26px !important;
}

/* Certificates: text left, cover preview right. Both file formats share the
   exact same frame, aspect ratio and crop treatment. */
.chapter-body--split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
  gap: clamp(24px, 4vw, 46px);
  max-width: 94ch;
}

.chapter-body--split .chapter-text {
  min-width: 0;
}

.certificate-slot {
  margin: 2px 0 0;
  width: 100%;
  max-width: 320px;
  justify-self: end;
}

.certificate-file {
  display: block;
  padding: 7px;
  overflow: hidden;
  background: #f4f1ec;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  transition: border-color 0.2s ease, transform 0.2s ease,
    box-shadow 0.2s ease;
}

/* One fixed cover ratio for every certificate, whatever the source format. */
.certificate-cover {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 32%;
  background: #f4f1ec;
  border-radius: 7px;
  transition: transform 0.35s ease;
}

.certificate-file:hover,
.certificate-file:focus-visible,
.certificate-file:active {
  border-color: var(--link);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
}

.certificate-file:hover .certificate-cover,
.certificate-file:focus-visible .certificate-cover,
.certificate-file:active .certificate-cover {
  transform: scale(1.02);
}

.certificate-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--dim);
}

.certificate-open {
  color: var(--link);
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.certificate-open:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

/* =========================================================================
   FOOTER
   ========================================================================= */

.site-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 46px var(--gutter) 58px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer-sign {
  margin: 0 0 7px;
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--text);
}

.footer-note {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.69rem;
  letter-spacing: 0.01em;
  color: var(--dim);
  text-wrap: balance;
}

/* =========================================================================
   PIXEL / WEB SIGNATURE — bottom right, decorative only
   ========================================================================= */

/* Density gradient anchored on the bottom-right corner: pixels thin out as
   the pattern climbs away from it. Fixed so it always reads as a signature
   in the lower corner of the viewport. */
.pixel-signature {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 0;
  width: clamp(250px, 30vw, 430px);
  height: auto;
  opacity: 0.85;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.24s ease;
}

/* =========================================================================
   PAGE LOADER (Chasing Squares), STATUS TOAST & 404 PAGE
   ========================================================================= */

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

html.page-loading .page-loader {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.loader-squares {
  position: relative;
  width: 34px;
  height: 34px;
}

.loader-squares span {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  background: var(--accent-bright);
  animation: chase-square 1.2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.loader-squares span:nth-child(1) {
  animation-delay: 0s;
}

.loader-squares span:nth-child(2) {
  background: var(--text);
  animation-delay: -0.3s;
}

.loader-squares span:nth-child(3) {
  animation-delay: -0.6s;
}

.loader-squares span:nth-child(4) {
  background: rgba(240, 235, 227, 0.55);
  animation-delay: -0.9s;
}

@keyframes chase-square {
  0%, 100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(21px, 0);
  }
  50% {
    transform: translate(21px, 21px);
  }
  75% {
    transform: translate(0, 21px);
  }
}

.status-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 220;
  transform: translate(-50%, 10px);
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text);
  background: rgba(25, 22, 19, 0.94);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.status-toast.is-success {
  border-color: rgba(147, 177, 220, 0.55);
}

.status-toast.is-error {
  border-color: rgba(209, 122, 107, 0.75);
}

.error-main {
  position: relative;
  width: 100%;
  max-width: var(--max);
  min-height: calc(100svh - var(--nav-h) - 140px);
  margin: 0 auto;
  padding: clamp(56px, 10vh, 110px) var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  align-items: center;
  gap: clamp(32px, 6vw, 72px);
}

.error-copy-col {
  max-width: 520px;
}

.error-code {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.error-heading {
  margin: 0 0 16px;
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.error-copy {
  max-width: 40ch;
  margin: 0 0 28px;
  font-size: 1rem;
  color: var(--muted);
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.error-visual-col {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
}

.error-thread {
  position: absolute;
  top: -120px;
  left: 50%;
  width: 1px;
  height: 190px;
  background: linear-gradient(to bottom, rgba(240, 235, 227, 0.12), rgba(240, 235, 227, 0.45));
  transform: translateX(-50%);
}

.error-emblem {
  position: relative;
  z-index: 1;
  color: var(--text);
  animation: error-sway 5.5s ease-in-out infinite;
  transform-origin: top center;
}

@keyframes error-sway {
  0%, 100% {
    transform: rotate(-2deg);
  }
  50% {
    transform: rotate(2deg);
  }
}

@media (max-width: 780px) {
  .error-main {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .error-visual-col {
    order: -1;
    min-height: 160px;
  }

  .error-thread {
    top: -64px;
    height: 110px;
  }
}

/* =========================================================================
   MOTION
   ========================================================================= */

.js body {
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

html.page-loading body {
  opacity: 0;
}

.js .fade-in {
  opacity: 0;
  transform: translateY(16px);
  clip-path: inset(0 0 12% 0 round 12px);
  transition: opacity 0.78s ease,
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    clip-path 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.js .fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
  clip-path: inset(0 0 0 0 round 12px);
}

.js .fade-in.is-revealed-done {
  clip-path: none;
  transform: none;
}

/* Mask-based reveal for photographs and project covers */
.js .reveal-mask img {
  clip-path: inset(100% 0 0 0 round 9px);
  transform: scale(1.04);
  transition: clip-path 0.95s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1.05s cubic-bezier(0.22, 1, 0.36, 1);
}

.js .reveal-mask.is-visible img {
  clip-path: inset(0 0 0 0 round 9px);
  transform: scale(1);
}

.js .project-card.fade-in .project-media {
  clip-path: inset(0 0 100% 0 round 10px);
  transition: clip-path 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.08s;
}

.js .project-card.fade-in.is-visible .project-media {
  clip-path: inset(0 0 0 0 round 10px);
}

/* Immediate Doherty-threshold press feedback */
.icon-link:active,
.game-toggle:active,
.game-info-toggle:active,
.project-link:active,
.chapter-toggle:active .chapter-num,
.certificate-file:active {
  transform: scale(0.95);
  transition-duration: 0.07s;
}

/* Line-by-line reveal (lines are produced by script.js) */

.reveal-lines .line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.14em;
  margin-bottom: -0.14em;
}

.reveal-lines .line-inner {
  display: block;
  transform: translateY(115%);
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-lines.is-revealed .line-inner {
  transform: translateY(0);
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 1100px) {
  .nav-links {
    gap: 18px;
  }

  .navbar {
    gap: 18px;
  }
}

@media (max-width: 980px) {
  :root {
    --nav-h: 96px;
    --game-band: 46px;
  }

  html {
    scroll-padding-top: calc(var(--nav-h) + var(--game-band) + 16px);
  }

  .navbar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--nav-h);
    padding-block: 10px;
    row-gap: 6px;
  }

  .brand {
    flex: 1;
  }

  .nav-links {
    order: 3;
    width: 100%;
    gap: 18px;
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    white-space: nowrap;
  }

  .hero {
    /* Tall enough that the full 150px strand can hang from the web knot with
       Spider-Man upside down, even on short viewports. */
    --stage-h: clamp(460px, 60vh, 560px);
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0;
    min-height: 0;
    /* Reserve the web stage's height at the top of the hero so the copy starts
       below the hanging character instead of under the web. */
    padding-top: calc(var(--stage-h) - var(--game-band) + 16px);
    padding-bottom: 0;
  }

  .hero-content {
    max-width: 640px;
    padding-bottom: 16px;
  }

  .hero-heading {
    font-size: clamp(2.4rem, 8vw, 3.5rem);
  }

  /* Stacked layout: the web still hangs from the navbar at the top of the
     hero, above the copy, spanning the full width. */
  .spider-stage {
    position: absolute;
    inset: auto;
    top: calc((var(--game-band) + 1px) * -1);
    left: 0;
    right: 0;
    width: 100%;
    height: var(--stage-h);
    margin: 0;
    pointer-events: auto;
  }

  .about-body {
    grid-template-columns: minmax(0, 0.62fr) minmax(0, 1.38fr);
    gap: 30px;
  }

  .about-photo {
    max-width: 260px;
    justify-self: start;
  }

  .journey-grid {
    grid-template-columns: 1fr;
  }

  .project-card {
    top: calc(var(--header-h) + 14px);
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .project-card:nth-child(2) {
    top: calc(var(--header-h) + 24px);
  }

  .project-card:nth-child(3) {
    top: calc(var(--header-h) + 34px);
  }

  .project-media {
    max-width: 620px;
  }

  /* Stacked cards lead with the cover, then title and details. */
  .project-card--cover .project-media {
    order: -1;
  }

  .chapter-toggle {
    grid-template-columns: 54px minmax(0, 1fr) 16px;
  }

  .chapter-hint {
    display: none;
  }

  .chapter-body {
    padding-left: 20px;
  }

  .chapter-body--split {
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 24px;
  }

  .certificate-slot {
    max-width: 260px;
  }
}

/* Tablet portrait: the photo and certificate move above/below their text. */
@media (max-width: 860px) {
  .about-body {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .about-photo {
    max-width: 240px;
  }

  .about-copy {
    padding-left: 0;
    border-left: 0;
  }

  .chapter-body--split {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .certificate-slot {
    justify-self: start;
    max-width: 320px;
  }
}

@media (max-width: 720px) {
  :root {
    --nav-h: 92px;
    --gutter: 18px;
  }

  .navbar {
    padding-block: 8px 6px;
    row-gap: 2px;
  }

  .brand {
    font-size: 0.9rem;
  }

  /* Compact 5-column nav: Home, About, Journey, Projects, Achievements. */
  .nav-links {
    display: grid;
    grid-template-columns: 0.78fr 0.92fr 1.05fr 1.05fr 1.55fr;
    gap: 0;
    padding-top: 4px;
    overflow: visible;
  }

  .nav-links a {
    padding-block: 9px;
    font-size: clamp(0.68rem, 3.1vw, 0.8rem);
    text-align: center;
    padding-inline: 2px;
  }

  .nav-links a::after {
    left: 16%;
    right: 16%;
  }

  .hero {
    --stage-h: clamp(460px, 54vh, 500px);
    padding-top: calc(var(--stage-h) - var(--game-band) + 16px);
  }

  .hero-heading {
    font-size: clamp(2.05rem, 9.4vw, 2.9rem);
  }

  .hero-lead {
    font-size: 1rem;
  }

  .hero-actions {
    margin-top: 22px;
  }

  .hero-cta {
    gap: 9px;
    padding: 10px 15px;
    font-size: 0.8rem;
  }

  .section {
    padding-block: clamp(52px, 9vw, 68px);
  }

  .about-photo {
    max-width: 220px;
  }

  .about-lead {
    font-size: 1.02rem;
  }

  .project-card {
    padding: 18px;
    gap: 18px;
  }

  .project-contrib {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .project-media {
    max-width: 100%;
  }

  .project-tree {
    padding: 6px 10px;
    font-size: 0.66rem;
  }

  .chapter-toggle {
    grid-template-columns: 48px minmax(0, 1fr) 14px;
    gap: 10px;
    padding-block: 18px;
  }

  .chapter::before {
    left: 23px;
  }

  .chapter-title {
    font-size: 1.04rem;
  }

  .chapter-body {
    padding-right: 0;
    padding-left: 12px;
    margin-bottom: 26px;
  }

  .chapter-body--split {
    gap: 22px;
  }

  .certificate-slot {
    max-width: min(100%, 320px);
  }

  .site-footer {
    padding: 38px var(--gutter) 52px;
  }

  .pixel-signature {
    width: clamp(210px, 58vw, 320px);
    opacity: 0.7;
  }

  /* Game Mode */
  .shooter-stage {
    height: clamp(390px, 62vh, 490px);
  }

  /* The mobile HUD wraps to two rows, so the panel clears them both. */
  .game-controls-panel {
    top: calc(100% + 76px);
  }

  .shooter-hud {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 0.6rem 0.75rem;
  }

  .hud-group {
    gap: 0.7rem;
  }

  .hud-stat {
    font-size: 0.68rem;
  }

  .hud-btn {
    padding: 0.2rem 0.42rem;
    font-size: 0.64rem;
  }
}

@media (max-width: 560px) {
  :root {
    --nav-h: 88px;
  }

  .nav-social {
    gap: 0;
  }

  .icon-link {
    width: 32px;
    height: 32px;
  }

  .game-toggle {
    height: 32px;
  }

  .hero {
    --stage-h: clamp(450px, 54vh, 480px);
    padding-top: calc(var(--stage-h) - var(--game-band) + 16px);
  }

  .hero-heading {
    font-size: clamp(1.8rem, 8.8vw, 2.4rem);
  }

  .hero-lead {
    font-size: 0.96rem;
    line-height: 1.68;
  }

  .hero-actions {
    margin-top: 22px;
  }

  .hero-cta {
    font-size: 0.76rem;
    padding: 9px 14px;
    gap: 8px;
  }

  .section {
    padding-block: 54px;
  }

  .about-photo {
    max-width: 200px;
  }

  .project-card {
    padding: 16px;
    gap: 16px;
    border-radius: 12px;
  }

  .project-card h3 {
    font-size: 1.18rem;
  }

  .tree-list {
    margin-top: -16px;
    margin-bottom: 18px;
    gap: 6px 18px;
  }

  .chapter-toggle {
    grid-template-columns: 42px minmax(0, 1fr) 12px;
    gap: 8px;
    padding-block: 16px;
  }

  .chapter::before {
    left: 20px;
  }

  .chapter-num {
    width: 28px;
    height: 28px;
    margin-left: 5px;
    font-size: 0.64rem;
  }

  .certificate-slot {
    max-width: min(100%, 320px);
  }
}

/* Very narrow phones: keep all five nav items readable without overflow. */
@media (max-width: 380px) {
  :root {
    --gutter: 16px;
  }

  .nav-links a {
    font-size: 0.65rem;
  }

  .hero-actions {
    margin-top: 20px;
  }

  .hero-cta {
    font-size: 0.73rem;
    padding: 9px 13px;
    gap: 7px;
  }
}

/* Short landscape phones: keep the arcade and its touch controls inside the
   viewport without hiding the Game Mode launcher below the navbar. */
@media (max-height: 600px) and (max-width: 980px) {
  .shooter-stage {
    height: clamp(300px, calc(100svh - var(--header-h) - 24px), 430px);
  }

  .project-card {
    position: relative;
    top: auto !important;
    height: auto !important;
  }
}

/* Touch: never leave a card stuck in its hover lift after a tap,
   while preserving tactile active/focus feedback. */
@media (hover: none) {
  .journey-card:hover {
    transform: none;
    border-color: var(--line);
    background-color: var(--bg-elevated);
    box-shadow: none;
  }

  .journey-card:hover::before {
    width: 46px;
    opacity: 0.7;
  }

  .journey-card:active,
  .journey-card:focus-visible {
    transform: translateY(-4px);
    border-color: rgba(209, 122, 107, 0.4);
    background-color: var(--bg-soft);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24);
  }

  .journey-card:active::before,
  .journey-card:focus-visible::before {
    width: 72px;
    opacity: 1;
  }

  .project-card:hover .project-cover,
  .project-card:hover .project-fallback {
    transform: none;
  }

  .project-card:active .project-cover,
  .project-card:focus-within .project-cover,
  .project-card:active .project-fallback,
  .project-card:focus-within .project-fallback {
    transform: scale(1.015);
  }
}

/* =========================================================================
   REDUCED MOTION
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .cursor {
    animation: none;
    opacity: 1;
  }

  .js body {
    transition: none;
  }

  .js .fade-in,
  .js .reveal-mask img,
  .js .project-card.fade-in .project-media {
    opacity: 1;
    transform: none;
    clip-path: none;
    transition: none;
  }

  .icon-swap-layer,
  .chapter {
    transition: none !important;
    filter: none !important;
  }

  .project-stack.has-focus .project-card:not(:focus-within):not(.is-touch-focused) {
    filter: none;
  }

  body.chapter-open #home,
  body.chapter-open #about,
  body.chapter-open #journey,
  body.chapter-open #projects,
  body.chapter-open .site-footer {
    filter: none;
    opacity: 1;
    transition: none;
  }

  .reveal-lines .line {
    overflow: visible;
  }

  .reveal-lines .line-inner {
    transform: none;
    transition: none;
  }

  [data-parallax] {
    transform: none !important;
    will-change: auto;
  }

  .journey-ribbon-track,
  .js .journey-fill-title,
  .js .journey-card .file-tab,
  .js .journey-card p:not(.journey-step),
  .error-emblem,
  .page-loader,
  .loader-squares span,
  .status-toast,
  .project-card,
  .game-drawer,
  .game-toggle,
  .game-info-toggle,
  .hero-cta,
  .chapter-panel,
  .project-cover,
  .journey-card,
  .journey-card::before,
  .certificate-file,
  .certificate-cover {
    transition: none;
  }

  .project-card:hover .project-cover {
    transform: none;
  }

  .journey-card:hover,
  .journey-card:focus-visible {
    transform: none;
  }

  .journey-card:hover::before,
  .journey-card:focus-visible::before {
    width: 46px;
  }

  .certificate-file:hover .certificate-cover,
  .certificate-file:focus-visible .certificate-cover {
    transform: none;
  }
}
