/* PICTURES: the working picture on top of the two home practice cards (Immi-OS, Finance).
   Loads after styles.css and cards.css. Home page only. Every colour is a token, so both themes follow.

   STRUCTURE (index.html)
     .fit.practice.has-underglow
       .pic            role="img" + aria-label: one image for assistive technology
         .pic-frame.pic-wide   landscape drawing, viewBox 580 x 250, type 12.5 units and up
         .pic-frame.pic-tall   portrait drawing, viewBox 280 wide, type 13 units and up
           svg  +  span.pic-tag "SAMPLE" (HTML, so it stays 12 px at every scale; placed in % of the frame)
       h4, h3, p, a    unchanged

   WHICH DRAWING IS SHOWN
     Picture text must render at 12 px or more. The landscape drawing needs a frame of 557 px for that, the
     portrait one needs 259 px. Card inner width: one column (up to 860 px) = page width - 58; two columns
     (861 px and up) = (min(page width, 1240) - 76) / 2 - 2. Media queries count a desktop scrollbar (up to
     17 px) that the page width does not, so the two landscape thresholds sit 20 px above the bare minimum.
       up to 639 px          portrait, frame up to 340 px (320 px viewport: 262 px frame, type 12.2 px)
       640 to 860 px         landscape, frame 565 to 640 px
       861 to 1219 px        portrait, frame 300 px, both panels the same height (cards are 380 to 570 px wide)
       1220 px and up        landscape, frame 561 to 580 px

   MOTION
     pictures.js watches each picture and adds .pic-play once, when 35% of it is in view. Before that it adds
     .pic-arm, which hides the parts that will draw. Everything below is CSS: lines draw in, ticks follow one
     by one, the signature writes, the mismatch dashes travel and settle. Only stroke-dashoffset and opacity
     change, so nothing moves in the layout. With no script, with ?shot=1 (no "js" class) or under reduced
     motion, no rule here applies and the finished drawing is shown. */

@property --pic-on{syntax:"<number>";inherits:false;initial-value:0}

/* ---------- the card: same padding as styles.css, named so the panel can cancel it ---------- */
.fit.practice{--pp-x:34px;--pp-t:34px;padding:var(--pp-t) var(--pp-x) 26px;overflow:hidden}

/* ---------- the panel: full bleed to the card's edges, dotted ground, hairline under it ---------- */
.pic{
  --pic-on:0;
  flex:none;display:flex;justify-content:center;align-items:center;overflow:hidden;
  -webkit-user-select:none;user-select:none;
  /* the text block keeps the top inset it had inside the card */
  margin:calc(-1*var(--pp-t)) calc(-1*var(--pp-x)) var(--pp-t);
  border-bottom:1px solid var(--hair);
  /* dots, then the card spotlight carried across the panel (same point as cards.css, which measures --mx / --my
     from the card's border edge, one pixel outside this box), then the ground */
  background:
    radial-gradient(var(--hair) 1px,transparent 1.2px) 0 0/16px 16px,
    radial-gradient(360px circle at calc(var(--mx,-999px) - 1px) calc(var(--my,-999px) - 1px),rgba(var(--ember-rgb),calc(var(--cs-wash,.2)*var(--pic-on))),transparent 58%),
    linear-gradient(180deg,var(--raised),var(--bg));
  transition:--pic-on .26s ease;
}
@media (hover:hover) and (pointer:fine){
  .fit.practice:hover .pic{--pic-on:1}
  .fit.practice:has(:focus-visible) .pic{--pic-on:1}
}
.pic-frame{position:relative;width:100%}
/* the drawing may run past its frame (the ember line does, when the panel is wider); the panel clips it */
.pic-frame svg{display:block;width:100%;height:auto;overflow:visible}
.pic-wide{display:none;max-width:640px}
.pic-tall{max-width:340px}

/* SAMPLE: the values are invented, and the picture says so */
.pic-tag{position:absolute;right:var(--tag-r);top:var(--tag-y);transform:translateY(-50%);
  font-family:var(--mono);font-size:.75rem;font-weight:500;line-height:1;letter-spacing:.14em;
  color:var(--mute);border:1px solid var(--hair-2);border-radius:2px;padding:3px 4px 3px 6px;white-space:nowrap;pointer-events:none}
.pic-immi .pic-wide .pic-tag{--tag-r:3.448%;--tag-y:13.2%}
.pic-fin  .pic-wide .pic-tag{--tag-r:5.517%;--tag-y:8.4%}
.pic-immi .pic-tall .pic-tag{--tag-r:8.571%;--tag-y:8.46%}
.pic-fin  .pic-tall .pic-tag{--tag-r:5.714%;--tag-y:6.333%}

@media (max-width:860px){
  .fit.practice{--pp-x:22px;--pp-t:26px;padding:var(--pp-t) var(--pp-x) 24px}
}
@media (min-width:640px) and (max-width:860px),(min-width:1220px){
  .pic-wide{display:block}
  .pic-tall{display:none}
}
/* two narrow cards side by side: portrait drawings at one fixed size, panels the same height */
@media (min-width:861px) and (max-width:1219px){
  .pic{min-height:426px}
  .pic-tall{max-width:300px}
}

