.swarm-story {
  --sw-accent: var(--safety-orange, #ff5f15);
  --sw-text: var(--off-white, #faf9f6);
  --sw-edge: max(clamp(1.1rem, 5vw, 6rem), calc((100vw - 96rem) / 2));
  --sw-inset: clamp(1.25rem, 5.5svh, 4.5rem);
  --sw-foot: 3.3rem;
  --sw-sticky-top: var(--mast-height, 64px);
  position: relative;
  isolation: isolate;
  background: #17181a;
  color: var(--sw-text);
}
.swarm-pin { position: relative; }
.swarm-visual { display: none; }
#swarm-stage { width: 100%; height: 100%; }
.swarm-panel {
  min-width: 0;
  padding: clamp(3rem, 7vw, 6rem) var(--sw-edge);
  scroll-margin-top: calc(var(--mast-height, 64px) + 1rem);
}
.swarm-caption { max-width: 42rem; }
.swarm-panel h1, .swarm-panel h2, .swarm-panel p { margin: 0; }
.swarm-panel h1 {
  font: 400 clamp(2.8rem, 6.55vw, 6.5rem)/.96 var(--font-display);
  letter-spacing: -.06em;
}
.swarm-panel h2 {
  font: 650 clamp(1.9rem, 3.45vw, 3.9rem)/1.04 var(--font-header);
  letter-spacing: -.045em;
  text-wrap: balance;
}
.swarm-panel h1 span, .swarm-panel h2 span { color: var(--sw-accent); }
.swarm-panel p { max-width: 43ch; font: 400 1rem/1.48 var(--font-body); color: #f0efeb; }
.swarm-panel h1 + p { max-width: 37ch; font-size: clamp(1.03rem, 1.4vw, 1.43rem); margin-top: 1.25rem; }
.swarm-panel h2 + p { margin-top: .75rem; }
.swarm-panel p + p { margin-top: .85rem; }
#swarm-descent ul { max-width: 52ch; margin: .75rem 0 .9rem; padding-inline-start: 1.2rem; line-height: 1.42; }
#swarm-descent li + li { margin-top: .4rem; }
#swarm-descent li::marker { color: var(--sw-accent); }
.swarm-panel .swarm-service {
  display: flex; align-items: center; gap: .65rem;
  max-width: none; margin-bottom: .8rem;
  color: #efeeea;
  font: 680 .78rem/1.4 var(--font-header); letter-spacing: .085em; text-transform: uppercase;
}
.swarm-service::before { content: ''; flex: none; width: 1.5rem; height: 2px; background: var(--sw-accent); }
.swarm-exit { text-decoration-color: var(--sw-accent); text-underline-offset: .27em; }
#swarm-clouds {
  display: grid; grid-template-rows: 1fr auto; align-items: center; gap: 1rem;
  min-height: calc(100svh - var(--mast-height, 64px));
  padding-block: var(--sw-inset);
  background: linear-gradient(90deg, #101114c9, #15151750 44%, transparent 70%),
              url('swarm/art/hover-drone.webp') 83% 39% / 27% auto no-repeat,
              url('swarm/art/sky.webp') center 48% / cover no-repeat;
}
#swarm-clouds .swarm-caption { width: min(48%, 45rem); }
#swarm-inside .swarm-caption { max-width: min(46%, 39rem); }
#swarm-inside h2 { font: 400 clamp(2.65rem, 5vw, 5.8rem)/1 var(--font-display); letter-spacing: -.06em; }
#models .swarm-model-details { margin-top: .85rem; }
.swarm-story + .swarm-model-details { padding: 2rem 5vw; background: var(--ink); }
.swarm-story + .swarm-model-details p { max-width: 54ch; margin-inline: auto; }
.swarm-cue {
  justify-self: center; display: grid; justify-items: center; gap: .22rem;
  padding: .3rem .85rem; color: var(--sw-text); text-decoration: none;
  background: radial-gradient(ellipse, #1012159c 0%, #10121555 42%, transparent 73%);
}
.swarm-cue span {
  display: flex; align-items: center; gap: .55em; white-space: nowrap;
  font: 400 clamp(.93rem, 1.35vw, 1.16rem)/1.3 var(--font-display);
  text-transform: uppercase; letter-spacing: .07em; text-shadow: 0 1px 3px #101215;
}
.swarm-cue span::before, .swarm-cue span::after {
  content: ''; width: .65em; height: .5em; border-top: 1px solid var(--sw-accent);
  border-left: 2px solid var(--sw-accent); transform: skewX(-24deg);
}
.swarm-cue span::after { transform: scaleX(-1) skewX(-24deg); }
.swarm-cue svg { display: block; width: clamp(4.6rem, 10svh, 6rem); height: auto; fill: var(--sw-accent); overflow: visible; }
.swarm-cue:is(:hover, :focus-visible) span { text-decoration: underline; text-underline-offset: .2em; }
@media (prefers-reduced-motion: no-preference) {
  .swarm-cue path { animation: swarm-arrow 1.65s ease-in-out infinite; }
  .swarm-cue path + path { animation-delay: .14s; }
  @keyframes swarm-arrow { 0%, 75%, 100% { transform: translateY(0); } 38% { transform: translateY(4px); } }
}

.swarm-controls {
  display: flex; align-items: end; justify-content: space-between; gap: 1rem;
  padding: 0 var(--sw-edge) max(.3rem, env(safe-area-inset-bottom));
  color: #f5f3ee;
  font: 600 .85rem/1.2 var(--font-header);
}
.swarm-controls summary, .swarm-exit, .swarm-controls nav a {
  display: flex; align-items: center; min-height: 44px; width: fit-content;
}
.swarm-chapters { position: relative; }
.swarm-chapters summary { gap: .6em; list-style: none; cursor: pointer; }
.swarm-chapters summary::-webkit-details-marker { display: none; }
.swarm-chapters summary::before {
  content: ''; width: .6rem; height: .6rem; border-top: 1.5px solid var(--sw-accent);
  border-left: 1.5px solid var(--sw-accent); transform: translateY(.14rem) rotate(45deg);
}
.swarm-chapters[open] summary::before { transform: translateY(-.12rem) rotate(225deg); }
.swarm-chapters nav {
  position: absolute; z-index: 2; left: 0; bottom: calc(100% + .15rem);
  min-width: 9.5rem; padding: .2rem .72rem; background: #191a1c; border: 1px solid #605d5b;
}
.swarm-chapters nav a { width: 100%; gap: .58rem; text-decoration: none; }
.swarm-chapters nav a::before { content: ''; width: .4rem; height: .4rem; background: transparent; }
.swarm-chapters nav a[aria-current='step']::before { background: var(--sw-accent); }
.swarm-controls a:hover, .swarm-controls summary:hover { text-decoration: underline; }
.swarm-story :is(a, summary):focus-visible,
.swarm-panel :is(h1, h2):focus { outline: 2px solid var(--sw-accent); outline-offset: 2px; }

/* All four chapters share the same full-bleed camera and the same pin. */
.swarm-story.is-scrubbed::after { content: ''; display: block; height: 550svh; }
.is-scrubbed .swarm-pin {
  position: sticky; top: var(--sw-sticky-top); min-height: calc(100svh - var(--mast-height, 64px));
  display: grid; isolation: isolate;
}
.is-scrubbed .swarm-visual {
  display: block; position: absolute; z-index: -1; inset: 0; overflow: hidden;
  background: #292a2c url('swarm/art/sky.webp') center / cover;
}
.is-scrubbed .swarm-copy { display: grid; }
.is-scrubbed .swarm-panel {
  grid-area: 1 / 1; position: relative; isolation: isolate; visibility: hidden;
  padding-block: var(--sw-inset) calc(var(--sw-foot) + .75rem);
  text-shadow: 0 1px 4px #131416a6, 0 2px 22px #11121565;
}
.is-scrubbed .swarm-panel.is-current { visibility: visible; }
.is-scrubbed .swarm-panel::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: -1;
  background: linear-gradient(155deg, #121317ad 0%, #12131738 29%, transparent 48%);
}
.is-scrubbed #swarm-clouds {
  background: none; min-height: 0;
  opacity: var(--sw-intro-alpha, 1);
}
.is-scrubbed #swarm-clouds::before, .is-scrubbed #swarm-inside::before {
  background: linear-gradient(90deg, #101114ce 0%, #1112158a 27%, #11121520 51%, transparent 67%);
}
.is-scrubbed #swarm-descent { opacity: var(--sw-descent-alpha, 1); }
.is-scrubbed #swarm-descent .swarm-caption { max-width: min(52%, 39rem); }
.is-scrubbed #swarm-impact { opacity: var(--sw-impact-alpha, 1); }
.is-scrubbed #swarm-impact::before { content: none; }
/* Keep the stage clear until chapter navigation focuses its text equivalent. */
.is-scrubbed #swarm-impact .swarm-caption {
  position: absolute;
}
.is-scrubbed #swarm-impact .swarm-caption:not(:focus-within) {
  width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.is-scrubbed #swarm-impact .swarm-caption:focus-within {
  top: calc(var(--sw-inset) + var(--mast-height, 64px) - var(--sw-sticky-top));
  inset-inline: var(--sw-edge);
  padding: 1rem; background: #191a1c;
}
.is-scrubbed #swarm-inside { display: grid; align-items: center; opacity: var(--sw-inside-alpha, 1); }
.is-scrubbed .swarm-controls {
  position: absolute; inset: auto 0 0; z-index: 1; pointer-events: none;
  background: linear-gradient(transparent, #1011159c);
}
.is-scrubbed .swarm-controls > * { pointer-events: auto; }

@media (orientation: portrait) {
  .swarm-story { --sw-inset: clamp(1.2rem, 4svh, 2.5rem); }
  #swarm-clouds { align-items: start; background-position: center, 84% 61%, center; background-size: auto, 43% auto, cover; }
  #swarm-clouds .swarm-caption, #swarm-inside .swarm-caption,
  .is-scrubbed #swarm-descent .swarm-caption { width: auto; max-width: 36rem; }
  .swarm-panel h1 { font-size: clamp(2.35rem, 12.65vw, 4.7rem); }
  .swarm-panel h2 { font-size: clamp(1.85rem, 7vw, 2.9rem); }
  .swarm-panel .swarm-service { font-size: .69rem; margin-bottom: .7rem; }
  .swarm-panel h1 + p { font-size: 1rem; line-height: 1.42; margin-top: .8rem; max-width: 34ch; }
  .swarm-panel h2 + p, .swarm-panel p + p { margin-top: .65rem; }
  .is-scrubbed #swarm-clouds::before, .is-scrubbed #swarm-inside::before {
    background: linear-gradient(180deg, #121317bb, #12131794 26%, #12131743 46%, transparent 66%);
  }
  .is-scrubbed #swarm-inside { align-items: start; }
  #swarm-inside h2 { font-size: clamp(2.4rem, 9vw, 4rem); }
  #swarm-inside p { font-size: .98rem; line-height: 1.37; }
}
@media (max-height: 640px) {
  .swarm-story { --sw-inset: 1rem; --sw-foot: 2.85rem; }
  .swarm-cue svg { width: 4.1rem; }
  .swarm-panel h1 + p, .swarm-panel p { font-size: 1rem; line-height: 1.37; }
}
@media (orientation: landscape) and (max-height: 550px) {
  .swarm-story { --sw-inset: .7rem; }
  .swarm-panel h1, #swarm-inside h2 { font-size: clamp(2rem, 4.5vw, 3.3rem); }
  .swarm-panel h2 { font-size: clamp(1.7rem, 3vw, 2.6rem); }
  .swarm-panel h1 + p, .swarm-panel h2 + p, .swarm-panel p + p { margin-top: .42rem; }
  .swarm-panel .swarm-service { font-size: .7rem; margin-bottom: .38rem; }
  .swarm-cue { padding-block: .1rem; }
  .swarm-cue svg { width: 3rem; }
  .swarm-panel p, .swarm-panel h1 + p { font-size: .95rem; }
  .is-scrubbed #swarm-descent { align-content: end; }
  .is-scrubbed #swarm-descent .swarm-caption { max-width: 42rem; }
  #swarm-descent ul { max-width: none; margin-block: .4rem .5rem; font-size: .95rem; line-height: 1.3; }
  #swarm-descent li + li { margin-top: .22rem; }
  #swarm-descent p { max-width: none; }
  .is-scrubbed #swarm-inside { align-items: end; }
  #swarm-inside .swarm-caption { max-width: 54%; }
}
@media (prefers-reduced-motion: reduce) {
  .swarm-story.is-scrubbed::after { height: 150svh; }
}
