/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
* {
  box-sizing: border-box;
}

/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ======================================
   MY STYLES
====================================== */

/* Fonts */
@font-face {
  font-family: "BobbySoft";
  src: url("fonts/bobby-jones-soft.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "BobbySoftOutline";
  src: url("fonts/bobby-jones-soft-outline.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "AccentScript";
  src: url("fonts/JimmyScript-Rg.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Design tokens */
:root {
  --bg:      #f6f1e8;
  --text:    #0b0b0e;
  --muted:   rgba(11, 11, 14, .70);
  --border:  rgba(11, 11, 14, .14);
  --surface: rgba(255, 255, 255, .50);
  --accent:  #ff4d5a;

  --max:    1200px;
  --pad:    clamp(20px, 6vw, 84px);
  --rail:   92px;
  --radius: 20px;

  --font-display:         "BobbySoft", "Arial Black", "Trebuchet MS", sans-serif;
  --font-display-outline: "BobbySoftOutline", "Arial Black", "Trebuchet MS", sans-serif;
  --font-body:            "Inter", system-ui, -apple-system, sans-serif;
  --font-accent:          "AccentScript", "Brush Script MT", "Segoe Script", cursive;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:      #0b0b0e;
  --text:    #f6f1e8;
  --muted:   rgba(246, 241, 232, .72);
  --border:  rgba(246, 241, 232, .16);
  --surface: rgba(255, 255, 255, .06);
  --accent:  #ff4d5a;

  color-scheme: dark;
}


/* Base */
html {
  /* FIX: smooth scrolling for anchor nav links */
  scroll-behavior: smooth;
  /* (prefers-reduced-motion override is handled by the global reset block above) */
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
  /* Prevent any absolutely-positioned element from creating horizontal scroll.
     overflow-x: clip (unlike hidden) does not create a new scroll container,
     so position:sticky on the mobile rail still works correctly. */
  overflow-x: clip;
}

/* FIX: .sr-only replaces inline "position:absolute; left:-9999px" on the template textarea */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link — keyboard users can jump past the nav */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--bg);
  color: var(--text);
  padding: 10px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: top .1s ease;
}
.skip-link:focus { top: 0; }

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
a:hover { border-bottom-color: var(--accent); }

/* FIX: restore underline on focus for non-card links so keyboard users retain affordance */
a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

/* h3 base transform-style:  was missing, causing timeline/card headings to look like body text */
h3 {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

/* Main frame */
#main {
  margin-left: var(--rail);
}

/* ======================================
   RAIL
====================================== */

#rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  border-right: 1px solid var(--border);
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 12px;
  z-index: 50;
}

#railBrand {
  font-family: var(--font-display);
  letter-spacing: 0.5px;
  border-bottom: none;
  font-size: 1.2rem;
  width: 100%;
  text-align: center;
}

/* #railLinks is a <ul> — Meyer reset handles list/margin/padding */
#railLinks {
  display: grid;
  gap: 14px;
}

/* Style the <li> children transparently so the grid still works */
#railLinks li {
  display: contents;
}

#railLinks a {
  display: grid;
  gap: 6px;
  padding: 12px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
}

#railLinks a span[data-railnum] {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

#railLinks a span[data-raillabel] {
  font-size: 0.9rem;
}

#railLinks a[data-active="true"] {
  border-color: var(--border);
  background: var(--surface);
}

#themeToggle {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.85rem;
}
#themeToggle:hover {
  border-color: var(--accent);
}

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

#hero {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(70px, 10vw, 130px) var(--pad) clamp(80px, 12vw, 170px);
  /* Removed overflow:hidden so the illustration isn't clipped */
}

#heroMeta {
  display: flex;
  gap: 14px;
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 26px;
}

#heroTitle {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6.5vw, 6rem);
  /* FIX: removed duplicate line-height declaration (was 1.0 then 0.9) */
  line-height: 0.9;
  margin: 0 0 18px;
  letter-spacing: 0.5px;
  max-width: 12ch;
}

#line1 {
  display: block;
  font-size: 2.2rem;
  letter-spacing: 0.04em;
}

#line2 {
  display: block;
  font-family: var(--font-display-outline);
  font-size: clamp(4rem, 12vw, 9rem);
  margin-left: -0.05em;
}

#line3 {
  display: block;
  font-size: clamp(3rem, 8vw, 6rem);
}

