/* Stock the Shelves (PURP Buying): order to shelf on one line. The product pages' chrome, type,
   colour, hero and finale come from point-of-sale.css; this file is Buying's own: a hero film, the
   line (a conveyor of stations one order travels as the reader scrolls, its viewer pinned above the
   stations' words and driven by the lock-on controller in run-the-floor.mjs) and the one-scan moment.
   It takes the page's colour names from there too (the light Mist page, the stage palette on the
   line) and only sets its own components on them. */

/* ---- Hero: the order arrives ---- */
/* No PURP light here: the headline opens the page and the film rides in along the line beneath it. */
.shelves-hero h1 { animation-delay: .15s; }
.shelves-hero .pos-hero__lede { animation-delay: 1.1s; }
/* One purchase order on three screens, edge to edge under the headline: one per step of its progress bar
   in Admin, each under its tab. They share the first screen with the headline, so their width follows the
   height left for them: the navigation and bar (140), the headline (95), the tabs and lines (86), the gaps
   and the lede leave 100svh - 420px for a screen's height. Each step is a row of the list's grid (subgrid),
   so the tabs, lines and screens line up across the three however a line wraps. */
.po-steps { --po-gap: clamp(14px, 1.6vw, 28px); --po-w: min(100vw - var(--scrollbar, 0px) - 2 * var(--gutter), 3 * max(250px, (100svh - 420px) * 16 / 9) + 2 * var(--po-gap)); width: var(--po-w); margin: 30px 0 0 calc(50% - var(--po-w) / 2); animation: ride-in 1.3s var(--ease) .4s both; }
.po-steps__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 var(--po-gap); margin: 0; padding: 0; list-style: none; }
.po-step { display: grid; grid-row: span 3; grid-template-rows: subgrid; justify-items: center; text-align: center; }
.po-step__tab { min-height: 34px; padding: 0 16px; border: 1px solid var(--edge-line); border-radius: 999px; background: var(--raised); color: var(--type-muted); font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background-color .3s ease, border-color .3s ease, color .3s ease; }
.po-step__tab:hover { color: var(--type); }
.po-step.is-on .po-step__tab { border-color: var(--action); background: var(--action); color: var(--on-action); }
.po-step__line { margin: 10px 0 16px; font-size: 15px; line-height: 1.35; color: var(--type-muted); }
.po-step__screen { position: relative; isolation: isolate; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; background: var(--surface); box-shadow: var(--film-shadow); transition: box-shadow .5s var(--ease); }
.po-step.is-on .po-step__screen { box-shadow: 0 0 0 2px var(--action), var(--film-shadow); }
.po-step__screen video { display: block; width: 100%; height: 100%; object-fit: cover; filter: saturate(.75) brightness(.95); transition: filter .5s var(--ease); }
.po-step.is-on .po-step__screen video { filter: none; }
/* How far the lit step's film has played, along the foot of its screen. */
.po-step__played { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; height: 4px; background: var(--action); opacity: 0; transform: scaleX(var(--played, 0)); transform-origin: left; }
.po-step.is-on .po-step__played { opacity: 1; }
.po-step__screen > .video-toggle { z-index: 2; right: 12px; bottom: 14px; width: 34px; height: 34px; }
.po-step__screen > .video-toggle svg { width: 15px; height: 15px; }
/* Too narrow for three screens side by side: the tabs sit in a row, as they do in Admin, over the one
   screen of the lit step. */
@media (max-width: 1023px) {
  .po-steps { --po-w: var(--content); }
  .po-steps__list { grid-template-columns: repeat(3, auto); gap: 0 6px; }
  .po-step { display: contents; }
  .po-step__tab { grid-row: 1; justify-self: center; }
  .po-step__line { grid-row: 2; grid-column: 1 / -1; justify-self: center; text-align: center; }
  .po-step__screen { grid-row: 3; grid-column: 1 / -1; }
  .po-step:not(.is-on) :is(.po-step__line, .po-step__screen) { display: none; }
}
@keyframes ride-in { from { opacity: 0; transform: translateX(-64px) scale(.97); filter: blur(5px); } to { opacity: 1; transform: none; filter: none; } }

