/* Flair layer. Loaded on every page after motion.css; the behaviour half lives in assets/js/flair.js.
   Each addition is a numbered FLAIR-<n> block (see FLAIR.md); delete a block to revert it.
   Motion is transform/opacity only and sits inside prefers-reduced-motion:no-preference, so with reduced
   motion every block below is inert and the page stays static and fully visible. Classes use the fl- prefix. */

/* ===== FLAIR-1: home and 404 hero power-on. The sun rises behind the horizon, the grid lines flicker on,
   and two light cycles (cyan from the left, violet from the right) race along the dimmed horizon and light it as they meet under the sun.
   As they meet, the neon bar under "This is the wave." charges from the left. Plays once per load, about 2.6 s.
   The sun line repeats motion.css's three sun loops and adds the rise. ===== */
@media (prefers-reduced-motion: no-preference) {
  .hero .sun{animation:sun-pulse 6s ease-in-out infinite alternate,sun-slices 9s linear infinite,sun-breathe 6s ease-in-out infinite alternate,fl-sun-rise 1.7s .1s cubic-bezier(.2,.7,.2,1) both}
  .hero .floor-plane{animation:fl-power-on 1s .15s steps(1,end) both}
  .hero .horizon{animation:fl-horizon-on 2.3s .35s ease-out both}
  .hero .hero-scene::before,.hero .hero-scene::after{content:"";position:absolute;z-index:4;top:calc(var(--sky-h) - 13px);width:50%;height:24px;pointer-events:none;opacity:0;background-repeat:no-repeat}
  .hero .hero-scene::before{left:0;
    background-image:radial-gradient(circle 13px at 100% 50%,#fff 0 2px,rgba(62,240,255,.9) 4px,rgba(62,240,255,.25) 8px,transparent),
      linear-gradient(90deg,rgba(62,240,255,0),rgba(62,240,255,.6) 60%,#3ef0ff 96%,#fff),linear-gradient(90deg,rgba(62,240,255,0) 30%,rgba(62,240,255,.28));
    background-size:100% 100%,100% 3px,100% 11px;background-position:0 0,0 50%,0 50%;animation:fl-cycle-l 2.3s .35s cubic-bezier(.5,0,.3,1) both}
  .hero .hero-scene::after{right:0;
    background-image:radial-gradient(circle 13px at 0 50%,#fff 0 2px,rgba(181,123,255,.95) 4px,rgba(157,77,255,.3) 8px,transparent),
      linear-gradient(270deg,rgba(181,123,255,0),rgba(181,123,255,.6) 60%,#b57bff 96%,#fff),linear-gradient(270deg,rgba(157,77,255,0) 30%,rgba(157,77,255,.32));
    background-size:100% 100%,100% 3px,100% 11px;background-position:0 0,0 50%,0 50%;animation:fl-cycle-r 2.3s .35s cubic-bezier(.5,0,.3,1) both}
  #top .slogan::after{transform-origin:left;animation:fl-charge .8s 1.3s cubic-bezier(.2,.7,.2,1) both}
  @keyframes fl-charge{from{scale:0 1}}
  @keyframes fl-horizon-on{0%,38%{opacity:.18}52%,100%{opacity:1}}
  @keyframes fl-sun-rise{from{translate:0 55%;opacity:0}35%{opacity:1}to{translate:0 0;opacity:1}}
  @keyframes fl-power-on{0%{opacity:0}18%{opacity:.55}26%{opacity:.12}40%{opacity:.8}48%{opacity:.4}60%,100%{opacity:1}}
  @keyframes fl-cycle-l{0%{opacity:1;transform:translateX(-100%)}40%{opacity:1;transform:translateX(0)}62%{opacity:1;transform:translateX(0)}100%{opacity:0;transform:translateX(0)}}
  @keyframes fl-cycle-r{0%{opacity:1;transform:translateX(100%)}40%{opacity:1;transform:translateX(0)}62%{opacity:1;transform:translateX(0)}100%{opacity:0;transform:translateX(0)}}
}

/* ===== FLAIR-2: Overdrive easter egg (home, projects, 404). The Konami code, or a click on the sun, kicks the grid
   and the disciplines marquee to triple speed for a few seconds, swells the sun, surges the horizon and sends a cyan
   shock ring out from it, with a small toast whose bar drains as the overdrive runs out.
   The class, ring and toast are added by flair.js (FLAIR-2 block) only when motion is allowed. ===== */
@media (prefers-reduced-motion: no-preference) {
  .sun{transition:scale .6s cubic-bezier(.2,.7,.2,1)}
  .fl-od .sun{scale:1.08}
  .horizon{transition:scale .5s cubic-bezier(.2,.7,.2,1)}
  .fl-od .horizon{scale:1 1.8}
  .fl-ring{position:absolute;z-index:2;left:50%;top:calc(var(--sky-h) - var(--sun-d)*.62);width:var(--sun-d);height:var(--sun-d);margin-left:calc(var(--sun-d)/-2);
    border:3px solid #3ef0ff;border-radius:50%;box-shadow:0 0 22px rgba(62,240,255,.8),inset 0 0 18px rgba(157,77,255,.6);pointer-events:none;
    animation:fl-ring 1.4s cubic-bezier(.15,.6,.3,1) both}
  .fl-toast{position:fixed;z-index:45;left:50%;top:calc(var(--fl-hh,72px) + 14px);padding:9px 16px 9px 14px;display:flex;align-items:center;gap:10px;
    background:rgba(20,5,39,.94);border:1px solid #3ef0ff;border-radius:3px;box-shadow:0 0 24px -4px rgba(62,240,255,.7);
    color:#e0ccff;font:700 .75rem/1.2 var(--mono-font);letter-spacing:.2em;text-transform:uppercase;pointer-events:none;
    transform:translate(-50%,-8px);opacity:0;transition:opacity .3s,transform .3s cubic-bezier(.2,.7,.2,1)}
  .fl-toast::before{content:"";width:8px;height:8px;background:#3ef0ff;transform:rotate(45deg);box-shadow:0 0 10px #3ef0ff}
  .fl-toast.fl-on{opacity:1;transform:translate(-50%,0)}
  .fl-toast::after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;background:linear-gradient(90deg,#3ef0ff,#b57bff);transform-origin:left}
  .fl-toast.fl-on::after{animation:fl-drain 3.2s linear both}
  @keyframes fl-drain{to{transform:scaleX(0)}}
  @keyframes fl-ring{0%{transform:scale(.85);opacity:1}55%{opacity:.75}100%{transform:scale(3.4);opacity:0}}
}

/* ===== FLAIR-3: neon controls on the synthwave pages. Buttons get a light sweep on hover and a short press on click;
   the header helm mark lifts and brightens on hover. ===== */
@media (prefers-reduced-motion: no-preference) {
  body.theme-home .button{overflow:hidden}
  body.theme-home .button::after{content:"";position:absolute;inset:0;pointer-events:none;
    background:linear-gradient(105deg,transparent 30%,rgba(255,255,255,.55) 48%,rgba(255,255,255,.15) 54%,transparent 66%);
    transform:translateX(-110%);opacity:0}
  body.theme-home .button:hover::after,body.theme-home .button:focus-visible::after{opacity:1;transform:translateX(110%);transition:transform .7s cubic-bezier(.3,.6,.2,1),opacity .2s}
  body.theme-home .button:active{transform:translateY(0) scale(.97);transition-duration:.08s}
  body.theme-home .wordmark .frame-mark{transition:transform .35s cubic-bezier(.2,.7,.2,1),box-shadow .35s}
  body.theme-home .wordmark:hover .frame-mark{transform:translateY(-1px) rotate(-8deg) scale(1.08)}
}

/* ===== FLAIR-4: card spotlight on home and projects. A soft cyan-violet light follows the pointer across a card,
   behind its text (a cool steel light on the Blackshield Company group cards). flair.js (FLAIR-4 block) adds one empty
   span.fl-spot to each card and moves it with transform. ===== */
.fl-card{isolation:isolate}
.fl-spot{position:absolute;left:0;top:0;pointer-events:none}
.fl-spot::before{content:"";position:absolute;inset:0;opacity:0}
@media (prefers-reduced-motion: no-preference) {
  body.theme-home .fl-spot{z-index:-1;width:440px;height:440px;margin:-220px 0 0 -220px}
  body.theme-home .fl-spot::before{border-radius:50%;background:radial-gradient(circle closest-side,rgba(62,240,255,.2),rgba(157,77,255,.16) 45%,transparent);transition:opacity .35s}
  body.theme-home .fl-card:hover .fl-spot::before{opacity:1}
  body.theme-home .proj-blackshield .fl-spot::before{background:radial-gradient(circle closest-side,rgba(216,211,200,.13),rgba(143,149,156,.1) 45%,transparent)}
}

/* ===== FLAIR-5: Blackshield and Mods (and the Glyphsmith Blackshield theme page): forged steel. On hover a cold steel
   glint with a blood-red edge passes once across the card, like light down a fresh-ground blade. ===== */
@media (prefers-reduced-motion: no-preference) {
  body:is(.theme-blackshield,.theme-mods,.palette-blackshield) .fl-spot{z-index:4;inset:0;
    background:linear-gradient(105deg,transparent 43%,rgba(216,211,200,.08) 47%,rgba(255,255,255,.24) 49.6%,rgba(193,18,31,.5) 50.4%,rgba(193,18,31,.1) 51.6%,transparent 54%);
    transform:translateX(-100%)}
  body:is(.theme-blackshield,.theme-mods,.palette-blackshield) .fl-card:hover .fl-spot{transform:translateX(100%);transition:transform 1.1s cubic-bezier(.4,0,.2,1)}
}

/* ===== FLAIR-6: Glyphsmith (main and Steel & Ember pages): precise. On hover or keyboard focus, four registration
   corners snap in around the card, like a selection in a design tool. ===== */
@media (prefers-reduced-motion: no-preference) {
  body.theme-glyphsmith:not(.palette-blackshield) .fl-spot{z-index:5;inset:6px}
  body.theme-glyphsmith:not(.palette-blackshield) .fl-spot::before{--c:rgba(216,211,200,.8);transform:scale(1.03);
    background:linear-gradient(var(--c),var(--c)) 0 0/14px 2px,linear-gradient(var(--c),var(--c)) 0 0/2px 14px,
      linear-gradient(var(--c),var(--c)) 100% 0/14px 2px,linear-gradient(var(--c),var(--c)) 100% 0/2px 14px,
      linear-gradient(var(--c),var(--c)) 0 100%/14px 2px,linear-gradient(var(--c),var(--c)) 0 100%/2px 14px,
      linear-gradient(var(--c),var(--c)) 100% 100%/14px 2px,linear-gradient(var(--c),var(--c)) 100% 100%/2px 14px;
    background-repeat:no-repeat;transition:opacity .18s,transform .22s cubic-bezier(.2,.8,.2,1)}
  body.theme-glyphsmith.palette-steel-and-ember .fl-spot::before{--c:rgba(242,140,56,.85)}
  body.theme-glyphsmith:not(.palette-blackshield) .fl-card:is(:hover,:focus-within) .fl-spot::before{opacity:1;transform:none}
}

/* ===== FLAIR-7: Ironwright (page, and its card on home): forge sparks. On hover a few amber sparks rise from the
   lower right of the card and burn out. ===== */
@media (prefers-reduced-motion: no-preference) {
  body.theme-ironwright .fl-spot,body.theme-home .brand-ironwright .fl-spot{z-index:5;left:auto;top:auto;right:22px;bottom:16px;width:70px;height:90px;margin:0}
  body.theme-ironwright .fl-spot::before,body.theme-home .brand-ironwright .fl-spot::before{background:radial-gradient(circle,#fff1c9 0 1.6px,rgba(224,178,92,.5) 2.4px,transparent 4px) 12px 70px/10px 10px,radial-gradient(circle,#e0b25c 0 1.3px,rgba(224,178,92,.4) 2px,transparent 3.5px) 36px 54px/10px 10px,
      radial-gradient(circle,#f4d58a 0 1px,transparent 2px) 52px 76px/8px 8px,radial-gradient(circle,#f4d58a 0 1.6px,rgba(224,178,92,.5) 2.4px,transparent 4px) 26px 82px/10px 10px,
      radial-gradient(circle,#fff1c9 0 1px,transparent 2px) 46px 40px/8px 8px;
    background-repeat:no-repeat;border-radius:0;transition:none}
  body.theme-ironwright .fl-card:hover .fl-spot::before,body.theme-home .brand-ironwright.fl-card:hover .fl-spot::before{animation:fl-sparks 1.1s cubic-bezier(.2,.6,.4,1) both}
  @keyframes fl-sparks{0%{opacity:0;transform:translateY(14px) scale(.8)}20%{opacity:1}70%{opacity:.85}100%{opacity:0;transform:translateY(-46px) scale(1.05)}}
}

/* ===== FLAIR-8: Lampstand: a slow warm light. A faint lamp-gold glow behind the heading brightens and settles
   over about sixteen seconds. No neon, nothing that draws the eye. ===== */
@media (prefers-reduced-motion: no-preference) {
  body.theme-lampstand .ministry{position:relative;isolation:isolate}
  body.theme-lampstand .ministry::before{content:"";position:absolute;z-index:-1;left:50%;top:0;width:min(46rem,100%);height:16rem;transform:translateX(-50%);pointer-events:none;
    background:radial-gradient(ellipse 50% 50% at 50% 45%,rgba(240,204,130,.075),transparent 72%);animation:fl-warm-light 16s ease-in-out infinite alternate}
  @keyframes fl-warm-light{from{opacity:.35}to{opacity:1}}
}

/* ===== FLAIR-9: reading progress. A hairline along the bottom of the header fills as the page scrolls
   (scroll-driven, no script). Cyan on the synthwave pages, each brand's accent on its own pages, none on Lampstand. ===== */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    .header::before{content:"";position:absolute;z-index:1;left:0;right:0;bottom:-1px;height:2px;pointer-events:none;transform-origin:left;transform:scaleX(0);
      background:linear-gradient(90deg,#3ef0ff,#e0ccff);box-shadow:0 0 10px rgba(62,240,255,.8);
      animation:fl-progress linear both;animation-timeline:scroll(root)}
    body.flat .header::before{background:var(--frame-accent,var(--accent));box-shadow:none}
    body.theme-lampstand .header::before{content:none}
    @keyframes fl-progress{to{transform:scaleX(1)}}
  }
}

/* ===== FLAIR-10: page transitions. Same-site navigation cross-fades the page while the header and the sprite dock
   hold still. Browsers without cross-document view transitions simply navigate as before. Lampstand fades more slowly. ===== */
@media (prefers-reduced-motion: no-preference) {
  @view-transition{navigation:auto}
  .header{view-transition-name:fl-header}
  .sprite-dock{view-transition-name:fl-dock}
  ::view-transition-old(root){animation:fl-vt-out .2s ease-in both}
  ::view-transition-new(root){animation:fl-vt-in .34s cubic-bezier(.2,.7,.2,1) both}
  html:has(body.theme-lampstand)::view-transition-new(root){animation:fl-vt-fade .6s ease both}
  @keyframes fl-vt-out{to{opacity:0}}
  @keyframes fl-vt-in{from{opacity:0;transform:translateY(10px)}}
  @keyframes fl-vt-fade{from{opacity:0}}
}

/* ===== FLAIR-11: typography. Balanced heading lines, no orphans in body copy, kerning and optical sizes on,
   and tabular figures with a slashed zero in the mono labels (01 / the work, versions, dock state). ===== */
h1,h2,h3{text-wrap:balance}
main p,main li{text-wrap:pretty}
body{font-kerning:normal;font-optical-sizing:auto}
.eyebrow,.card-kicker,.tags,code,pre,.sprite-label,.clip figcaption{font-variant-numeric:tabular-nums slashed-zero}

/* ===== FLAIR-12: home portrait tilt. The helm portrait tilts a few degrees toward the pointer, like a hologram card.
   flair.js (FLAIR-12 block) sets the rotate property; the frame's float keeps running underneath. ===== */
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  #top .portrait{perspective:900px}
  #top .portrait-frame{transition:rotate .5s cubic-bezier(.2,.7,.2,1)}
  #top .portrait-frame.fl-tilting{transition-duration:.12s}
}

/* ===== FLAIR-13: 404 signal. The heading comes on like an old tube: a bright line opens into the words. ===== */
@media (prefers-reduced-motion: no-preference) {
  .hero.lost h1{transform-origin:50% 50%;animation:fl-tube .7s .3s cubic-bezier(.2,.7,.2,1) both}
  @keyframes fl-tube{0%{opacity:0;transform:scale(1.15,.02)}35%{opacity:1;transform:scale(1.06,.04)}70%{transform:scale(1,1.04)}100%{opacity:1;transform:none}}
}

/* ===== FLAIR-14: group headers draw their own light trail. As a project group header scrolls into view, a light
   runs along its rule from the left and leaves it lit, like the hero's light cycles: cyan-violet for synth's
   projects and the studios, cold steel with a blood-red head for the Blackshield Company group. Scroll-driven,
   no script; browsers without view timelines keep the plain rule. ===== */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .group-head{position:relative;view-timeline:--fl-gh block}
    .group-head::before,.group-head::after{content:"";position:absolute;left:0;right:0;pointer-events:none;
      animation-timing-function:linear;animation-fill-mode:both;animation-timeline:--fl-gh;animation-range:entry 100% cover 45%}
    .group-head::after{bottom:-1px;height:1px;transform-origin:left;transform:scaleX(0);
      background:linear-gradient(90deg,rgba(181,123,255,.4),#b57bff 55%,#3ef0ff);box-shadow:0 0 8px rgba(62,240,255,.45);animation-name:fl-trail}
    .group-head::before{z-index:1;bottom:-5px;height:9px;
      background:radial-gradient(circle 4.5px at calc(100% - 5px) 50%,#fff 0 1.4px,#3ef0ff 2.6px,rgba(62,240,255,.3) 3.6px,transparent);animation-name:fl-trail-head}
    .proj-group-blackshield .group-head::after{background:linear-gradient(90deg,rgba(143,149,156,.35),#c9ced4 70%,#d8d3c8);box-shadow:none}
    .proj-group-blackshield .group-head::before{background:radial-gradient(circle 4.5px at calc(100% - 5px) 50%,#fff 0 1.2px,#c1121f 2.6px,rgba(193,18,31,.3) 3.6px,transparent)}
    @keyframes fl-trail{to{transform:scaleX(1)}}
    @keyframes fl-trail-head{from{transform:translateX(-100%)}88%{opacity:1}to{transform:none;opacity:0}}
  }
}

/* ===== FLAIR-15: the Blackshield Company group keeps its livery on hover. On home and /projects/ the cards in that
   group have a blood-red tab; the hover bar along their top runs steel to blood red instead of the synthwave
   cyan-violet, so it no longer stacks a neon stripe under the red tab. Colour only, no motion. ===== */
body.theme-home .proj-blackshield.card::before{background:linear-gradient(90deg,#8f959c,#d8d3c8 45%,#c1121f)}

/* ===== FLAIR-16: home sunset on scroll. As the hero scrolls away, the sun sinks a third of the way behind the grid
   floor, and rises again on the way back up. Scroll-driven (no script), translate only, home only. ===== */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    #top .sun{animation:sun-pulse 6s ease-in-out infinite alternate,sun-slices 9s linear infinite,sun-breathe 6s ease-in-out infinite alternate,fl-sun-rise 1.7s .1s cubic-bezier(.2,.7,.2,1) both,fl-sunset linear both;
      animation-timeline:auto,auto,auto,auto,scroll(root);animation-range:normal,normal,normal,normal,0 320px}
    @keyframes fl-sunset{to{translate:0 34%}}
  }
}
