/* ==========================================================================
   SCROLL WASH + EDITOR MOTIFS
   Things an editor looks at every day, drawn very quietly in the background:
   timeline ruler + playhead, tracks with clips and audio, keyframe graph,
   colour-grading wheels, audio waveform. All use theme variables so they
   sit inside both Day and Night. Transform/opacity only; paused offscreen.
   ========================================================================== */

/* ---------- Section gradient wash (fixed, follows the active section) ---------- */
@property --ax { syntax: "<percentage>"; inherits: false; initial-value: 20%; }
@property --ay { syntax: "<percentage>"; inherits: false; initial-value: 30%; }

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  --ax: 20%;
  --ay: 30%;
  background:
    radial-gradient(80% 70% at var(--ax) var(--ay), rgba(var(--wash), var(--wash-a)), transparent 72%),
    radial-gradient(65% 60% at calc(100% - var(--ax)) calc(100% - var(--ay)), rgba(var(--wash-2), var(--wash-a)), transparent 70%);
  transition:
    --ax 1.8s var(--ease-io),
    --ay 1.8s var(--ease-io),
    opacity 1.1s var(--ease-io);
}
.ambient.is-on { opacity: 1; }

/* Motif play-state: only animate while on screen */
.motif * { animation-play-state: paused !important; }
.motif.in-view * { animation-play-state: running !important; }
.motif { pointer-events: none; user-select: none; }

/* ---------- Timeline ruler at the top of each section ---------- */
.ruler {
  --ph: 0px;
  position: relative;
  height: 32px;
  margin-bottom: clamp(36px, 5vw, 60px);
  color: rgba(var(--motif), calc(var(--motif-a) * 2.6));
}
.ruler__cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-bottom: 1px solid currentColor;
  background: repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 100%) 0 100% / calc(100% / 60) 6px repeat-x;
}
.ruler__cells span {
  position: relative;
  padding-left: 7px;
  font: 600 0.6875rem / 1 var(--font-body);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.ruler__cells span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: currentColor;
  color: rgba(var(--motif), calc(var(--motif-a) * 2.6));
}
.ruler__ph {
  position: absolute;
  left: 0;
  top: -4px;
  bottom: -8px;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--glow);
  transform: translateX(var(--ph));
}
:root[data-scheme="dark"] .ruler__ph { background: var(--lavender); }
.ruler__ph::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 12px;
  height: 10px;
  transform: translateX(-50%);
  background: inherit;
  clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%);
}
@media (max-width: 600px) {
  .ruler__cells { grid-template-columns: repeat(3, minmax(0, 1fr)); background-size: calc(100% / 30) 6px; }
  .ruler__cells span:nth-child(n + 4) { display: none; }
}

/* ---------- Timeline tracks (Works) ---------- */
.tracks {
  position: relative;
  display: grid;
  gap: 8px;
  margin-top: clamp(40px, 6vw, 72px);
  color: rgba(var(--motif), 1);
}
.trk { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 10px; }
.trk__lbl {
  font: 700 0.6875rem / 1 var(--font-body);
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-align: center;
  padding: 7px 0;
  border-radius: 6px;
  background: rgba(var(--motif), calc(var(--motif-a) * 0.6));
}
.trk__lane { position: relative; height: 34px; border-radius: 8px; background: rgba(var(--motif), calc(var(--motif-a) * 0.35)); }
.trk__lane i {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: var(--l);
  width: var(--w);
  border-radius: 6px;
  background: rgba(var(--motif), calc(var(--motif-a) * 1.1));
  box-shadow: inset 0 0 0 1px rgba(var(--motif), calc(var(--motif-a) * 2));
}
.trk__lane i::before {   /* clip thumbnail strip */
  content: "";
  position: absolute;
  inset: 4px 6px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, rgba(var(--motif), calc(var(--motif-a) * 1.6)) 0 18px, transparent 18px 22px);
}
.trk--a .trk__lane i { background: rgba(var(--motif), calc(var(--motif-a) * 0.8)); }
.trk--a .trk__lane i::before {
  inset: 3px 4px;
  background: repeating-linear-gradient(90deg, rgba(var(--motif), calc(var(--motif-a) * 3)) 0 2px, transparent 2px 4px);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M0 10 Q10 2 20 9 T40 8 T60 12 T80 4 T100 10 T120 6 T140 13 T160 5 T180 11 T200 9 L200 11 Q190 18 180 12 T160 15 T140 8 T120 15 T100 10 T80 17 T60 9 T40 13 T20 11 T0 10Z'/%3E%3C/svg%3E") center / 100% 100%;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M0 10 Q10 2 20 9 T40 8 T60 12 T80 4 T100 10 T120 6 T140 13 T160 5 T180 11 T200 9 L200 11 Q190 18 180 12 T160 15 T140 8 T120 15 T100 10 T80 17 T60 9 T40 13 T20 11 T0 10Z'/%3E%3C/svg%3E") center / 100% 100%;
}
.tracks__run { position: absolute; top: -6px; bottom: -6px; left: 50px; right: 0; container-type: inline-size; }
.tracks__ph {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--glow);
  animation: playhead 16s linear infinite;
}
:root[data-scheme="dark"] .tracks__ph { background: var(--lavender); }
@keyframes playhead { from { transform: translateX(0); } to { transform: translateX(100cqw); } }

