/* ==========================================================================
   HERO RIG · the wireframe book that opens and projects its contents
   --------------------------------------------------------------------------
   One authored object for the hero of the book landing pages. It stands on
   the existing perspective grid (.hero-floor / .hero-horizon, which are NOT
   ours and stay exactly as they are) and replaces the old arc of plates.

   Loaded AFTER css/libro.css, from which it borrows the tokens
   (--cyan, --phosphor, --violet, --ink-*, --display, --ease-out, ...).

   Contract
   - every selector is scoped to `.rig` or to a `rig-` class;
   - the content is static HTML: CSS alone gives the 3D pose, the open book,
     the three projections and the idle motion. With scripting off the hero
     still shows an open wireframe book projecting its three planes;
   - JS only adds the pointer reaction, by writing five custom properties on
     `.rig` (--yaw and --pitch in degrees as unitless numbers, --mx / --my in
     -1..1, --ab the chromatic aberration multiplier) plus the classes
     `is-live` and `is-swapping`;
   - under prefers-reduced-motion everything is frozen in the settled pose.

   Layer map (outside in)
     .rig                 flex column: stage + caption. Holds every variable.
       .rig-stage         the perspective camera (aria-hidden)
         .rig-scene       global scale, keeps the whole rig in budget
           .rig-world     <- pointer yaw / pitch (JS)
             .rig-orbit   <- idle orbit (CSS)
               .rig-proj  the three projected planes
               .rig-book  the opening book
       .rig-cap           real text, the only thing a screen reader sees
   ========================================================================== */

.rig {
  /* --- geometry: every breakpoint only retunes these -------------------- */
  /* the stage takes what the hero has left once the title block and the
     caption are paid for, and the scene scales itself to fit whatever that
     turns out to be. --dw / --dh are the design size of the composition and
     the stage is a size container, so the scale is a ratio the browser
     computes: no breakpoint has to guess how tall the title block got. */
  --dw:       884px;                     /* design width of the composition  */
  --dh:       340px;                     /* design height                    */
  --dx:       24px;                      /* the drawn union leans left by     */
                                         /* this much: shift it back          */
  --smax:     1.22;                      /* never blow it up past this       */
  --rig-s:    0.84;                      /* replaced below where supported   */
  --pw:       180px;                     /* half-spread width (one page)     */
  --ph:       240px;                     /* page height                      */
  --book-y:   84px;                      /* book offset below stage centre   */
  --book-rx:  58deg;                     /* the book lies on the grid        */
  --ox:       238px;                     /* lateral offset, flanking planes  */

  /* --- live state: JS writes these, CSS has sane defaults --------------- */
  --yaw:      0;                         /* deg, pointer                     */
  --pitch:    0;                         /* deg, pointer                     */
  --mx:       0;                         /* -1..1, pointer, parallax         */
  --my:       0;                         /* -1..1, pointer, parallax         */
  --ab:       1;                         /* chromatic aberration multiplier  */
  --idle:     2.6;                       /* deg, idle orbit amplitude        */

  /* --- light ------------------------------------------------------------ */
  --line:     rgba(196, 238, 255, 0.78); /* the structural stroke            */
  --line-dim: rgba(150, 206, 255, 0.34); /* leaves, secondary structure      */

  position: relative;
  z-index: 1;
  grid-row: 2 / 4;              /* the hero's 1fr row plus its caption row */
  /* a grid, not a flex column: the stage needs a *definite* height for its
     container query to resolve, and a track gives it one even when the row
     collapses to the minimum. */
  display: grid;
  grid-template-rows: minmax(152px, 1fr) auto;
  justify-items: center;
  min-width: 0;
  min-height: 0;
}

.rig.is-live { --idle: 1.1; }   /* the pointer is driving: idle steps back */

/* The real scale: the browser divides the stage by the design size, so the
   rig fits exactly however tall the hero's title block turns out to be.
   Engines without container-query units or calc() length division keep the
   stepped fallback at the bottom of this file. */
@supports (container-type: size) and (scale: calc(10cqh / 10px)) {
  .rig {
    --rig-s: min(var(--smax),
                 max(0.34, calc(100cqh / var(--dh))),
                 calc((100cqw - 2 * var(--pad, 24px)) / var(--dw)));
  }
}

