/* ==========================================================================
   fx.css — the design layer: motion, section identity, project-page layout
   --------------------------------------------------------------------------
   Everything added in the redesign lives here and in js/fx.js, on top of
   style.css and pcb.css. Remove the two <link>/<script> lines for these
   files and the site falls back to the plain layout underneath — nothing in
   the other files depends on them.

   It only uses tokens the themes already define (--gold, --cyan-rgb, glass
   tokens…), so dark and light both work with no extra values. All motion
   switches off under prefers-reduced-motion (see the end of this file and
   the global rule in style.css).
   ========================================================================== */

/* ----------------------------------------------------- section identity --
   Each section gets an accent (teal for the engineering sections, gold for
   the personal ones) and a number in its eyebrow, so scrolling reads as a
   sequence of distinct chapters rather than one long repeated block. */
#work, #experience, #about   { --acc: var(--cyan); --acc-rgb: var(--cyan-rgb); }
#approach, #beyond, #contact { --acc: var(--gold); --acc-rgb: var(--gold-rgb); }

.section .eyebrow { color: var(--acc, var(--gold)); }
.eyebrow[data-n]::before {
  content: attr(data-n); font-family: var(--mono); letter-spacing: .1em;
  color: var(--fg-3); margin-right: 12px;
}
.section .sec-rule .via { border-color: rgba(var(--acc-rgb, var(--cyan-rgb)), .55); }
.section .sec-rule .via::after { background: var(--acc, var(--cyan)); }
.section .sec-rule .ln {
  background: linear-gradient(90deg, rgba(var(--acc-rgb, var(--cyan-rgb)), .42), rgba(var(--acc-rgb, var(--cyan-rgb)), .14) 60%, transparent);
}

/* Two sections sit on a faint full-width panel so the page has rhythm:
   work → panel → experience → panel → about → contact card. */
#approach, #beyond {
  background:
    linear-gradient(180deg, transparent, rgba(var(--acc-rgb), .05) 16%, rgba(var(--acc-rgb), .05) 84%, transparent);
}

/* The contact section is the last thing on the page, so it becomes one
   large glass card instead of loose centred text. */
.contact > .wrap {
  width: calc(100% - (var(--gutter) * 2));
  max-width: 980px;
  padding: clamp(40px, 6vw, 84px) clamp(22px, 5vw, 64px);
  border-radius: 28px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-spec), var(--glass-glow), var(--glass-drop);
  position: relative; overflow: hidden;
}
.contact > .wrap::before {                 /* a warm light source behind the heading */
  content: ''; position: absolute; left: 50%; top: -40%; width: 70%; aspect-ratio: 1;
  transform: translateX(-50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(var(--gold-rgb), .16), transparent 62%);
}
.contact > .wrap > * { position: relative; }

/* ---------------------------------------------------------------- hero ---
   The first screen assembles itself: each piece rises in, one after the
   other, and a few board traces draw in behind the text. */
@keyframes fxFade { from { opacity: 0; } to { opacity: 1; } }
/* (the hero's own entrance lives in system.css: v4Appear) */

.hero-circuit {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 1; pointer-events: none; overflow: visible;
  animation: fxFade 1.2s ease backwards;
}
.hero-circuit .t {
  fill: none; stroke: var(--trace); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: fxDraw 2.4s var(--ease-out) forwards;
}
.hero-circuit .t.g { stroke: var(--trace-gold); }
.hero-circuit .t:nth-of-type(2) { animation-delay: .15s; }
.hero-circuit .t:nth-of-type(3) { animation-delay: .3s; }
.hero-circuit .t:nth-of-type(4) { animation-delay: .45s; }
.hero-circuit .t:nth-of-type(5) { animation-delay: .6s; }
.hero-circuit .t:nth-of-type(6) { animation-delay: .75s; }
.hero-circuit .t:nth-of-type(7) { animation-delay: .9s; }
/* pads: a copper ring with a drilled hole, like a real via */
.hero-circuit .pad  { fill: var(--copper); stroke: var(--trace); stroke-width: 1.4; }
.hero-circuit .pad.g { stroke: var(--trace-gold); }
.hero-circuit .hole { fill: var(--ink); }
@keyframes fxDraw { to { stroke-dashoffset: 0; } }

/* COMETS. A signal is three dashes on the same path: a long faint tail, a
   medium body and a short bright head. Each dash has its own length (--L),
   and all three start at an offset equal to that length, so their leading
   edges stay together as they travel. Only stroke-dashoffset animates: no
   filters, no layout. */
