/* ==========================================================================
   FIG. 02 "sentinel": the AN/MPQ-64 Sentinel radar as a technical drawing.
   Built by js/figures/sentinel.js. Every selector starts with .fg-sentinel.

   Three values are set by the script on the root element:
     --u       the number of drawing units in one screen pixel. Writing a
               line weight as calc(var(--u) * 1.25px) therefore always gives
               a line 1.25 pixels thick on screen, however large the drawing
               is shown.
     --fs      the size of the lettering on screen (11px).
     --labels  when the lettering fades in during the reveal (2.3s).

   Line types, as on a paper drawing:
     obj      object lines: the visible outlines (brightest, heaviest)
     det      detail lines: seams, louvres, ribs (thinner and dimmer)
     row      the rows of radiating elements on the antenna face
     centre   centre lines: long dash, short dash
     dim      dimension and extension lines
     lead     leader lines of the callouts
     hatch    the hatch marks under the ground line
     rot, beam, arc   the amber highlights: rotation arrow and beam fan
   ========================================================================== */

.fg-sentinel {
  --u: 1;
  --fs: 11px;
  display: block;
}

/* Zero-height strip the script measures to learn the width of the stage. */
.fg-sentinel__ruler {
  height: 0;
}

.fg-sentinel__svg {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  overflow: visible;
  font-family: var(--font-mono);
}

/* ---------- Linework --------------------------------------------------- */