/* --- the camera ---------------------------------------------------------- */
/* The stage takes the height the hero row has left. It is a size container,
   which is what lets the scene scale itself with cqh / cqw above. */
.rig-stage {
  position: relative;
  grid-row: 1;
  width: 100%;
  min-width: 0;
  container-type: size;
  perspective: 1150px;
  perspective-origin: 50% 44%;
  pointer-events: none;         /* nothing in the rig is interactive */
}

.rig-scene,
.rig-world,
.rig-orbit,
.rig-proj {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.rig-scene { transform: scale(var(--rig-s)) translateX(var(--dx)); }

/* pointer yaw / pitch. No transition: libro.js-style rAF easing happens in
   hero-book.js, so the value arriving here is already damped. */
.rig-world {
  transform: rotateX(calc(var(--pitch) * 1deg)) rotateY(calc(var(--yaw) * 1deg));
}

/* the idle orbit: slow, always on, the only motion a touch screen gets */
.rig-orbit { animation: rig-orbit 19s ease-in-out infinite; }
@keyframes rig-orbit {
  0%   { transform: rotateY(calc(var(--idle) * -1deg)) rotateX(calc(var(--idle) *  0.26deg)); }
  50%  { transform: rotateY(calc(var(--idle) *  1deg)) rotateX(calc(var(--idle) * -0.22deg)); }
  100% { transform: rotateY(calc(var(--idle) * -1deg)) rotateX(calc(var(--idle) *  0.26deg)); }
}

/* ==========================================================================
   THE BOOK
   Eight sheets hinged on one gutter. Each sheet is a flat plane carrying a
   1px hairline and its own cyan / phosphor ghost; the hinge angles do the
   rest. The open pose lives in --a1, the closed pose in --a0, and one
   keyframe walks from one to the other exactly once, on load.
   ========================================================================== */
.rig-book {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--pw) * 2);
  height: var(--ph);
  margin-left: calc(var(--pw) * -1);
  margin-top: calc(var(--ph) / -2);
  transform-style: preserve-3d;
  transform: translate3d(0, var(--book-y), 0) rotateX(var(--book-rx));
}

.rig-half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
}
.rig-half--l { left: 0; }
.rig-half--r { right: 0; }

.rig-sheet {
  --in: 0px;                         /* leaves are a hair smaller than the board */
  position: absolute;
  top: var(--in);
  bottom: var(--in);
  width: calc(100% - var(--in));
  transform: rotateY(var(--a1));     /* the settled, open pose */
  animation: rig-open 1.5s var(--ease-out) both;
  /* the signature: a phosphor and a cyan ghost of the same hairline */
  filter:
    drop-shadow( 1.2px 0 0 rgba(61, 255, 154, 0.5))
    drop-shadow(-1.2px 0 0 rgba(34, 227, 255, 0.48));
}
.rig-half--l .rig-sheet { right: 0; transform-origin: 100% 50%; border-radius: 7px 2px 2px 7px; }
.rig-half--r .rig-sheet { left: 0;  transform-origin: 0% 50%;  border-radius: 2px 7px 7px 2px; }

@keyframes rig-open {
  from { transform: rotateY(var(--a0)); }
  to   { transform: rotateY(var(--a1)); }
}

/* the front cover sweeps the whole arc, the leaves follow it, staggered.
   The angles are spread wide enough that each sheet reads on its own
   instead of hatching into a wedge. */
.rig-half--l .rig-s1 { --a0: 178deg; --a1:  3.5deg; --in: 0px;  animation-delay: 0.14s; }
.rig-half--l .rig-s2 { --a0: 174deg; --a1:  8deg;   --in: 5px;  animation-delay: 0.26s; }
.rig-half--l .rig-s3 { --a0: 170deg; --a1: 12.5deg; --in: 8px;  animation-delay: 0.38s; }
.rig-half--l .rig-s4 { --a0: 166deg; --a1: 18deg;   --in: 11px; animation-delay: 0.52s; }
/* the back half only settles: it was the bottom of the closed book */
.rig-half--r .rig-s1 { --a0:  -1deg; --a1:  -3.5deg; --in: 0px;  animation-delay: 0.42s; }
.rig-half--r .rig-s2 { --a0:  -2deg; --a1:  -8deg;   --in: 5px;  animation-delay: 0.50s; }
.rig-half--r .rig-s3 { --a0:  -3deg; --a1: -12.5deg; --in: 8px;  animation-delay: 0.58s; }
.rig-half--r .rig-s4 { --a0:  -4deg; --a1: -18deg;   --in: 11px; animation-delay: 0.66s; }