.comet { fill: none; stroke-linecap: round; stroke-dasharray: var(--L) 2; stroke-dashoffset: var(--L);
         animation: fxComet var(--dur, 7s) linear var(--delay, 2.4s) infinite; }
.comet.tail { --L: .09; stroke-width: 2;   stroke-opacity: .22; }
.comet.body { --L: .035; stroke-width: 2.2; stroke-opacity: .6; }
.comet.head { --L: .006; stroke-width: 3.4; stroke-opacity: 1; }
.comet.gd { stroke: var(--gold-hi); }
.comet.cy { stroke: var(--cyan-hi); }
@keyframes fxComet { from { stroke-dashoffset: var(--L); } to { stroke-dashoffset: calc(var(--L) - 1.1); } }
@media (max-width: 880px) { .hero-circuit { display: none; } }

/* Stat tiles: a soft accent line appears under the number on hover. */
.stat { transition: transform .4s var(--ease), box-shadow .4s var(--ease); }
.stat:hover { transform: translateY(-3px); }
.stat-v { display: inline-block; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- motion ---
   Cards tilt towards the pointer (js/fx.js sets --rx/--ry/--mx/--my) and a
   soft highlight follows it, like light on glass. Touch screens get none of
   this, just the plain cards. */
/* Cards that also scroll-reveal (.rv) only start tilting once revealed,
   so the reveal's slide-up is not overwritten. */
.fx-tilt:not(.rv), .rv.in.fx-tilt {
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift, 0px));
}
/* A dedicated layer only while the pointer is on the card. Promoting every
   card permanently cost GPU memory and made scrolling heavier. */
.fx-tilt.is-hover { will-change: transform; }
.fx-tilt { transition: transform .5s var(--ease-out), box-shadow .5s var(--ease-out); }
.rv.fx-tilt { transition: opacity .8s var(--ease-out), transform .5s var(--ease-out); }
.fx-tilt.is-hover { --lift: -4px; }
.fx-glare {
  position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit;
  background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.06), transparent 50%);
  opacity: 0; transition: opacity .4s var(--ease);
}
.fx-tilt.is-hover .fx-glare { opacity: 1; }
.moment { position: relative; }

.btn { position: relative; }
.btn:hover {
  box-shadow: 0 0 0 1px rgba(var(--gold-rgb), .3), 0 10px 24px -12px rgba(0, 0, 0, .5);
}
.band-go svg, .btn svg { transition: transform .34s var(--ease); }
.btn:hover svg { transform: translate(2px, -2px); }

/* Groups reveal one card at a time instead of all at once. Only the fade
   is delayed (the first value), so the tilt still responds instantly. */
.evidence .ev:nth-child(2), .moments .moment:nth-child(2) { transition-delay: .09s, 0s; }
.evidence .ev:nth-child(3), .moments .moment:nth-child(3) { transition-delay: .18s, 0s; }
.moments .moment:nth-child(4) { transition-delay: .27s, 0s; }
.cols .col:nth-child(2) { transition-delay: .09s; }
.mini-grid .mini:nth-child(2) { transition-delay: .07s, 0s; }
.mini-grid .mini:nth-child(3) { transition-delay: .14s, 0s; }
.mini-grid .mini:nth-child(4) { transition-delay: .21s, 0s; }
.cols .col:nth-child(3) { transition-delay: .18s; }

/* Evidence metrics get a thin accent bar that grows in with the card. */
.ev-metric { position: relative; padding-bottom: 14px; }
.ev-metric::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--gold), transparent);
  transition: width 1.1s var(--ease-out) .3s;
}
.ev.in .ev-metric::after { width: 64px; }

/* ------------------------------------------------------- project pages ---
   Text on the left, a sticky "key facts" card on the right; the gallery is
   a two-column grid, and every picture opens in a lightbox. */
.case-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(28px, 4vw, 56px); align-items: start;
  margin-top: clamp(26px, 4vw, 44px);
}
.case-main .case-grid { grid-template-columns: 1fr; gap: clamp(22px, 3vw, 34px); }
.case-main .case-grid section { padding-left: 18px; border-left: 1px solid var(--hair-2); }
.case-main .case-grid p { font-size: 15.5px; line-height: 1.72; max-width: 68ch; }