#lead {
  margin: 0 0 12px;
  font-size: 1.18rem;
  color: var(--muted);
  max-width: 60ch;
}

#accentLine {
  margin: 10px 0 0;
  font-family: var(--font-accent);
  font-size: 5rem;
}

#heroArt {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(250px, 42vw, 450px);
  opacity: 1;
  filter: none;
  pointer-events: none;
}

/* ======================================
   SECTION STRUCTURE
====================================== */

#work, #about, #contact {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(70px, 10vw, 140px) var(--pad);
  position: relative;
}

#workHeader, #aboutHeader, #contactHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  margin-bottom: 28px;
}

h2 {
  font-family: var(--font-display);
  font-size: clamp(2.0rem, 3.2vw, 3rem);
  margin: 0;
}

h2 span[data-sectionnum] {
  display: inline-block;
  margin-right: 10px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  opacity: 0.7;
  transform: translateY(-6px);
}

/* workArt — full colour, larger, no filter */
#workArt {
  width: clamp(220px, 26vw, 380px);
  opacity: 1;
  filter: none;
  pointer-events: none;
  /* Pivot from the anchor ring at the very top */
  transform-origin: top center;
  will-change: transform;
}

/* Pendulum swing with natural damping — replays on every section mouseenter */
@keyframes anchor-swing {
  0%   { transform: rotate(  0deg); }
  18%  { transform: rotate(-12deg); }
  38%  { transform: rotate(  8deg); }
  54%  { transform: rotate( -5deg); }
  68%  { transform: rotate(  3deg); }
  80%  { transform: rotate( -1.5deg); }
  100% { transform: rotate(  0deg); }
}

#workArt.swinging {
  animation: anchor-swing 1.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

@media (prefers-reduced-motion: reduce) {
  #workArt { animation: none; }
}

/* aboutArt / contactArt stay as decorative greyscale */
#aboutArt, #contactArt {
  width: clamp(150px, 18vw, 260px);
  opacity: 0.09;
  filter: grayscale(1) contrast(1.2);
  pointer-events: none;
}

/* ======================================
   WORK GRID
====================================== */

#workGrid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

a[data-card] {
  grid-column: span 6;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  background: transparent;
  overflow: hidden;
  transition: transform .2s ease, background-color .2s ease, border-color .2s ease, color .2s ease;
}

/* FIX: h3 inside cards — override global h3 for correct sizing */
a[data-card] h3 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

a[data-card] p {
  margin: 0 0 14px;
  color: var(--muted);
  max-width: 60ch;
}

div[data-tags] {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

span[data-tag] {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

img[data-watermark] {
  position: absolute;
  right: -6%;
  bottom: -12%;
  width: 60%;
  opacity: 0;
  transform: rotate(-8deg);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}

a[data-card]:hover {
  transform: translateY(-3px);
  background: var(--accent);
  /* Dark text on red: #0b0b0e on #ff4d5a = 4.7:1, passes WCAG AA */
  color: #0b0b0e;
  border-color: var(--accent);
}

a[data-card]:hover p {
  color: rgba(11, 11, 14, .75);
}

a[data-card]:hover span[data-tag] {
  border-color: rgba(11, 11, 14, .25);
}

a[data-card]:hover img[data-watermark] {
  opacity: 0.18;
  transform: rotate(-4deg) scale(1.02);
}

/* ======================================
   ABOUT + CONTACT BODY
====================================== */

#aboutBody, #contactBody {
  max-width: 70ch;
}

#aboutBody p, #contactBody p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 1.05rem;
}

#emailLink {
  display: inline-block;
  margin-top: 6px;
  /* FIX: font-weight 650 is not a valid value — Inter has no 650 axis */
  font-weight: 700;
  border-bottom: 1px solid transparent;
}

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

#footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 30px var(--pad) 70px;
  color: var(--muted);
}

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

