/*
 * DOAR Dynamic Animation: engine styles only (stage, progress rail, skip button, shared typography).
 * Loaded only on pages that use the "DOAR Dynamic Animation" content block.
 * Scene styles are NOT here: each scene file carries its own CSS (register(..., { styles })) and the
 * engine adds it to the page when the scene is shown, so report content never lives in the theme.
 * Source of truth: the engine section of Charts/TradeSecrets/Dynamic Website/prototype/css/prototype.css.
 */

/* Tokens are scoped to the block so they never affect the rest of the site.
   The engine overwrites the --scene-* values from each block's background color. */
.DOAR-dynamic-animation {
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Work Sans", "Helvetica Neue", Arial, sans-serif;
  --font-data: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --site-header-height: var(--DOAR-header-height, 80px);
  /* Chart label size: 20px on desktop, scaling down to 14px on phones. Inside a scene it is redefined
     from the scene's width (see .DOAR-dynamic-animation-scene). */
  --DOAR-label-size: clamp(14px, calc(11.9px + 0.563vw), 20px);
  --accent-brick: #a0473c;
  --scene-background: #d8dcde;
  --scene-ink: #2b2b2b;
  --scene-muted: #4f5558;
  --scene-accent: #a0473c;
  --scene-eyebrow: #a0473c;
  --scene-group-heading: #4f5558;
  --scene-rule: rgba(43, 43, 43, 0.13);
  --scene-axis: rgba(43, 43, 43, 0.5);
  --scene-label-backing: rgba(216, 220, 222, 0.9);
  --scene-primary-mark: #3e6b71;
  --scene-highlight-mark: #a0473c;
  --scene-progress: #a0473c;
  --scene-control-background: rgba(255, 255, 255, 0.7);
  --scene-control-ink: #2b2b2b;
  --scene-control-border: rgba(43, 43, 43, 0.3);
  width: 100%;
  max-width: 100%;
  text-align: left;
}
.DOAR-dynamic-animation *, .DOAR-dynamic-animation *::before, .DOAR-dynamic-animation *::after { box-sizing: border-box; }
/* Elements with the hidden attribute stay hidden even when a class sets display. */
.DOAR-dynamic-animation [hidden] { display: none !important; }
/*
 * Theme heading/paragraph margins should not leak into scene captions. :where() keeps this at one
 * class of specificity: it still beats the theme's element rules (h3, p), but a scene's own class rule
 * (added to <head> later) wins, so scene margins like .turntable-grid-rule's apply.
 */
.DOAR-dynamic-animation :where(h3, p) { margin-top: 0; }