.case-facts {
  position: sticky; top: calc(var(--navh) + 30px);
  border-radius: 18px; padding: 22px 22px 18px;
}
.case-facts h2 {
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold);
  font-weight: 500; margin-bottom: 14px;
}
.case-facts dl { display: grid; gap: 12px; }
.case-facts dt { font-size: 9.5px; letter-spacing: .15em; text-transform: uppercase; color: var(--fg-k); }
.case-facts dd { font-size: 13.5px; color: var(--fg); margin-top: 3px; line-height: 1.45; }
.case-facts .tags { margin-top: 6px; gap: 6px; }
.case-facts .tag { font-size: 10.5px; padding: 3px 9px; }
.case-facts .btn { width: 100%; justify-content: center; margin-top: 16px; }
.case-facts .note { margin-top: 12px; font-size: 12px; }

.shots-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.shots-grid .shot { max-width: none; margin: 0; }
.shots-grid .shot:only-child { grid-column: 1 / -1; max-width: 760px; }

.case-hero img, .shot img, .moment img { cursor: zoom-in; }

@media (max-width: 1024px) {
  .case-layout { grid-template-columns: 1fr; }
  .case-facts { position: static; order: -1; }
}
@media (max-width: 620px) {
  .shots-grid { grid-template-columns: 1fr; }
  .case-facts h2, .case-facts dt, .eyebrow[data-n]::before { font-size: 11.5px; }
}