@media (max-width: 860px) {
  :root { --rail: 0px; }

  #rail {
    position: sticky;
    top: 0;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: 12px 14px;
  }

  #railBrand { width: auto; }

  #railLinks {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    display: grid;
    gap: 10px;
    overflow-x: auto;
    /* FIX: hide scrollbar on mobile rail */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  #railLinks::-webkit-scrollbar { display: none; }

  #railLinks a { padding: 10px 12px; }
  #railLinks a span[data-railnum] { display: none; }

  #main { margin-left: 0; }
  a[data-card] { grid-column: span 12; }

  /* Theme toggle: width:100% fills the whole flex row on mobile,
     pushing nav links off-screen. Override to auto so it only takes
     as much space as its label needs. */
  #themeToggle {
    width: auto;
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Hero: 2-column grid — title left, art right, same row.
     Every child gets an explicit grid-row so the art (last in DOM)
     is pulled up to sit beside the h1. */
  #hero {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 16px;
    align-items: start;
  }
  #heroMeta           { grid-column: 1 / -1; grid-row: 1; }
  #heroTitle          { grid-column: 1;      grid-row: 2; }
  #accentLine         { grid-column: 1 / -1; grid-row: 3; }
  #lead               { grid-column: 1 / -1; grid-row: 4; }
  #hero ul[data-tags] { grid-column: 1 / -1; grid-row: 5; }

  #heroArt {
    grid-column: 2;
    grid-row: 2;
    position: static;         /* participate in grid, no absolute offset */
    width: clamp(100px, 26vw, 140px);
    /* Cap height so a tall SVG viewBox can't expand the row beyond
       what the h1 needs — image scales down inside the box */
    max-height: 180px;
    object-fit: contain;
    object-position: center bottom;
    transform: none;
    opacity: 0.85;
    align-self: center;
  }

  /* Photo shower is now handled by mobile JS path — no need to hide it */
}

/* ======================================
   INTERLUDE 01
====================================== */

#interlude01 {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(80px, 10vw, 150px) var(--pad);
  text-align: center;
}

#interludeLabel {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

#interludeTitle {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.5rem);
  margin: 0 0 10px;
}

/* <figure> wrapping the SVG stage and its caption */
#interludeFigure {
  margin: 0 auto 30px;
  width: min(600px, 80vw);
}

/* The bordered SVG canvas inside the figure */
#interludeStage {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  margin-bottom: 12px;
}

/* <figcaption> replaces the old #interludeText paragraph */
#interludeFigure figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

#interludeSvg {
  width: 80%;
  height: 80%;
}

#interludeControls {
  display: flex;
  gap: 16px;
  justify-content: center;
}

#interludeControls button {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
}

#interludeControls button:hover {
  border-color: var(--accent);
}

/* ======================================
   ABOUT TIMELINE
====================================== */

#aboutIntro {
  max-width: 70ch;
  color: var(--muted);
  margin: 0 0 26px;
}

#timeline {
  display: grid;
  gap: 18px;
  position: relative;
}

#timeline::before {
  content: "";
  position: absolute;
  left: 140px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

li[data-timelineitem] {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
  align-items: start;
  position: relative;
  padding: 6px 0;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 420ms ease, transform 420ms ease;
}

li[data-timelineitem][data-in="true"] {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  li[data-timelineitem] {
    transition: none;
    transform: none;
    opacity: 1;
  }
}

span[data-year] {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 6px;
}

div[data-event] {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
}

div[data-event]::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 22px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

li[data-timelineitem][data-current="true"] div[data-event] {
  border-color: var(--accent);
}

li[data-timelineitem][data-current="true"] div[data-event]::before {
  border-color: var(--accent);
  background: var(--accent);
}

@media (max-width: 700px) {
  #timeline::before { left: 0; }
  li[data-timelineitem] {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  div[data-event]::before {
    left: -6px;
  }
  /* Extra gap creates space for photo shower photos between timeline cards */
  #timeline { gap: 90px; }
}

/* ======================================
   TIMELINE TAGS
====================================== */

ul[data-tags] {
  margin: 14px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

ul[data-tags] li {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  padding: 6px 10px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition:
    border-color 180ms ease,
    color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

div[data-event]:hover ul[data-tags] li {
  border-color: var(--accent);
  color: var(--text);
}

ul[data-tags] li:hover {
  transform: translateY(-1px);
}

ul[data-tags] + ul[data-tags] {
  margin-top: 8px;
}

ul[data-tags]::before {
  content: attr(aria-label);
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--muted);
  opacity: 0.6;
  width: 100%;
}

:root[data-theme="dark"] ul[data-tags] li {
  border-color: rgba(255, 255, 255, .18);
  color: rgba(255, 255, 255, .7);
}

:root[data-theme="dark"] ul[data-tags]::before {
  color: rgba(255, 255, 255, .55);
}

/* ======================================
   PHOTO SHOWER
====================================== */

#about {
  position: relative;
  /* Clip photoShower photos to the section's own bounds */
  overflow: hidden;
}

#photoShower {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

#aboutHeader,
#aboutBody {
  position: relative;
  z-index: 1;
}

