/* Figures and motion ------------------------------------------------ */
/* Each project diagram sits in a large card: a mono caption with the
   pause button, then a near-black plate with a faint dot grid. Diagrams
   are inline SVG drawn finished, which is what shows without JavaScript or
   with reduced motion; reel.js animates them. */
.reel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 20px;
}

/* On a phone the plate runs nearly to the card's edge, so the diagram
   notes stay readable. */
@media (max-width: 719px) {
  .reel {
    gap: 12px;
    padding: 14px 8px 8px;
  }
}

.reel__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 28px;
  padding: 0 4px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.reel__name {
  margin-right: auto;
}

.reel__clock {
  font-variant-numeric: tabular-nums;
}

/* Pause bars while playing, a play triangle once paused. */
.reel__toggle {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  color: var(--text);
  transition: border-color 200ms;
}

@media (hover: hover) {
  .reel__toggle:hover { border-color: var(--muted); }
}

.reel__toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 9px;
  border-inline: 2px solid currentColor;
  transform: translate(-50%, -50%);
}

.reel__toggle[aria-pressed="true"]::before {
  width: 9px;
  border: 0;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transform: translate(-40%, -50%);
}

/* Widens the touch target to 48px without growing the button. */
.reel__toggle::after {
  content: "";
  position: absolute;
  inset: -8px;
}

.reel__scene {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 320;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card) radial-gradient(rgba(255, 255, 255, 0.09) 0.8px, transparent 0.8px) 0 0 / 16px 16px;
}

/* The screenshot fills the plate's box, letterboxed, never cropped. */
.reel__scene--plate {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  overflow: hidden;
  aspect-ratio: 1440 / 900;
}

.reel__scene--plate img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Diagram parts. Anything the timeline moves is tagged data-a and scales
   or turns around its own centre. */
.reel [data-a] {
  transform-box: fill-box;
  transform-origin: center;
}

.reel .reel__cover {
  fill: var(--card);
  transform-origin: 100% 50%;
}