/* ------------------------------------------------------------ lightbox --- */
.lb {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center; padding: clamp(14px, 4vw, 48px);
  background: rgba(4, 8, 15, .93);
  opacity: 0; pointer-events: none; transition: opacity .22s cubic-bezier(.4, 0, 1, 1);
}
.lb.open { opacity: 1; pointer-events: auto; transition: opacity .28s var(--ease); }
.lb figure { max-width: min(1400px, 100%); max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.lb img {
  max-width: 100%; max-height: calc(100vh - 150px); width: auto; height: auto;
  border-radius: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
  transform: scale(.97); transition: transform .35s var(--ease-out);
}
.lb.open img { transform: none; }
.lb figcaption { color: #D9DEE6; font-size: 13.5px; text-align: center; max-width: 70ch; }
.lb button {
  position: absolute; width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; color: #F2EFE7;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background .25s var(--ease);
}
.lb button:hover { background: rgba(255,255,255,.16); }
.lb button svg { width: 18px; height: 18px; }
.lb .lb-x    { top: 18px; right: 18px; }
.lb .lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lb .lb-next { right: 18px; top: 50%; transform: translateY(-50%); }
.lb .lb-count { position: absolute; top: 28px; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 12px; color: #9FAAB9; }
.lb.single .lb-prev, .lb.single .lb-next, .lb.single .lb-count { display: none; }
body.lb-lock { overflow: hidden; }


/* -------------------------------------------------------------- signals ---
   Comets travelling along lines the page already has: the section rules,
   the work connectors and the case-page text columns. Each rule's comet is
   one element as long as its rule, with the comet painted at its start and
   slid along with transform — no layout, no filters. */
@keyframes fxRunX { 0% { transform: translateX(-72px); opacity: 0; } 8%, 86% { opacity: 1; } 100% { transform: translateX(100%); opacity: 0; } }
@keyframes fxRunY { 0% { transform: translateY(-72px); opacity: 0; } 8%, 86% { opacity: 1; } 100% { transform: translateY(100%); opacity: 0; } }
@keyframes fxSig { from { stroke-dashoffset: var(--L, .04); } to { stroke-dashoffset: calc(var(--L, .04) - 1.1); } }

.sec-rule .ln { position: relative; overflow: visible; }
.sec-rule .ln::after {
  content: ''; position: absolute; left: 0; top: -5px; width: 100%; height: 11px; pointer-events: none; opacity: 0;
  background:
    radial-gradient(circle 5px at 66px 50%, #fff 0, rgba(var(--acc-rgb, var(--gold-rgb)), .9) 1.5px, transparent 5px) no-repeat,
    linear-gradient(90deg, transparent, rgba(var(--acc-rgb, var(--gold-rgb)), .85)) 0 50% / 66px 1.5px no-repeat;
  animation: fxRunX 6s linear infinite;
}
#approach .sec-rule .ln::after { animation-duration: 7s; animation-delay: 1.5s; }
#experience .sec-rule .ln::after { animation-delay: .8s; }
#beyond .sec-rule .ln::after { animation-duration: 6.5s; animation-delay: 2.2s; }
#about .sec-rule .ln::after { animation-delay: 3s; }

/* case pages: down each text column's rule */
.case-main .case-grid section { position: relative; }
.case-main .case-grid section::before {
  content: ''; position: absolute; left: -5px; top: 0; width: 11px; height: 100%; pointer-events: none; opacity: 0;
  --acc: var(--gold); --acc-rgb: var(--gold-rgb);
  background:
    radial-gradient(circle 5px at 50% 66px, #fff 0, rgba(var(--acc-rgb), .9) 1.5px, transparent 5px) no-repeat,
    linear-gradient(180deg, transparent, rgba(var(--acc-rgb), .85)) 50% 0 / 1.5px 66px no-repeat;
  animation: fxRunY 5s linear infinite;
}
.case-main .case-grid section:nth-child(2)::before { animation-duration: 6.5s; animation-delay: 1.2s; --acc: var(--cyan); --acc-rgb: var(--cyan-rgb); }
.case-main .case-grid section:nth-child(3)::before { animation-duration: 5.5s; animation-delay: 2.4s; }
.case-main .case-grid section:nth-child(4)::before { animation-duration: 7s; animation-delay: .6s; --acc: var(--cyan); --acc-rgb: var(--cyan-rgb); }

/* work connectors: js/fx.js adds a tail + head pair per trace. No
   vector-effect: with non-scaling-stroke Chrome measures the dash in screen
   pixels instead of pathLength units, and the signal vanishes. */
.conn-line .sig { fill: none; stroke-linecap: round; stroke-dasharray: var(--L) 2; stroke-dashoffset: var(--L);
                  animation: fxSig 6s linear infinite; }
.conn-line .sig.tail { --L: .08; stroke-width: 2; stroke-opacity: .25; }
.conn-line .sig.head { --L: .012; stroke-width: 2.8; }
.conn-line .sig.g { stroke: var(--gold-hi); }
.conn-line .sig.c { stroke: var(--cyan-hi); }

/* -------------------------------------------------------------- polish ---
   Two small touches. Everything that moves is scoped to html.fx-on, which
   js/fx.js sets only when the visitor has not asked for reduced motion, so
   without JS (or with reduced motion) the page simply shows its final state. */

/* 1. Section rules draw themselves in, and the via pops in at the end. */
.fx-on .sec-rule .ln { transform: scaleX(0); transform-origin: 0 50%; transition: transform 1.3s var(--ease-out); }
.fx-on .sec-rule .via { opacity: 0; transform: scale(.3); transition: opacity .5s var(--ease) 1s, transform .6s var(--ease-out) 1s; }
.fx-on .sec-head.drawn .sec-rule .ln { transform: none; }
.fx-on .sec-head.drawn .sec-rule .via { opacity: 1; transform: none; }

/* 2. Back to top: a small glass button once you are well down the page. */
.fx-top {
  position: fixed; right: clamp(14px, 3vw, 28px); bottom: clamp(14px, 3vw, 28px); z-index: 90;
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--gold-hi);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-filter-sm); -webkit-backdrop-filter: var(--glass-filter-sm);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-spec), var(--glass-drop);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .35s var(--ease), transform .35s var(--ease), box-shadow .3s var(--ease);
}
.fx-top.show { opacity: 1; transform: none; pointer-events: auto; }
.fx-top:hover { box-shadow: var(--glass-spec), 0 0 0 1px rgba(var(--gold-rgb), .35), 0 10px 24px -10px rgba(0, 0, 0, .5); }
.fx-top svg { width: 18px; height: 18px; }
body.lb-lock .fx-top { display: none; }

/* ------------------------------------------------------ reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .hero-circuit .t { stroke-dashoffset: 0; }
  .comet { display: none; }
  .fx-tilt { transform: none !important; }
  .sec-rule .ln::after, .case-main .case-grid section::before, .conn-line .sig { display: none; }
}
@media print {
  .hero-circuit, .fx-glare, .lb { display: none !important; }
  .contact > .wrap { background: none; box-shadow: none; border: 0; }
}

/* Off-screen or collapsed: animations paused (js/fx.js pauseOffscreen). */
.is-off .comet, .is-off .sig, .sec-rule.is-off .ln::after, section.is-off::before,
.plist-more:not(.open) .sig { animation-play-state: paused; }