/* ---------- Keyframe graph (Skills) ---------- */
.kf {
  position: absolute;
  left: 25%;
  top: 92px;
  width: min(34%, 440px);
  height: auto;
  color: rgba(var(--motif), calc(var(--motif-a) * 3));
  overflow: visible;
}
.kf .grid line { stroke: rgba(var(--motif), calc(var(--motif-a) * 0.9)); stroke-width: 1; }
.kf .curve {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-dasharray: 640;
  stroke-dashoffset: 640;
  animation: kf-draw 7s var(--ease-io) infinite;
}
.kf .handle { stroke: currentColor; stroke-width: 1; opacity: 0.55; }
.kf .key { fill: var(--bg); stroke: currentColor; stroke-width: 1.6; transform-box: fill-box; transform-origin: center; animation: kf-pulse 7s var(--ease-io) infinite; }
.kf .key:nth-of-type(2) { animation-delay: 0.6s; }
.kf .key:nth-of-type(3) { animation-delay: 1.2s; }
.kf .key:nth-of-type(4) { animation-delay: 1.8s; }
@keyframes kf-draw { 0% { stroke-dashoffset: 640; } 45%, 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -640; } }
@keyframes kf-pulse { 0%, 100% { transform: rotate(45deg) scale(1); } 40% { transform: rotate(45deg) scale(1.35); fill: currentColor; } }

/* ---------- Colour wheels (About) ---------- */
.grade {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
  padding: 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(var(--motif), calc(var(--motif-a) * 0.25));
}
.wheel { display: grid; justify-items: center; gap: 8px; }
.wheel__ring {
  position: relative;
  width: 100%;
  max-width: 92px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(var(--motif), calc(var(--motif-a) * 2.4));
  background:
    radial-gradient(circle, rgba(var(--motif), calc(var(--motif-a) * 0.8)) 0 1px, transparent 1.5px),
    conic-gradient(from 0deg, rgba(var(--particle), 0.18), rgba(var(--wash), 0.2), rgba(var(--particle), 0.06), rgba(var(--particle), 0.18));
}
.wheel__ring::before,
.wheel__ring::after {
  content: "";
  position: absolute;
  background: rgba(var(--motif), calc(var(--motif-a) * 1.6));
}
.wheel__ring::before { left: 50%; top: 14%; bottom: 14%; width: 1px; }
.wheel__ring::after { top: 50%; left: 14%; right: 14%; height: 1px; }
.wheel__dot {
  position: absolute;
  inset: 0;
  animation: wheel-orbit 9s var(--ease-io) infinite alternate;
}
.wheel__dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 34%;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  box-shadow: 0 0 8px var(--glow);
}
:root[data-scheme="dark"] .wheel__dot::after { border-color: var(--lavender); }
.wheel:nth-child(2) .wheel__dot { animation-duration: 11s; animation-delay: -3s; }
.wheel:nth-child(3) .wheel__dot { animation-duration: 13s; animation-delay: -6s; }
@keyframes wheel-orbit { from { transform: rotate(-40deg); } to { transform: rotate(70deg); } }
.wheel__lbl { font: 600 0.75rem / 1 var(--font-body); color: var(--ink-3); }