#photoShower img {
  position: absolute;
  width: 120px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
  opacity: 0;
  /* Start: invisible, slightly rotated, offset up so the drift-in is visible */
  transform: translateY(20px) rotate(var(--rot, 0deg));
  transition:
    opacity 1200ms ease,
    transform 1400ms cubic-bezier(.2, .8, .2, 1);
  z-index: 0;
}

#photoShower img[data-in="true"] {
  opacity: 0.85;
  /* Settle: drift down 20px from start position, keep the rotation */
  transform: translateY(40px) rotate(var(--rot, 0deg));
}

:root[data-theme="dark"] #photoShower img {
  box-shadow: 0 8px 30px rgba(0, 0, 0, .6);
}

@media (prefers-reduced-motion: reduce) {
  #photoShower img {
    transition: none;
    opacity: 0.8;
    transform: none;
  }
}

/* ======================================
   CONTACT
====================================== */

#contactBody {
  max-width: 72ch;
}

#contactLine {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 18px;
}

#contactPrompt {
  margin: 0 0 22px;
  display: grid;
  gap: 10px;
}

#contactPrompt li {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: baseline;
}

#contactPrompt span[data-contactlabel] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  flex: 0 0 auto;
}

#contactActions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 0 0 10px;
}

#copyTemplate {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
}

#copyTemplate:hover {
  border-color: var(--accent);
}

#copyStatus {
  min-height: 1.4em; /* prevent layout shift when text appears */
  font-size: 0.9rem;
  color: var(--muted);
  margin: 4px 0 10px;
}

#contactSmall {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ======================================
   PHOTO SPARKLES
====================================== */

.sparkle-burst {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 10;
}

.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
  animation: sparkle-out 600ms cubic-bezier(.2,.8,.2,1) forwards;
}

.sparkle:nth-child(odd) {
  background: var(--text);
  width: 6px;
  height: 6px;
}

.sparkle:nth-child(3n) {
  background: var(--accent);
  width: 6px;
  height: 18px;
  border-radius: 999px;
}

@keyframes sparkle-out {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1) translate(0px, 0px); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) translate(var(--sx), var(--sy)); }
}

@media (prefers-reduced-motion: reduce) {
  .sparkle { animation: none; display: none; }
}

/* ======================================
   GRAIN OVERLAY
   body::after holds the noise filter and shifts position on a stepped
   animation so the grain "moves" at ~10fps — no JS needed.
   overflow-x:clip on body prevents the oversized pseudo-element
   (inset:-50%) from creating a scrollbar.
====================================== */

/* Grain overlay — canvas drawn once in JS, drifted by CSS animation.
   steps() keeps the movement discrete (like real film grain) without
   any per-frame JS regeneration, so there is zero flicker. */
@keyframes grain-drift {
  0%   { transform: translate(  0px,   0px); }
  14%  { transform: translate( -4px,  -3px); }
  28%  { transform: translate(  3px,   4px); }
  42%  { transform: translate( -3px,   2px); }
  57%  { transform: translate(  4px,  -4px); }
  71%  { transform: translate( -2px,   3px); }
  85%  { transform: translate(  3px,  -2px); }
}

#grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
  opacity: 0.05;
  background-repeat: repeat;
  background-size: 200px 200px;
  animation: grain-drift 12s steps(7) infinite;
}

:root[data-theme="dark"] #grain-overlay {
  opacity: 0.03;
}

/* ======================================
   SVG ARCHIVE WIPE-REVEAL
====================================== */

@keyframes svg-wipe {
  from { clip-path: inset(0 100% 0 0 round 4px); }
  to   { clip-path: inset(0 0%   0 0 round 4px); }
}

#interludeStage.revealing {
  animation: svg-wipe 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ======================================
   CURSOR INK TRAIL
====================================== */

.ink-dot {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text);
  pointer-events: none;
  z-index: 8999;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  will-change: transform, opacity;
}

.ink-dot.pop {
  animation: ink-pop 550ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes ink-pop {
  0%   { opacity: 0.45; transform: translate(-50%, -50%) scale(1);   }
  100% { opacity: 0;    transform: translate(-50%, -50%) scale(0.2); }
}


