/* =====================================================================================
   Dashboard motion layer — module "ambient"  (prefix: am-)
   Owns: .hud::after, .tile::after (left unused, see section 2), #dash::before, pointer effects on
         .hud / .tile / #card-resume, and the .am-* nodes it appends inside the light cards.
   Nothing here is visible until ambient.js adds its classes (am-on / am-live / am-lit ...),
   so with the script missing the page equals the static base.
   Every loop and every pointer effect is a transform / opacity change (compositor); nothing here
   repaints or relayouts a card while it runs. Colours: theme tokens only, with the contract fallbacks.
   ===================================================================================== */

#dash{
  position:relative;            /* containing block for ::before — does not change layout */
  isolation:isolate;            /* keeps the z-index:-1 backdrop above the page fill, below the cards */
  /* the page accent; ambient.js swaps in --alert only in themes where the accent IS the card border
     colour (royal family: brand = line), where an accent-coloured light would not show on the border */
  --am-hot:var(--brand,#FF52A2);
  /* ornaments use the dark fill, not the text ink: some themes set --ink to pure black, and
     translucent black reads as grey */
  --am-ink:var(--fill,#006D40);
  --am-edge:var(--line,#006D40);
  --am-face:var(--surface,#FFFFFF);
  --am-ease:cubic-bezier(.22,1,.36,1);
}

/* ---------- 1. backdrop: faint dot field (a heavier dot every 4th), floating behind the columns ----------
   The field is painted once and only its layer moves. Bleed + drift (13px / 9px) never passes
   #dash's right edge and stays inside main's padding on the other sides, so it cannot add scroll
   (not even on a viewport narrow enough that the grid itself already overflows). */
#dash::before{
  content:'';
  position:absolute;
  z-index:-1;
  inset:-14px 13px -22px -19px;
  pointer-events:none;
  opacity:0;
  background-image:
    radial-gradient(circle at 50% 50%,var(--am-ink) 0 1.7px,transparent 2.3px),
    radial-gradient(circle at 50% 50%,var(--am-ink) 0 .9px,transparent 1.5px);
  background-size:104px 104px,26px 26px;
  background-position:0 0,13px 13px;
  -webkit-mask-image:linear-gradient(90deg,transparent 0,#000 5%,#000 calc(100% - 14px),transparent 100%),linear-gradient(180deg,transparent 0,#000 5%,#000 90%,transparent 100%);
  -webkit-mask-composite:source-in;
  mask-image:linear-gradient(90deg,transparent 0,#000 5%,#000 calc(100% - 14px),transparent 100%),linear-gradient(180deg,transparent 0,#000 5%,#000 90%,transparent 100%);
  mask-composite:intersect;
  transition:opacity 1.6s var(--am-ease);
}
#dash.am-on::before{opacity:.3}
/* two unsynchronised sine-like swings = a slow Lissajous float that never visibly repeats */
#dash.am-on.am-inview::before{
  will-change:transform,translate;
  animation:am-drift-x 41s ease-in-out infinite alternate,am-drift-y 59s ease-in-out infinite alternate;
}
@keyframes am-drift-x{from{translate:-13px 0}to{translate:13px 0}}
@keyframes am-drift-y{from{transform:translateY(-9px)}to{transform:translateY(9px)}}

/* ---------- 2. cursor spotlight (reveal light) on cards and tiles ----------
   One .am-spot per card (inside its .am-layer) and per tile: a frame the size of the border box,
   masked so the light is full strength on the border ring and a whisper on the face, holding a
   soft disc that ambient.js moves under the pointer with a transform.
   Why not custom properties on .hud::after / .tile::after: every write restyled the card and its
   children (~50 extra elements a frame while the pointer moved) and re-rastered a card-sized
   gradient, which dropped frames once the other modules were animating. A transform on a leaf
   node restyles one element and repaints nothing. */
#dash .hud{--am-bw:2px;--am-r1:150px}
#dash .tile{--am-bw:1px;--am-r1:104px}

#dash .am-spot{
  position:absolute;
  inset:0;                          /* inside .am-layer = the card's border box */
  padding:var(--am-bw);             /* content box = the face, the padding ring = the border */
  border-radius:inherit;
  overflow:hidden;
  pointer-events:none;
  opacity:0;
  -webkit-mask:linear-gradient(rgba(0,0,0,.92),rgba(0,0,0,.92)) content-box,linear-gradient(#000,#000) border-box;
  -webkit-mask-composite:xor;
  mask:linear-gradient(rgba(0,0,0,.92),rgba(0,0,0,.92)) content-box,linear-gradient(#000,#000) border-box;
  mask-composite:exclude;
  transition:opacity .7s var(--am-ease);
}
#dash .tile > .am-spot{inset:calc(var(--am-bw) * -1)}
/* the light source: holds its colour, then drops off quickly (short blend = no muddy band) */
#dash .am-spot > i{
  position:absolute;
  left:calc(var(--am-r1) * -1);
  top:calc(var(--am-r1) * -1);
  width:calc(var(--am-r1) * 2);
  height:calc(var(--am-r1) * 2);
  border-radius:50%;
  background:radial-gradient(closest-side,var(--am-hot) 0,var(--am-hot) 20%,62%,transparent 84%);
  transform:translate3d(-999px,-999px,0);
}
#dash .hud.am-lit > .am-layer > .am-spot,
#dash .tile.am-lit > .am-spot{opacity:1;transition-duration:.28s}
#dash .hud.am-lit > .am-layer > .am-spot > i,
#dash .tile.am-lit > .am-spot > i{will-change:transform}

/* ---------- 3. tile tilt / magnetic arrow (transforms are written by ambient.js) ---------- */
#dash .tile.am-tilt{will-change:transform}
#card-resume .resume-go{position:relative}
#card-resume .resume-go.am-mag,
#card-resume .resume-go.am-mag > svg{will-change:transform}

/* soft sonar ping around the continue arrow */
#card-resume .am-ping{
  position:absolute;
  inset:0;
  border-radius:inherit;
  border:1.5px solid var(--fill,#006D40);
  box-sizing:border-box;
  opacity:0;
  pointer-events:none;
  animation:am-ping 3.6s cubic-bezier(.16,.8,.3,1) infinite;
  animation-play-state:paused;
}
#card-resume.am-inview .am-ping{animation-play-state:running}
@keyframes am-ping{
  0%{transform:scale(1);opacity:0}
  8%{opacity:.6}
  62%,100%{transform:scale(1.95);opacity:0}
}

/* ---------- 4. HUD overlay appended to every card (one .am-layer = the card's border box) ---------- */
#dash .am-layer{
  position:absolute;
  z-index:1;                    /* above the card's content */
  inset:calc(var(--am-bw) * -1);
  border-radius:inherit;        /* passed on to .am-spot */
  pointer-events:none;
  opacity:0;
  transition:opacity .9s var(--am-ease) var(--am-in,0s);
}
#dash .hud.am-live > .am-layer{opacity:1}
/* the comet's glow reaches ~12px past the card; keep painting it, but as ink only, so a card at the
   edge of an already-overflowing viewport does not make the page's scroll width breathe */
@supports (overflow-clip-margin:1px){
  #dash .am-layer{overflow:clip;overflow-clip-margin:24px}
}

/* 4a. corner brackets — an inner rounded rect drawn only around its corners; they reach out on hover.
       Static SVG: nothing repaints unless the card is hovered. */
#dash .am-fx{position:absolute;left:0;top:0;width:100%;height:100%;overflow:visible;fill:none}
#dash .am-brk{
  stroke:var(--am-ink);
  stroke-width:1.25;
  stroke-linecap:round;
  stroke-dasharray:var(--am-da,0 9999);
  opacity:.34;
  transition:stroke-dasharray .6s var(--am-ease),opacity .45s var(--am-ease),stroke .45s var(--am-ease);
}
#dash .hud.am-live > .am-layer .am-brk{animation:am-brk-in 1.1s var(--am-ease) var(--am-in,0s) backwards}
@keyframes am-brk-in{from{stroke-dasharray:var(--am-d0,0 9999);opacity:0}}
#dash .hud:hover > .am-layer .am-brk,
#dash .hud:focus-within > .am-layer .am-brk{
  stroke-dasharray:var(--am-db,0 9999);
  stroke:var(--am-hot);
  opacity:.95;
}