/* ---------- Audio waveform (Contact) ---------- */
.wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(24px, 4vw, 48px);
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding-inline: var(--gutter);
  z-index: -1;
}
.wave span {
  flex: 1 1 0;
  max-width: 6px;
  height: var(--h, 40%);
  border-radius: 3px;
  background: rgba(var(--motif), calc(var(--motif-a) * 1.5));
  transform-origin: center;
  animation: wave 2.4s var(--ease-io) infinite alternate;
  animation-delay: var(--dl, 0s);
}
@keyframes wave { from { transform: scaleY(0.35); } to { transform: scaleY(1); } }

@media (prefers-reduced-motion: reduce) {
  .motif * { animation: none !important; }
  .ambient { transition: opacity 0.3s; }
}

/* ---------- Camera: aperture iris (Experience) ---------- */
.tl-wrap { position: relative; }
.iris, .histo { position: absolute; z-index: 0; pointer-events: none; }
.tl { z-index: 1; }
.iris { left: 14%; top: 2%; width: min(18vw, 210px); color: rgba(var(--motif), calc(var(--motif-a) * 2.8)); }
.iris__ring { fill: none; stroke: currentColor; stroke-width: 1.2; }
.iris__ring--in { stroke-dasharray: 2 5; }
.iris__blades { transform-origin: 100px 100px; animation: iris 9s var(--ease-io) infinite alternate; }
.iris__blades path { fill: rgba(var(--motif), calc(var(--motif-a) * 0.9)); stroke: currentColor; stroke-width: 1; stroke-linejoin: round; }
@keyframes iris { from { transform: rotate(-10deg) scale(0.92); } to { transform: rotate(28deg) scale(1.06); } }

/* ---------- Camera: live histogram (Experience) ---------- */
.histo { right: 12%; top: 31%; width: min(22vw, 250px); color: rgba(var(--motif), calc(var(--motif-a) * 2.6)); }
.histo__frame { fill: rgba(var(--motif), calc(var(--motif-a) * 0.3)); stroke: currentColor; stroke-width: 1; }
.histo__area { fill: rgba(var(--motif), calc(var(--motif-a) * 1.2)); transform-origin: 50% 100%; animation: histo 4.5s var(--ease-io) infinite alternate; }
.histo__line { fill: none; stroke: currentColor; stroke-width: 1.4; transform-origin: 50% 100%; animation: histo 4.5s var(--ease-io) infinite alternate; }
@keyframes histo { from { transform: scaleY(0.82) scaleX(0.98); } to { transform: scaleY(1.05) scaleX(1.01); } }
@media (max-width: 860px) { .iris, .histo { display: none; } }

/* ---------- Camera: lens focus scale (Skills) ---------- */
.focus {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: clamp(44px, 6vw, 72px);
  color: rgba(var(--motif), calc(var(--motif-a) * 2.6));
}
.focus__lbl, .focus__unit { flex: none; font: 600 0.75rem / 1 var(--font-body); color: var(--ink-3); }
.focus__win {
  position: relative;
  flex: 1 1 auto;
  height: 40px;
  overflow: hidden;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  -webkit-mask: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  mask: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}
.focus__win::after {   /* fixed index mark */
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--glow);
}
:root[data-scheme="dark"] .focus__win::after { background: var(--lavender); }
.focus__scale {
  display: flex;
  width: max-content;
  height: 100%;
  align-items: center;
  animation: focus-pull 14s var(--ease-io) infinite alternate;
}
.focus__scale b {
  width: 90px;
  text-align: center;
  font: 600 0.75rem / 1 var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  background: repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 100%) 0 0 / 18px 6px repeat-x;
  padding-top: 12px;
}
@keyframes focus-pull { from { transform: translateX(-2%); } to { transform: translateX(-46%); } }
