/* ==========================================================================
   TechRS — intro.css · homepage entrance (design spec v4 §6)
   --------------------------------------------------------------------------
   Linked by home.html only. boot.js decides in <head> and sets
   html[data-intro="play"]; intro.js builds the overlay and drives the
   timeline (WAAPI). States on <html>:
     data-intro="play"  boot decided: the pre-paint cover below is up
     data-intro="run"   intro.js owns the screen (the .intro overlay)
     data-intro="in"    dock started: the page reveals (home.css rises the
                        [data-intro-item] pieces; field.js starts its sweep)
     (absent)           settled, 1.4 s after "in"
   Scrolling is locked during play/run; intro.js keeps it locked (inline
   overflow on <html>) until the logo has docked.
   Overlay (built by intro.js, never present without JS):
     .intro            fixed, full viewport, catches the skip gestures and
                       every pointer until it is removed (never pass-through)
       .intro-stage    aria-hidden visual: .intro-bg (paper that fades),
                       svg.intro-routes (the routing traces), .intro-mark
                       (svg.logo.intro-logo, a clone of the header logo:
                       it follows the theme) and .intro-tagline
       .intro-skip     the real "Skip intro" button (not aria-hidden)
   Geometry tokens on .intro (intro.js measures the result, never reads
   them): --intro-w logo width · --intro-h its height · --intro-lift how far
   the logo sits above centre · --intro-gap logo → tagline.
   ========================================================================== */

/* 1. Pre-paint cover: paper (or ink, in dark) before <body> has painted, so
      the page never flashes. CSS failsafe: it lifts itself after 5 s even if
      no script ever runs. */
html[data-intro="play"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  background: var(--bg-page);
  animation: intro-failsafe 0s linear 5s forwards;
}
@keyframes intro-failsafe {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* 2. No scrolling while the intro owns the screen. The gutter stays, so the
      layout (and the docking target) does not shift when the scrollbar
      returns. */
html[data-intro="play"],
html[data-intro="run"] {
  overflow: hidden;
  scrollbar-gutter: stable;
}
/* Failsafe: whatever happens to the scripts, scrolling comes back 8 s after
   boot.js decided (a discrete keyframe also beats intro.js's inline lock). */
html[data-intro] {
  animation: intro-unlock 0s linear 8s forwards;
}
@keyframes intro-unlock {
  to {
    overflow: visible;
  }
}

/* 3. The overlay */
.intro {
  --intro-w: min(76vw, 760px);
  --intro-h: calc(var(--intro-w) * 0.155556); /* logo viewBox 900 × 140 */
  --intro-lift: clamp(8px, 2.4vh, 24px);
  --intro-gap: clamp(18px, 3.6vh, 34px);
  --intro-route-w: 2px;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  contain: strict;
  overflow: hidden;
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  /* CSS failsafe behind intro.js's own watchdog (visibility: hidden also
     lets pointers through again) */
  animation: intro-failsafe 0s linear 7s forwards;
  /* No pointer-events: none while it docks: a press meant to skip must
     never land on the still-hidden page underneath. */
}
.intro-stage,
.intro-bg {
  position: absolute;
  inset: 0;
}
.intro-stage {
  pointer-events: none;
}
.intro-bg {
  background: var(--bg-page);
}

/* Routing traces: one full-viewport SVG, 1 unit = 1 CSS px */
.intro-routes {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  max-inline-size: none;
  overflow: visible;
}
.intro-route,
.intro-head-ring,
.intro-head-core,
.intro-ping {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.intro-route {
  stroke-width: var(--intro-route-w);
}
/* the head is a travelling node ring: teal ring, paper core */
.intro-head-ring {
  stroke-width: calc(var(--intro-route-w) * 3.4);
}
.intro-head-core {
  stroke: var(--bg-page);
  stroke-width: calc(var(--intro-route-w) * 1.5);
}
.intro-ping {
  stroke-width: 1.25px;
  vector-effect: non-scaling-stroke; /* it widens by scale(); the hairline stays */
  opacity: 0;
}

/* The logo clone (centred; intro.js FLIPs it into the header logo) */
.intro-mark {
  position: absolute;
  inset-block-start: calc(50% - var(--intro-h) / 2 - var(--intro-lift));
  inset-inline-start: calc(50% - var(--intro-w) / 2);
  inline-size: var(--intro-w);
  transform-origin: 0 0;
}
.intro-logo {
  display: block;
  inline-size: 100%;
  block-size: auto;
  max-inline-size: none;
  overflow: visible;
}
.intro-scan {
  fill: var(--logo-accent, var(--accent));
}

/* Mono tagline that types under the logo */
.intro-tagline {
  position: absolute;
  inset-inline: 0;
  inset-block-start: calc(50% + var(--intro-h) / 2 - var(--intro-lift) + var(--intro-gap));
  margin: 0;
  padding-inline: 16px;
  font-family: var(--font-micro);
  font-size: clamp(0.66rem, 0.6rem + 0.2vw, 0.76rem);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.24em;
  text-align: center;
  text-transform: var(--eyebrow-case);
  text-wrap: balance; /* the full line is always laid out, so typing never reflows */
  color: var(--text-muted);
  opacity: 0;
}
:root:lang(he) .intro-tagline {
  font-size: clamp(0.8rem, 0.75rem + 0.2vw, 0.9rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}
/* a11y toolbar "readable font", as core.css sets it for its micro labels
   (the Skip button, a <button>, is already covered there) */
:root.a11y-readable-font .intro-tagline {
  font-family: Arial, Tahoma, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  word-spacing: 0.08em;
}
.intro-rest {
  visibility: hidden;
}
.intro-caret {
  display: inline-block;
  inline-size: 2px;
  block-size: 1.1em;
  margin-inline-end: 0.24em;
  vertical-align: -0.2em;
  background: var(--accent);
}
:root:lang(he) .intro-caret {
  margin-inline: 0.12em;
}
.intro-caret.is-idle {
  animation: intro-blink 1s steps(1) infinite;
}
@keyframes intro-blink {
  50% {
    opacity: 0;
  }
}

/* Skip button: real, focusable, bottom inline-end, mono micro text. Its
   bottom hairline fills as the intro runs. */
.intro-skip {
  position: absolute;
  inset-block-end: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  inset-inline-end: clamp(16px, 2.8vw, 36px);
  display: inline-flex;
  align-items: center;
  min-block-size: 32px;
  padding: 6px 12px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-muted);
  font-family: var(--font-micro);
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: var(--eyebrow-case);
  pointer-events: auto;
  animation: intro-skip-in 0.5s var(--ease-out) 0.3s both;
  transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
:root:lang(he) .intro-skip {
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.intro-skip:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.intro-skip:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  color: var(--text-primary);
}
.intro-skip-bar {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  block-size: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 0;
}
[dir="rtl"] .intro-skip-bar {
  transform-origin: 100% 0;
}
@keyframes intro-skip-in {
  from {
    opacity: 0;
  }
}

@media (max-width: 599.98px) {
  .intro {
    --intro-w: 88vw;
    --intro-route-w: 1.5px;
  }
  .intro-tagline {
    letter-spacing: 0.16em;
  }
  .intro-caret {
    margin-inline-end: 0.16em;
  }
}

/* Never for reduced motion, forced colours or print (boot.js and intro.js
   already refuse; this is the belt to their braces). */
@media (prefers-reduced-motion: reduce), (forced-colors: active), print {
  html[data-intro] body::after,
  .intro {
    display: none !important;
  }
}
:root.a11y-reduce-motion[data-intro] body::after,
:root.a11y-reduce-motion .intro {
  display: none !important;
}