/* the hairlines. Covers are lit, leaves are quiet, the two inner pages
   carry the content the planes above are projecting. */
.rig-sheet::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--line-dim);
}
.rig-s1::before { box-shadow: inset 0 0 0 1.15px rgba(170, 232, 255, 0.72); }
/* The One Warm Thing Rule: the cover's rose belongs to the book and only
   to the book, so it rides on the two boards' fore-edge and nowhere else.
   One warm hairline on the object being sold; the plates stay cyan. */
.rig-half--l .rig-s1::before {
  box-shadow: inset 1.8px 0 0 0 rgba(226, 47, 102, 0.9),
              inset 0 0 0 1.15px rgba(170, 232, 255, 0.72);
}
.rig-half--r .rig-s1::before {
  box-shadow: inset -1.8px 0 0 0 rgba(226, 47, 102, 0.9),
              inset 0 0 0 1.15px rgba(170, 232, 255, 0.72);
}
.rig-s4::before { box-shadow: inset 0 0 0 1px rgba(170, 232, 255, 0.5); }

/* the cover's inner frame line, a printed book's blind rule */
.rig-s1::after {
  content: '';
  position: absolute;
  inset: 11px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 0.75px rgba(130, 200, 255, 0.3);
}

/* the left inner page: ruled text */
.rig-half--l .rig-s4::after {
  content: '';
  position: absolute;
  inset: 26px 26px 30px 30px;
  background:
    repeating-linear-gradient(to bottom,
      rgba(150, 216, 255, 0.34) 0 1px, transparent 1px 24px);
  -webkit-mask-image: linear-gradient(to right, #000 0 58%, transparent 90%);
          mask-image: linear-gradient(to right, #000 0 58%, transparent 90%);
}
/* the right inner page: the printed resonance curve the centre plate
   projects, axes and trace, drawn once as an inline SVG */
.rig-half--r .rig-s4::after {
  content: '';
  position: absolute;
  left: 24px;
  top: 58px;
  width: 100px;
  height: 80px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 80'%3E%3Cpath d='M1 2V78H99' fill='none' stroke='rgba(150,216,255,0.42)' stroke-width='1'/%3E%3Cpath d='M2.0 64.0 4.4 63.4 6.8 62.7 9.2 61.9 11.6 61.0 14.0 60.1 16.4 59.0 18.8 57.7 21.2 56.3 23.6 54.6 26.0 52.7 28.4 50.4 30.8 47.7 33.2 44.5 35.6 40.5 38.0 35.7 40.4 30.0 42.8 23.3 45.2 16.2 47.6 10.4 50.0 8.0 52.4 10.3 54.8 16.1 57.2 23.1 59.6 29.7 62.0 35.3 64.4 40.1 66.8 43.9 69.2 47.2 71.6 49.8 74.0 52.1 76.4 54.0 78.8 55.6 81.2 57.0 83.6 58.3 86.0 59.4 88.4 60.3 90.8 61.2 93.2 62.0 95.6 62.6 98.0 63.3' fill='none' stroke='rgba(110,255,180,0.6)' stroke-width='1.3'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
}

/* the gutter: the one bright line of the whole book */
.rig-spine {
  position: absolute;
  left: 50%;
  top: 2%;
  width: 1.4px;
  height: 96%;
  margin-left: -0.7px;
  background: linear-gradient(to bottom,
    transparent, rgba(126, 240, 255, 0.95) 18%, rgba(126, 240, 255, 0.95) 82%, transparent);
  box-shadow: 0 0 14px 2px rgba(34, 227, 255, 0.45);
}

/* the pool of light the open book sits in: an emitter, so it may glow */
.rig-pool {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--pw) * 3.1);
  height: calc(var(--ph) * 1.5);
  transform: translate3d(-50%, -50%, -1px);
  background:
    radial-gradient(closest-side at 50% 58%, rgba(226, 47, 102, 0.22), transparent 60%),
    radial-gradient(closest-side, rgba(34, 227, 255, 0.18), rgba(34, 227, 255, 0.05) 58%, transparent 76%);
  animation: rig-pool 7.5s ease-in-out infinite alternate;
}
@keyframes rig-pool {
  from { opacity: 0.72; }
  to   { opacity: 1; }
}