/* ---- The line ---- */
/* A stage (point-of-sale.css): the hero fades into it at dusk, and it fades back out into the scan. */
.line {
  --section-top: 110px;
  --fade-in: 110px;
  --fade-out: 150px;
  padding: var(--section-top) var(--gutter) 180px;
  scroll-margin-top: calc(-1 * var(--section-top));
  background:
    linear-gradient(to bottom, var(--dusk-2), var(--dusk-3) calc(var(--fade-in) / 2), transparent var(--fade-in)),
    linear-gradient(to top, var(--dusk-2), var(--dusk-3) calc(var(--fade-out) / 2), transparent var(--fade-out)),
    var(--ground);
  text-align: center;
}
/* The one time contrast: the old way is struck through as the heading arrives. */
.line h2 { font-size: clamp(40px, 5.6vw, 76px); line-height: 1.04; font-weight: 600; letter-spacing: -.02em; }
.line h2 s { position: relative; display: block; width: fit-content; margin: 0 auto; color: var(--type-quiet); text-decoration: none; }
.line h2 s::after { content: ""; position: absolute; top: 52%; right: -3%; left: -3%; height: .07em; border-radius: 999px; background: var(--accent); transform-origin: left; }
.line h2 > span { display: block; padding-bottom: .06em; background: var(--headline); -webkit-background-clip: text; background-clip: text; color: transparent; }
.line__lede { --reveal-order: 1; max-width: 32ch; margin: 18px auto 0; font-size: clamp(19px, 1.9vw, 24px); line-height: 1.3; color: var(--type-muted); }
.line__body { width: var(--content); margin: 44px auto 0; overflow-anchor: none; }
.line__steps { margin: 0; padding: 0; list-style: none; }

/* The viewer rides pinned under the bar while the stations' words scroll beneath it. Its film leaves
   about 190px under it for the words: --bar-space, the rail (49), the readout (30), the padding (38)
   and those 190px leave 100svh - --bar-space - 310px for the 16:9 film. */
.line__stage {
  --film-width: min(100%, max(420px, calc((100svh - var(--bar-space) - 310px) * 16 / 9)));
  position: sticky;
  z-index: 2;
  top: var(--bar-space);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 30px;
  overflow-anchor: none;
  /* It hides the words passing under it, and its foot fades so they come out from beneath softly. */
  background: linear-gradient(180deg, var(--ground) calc(100% - 30px), transparent);
}
/* Pinned, it also covers the space above it, where the words would show through the bar's veil. */
.line__stage::before { content: ""; position: absolute; z-index: -1; right: 0; bottom: 100%; left: 0; height: var(--bar-space); background: var(--ground); opacity: 0; }
.line__stage.is-pinned::before { opacity: 1; }
.line__rail, .line__film, .line__readout { width: var(--film-width); }

/* The rail: six stations, the supplier's file first. The order (the bright dot) rides along it to
   the station on screen, lighting the track behind it; --lock-at is the station's index. */