/* ---------- the drawing: every mark is a class, every class takes a token ---------- */
.pic text{font-family:var(--mono)}
.pc-sheet{fill:var(--raised);stroke:var(--hair-2)}
.pc-bar{fill:var(--hair-2)}
.pc-hl{fill:var(--raised);stroke:var(--ember);stroke-width:1.4}
.pc-ln{fill:none;stroke:var(--mute);stroke-width:1.2}
.pc-line{stroke:var(--ember);stroke-width:2}
.pc-box{fill:var(--bg);stroke:var(--ember);stroke-width:2}
.pc-tick{fill:none;stroke:var(--ember);stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
.pc-chk{fill:none;stroke:var(--ember-text);stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.pc-rule{stroke:var(--hair)}
.pc-sig{fill:none;stroke:var(--text);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.pc-dash{fill:none;stroke:var(--ember);stroke-width:1.5;stroke-dasharray:4 5}
.pc-tagbox{fill:var(--bg);stroke:var(--ember);stroke-width:1.4}
.pc-emt{fill:var(--ember-text)}
.pc-tx{fill:var(--soft)}
.pc-hd{fill:var(--mute)}
.pc-str{fill:var(--text)}

/* ---------- motion (see the note at the top) ---------- */
@media (prefers-reduced-motion:no-preference){
  html.js .pic-arm .pc-draw,html.js .pic-arm .pc-fade,html.js .pic-arm .pc-flow{opacity:0}
  html.js .pic-play .pc-draw{animation:pc-draw var(--t,.6s) cubic-bezier(.45,0,.2,1) var(--d,0s) backwards}
  html.js .pic-play .pc-fade{animation:pc-fade .45s ease var(--d,0s) backwards}
  html.js .pic-play .pc-flow{animation:pc-fade .45s ease var(--d,0s) backwards,pc-travel 6.5s cubic-bezier(.2,.55,.3,1) var(--d,0s) backwards}

  /* Immi-OS: three details run into the checkpoint, it ticks, four checks tick, the signature writes */
  .pic-immi .pc-ln .pc-draw:nth-child(1){--d:.15s}
  .pic-immi .pc-ln .pc-draw:nth-child(2){--d:.29s}
  .pic-immi .pc-ln .pc-draw:nth-child(3){--d:.43s}
  .pic-immi .pc-tick{--d:.98s;--t:.4s}
  .pic-immi .pc-chks :nth-child(1){--d:1.4s;--t:.3s}
  .pic-immi .pc-chks :nth-child(2){--d:1.66s;--t:.3s}
  .pic-immi .pc-chks :nth-child(3){--d:1.92s;--t:.3s}
  .pic-immi .pc-zero{--d:2.18s}
  .pic-immi .pc-sig{--d:2.5s;--t:1s}
  .pic-immi .pc-to{--d:3.15s}

  /* Finance, landscape: each pair runs through the rule in one stroke */
  .pic-fin .pic-wide .pc-ln .pc-draw:nth-child(1){--d:.15s;--t:1s}
  .pic-fin .pic-wide .pc-ln .pc-draw:nth-child(2){--d:.33s;--t:1s}
  .pic-fin .pic-wide .pc-ln .pc-draw:nth-child(3){--d:.51s;--t:1s}
  .pic-fin .pic-wide .pc-tick{--d:.95s;--t:.4s}
  .pic-fin .pic-wide .pc-flow{--d:1.7s}
  .pic-fin .pic-wide .pc-person{--d:2s}
  /* Finance, portrait: in from the ledger, tick, out to the bank */
  .pic-fin .pic-tall .pc-ln .pc-draw:nth-child(1){--d:.15s;--t:.5s}
  .pic-fin .pic-tall .pc-ln .pc-draw:nth-child(2){--d:.27s;--t:.5s}
  .pic-fin .pic-tall .pc-ln .pc-draw:nth-child(3){--d:.39s;--t:.5s}
  .pic-fin .pic-tall .pc-tick{--d:.85s;--t:.4s}
  .pic-fin .pic-tall .pc-ln .pc-draw:nth-child(4){--d:1.25s;--t:.5s}
  .pic-fin .pic-tall .pc-ln .pc-draw:nth-child(5){--d:1.37s;--t:.5s}
  .pic-fin .pic-tall .pc-ln .pc-draw:nth-child(6){--d:1.49s;--t:.5s}
  .pic-fin .pic-tall .pc-flow{--d:2.05s}
  .pic-fin .pic-tall .pc-person{--d:2.35s}
}
/* drawn paths carry pathLength="1", so one dash is the whole path */
@keyframes pc-draw{
  from{stroke-dasharray:1;stroke-dashoffset:1;opacity:0}
  5%{opacity:1}
  to{stroke-dasharray:1;stroke-dashoffset:0;opacity:1}
}
@keyframes pc-fade{from{opacity:0}to{opacity:1}}
/* six dash lengths toward the tag, slowing to a stop */
@keyframes pc-travel{from{stroke-dashoffset:54}to{stroke-dashoffset:0}}
@media (prefers-reduced-motion:reduce){.pic{transition:none}}