/* 4b. energy line — a comet that rides the centre of the border.
       .am-comet is moved by a Web Animation (translate + rotate keyframes built from the card size);
       .am-tail stretches along the edges and tucks in before every corner (scaleX).
       .am-glow / .am-tip are real nodes, not pseudo-elements: a pseudo-element is restyled together
       with its animated parent on every style pass. */
#dash .am-orbit,
#dash .am-comet{position:absolute;left:0;top:0;width:0;height:0}
#dash .am-glow{                     /* glow, stretched along the direction of travel */
  position:absolute;
  left:-33px;
  top:calc(var(--am-rr,21px) * -1 - 10px);
  width:48px;
  height:20px;
  border-radius:50%;
  background:radial-gradient(closest-side,var(--am-hot),transparent);
  opacity:.38;
}
#dash .am-tail{                     /* needle: hairline at the far end, border-wide at the head */
  position:absolute;
  right:0;
  top:calc(var(--am-rr,21px) * -1 - 1.25px);
  width:0;
  height:0;
  border-style:solid;
  border-color:transparent var(--am-hot) transparent transparent;
  border-width:1.25px var(--am-tl,150px) 1.25px 0;
  transform-origin:100% 50%;
}
#dash .am-tip{                      /* white-hot tip */
  position:absolute;
  left:-5px;
  top:calc(var(--am-rr,21px) * -1 - .8px);
  width:6px;
  height:1.6px;
  border-radius:1px;
  background:var(--am-face);
  opacity:.95;
}