.line__rail { position: relative; margin-bottom: 14px; }
.line__track { position: absolute; top: 5px; right: calc(100% / 14); left: calc(100% / 14); height: 2px; border-radius: 2px; background: color-mix(in srgb, var(--pdb-purp-lavender, #d9cbff) 22%, transparent); }
.line__fill { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, var(--soft), var(--accent)); box-shadow: 0 0 10px color-mix(in srgb, var(--pdb-purp-orchid, #a78bfa) 70%, transparent); transform: scaleX(calc((var(--lock-at, 0) + 1) / 6)); transform-origin: left; transition: transform .9s var(--ease); }
.line__order { position: absolute; z-index: 1; top: 50%; left: calc((var(--lock-at, 0) + 1) / 6 * 100%); width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--type); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pdb-purp-orchid, #a78bfa) 36%, transparent), 0 0 22px 4px color-mix(in srgb, var(--pdb-purp-orchid, #a78bfa) 80%, transparent); transition: left .9s var(--ease); }
.line__stations { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.line__stations li { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 0 2px; color: var(--type-quiet); font-size: 12px; line-height: 1.2; font-weight: 600; letter-spacing: .01em; transition: color .5s var(--ease); }
.line__stations li::before { content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ground); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--pdb-purp-lavender, #d9cbff) 36%, transparent); transition: background-color .5s var(--ease), box-shadow .5s var(--ease); }
.line__stations .line__origin, .line__stations .is-passed { color: var(--type-muted); }
.line__stations .line__origin::before, .line__stations .is-passed::before { background: var(--soft); box-shadow: none; }
.line__stations .is-active { color: var(--type); }

/* The film: each station's film fades in over the last (the controller lets the old one go only
   once it is covered), and a light runs across the screen as the order arrives. */
.line__film { position: relative; }
.line__screen { position: relative; isolation: isolate; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 18px; background: var(--surface); box-shadow: var(--film-shadow); }
.line__feed { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.line__feed.is-shown { opacity: 1; transition: opacity .56s cubic-bezier(.4, 0, .2, 1); }
.line__sweep { position: absolute; inset: 0; overflow: hidden; border-radius: 18px; pointer-events: none; }
.line__sweep::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 36%; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--pdb-purp-lavender, #d9cbff) 16%, transparent) 72%, color-mix(in srgb, var(--pdb-purp-pearl, #f8f5ff) 34%, transparent) 97%, transparent); opacity: 0; }
.line__stage.is-locking .line__sweep::before { animation: deliver .95s cubic-bezier(.45, 0, .2, 1); }
.line__film > .video-toggle { right: 12px; bottom: 12px; }
/* The readout names the station and what its film shows; the old line fades as the new one arrives. */
.line__readout { display: grid; min-height: 1.5em; margin-top: 12px; color: var(--type-muted); font-size: 13px; line-height: 1.4; font-weight: 500; letter-spacing: .01em; }
.line__readout > span { grid-area: 1 / 1; transition: opacity .4s var(--ease); }
.line__readout > span.is-entering, .line__readout > span.is-leaving { opacity: 0; }

/* The stations' words: the one at the reader's line is lit. */
.line__step { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: max(46svh, 260px); color: var(--type-quiet); transition: color .42s var(--ease); }
.line__step.is-active { color: var(--type); }
.line__step h3 { font-size: clamp(26px, 2.6vw, 36px); line-height: 1.1; font-weight: 600; letter-spacing: -.015em; }
.line__step p { max-width: 44ch; margin-top: 10px; font-size: 19px; line-height: 1.35; color: var(--type-quiet); transition: color .42s var(--ease); }
.line__step.is-active p { color: var(--type-muted); }

/* ---- One scan ---- */
/* Back on the light page between two stages: dawn above, dusk below into the finale. A reader carried
   here from the line lands with the section's top at the window's top, so the heading sits well below
   the bar. */
.scan {
  --fade-in: 112px;
  --fade-out: 180px;
  padding: 150px var(--gutter) 130px;
  background:
    linear-gradient(to bottom, var(--dusk-2), var(--dusk-1) calc(var(--fade-in) / 2), transparent var(--fade-in)),
    linear-gradient(to top, var(--dusk-2), var(--dusk-1) calc(var(--fade-out) / 2), transparent var(--fade-out)),
    radial-gradient(ellipse 60% 40% at 50% 46%, var(--glow), transparent 72%),
    var(--ground);
  text-align: center;
}
.scan h2 { font-size: clamp(38px, 5vw, 64px); line-height: 1.05; font-weight: 600; letter-spacing: -.018em; }
/* The heading, the whole film and the line under it fit one screen from where the carry lands, with
   the line clear of the bottom band where reveals wait: the padding (150), the heading (67), the gaps
   (52), the line (31) and 80px to spare. */
.scan__film { width: min(var(--content), max(520px, calc((100svh - 380px) * 16 / 9))); margin: 28px auto 0; aspect-ratio: 16 / 9; box-shadow: var(--film-shadow); }
.scan__line { --reveal-order: 1; margin-top: 24px; font-size: clamp(20px, 2vw, 26px); line-height: 1.2; font-weight: 600; }

@keyframes deliver { from { opacity: 1; transform: translateX(-110%); } to { opacity: 1; transform: translateX(290%); } }

@media (max-width: 734px) {
  .po-step__tab { min-height: 40px; padding: 0 10px; font-size: 12px; }
  .po-step__line { margin: 12px 0 14px; font-size: 14px; }
  .po-step__screen { border-radius: 12px; }
  .line { --section-top: 76px; --fade-in: 94px; --fade-out: 130px; padding-bottom: 150px; }
  .line__lede { font-size: 18px; }
  .line__body { margin-top: 32px; }
  .line__stations li { gap: 8px; font-size: 11px; }
  .line__film > .video-toggle { right: 8px; bottom: 8px; }
  .line__screen, .line__sweep { border-radius: 12px; }
  .line__readout { font-size: 12px; }
  .line__step { min-height: max(40svh, 220px); }
  .line__step h3 { font-size: 24px; }
  .line__step p { font-size: 16px; }
  .scan { padding: 120px var(--gutter) 88px; }
  .scan__film { width: var(--content); margin-top: 30px; }
}

/* With the script and motion, the strike draws as the heading arrives; otherwise it is simply drawn. */
@media (prefers-reduced-motion: no-preference) {
  .js .line h2:not(.is-visible) s::after { transform: scaleX(0); }
  .line h2 s::after { transition: transform .9s var(--ease) .6s; }
  .line__stage::before { transition: opacity .2s linear; }
}

@media (prefers-reduced-motion: reduce) {
  .po-steps { animation: none; }
  .po-step__tab, .po-step__screen, .po-step__screen video { transition: none; }
  .line__fill, .line__order, .line__stations li, .line__stations li::before, .line__step, .line__step p, .line__feed.is-shown, .line__readout > span { transition: none; }
  .line__sweep { display: none; }
}
