/* The range (#range, brief 7.2), rebuilt 29 Oct 2026: the roll-away. Theme studio: the section paints --studio-floor,
   the hero's floor and the floor every roll-away frame is composited onto, so hero, film and section are one floor.
   Two layouts:
   - default (reduced motion, no GSAP, no script): the words, then a still of the stack rolling away (a CSS image, so
     the motion layout never downloads it), then the caption;
   - html.has-motion: a pinned stage, the film on a canvas (js/sections/range.js places and sizes it for the screen)
     and the words above it, each line shown only behind the stack's trailing edge (a mask range.js sets per frame).
   Every selector is scoped under #range. */

#range {
  --range-gap: clamp(18px, 2.6vh, 28px);   /* eyebrow to heading, heading to the labels */
  background: var(--studio-floor);
}

/* ------------------------------------------------------------------ words */
#range .range-words { display: grid; justify-items: start; gap: var(--range-gap); }
#range .range-title { max-width: none; }
#range .range-kinds { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin: 0; color: var(--ink); }
#range .range-kinds > span { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
#range .range-kinds > span::before {
  content: ""; flex: none; width: 6px; height: 6px; border-radius: 1px; background: var(--yellow);
  box-shadow: 0 0 0 1px rgba(138, 100, 0, .28);    /* keeps the yellow square crisp on the light floor */
}
#range .range-caption { color: color-mix(in srgb, var(--ink) 66%, transparent); }

/* ------------------------------------------------------------------ default: the still layout */
#range { padding-block: var(--section-pad) clamp(56px, 9vh, 112px); }
#range .range-stage { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
#range .range-film { display: none; }
#range .range-still {
  width: 100%; aspect-ratio: 1600 / 660; margin-top: clamp(8px, 2vh, 24px);
  background: var(--studio-floor) url("../../assets/rollaway/poster.webp") 64% 50% / cover no-repeat;
}
#range .range-caption { margin-top: 10px; }
@media (max-width: 767.98px) {
  #range .range-title { font-size: min(46px, 11.6vw); }
  #range .range-still {
    aspect-ratio: 576 / 634; margin-top: 28px;
    background-image: url("../../assets/rollaway/poster-mobile.webp"); background-position: 50% 50%;
  }
}

/* ------------------------------------------------------------------ motion: the pinned film */
html.has-motion #range { padding: 0; }
html.has-motion #range .range-stage {
  position: relative; max-width: none; margin: 0; padding: 0;
  height: 100vh; height: 100svh; overflow: clip; isolation: isolate;
}
html.has-motion #range .range-still { display: none; }
html.has-motion #range .range-film { display: block; position: absolute; inset: 0; z-index: 0; pointer-events: none; }
/* range.js sets the canvas box (left, top, width, height) to the frame's place, so the frameSequence 'contain' draw
   is the final picture. The frames' own top and bottom rows are floor; the canvas fades them out over 10px anyway,
   so no row of the encoder's edge can show. On screens wider than the film can be drawn (short wide windows) the
   canvas is narrower than the stage and its sides fade out too (data-carry="sides"). */
html.has-motion #range .range-canvas {
  position: absolute; left: 0; top: 0; width: 100%; height: 60%; max-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
}
html.has-motion #range .range-film[data-carry="sides"] .range-canvas {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%),
                      linear-gradient(to right, transparent 0, #000 5%, #000 95%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%),
                      linear-gradient(to right, transparent 0, #000 5%, #000 95%, transparent 100%);
          mask-composite: intersect;
}
/* the words sit over the film on the page's own left edge (the .wrap content edge); range.js sets their top so the
   heading crosses the stack's middle, and a mask with one layer per line, so each line shows only behind the stack */
html.has-motion #range .range-words {
  position: absolute; z-index: 1; top: 40%;
  left: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  right: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  visibility: hidden;
}
html.has-motion #range[data-roll="on"] .range-words { visibility: visible; }
html.has-motion #range .range-title { white-space: nowrap; }
html.has-motion #range .range-caption {
  position: absolute; z-index: 1; margin: 0; bottom: 30px;
  right: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
}
/* short screens (a 1366x657 laptop window): the caption sits lower, so the film can still be drawn the full width */
@media (min-width: 768px) and (max-height: 759.98px) {
  html.has-motion #range .range-caption { bottom: 14px; }
}
/* the same failsafe as css/motion.css: a CDN that holds GSAP back (core.js has not marked html.ss-booted) never
   leaves the words hidden for more than 4 s */
@keyframes range-failsafe { to { visibility: visible; } }
html.has-motion:not(.ss-booted) #range .range-words { animation: range-failsafe 0s linear 4s forwards; }
/* and if GSAP is still held back after 3 s, the still shows under the words, as the hero, the hall and the foot show
   theirs (until 30 Oct 2026 the scene stayed the words alone on a bare floor until GSAP came): the words at the top of
   the screen in the stage's own flow, the still filling the rest. Its picture is set by an animation 3 s in, so a
   page whose GSAP comes in time never downloads it. Once core.js marks html.ss-booted, the film takes over. */
@keyframes range-held { from, to { background-image: url("../../assets/rollaway/poster.webp"); } }
@keyframes range-held-phone { from, to { background-image: url("../../assets/rollaway/poster-mobile.webp"); } }
html.has-motion:not(.ss-booted) #range .range-stage {
  display: flex; flex-direction: column;
  padding: calc(var(--nav-clear) + clamp(12px, 3vh, 32px)) 0 56px;
}
html.has-motion:not(.ss-booted) #range .range-words {
  position: relative; top: auto; left: auto; right: auto; flex: none; width: auto;
  margin-inline: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
}
html.has-motion:not(.ss-booted) #range .range-still {
  display: block; flex: 1 1 0; min-height: 0; width: auto; aspect-ratio: auto;
  margin: clamp(12px, 3vh, 32px) var(--gutter) 0;
  background-image: none; background-size: contain; background-position: 50% 100%;
  animation: range-held 0s linear 3s forwards;
}
@media (max-width: 767.98px) {
  html.has-motion:not(.ss-booted) #range .range-still { animation-name: range-held-phone; }
}

/* phones: the heading wraps into two lines; each line is shown behind the stack on its own */
@media (max-width: 767.98px) {
  html.has-motion #range .range-title { white-space: normal; font-size: min(46px, 11.6vw); }
  html.has-motion #range .range-caption { bottom: 18px; font-size: 12px; }
}