/* the light cone rising out of the gutter, bottom of the projection */
.rig-shaft {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 960px;
  height: 250px;
  transform: translate3d(-50%, 0, -30px) translateY(calc(var(--book-y) - 250px)) rotateX(5deg);
  transform-origin: 50% 100%;
  background: linear-gradient(to top, rgba(34, 227, 255, 0.14), rgba(123, 92, 255, 0.05) 46%, transparent 82%);
  clip-path: polygon(47.6% 100%, 52.4% 100%, 100% 0, 0 0);
  animation: rig-shaft 6.2s ease-in-out infinite alternate;
}
@keyframes rig-shaft {
  from { opacity: 0.55; }
  to   { opacity: 0.95; }
}

/* ==========================================================================
   THE THREE PROJECTED PLANES
   Each plane is positioned in 3D by its own variables, drifts on its own
   clock, and takes a share of the pointer parallax set by --par / --pry.
   ========================================================================== */
.rig-plane {
  --x: 0px; --y: 0px; --z: 0px;
  --ry: 0deg; --rx: 0deg; --rz: 0deg; --s: 1;
  --par: 0;            /* px of pointer parallax */
  --pry: 0;            /* deg of pointer yaw of its own */
  --dy: 6;             /* px of idle vertical drift */
  --dz: 12;            /* px of idle depth drift */
  --dur: 11s;

  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--w);
  height: var(--h);
  transform-style: preserve-3d;
  transform:
    translate(-50%, -50%)
    translate3d(
      calc(var(--x) + var(--mx) * var(--par) * 1px),
      calc(var(--y) + var(--my) * var(--par) * 0.45px),
      var(--z))
    rotateY(calc(var(--ry) + var(--mx) * var(--pry) * 1deg))
    rotateX(var(--rx))
    rotateZ(var(--rz))
    scale(var(--s));
}

.rig-plane-in {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: translateZ(0);
  animation: rig-drift var(--dur) ease-in-out infinite;
}
@keyframes rig-drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, calc(var(--dy) * -1px), calc(var(--dz) * 1px)); }
}

/* the faintest possible seat so stacked line art stays legible over the grid */
.rig-plane-in::before {
  content: '';
  position: absolute;
  inset: -16px -20px;
  border-radius: 16px;
  background:
    radial-gradient(74% 76% at 50% 86%, rgba(6, 10, 28, 0.9), rgba(6, 10, 28, 0.46) 52%, rgba(5, 8, 22, 0) 78%);
}

/* the tether: the beam that says this plane came out of the gutter. It
   leaves the plane at its inner bottom corner (--ta) and leans back toward
   the spine (--tr). */
.rig-tether {
  position: absolute;
  left: var(--ta, 50%);
  top: 100%;
  width: 1px;
  height: var(--tl, 90px);
  transform-origin: 50% 0;
  transform: rotate(var(--tr, 0deg));
  background: linear-gradient(to bottom, rgba(126, 240, 255, 0.62), rgba(126, 240, 255, 0));
}
.rig-tether::before {
  content: '';
  position: absolute;
  left: -2.5px;
  top: -2.5px;
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: rgba(126, 240, 255, 0.9);
  box-shadow: 0 0 10px 2px rgba(34, 227, 255, 0.6);
}

/* --- the three poses ----------------------------------------------------- */
/* the fan is read left to right: the receiver chain nearest and lowest, the
   tuned circuit in the middle, higher and further back but at full light
   (it is the plate the caption names first and the one the page lets you
   tune further down), the dipole on the right at the middle depth. */