.fg-sentinel__ln,
.fg-sentinel__fd {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Object lines: everything you would see as an edge of the real thing. */
.fg-sentinel__obj {
  stroke: var(--trace);
  stroke-width: calc(var(--u) * 1.25px);
}

/* Detail lines. */
.fg-sentinel__det {
  stroke: var(--trace-2);
  stroke-width: calc(var(--u) * 1px);
}

/* Rows of radiating elements: many close lines, so kept a little lighter
   than the other details to stop the face turning into a solid block. */
.fg-sentinel__row {
  stroke: var(--trace-2);
  stroke-width: calc(var(--u) * 0.8px);
  stroke-linecap: butt;
}

/* Centre lines: the long-dash, short-dash pattern used on drawings. */
.fg-sentinel__centre {
  stroke: var(--trace-3);
  stroke-width: calc(var(--u) * 1px);
  stroke-linecap: butt;
  stroke-dasharray:
    calc(var(--u) * 14px) calc(var(--u) * 3px)
    calc(var(--u) * 2px) calc(var(--u) * 3px);
}

/* Dimension lines, extension lines and their ticks. */
.fg-sentinel__dim {
  stroke: var(--trace-2);
  stroke-width: calc(var(--u) * 1px);
  stroke-linecap: butt;
}

/* Leader lines, and the dot where each one lands on its part. */
.fg-sentinel__lead {
  stroke: var(--trace-2);
  stroke-width: calc(var(--u) * 1px);
}
.fg-sentinel__dot {
  fill: var(--trace);
  stroke: none;
}

/* Hatch marks under the ground line. */
.fg-sentinel__hatch {
  stroke: var(--trace-3);
  stroke-width: calc(var(--u) * 1px);
  stroke-linecap: butt;
}

/* The accent colour is used for two things only: the rotation arrow in
   the front view and the beam fan in the side view. */
.fg-sentinel__rot {
  stroke: var(--amber);
  stroke-width: calc(var(--u) * 1.25px);
}
.fg-sentinel__beam {
  stroke: var(--amber);
  stroke-width: calc(var(--u) * 1px);
  stroke-linecap: butt;
  stroke-dasharray: calc(var(--u) * 5px) calc(var(--u) * 4px);
}
.fg-sentinel__arc {
  stroke: var(--amber-2);
  stroke-width: calc(var(--u) * 1px);
}

/* ---------- Lettering --------------------------------------------------- */

.fg-sentinel__tx {
  font-size: calc(var(--u) * var(--fs));
  font-weight: 500;
  letter-spacing: 0.08em;
  fill: var(--ink-2);
}

/* Callout labels. Long ones exist twice: on one line and split over two.
   The script adds --short to the root when the two-line version is wanted. */
.fg-sentinel--short .fg-sentinel__lbl--one {
  display: none;
}
.fg-sentinel:not(.fg-sentinel--short) .fg-sentinel__lbl--two {
  display: none;
}

/* Dimension letters A, B, C. */
.fg-sentinel__dimtx {
  fill: var(--ink-3);
}

/* "360° AZ" beside the rotation arrow. */
.fg-sentinel__az {
  fill: var(--amber);
}

/* View titles: FRONT ELEVATION, SIDE ELEVATION. */
.fg-sentinel__title {
  fill: var(--ink);
  letter-spacing: 0.14em;
}

/* ---------- Title block -------------------------------------------------
   Drawn in screen pixels inside a group the script scales by u, so plain
   px values are right here (no --u needed). One row of three cells on wide
   layouts, three rows on the stacked layout.                              */

.fg-sentinel__tb-ln {
  stroke: var(--line-2);
  stroke-width: 1px;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.fg-sentinel__tb-tx {
  font-size: var(--fs);
  fill: var(--ink-3);
}
.fg-sentinel__tb-val {
  fill: var(--ink);
}
.fg-sentinel--stack .fg-sentinel__strip {
  display: none;
}
.fg-sentinel:not(.fg-sentinel--stack) .fg-sentinel__box {
  display: none;
}

/* ---------- Reveal ------------------------------------------------------
   The script adds .is-armed to each part (front view, side view, title
   block) while it waits off screen, then .is-live to play the sequence,
   then removes both. Each line carries its own start delay in --d and,
   where it differs from the usual 0.9s, its own duration in --t.          */

/* Waiting: everything hidden. Every solid path has pathLength="1", so a
   dash of 1 covers the whole path and an offset of 1 slides it out of view. */
.fg-sentinel__part.is-armed .fg-sentinel__ln {
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1.001;
}
.fg-sentinel__part.is-armed .fg-sentinel__fd,
.fg-sentinel__part.is-armed .fg-sentinel__tx {
  opacity: 0;
}

/* Playing: solid lines draw in, dashed lines and dots fade in ... */
.fg-sentinel__part.is-live .fg-sentinel__ln {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--t, 0.9s) cubic-bezier(0.45, 0, 0.15, 1) var(--d, 0s);
}
.fg-sentinel__part.is-live .fg-sentinel__fd {
  opacity: 1;
  transition: opacity 0.6s ease var(--d, 0s);
}

/* ... and the lettering comes last, once the linework is complete. */
.fg-sentinel__part.is-live .fg-sentinel__tx {
  opacity: 1;
  transition: opacity 0.5s ease var(--labels, 2.3s);
}
/* The title block has little to draw, so its lettering need not wait. */
.fg-sentinel__tb.is-live .fg-sentinel__tx {
  transition-delay: 0.9s;
}

/* ---------- The one perpetual motion ------------------------------------
   The dashes of the beam lines drift slowly away from the antenna. The
   script adds .is-running only while the figure is on screen, the tab is
   visible, the visitor has not asked for reduced motion and has not
   pressed "Pause animations". One dash plus one gap is 9px, so moving by
   9px loops without a visible jump.                                       */

.fg-sentinel.is-running .fg-sentinel__beam {
  animation: fg-sentinel-beam 2.4s linear infinite;
}

@keyframes fg-sentinel-beam {
  to { stroke-dashoffset: calc(var(--u) * -9px); }
}

/* Belt and braces: the script never starts any motion when the visitor
   prefers reduced motion, and this makes sure nothing can move regardless. */
@media (prefers-reduced-motion: reduce) {
  .fg-sentinel *,
  .fg-sentinel {
    transition: none !important;
    animation: none !important;
  }
}

/* On paper the drawing is always complete, even if it was still waiting
   to be revealed when the page was printed. */
@media print {
  .fg-sentinel__part.is-armed .fg-sentinel__ln {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }
  .fg-sentinel__part.is-armed .fg-sentinel__fd,
  .fg-sentinel__part.is-armed .fg-sentinel__tx {
    opacity: 1;
  }
  .fg-sentinel *,
  .fg-sentinel {
    transition: none !important;
    animation: none !important;
  }
}