/* The block prints this hint just above the section, outside the token scope, so every token has a fallback. */
.scroll-hint {
  font-family: var(--font-data, "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--scene-muted, #4f5558);
  text-align: center;
  padding-block: 8px 28px;
  margin: 0;
}
.scroll-hint::after {
  content: "";
  display: block;
  width: 1px;
  height: 20px;
  margin: 10px auto 0;
  background: var(--scene-muted, #4f5558);
}
/* The block does not print, so neither does its hint. */
@media print { .scroll-hint { display: none; } }


/* ---------- DOAR Dynamic Animation engine ---------- */
.DOAR-dynamic-animation {
  position: relative;
  background: var(--scene-background);
  /* Lining figures: Cormorant Garamond's default old-style "1" looks like a capital I. Inherited by every scene. */
  font-variant-numeric: lining-nums;
}
.DOAR-dynamic-animation-track { position: relative; }
.DOAR-dynamic-animation-stage {
  position: sticky;
  top: var(--site-header-height);
  height: calc(100vh - var(--site-header-height));
  overflow: hidden;
  background: var(--scene-background);
}
@supports (height: 100svh) {
  .DOAR-dynamic-animation-stage { height: calc(100svh - var(--site-header-height)); }
}
/*
 * The scene root is a size container, so scene CSS sizes things from the scene (cqw / cqh, @container) rather
 * than the browser window. When the stage is smaller than the minimum layout size, the engine lays the scene out
 * larger and scales it down to fit (see the engine file), so the window's size would be the wrong measure.
 * The label size token is redefined here from the scene's width for the same reason.
 */
.DOAR-dynamic-animation-scene {
  position: absolute;
  inset: 0;
  container-type: size;
  --DOAR-label-size: clamp(14px, calc(11.9px + 0.563cqw), 20px);
}

.DOAR-dynamic-animation.is-static .DOAR-dynamic-animation-stage {
  position: relative;
  top: 0;
  height: min(860px, calc(100vh - var(--site-header-height)));
}

/* ---------- Loading placeholder ----------
   The WordPress block prints it inside the section, so it shows from the first paint, before any script arrives.
   The engine moves it into the stage (or adds it, on pages without the block) and fades it out once the scene
   is ready: drawn, laid out and, for 3D scenes, with three.js downloaded and the world built. */
.DOAR-dynamic-animation-loading {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding-inline: 16px;
  background: var(--scene-background);
  color: var(--scene-muted);
  text-align: center;
  transition: opacity 0.45s ease, visibility 0s linear 0.45s;
}
/* Before the engine runs it is the section's only child: give it one screen's height so the page doesn't jump. */
.DOAR-dynamic-animation > .DOAR-dynamic-animation-loading { height: calc(100vh - var(--site-header-height)); }
@supports (height: 100svh) {
  .DOAR-dynamic-animation > .DOAR-dynamic-animation-loading { height: calc(100svh - var(--site-header-height)); }
}
.DOAR-dynamic-animation-stage > .DOAR-dynamic-animation-loading { position: absolute; inset: 0; z-index: 3; }
.DOAR-dynamic-animation-loading.is-finished { opacity: 0; visibility: hidden; }
.DOAR-dynamic-animation-loading-message {
  margin: 0;
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: inherit;
}
.DOAR-dynamic-animation-loading-bar {
  position: relative;
  width: 120px;
  height: 2px;
  overflow: hidden;
  background: var(--scene-rule);
}
.DOAR-dynamic-animation-loading-bar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: var(--scene-progress);
  animation: DOAR-dynamic-animation-loading-sweep 1.4s ease-in-out infinite;
}
@keyframes DOAR-dynamic-animation-loading-sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}
@media (prefers-reduced-motion: reduce) {
  .DOAR-dynamic-animation-loading-bar::after { animation: none; width: 100%; opacity: 0.5; }
}
/* The scene's own text stays hidden until the scene is ready, so nothing shows before it has been laid out. */
.DOAR-dynamic-animation.is-loading .DOAR-dynamic-animation-scene { visibility: hidden; }

.DOAR-dynamic-animation-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(127, 127, 127, 0.18);
  z-index: 4;
}
.DOAR-dynamic-animation-progress span {
  display: block;
  height: 100%;
  background: var(--scene-progress);
  transform-origin: left center;
  transform: scaleX(0);
}

/* Top-right corner of the stage, so it never sits under the site's back-to-top button (bottom right). */
.DOAR-dynamic-animation-skip {
  position: absolute;
  right: max(16px, env(safe-area-inset-right, 0px));
  top: 14px;
  z-index: 5;
  font-family: var(--font-data);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--scene-control-border);
  background: var(--scene-control-background);
  color: var(--scene-control-ink);
  cursor: pointer;
}
.DOAR-dynamic-animation-skip:hover { border-color: var(--scene-control-ink); }
.DOAR-dynamic-animation-skip:focus-visible { outline: 2px solid var(--scene-progress); outline-offset: 2px; }
/* Narrow screens show just "Skip" (screen readers still hear "Skip animation"). */
@media (max-width: 899px) {
  .DOAR-dynamic-animation-skip { padding: 6px 11px; }
  .DOAR-dynamic-animation-skip-detail { display: none; }
}

/* Shared scene typography */
/* Eyebrows are the top line of scene captions; keep them clear of the Skip button in the top-right corner.
   The Skip button is never scaled, so the room is divided by the scene's scale to stay the same on screen. */
.scene-eyebrow {
  margin: 0 0 6px;
  padding-right: calc(150px / var(--DOAR-layout-scale, 1));
  font-family: var(--font-data);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.scene-headline {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 3.1cqw, 42px);
  line-height: 1.1;
  text-wrap: balance;
}
/* Matches the Skip button's own narrow-screen rule, which follows the browser window. */
@media (max-width: 899px) {
  .scene-eyebrow { padding-right: calc(64px / var(--DOAR-layout-scale, 1)); }
}
.scene-note {
  margin: 8px 0 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

/* ---------- 3D add-on: shared canvas ---------- */
.DOAR-dynamic-animation-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