.rig-plane--sup {                /* nearest, lowest, the widest drawing */
  --w: 344px; --h: 196px;
  --x: calc(var(--ox) * -1 - 70px); --y: -14px; --z: 100px;
  --ry: 24deg; --rx: -7deg; --rz: -4deg;
  --par: 26; --pry: 4;
  --dy: 7; --dz: 14; --dur: 10.5s;
  --ta: 100%; --tl: 92px; --tr: 76deg;
}
.rig-plane--lc {                 /* centre, highest, the named plate */
  --w: 252px; --h: 234px;
  --x: -6px; --y: -84px; --z: -150px;
  --ry: -3deg; --rx: -4deg; --rz: 0.5deg;
  --par: 11; --pry: 2;
  --dy: 5; --dz: 9; --dur: 13.5s;
  --ta: 50%; --tl: 74px; --tr: 2deg;
  --pk: 0.86;          /* furthest back: the perspective shrinks it ~14% */
}
.rig-plane--dip {                /* the middle depth */
  --w: 300px; --h: 190px;
  --x: var(--ox); --y: -58px; --z: 26px;
  --ry: -24deg; --rx: -6deg; --rz: 4deg;
  --par: 20; --pry: -4;
  --dy: 6; --dz: 12; --dur: 12s;
  --ta: 0%; --tl: 112px; --tr: -66deg;
  opacity: 0.95;
}

/* ==========================================================================
   THE LINE ART
   Each plate is drawn once into <defs> and used three times: a phosphor
   ghost, a cyan ghost, and the white-cyan core on top. The numerals are
   never ghosted, so the data stays crisp while the structure fringes.
   ========================================================================== */