.reel__wire,
.reel__track,
.reel__fill,
.reel__rail,
.reel__glyph {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reel__rail { stroke: var(--signal); stroke-width: 2; }
.reel:not(.is-live) .reel__rail { visibility: hidden; }
.reel__wire { stroke: var(--muted); stroke-width: 1.25; }
.reel__wire--dashed { stroke: var(--dim); stroke-dasharray: 3 4; }
.reel__track { stroke: rgba(255, 255, 255, 0.14); }
.reel__glyph { stroke: var(--bg); stroke-width: 2; }

/* Drawn by sliding the dash along a path whose length is set to 1. The gap
   is longer than the path so no stray cap shows at either end. */
.reel__draw { stroke-dasharray: 1 2; }

.reel__box { fill: var(--card); stroke: var(--muted); stroke-width: 1.25; }
.reel__box--ok { stroke: var(--signal); stroke-width: 2; }
.reel__box--missing { stroke: var(--dim); stroke-dasharray: 4 4; }
.reel__pill { fill: var(--card); stroke: var(--muted); stroke-width: 1.25; }
.reel__area { fill: rgba(109, 134, 255, 0.08); stroke: var(--muted); stroke-width: 1.25; }
.reel__ring { fill: none; stroke: var(--signal); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* Fills and strokes the SVG names by role rather than by colour. */
.is-signal { fill: var(--signal); }
.is-signal-soft { fill: var(--signal); opacity: 0.25; }
.is-band { fill: rgba(109, 134, 255, 0.12); }
.is-fail { fill: var(--muted); }
.is-doc { stroke: rgba(255, 255, 255, 0.22); }
.stroke-signal { stroke: var(--signal); }
.stroke-text { stroke: var(--text); }
.stroke-dim { stroke: var(--dim); }

.reel__text {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  text-anchor: middle;
}

.reel__text--start { text-anchor: start; }
.reel__text--end { text-anchor: end; }
.reel__text--bad { fill: var(--text); }
.reel__text--key { fill: var(--signal); }

.reel__text--note {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.reel__text--note.reel__text--bad { fill: var(--text); }
.reel__text--note.reel__text--key { fill: var(--signal); }

.reel__text--mono {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
}

.reel__text--num {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.reel__text--xl { font-size: 32px; }

/* Others: two small drawings on one plate, piano keys and a moon beside a
   calendar. Plain CSS animation, not reel.js: each plays once, for under
   five seconds, when the plate first comes into view, and with reduced
   motion they rest as drawn here. */
.pair {
  display: grid;
  grid-template: minmax(0, 1fr) / repeat(2, minmax(0, 1fr));
  overflow: hidden;
  aspect-ratio: 480 / 150;
}

@media (max-width: 719px) {
  .pair {
    aspect-ratio: 480 / 200;
  }
}

.pair__art {
  width: 100%;
  height: 100%;
  padding: 8% 0;
  overflow: visible;
}

.pair__keys {
  border-right: 1px dashed var(--line);
}

.keys__white rect {
  fill: var(--text);
  stroke: var(--card);
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: 50% 0;
}

.keys__black rect {
  fill: var(--bg);
}

.keys__waves,
.cal__head,
.cal__tick,
.cal__days {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.keys__waves { stroke: var(--signal); stroke-width: 2; }
.moon__body { fill: var(--signal); }
.moon__glow { fill: none; stroke: var(--signal); stroke-width: 1.5; opacity: 0.35; transform-box: fill-box; transform-origin: center; }
.cal__sheet { fill: var(--card); stroke: var(--muted); stroke-width: 1.25; }
.cal__head { stroke: var(--muted); stroke-width: 1.25; }
.cal__days { stroke: var(--dim); stroke-width: 3.5; }
.cal__tick { stroke: var(--signal); stroke-width: 3; stroke-dasharray: 1 2; }

/* Motion ------------------------------------------------------------ */
/* Others' two drawings play once the first time their plate is seen
   (reveal.js adds .is-visible). */
@media (prefers-reduced-motion: no-preference) {
  .is-visible .pair .keys__white rect { animation: key-press 600ms calc(300ms + var(--i) * 220ms) var(--ease-out) both; }
  .is-visible .pair .keys__waves { animation: draw 700ms 1900ms var(--ease) backwards; }
  .is-visible .pair .moon__glow { animation: moon-glow 1400ms 300ms ease-out 3 both; }
  .is-visible .pair .cal__tick { animation: draw 600ms 1200ms var(--ease) backwards; }
}

/* Titles: masked word reveal ----------------------------------------- */
/* motion.js wraps each word of a section, hero or project title in a
   mask (.word) and an inner span (.word__in), then adds .is-in when the
   title comes into view. Words rise from behind the mask about 60ms
   apart, and the italic accent word arrives last with a slight skew that
   settles. The text itself is untouched, so the heading reads the same to
   a screen reader. After a cross-page view transition (.vt) the title is
   shown at once, so the shared title can morph into it. */
.word {
  display: inline-block;
  clip-path: inset(-0.2em -0.35em -0.3em -0.35em);
}

.word__in {
  display: inline-block;
}

@media (prefers-reduced-motion: no-preference) {
  .split .word__in {
    transition: transform 1000ms cubic-bezier(0.16, 1, 0.3, 1) calc(var(--i, 0) * 60ms);
  }

  .split:not(.is-in) .word__in {
    transform: translateY(140%);
  }

  .split:not(.is-in) .word--serif .word__in {
    transform: translateY(140%) skewX(-10deg);
  }

  .vt .split .word__in {
    transform: none;
    transition: none;
  }
}

/* Cards: pointer spotlight ------------------------------------------- */
/* With a mouse or trackpad, motion.js tracks the pointer over a card
   (--mx, --my), and a soft light and a brighter stretch of border follow
   it. The card also lifts 3px. Never on touch screens. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .spot {
    isolation: isolate;
    transition: transform 400ms var(--ease-out), border-color 200ms;
  }

  .spot::before,
  .spot::after {
    content: "";
    position: absolute;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 300ms;
    pointer-events: none;
  }

  .spot::before {
    inset: 0;
    z-index: -1;
    background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 0%), hsl(var(--h) 100% 70% / 0.06), transparent 70%);
  }

  .spot::after {
    inset: -1px;
    padding: 1px;
    background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 0%), hsl(var(--h) 95% 75% / 0.6), transparent 70%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  }

  .spot:hover {
    transform: translateY(-3px);
  }

  .spot:hover::before,
  .spot:hover::after {
    opacity: 1;
  }

  /* Contact's pills lean a few pixels toward the pointer (motion.js). */
  .magnet {
    transition: transform 300ms var(--ease-out), border-color 200ms, background-color 200ms;
  }
}

/* Page transitions --------------------------------------------------- */
/* Between the main page and the project pages, browsers that support
   cross-document view transitions fade and slide the page, and a work
   card's title morphs into the project page's title (the shared
   view-transition-name below). Others simply navigate. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root) {
    animation: vt-out 220ms var(--ease) both;
  }

  ::view-transition-new(root) {
    animation: vt-in 380ms var(--ease-out) both;
  }

  ::view-transition-group(*) {
    animation-duration: 480ms;
    animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  }
}

.vt-website-revamp { view-transition-name: t-website-revamp; }
.vt-assistant-bot { view-transition-name: t-assistant-bot; }
.vt-trading-agent { view-transition-name: t-trading-agent; }
.vt-research-agent { view-transition-name: t-research-agent; }
.vt-v-bay { view-transition-name: t-v-bay; }
.vt-others { view-transition-name: t-others; }

@keyframes vt-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes vt-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes key-press {
  0%, 100% { fill: var(--text); transform: none; }
  30% { fill: var(--signal); transform: scaleY(0.96); }
}

@keyframes moon-glow {
  0% { opacity: 0.7; transform: scale(0.85); }
  100% { opacity: 0.35; transform: scale(1); }
}

@keyframes draw {
  from { stroke-dashoffset: 1; }
}