/* 4c. status glyph — a capsule sitting on the bottom border; one live dot hops across three slots */
#dash .am-sig{
  position:absolute;
  right:var(--am-sr,44px);
  bottom:calc(var(--am-bw) * .5 - 4.5px);
  width:30px;
  height:9px;
  box-sizing:border-box;
  border:1px solid var(--am-edge);
  border-radius:5px;
  background:var(--am-face);
}
#dash .am-sig::before{
  content:'';
  position:absolute;
  inset:0;
  opacity:.26;
  background:
    radial-gradient(circle at 7.5px 50%,var(--am-ink) 0 1.25px,transparent 1.75px),
    radial-gradient(circle at 14px 50%,var(--am-ink) 0 1.25px,transparent 1.75px),
    radial-gradient(circle at 20.5px 50%,var(--am-ink) 0 1.25px,transparent 1.75px);
}
#dash .am-sig i{
  position:absolute;
  left:6px;
  top:2px;
  width:3px;
  height:3px;
  border-radius:50%;
  background:var(--am-hot);
  opacity:0;
  animation:am-sig 3s cubic-bezier(.3,0,.3,1) infinite;
  animation-play-state:paused;
}
#dash .hud.am-inview > .am-layer .am-sig i{animation-play-state:running}
@keyframes am-sig{
  0%{opacity:0;transform:translateX(0)}
  6%{opacity:1;transform:translateX(0)}
  18%{opacity:0;transform:translateX(0)}
  18.01%{opacity:0;transform:translateX(6.5px)}
  24%{opacity:1;transform:translateX(6.5px)}
  36%{opacity:0;transform:translateX(6.5px)}
  36.01%{opacity:0;transform:translateX(13px)}
  42%{opacity:1;transform:translateX(13px)}
  56%,100%{opacity:0;transform:translateX(13px)}
}

/* CSS loops stop while the tab is hidden (the comet is paused from ambient.js) */
#dash.am-paused::before,
#dash.am-paused .am-sig i,
#dash.am-paused .am-ping{animation-play-state:paused!important}

/* ---------- reduced motion: resting ornaments only ---------- */
@media (prefers-reduced-motion:reduce){
  #dash::before,
  #dash .am-layer,
  #dash .am-brk,
  #dash .am-spot{transition-duration:.01s;transition-delay:0s}
  #dash.am-on.am-inview::before{animation:none;will-change:auto}
  #dash .hud.am-live > .am-layer .am-brk{animation:none}
  #dash .am-orbit,
  #card-resume .am-ping{display:none}
  #dash .am-sig i{animation:none;opacity:.9;transform:translateX(13px)}
}

/* ---------- paper / forced colours: decoration off, the cards stay exactly as the base draws them ---------- */
@media print,(forced-colors:active){
  #dash::before,
  #dash .am-layer,
  #dash .am-spot,
  #card-resume .am-ping{display:none!important}
}