.rig-art {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rig-art .rig-line   { color: var(--line); }
.rig-art .rig-ghost  { opacity: 0.62; }
.rig-art .rig-ghost--m {
  color: var(--phosphor);
  transform: translateX(calc(var(--ab) * 1.8px));
  animation: rig-fringe-m 8.5s ease-in-out infinite;
}
.rig-art .rig-ghost--c {
  color: var(--cyan);
  transform: translateX(calc(var(--ab) * -1.8px));
  animation: rig-fringe-c 8.5s ease-in-out infinite;
}
@keyframes rig-fringe-m {
  0%, 100% { transform: translateX(calc(var(--ab) * 1.5px)); }
  50%      { transform: translateX(calc(var(--ab) * 2.3px)); }
}
@keyframes rig-fringe-c {
  0%, 100% { transform: translateX(calc(var(--ab) * -1.5px)); }
  50%      { transform: translateX(calc(var(--ab) * -2.3px)); }
}

/* type inside the plates. Each class only states its design size (--fs);
   the floor is computed: no glyph may land under 6.5px once the scene scale
   has been applied, so when the rig shrinks the labels grow back against it
   (the plates are drawn with that headroom). Past the headroom the plate
   leaves, see THE FLOOR below. Plates are drawn 1 user unit = 1 CSS px. */
.rig-art text {
  --fs: 9px;
  font-family: var(--display);
  font-weight: 600;
  font-size: max(var(--fs), calc(6.5px / var(--rig-s) / var(--pk, 1)));
  letter-spacing: 0.01em;
  fill: var(--ink);
  stroke: none;
  font-variant-numeric: tabular-nums;
}
.rig-art .rig-tag {
  --fs: 10.5px;
  letter-spacing: 0.1em;
  fill: var(--cyan-soft);
}
.rig-art .rig-note  { --fs: 9px; fill: var(--ink-3); letter-spacing: 0.04em; }
.rig-art .rig-val   { --fs: 11.5px; fill: #ffffff; }
.rig-art .rig-unit  { --fs: 9px; fill: var(--cyan-soft); }
.rig-art .rig-qty   { --fs: 9px; fill: var(--ink); }
.rig-art .rig-sub   { font-size: max(0.8em, calc(6.5px / var(--rig-s) / var(--pk, 1))); }
.rig-art .rig-hot   { fill: var(--phosphor); }

/* phosphor is the trace: the resonance curve, the radiation pattern, the
   one fixed frequency of the receiver. It is never ghosted, like a real
   trace it only glows. */
.rig-art .rig-trace {
  stroke: var(--phosphor);
  stroke-width: 1.6;
  fill: none;
  filter: drop-shadow(0 0 3px rgba(61, 255, 154, 0.55));
}
.rig-art .rig-trace--arrow { stroke-width: 1.3; }
.rig-art .rig-node { fill: var(--line); stroke: none; }

/* ==========================================================================
   THE CAPTION · the only part of the rig that is not decorative
   ========================================================================== */
.rig-cap {
  position: relative;
  z-index: 2;
  grid-row: 2;
  width: 100%;
  padding-inline: var(--pad);
  margin-top: clamp(2px, 0.8vh, 12px);
  text-align: center;
  min-height: 3.8em;   /* reserved, so swapping the text never shifts layout */
}
.rig-cap-name {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--step-lead);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow:
    -0.012em 0 rgba(61, 255, 154, 0.5),
     0.012em 0 rgba(34, 227, 255, 0.5),
     0 0 26px rgba(34, 227, 255, 0.4);
}
.rig-cap-fact {
  display: block;
  margin-top: 0.3em;
  text-wrap: balance;
  font-size: var(--step-small);
  line-height: 1.5;
  color: var(--ink-2);
}
.rig-cap-name,
.rig-cap-fact { transition: opacity 0.26s var(--ease); }
.rig.is-swapping .rig-cap-name,
.rig.is-swapping .rig-cap-fact { opacity: 0; }

/* ==========================================================================
   RESPONSIVE
   The scale is computed, not stepped, so a breakpoint only has to change the
   composition and tell the scene how big that composition is (--dw / --dh).
   ========================================================================== */

/* Below 760px libro.css drops the hero's min-height, so the stage can no
   longer take "what is left of the viewport": it has to ask for a height.
   The height it may ask for is what the viewport has left once the nav and
   the title block are paid for, and the title block grows as the viewport
   narrows (313px at 390, 346px at 360, 373px at 320). `100svh + 100vw`
   tracks both at once, so the caption stays above the fold from 320 up
   without a breakpoint per phone. */
@media (max-width: 760px) {
  .rig { grid-template-rows: clamp(155px, calc(100svh + 100vw - 895px), 372px) auto; }
}

/* The phone. Three plates cannot be read in 350 x 340: stacked, they stop
   being a deck and become a pile, and the receiver chain is the one that
   loses first because its block labels fall under 6px. So the phone shows
   two plates, one above the other with real air between them: the tuned
   circuit the caption names, nearest and lowest, and the dipole above and
   behind it, whose geometry survives any scale. The book keeps the floor
   to itself. */
@media (max-width: 680px) {
  .rig {
    --dw: 416px;
    --dh: 556px;
    --dx: 20px;
    --smax: 0.95;
    --pw: 162px;
    --ph: 206px;
    --book-y: 200px;
  }
  .rig-stage { perspective: 1000px; perspective-origin: 50% 48%; }

  .rig-plane--sup { display: none; }

  /* the small print goes with it: under 6px it is texture, not information,
     and the caption under the rig carries those facts in real text */
  .rig-art .rig-note { display: none; }
  .rig-art text      { --fs: 11px; }
  .rig-art .rig-val  { --fs: 13px; }
  .rig-art .rig-qty  { --fs: 12px; }
  .rig-art .rig-unit { --fs: 13px; }
  .rig-art .rig-tag  { --fs: 12.5px; }

  .rig-plane--lc {
    --pk: 1;
    --x: -30px; --y: 2px; --z: 50px;
    --ry: 12deg; --rx: -5deg; --rz: -2deg;
    --par: 22; --pry: 3;
    --ta: 50%; --tl: 70px; --tr: 30deg;
  }
  .rig-plane--dip {
    --x: 26px; --y: -226px; --z: -40px;
    --ry: -17deg; --rx: -4deg; --rz: 3deg; --s: 0.95;
    --par: 14; --pry: -3;
    --ta: 22%; --tl: 34px; --tr: -30deg;
  }
  .rig-shaft { width: 430px; height: 240px; }
  .rig-cap { min-height: 5.2em; }
}

/* A short phone (375x667, 360x740) leaves the stage around 160px once the
   nav and the title block are paid for. Two plates in 160px are a thumbnail,
   so the short phone keeps only the plate the caption names and spends the
   whole height on it and on the book. */
@media (max-width: 680px) and (max-height: 760px) {
  .rig {
    /* the title block eats more of a short viewport, so the stage asks for
       less of it than the tall-phone rule above would give it */
    grid-template-rows: clamp(150px, calc(100svh + 100vw - 940px), 300px) auto;
    --dw: 340px;
    --dh: 330px;
    --dx: 30px;
    --pw: 118px;
    --ph: 152px;
    --book-y: 104px;
  }
  .rig-plane--dip { display: none; }
  .rig-plane--lc { --x: -24px; --y: -60px; --tl: 44px; --tr: 26deg; }
  .rig-shaft { width: 360px; height: 190px; }
}

/* a very short viewport has no room for the caption and the rig both: give
   the caption one line and let the scene shrink into whatever is left */
@media (max-height: 700px) {
  .rig-cap { min-height: 2.6em; }
  .rig-cap-fact { display: none; }
}

/* THE FLOOR. The labels may grow back against the scale by about a sixth
   before they start to crowd their own drawing; past that the plate leaves
   the rig, as the Transformer stack does on the AI page's phone, and the
   caption keeps saying in real text what it showed. The stage is the size
   container, so the rule follows the room the rig actually got, not a
   guessed viewport. Thresholds are the scale (stage height / --dh) at which
   that plate's smallest label would need more than its headroom. */
@media (min-width: 681px) {
  /* receiver chain: 9px labels in 40px boxes, about 12% headroom: s < 0.645 */
  @container (max-height: 219px) {
    .rig-plane--sup { display: none; }
    /* two plates left: they close ranks around the book, one either side */
    .rig-plane--lc  { --x: -150px; --y: -84px; --ry: 14deg; --ta: 78%; --tr: 38deg; --tl: 96px; }
    .rig-plane--dip { --x: 160px; }
  }
  /* dipole: airy, 30%: s < 0.56 */
  @container (max-height: 190px) { .rig-plane--dip { display: none; } }
  /* tuned circuit: 40%: s < 0.52 */
  @container (max-height: 176px) { .rig-plane--lc  { display: none; } }
}
@media (max-width: 680px) and (min-height: 761px) {
  /* tall phone, --dh 556 and 11px labels */
  @container (max-height: 268px) { .rig-plane--dip { display: none; } }
  @container (max-height: 236px) { .rig-plane--lc  { display: none; } }
}
@media (max-width: 680px) and (max-height: 760px) {
  /* short phone, --dh 330 */
  @container (max-height: 140px) { .rig-plane--lc  { display: none; } }
}

/* the stepped fallback, for engines that cannot divide a container-query
   length by a design length. Deliberately conservative: a slightly small
   rig is fine, a rig that spills out of the hero is not. */
@supports not ((container-type: size) and (scale: calc(10cqh / 10px))) {
  .rig { grid-template-rows: minmax(210px, 1fr) auto; }
  .rig { --rig-s: 0.86; }
  @media (min-height: 980px) { .rig { --rig-s: 1.06; } }
  @media (max-height: 880px) { .rig { --rig-s: 0.78; } }
  @media (max-height: 820px) { .rig { --rig-s: 0.64; } }
  @media (max-height: 780px) { .rig { --rig-s: 0.54; } }
  @media (max-width: 1000px) { .rig { --rig-s: 0.80; } }
  @media (max-width: 860px)  { .rig { --rig-s: 0.70; } }
  @media (max-width: 680px)  { .rig { --rig-s: 0.58; } }
  @media (max-width: 430px)  { .rig { --rig-s: 0.46; } }
  @media (max-width: 680px) and (max-height: 760px) { .rig { --rig-s: 0.40; } }
}

/* ==========================================================================
   REDUCED MOTION · the rig renders in its settled open pose and stays there.
   libro.css already clamps every animation with !important on `*`, so this
   block has to be important too in order to switch them off completely
   rather than snap them to a random keyframe.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .rig,
  .rig *,
  .rig *::before,
  .rig *::after {
    animation: none !important;
    transition: none !important;
  }
  /* every element below falls back to the static transform in its base rule:
     the book is open, the planes sit at their poses, the fringe is static. */
  .rig { --idle: 0; --yaw: 0; --pitch: 0; --mx: 0; --my: 0; --ab: 1; }
  .rig-pool  { opacity: 0.85; }
  .rig-shaft { opacity: 0.7; }
}
