/* =========================================================
   STORM — BALL ANATOMY (tech page)
   -----------------------------------------------------------
   Loads ON TOP of base-web-style.css + tech-dark-teal-skin.css.
   The look is the skin's; this file puts it back into the OLD
   page's layout, which Dylan preferred, measured off the old
   page at 1440 / 1024 / 768:

     1. the anatomy band — a darker band, a big title, the
        diagram at half the width, a small Watch Movie button
     2. each part as a row — copy left, cut-away right — with a
        Details button that opens its types underneath
     3. the types panel — a bordered panel with a sideways row
        of cards, image first, each row a keyboard-scrollable
        region
     4. the Insightful Tips panel, in the same shell
     5. the scroll-in animation (parts come out of each other)

   Cards, buttons, type and colour are all base + skin; no
   tokens are redefined.
   ========================================================= */

/* ---------------------------------------------------------
   1. ANATOMY BAND
   The old band was a dark stripe on a white page. On the dark
   skin it is the skin's raised ground (--spi-gray-100), so it
   still reads as a band.
--------------------------------------------------------- */
.ba-band {
  background: var(--spi-gray-100);
}

/* 64px on a desktop, as before, easing down on smaller screens */
.ba-band .spi-display {
  --spi-display-min: 32px;
  --spi-display-vw: 5vw;
  --spi-display-max: 64px;
}

/* Half the width, as before; never under 480px on a small
   screen, where half would shrink the labels past reading. */
.ba-diagram {
  --spi-figure-w: max(50%, min(100%, 480px));
}

.ba-watch {
  margin-top: 24px;
}

/* ---------------------------------------------------------
   2. A PART (.ba-part)
   Copy and Details button on the left, the cut-away on the
   right. From 1024 down the old page stacked them with the
   picture on top — 500px tall on a tablet, 250px on a phone.
--------------------------------------------------------- */
.ba-parts {
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.ba-part-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 32px;
}

.ba-part-text .spi-body {
  max-width: 640px;
}

/* The width holds the picture's column open BEFORE the lazy
   image arrives. Without it the auto column is 0px until load,
   then jumps to 280px and narrows the copy beside it. */
.ba-part-img {
  --spi-figure-w: 280px;
  width: 280px;
}

/* The Details pill, chevron turning over when its panel is open.
   Live, the store theme already makes every .btn a centred flex
   row; display and align-items are here for the page without the
   theme (a local preview), where .btn is inline-block and the
   chevron would sit on the text baseline. */
.ba-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.ba-toggle svg {
  flex: 0 0 auto;
  transition: transform 0.3s ease;
}

.ba-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

@media (max-width: 1024px) {
  .ba-part-row {
    grid-template-columns: 1fr;
  }

  .ba-part-img {
    order: -1;
    --spi-figure-w: 500px;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .ba-parts {
    gap: 32px;
  }

  .ba-part-img {
    --spi-figure-w: 250px;
  }
}

/* ---------------------------------------------------------
   3. PANELS (.ba-panel) — the types under each part, and
   Insightful Tips. The skin's .ui-card shell, without its
   hover lift: a whole panel jumping under the pointer reads
   as a button. The cards inside keep theirs.
--------------------------------------------------------- */
.ba-panel {
  padding: 32px 32px 8px;
}

/* A types panel opens 32px under its part's row. (Insightful
   Tips is the same shell but sits in its own section.) */
.ba-part > .ba-panel {
  margin-top: 32px;
}

.ba-panel:hover {
  transform: none;
  border-color: var(--brand-border);
  box-shadow: none;
}

/* The old cards were 300px of image plus 32px padding a side
   on a desktop, and 186px + 16px from 1024 down. */
.ba-type-row {
  --spi-scroll-w: 340px;
}

/* The type rows hold no links, so each is a focusable region
   (tabindex="0" in the page) for a keyboard user to scroll. */
.ba-type-row:focus-visible {
  outline: 2px solid var(--spi-accent);
  outline-offset: 2px;
}

.ba-type {
  display: flex;
  flex-direction: column;
}

/* height:auto keeps the ratio once max-width shrinks the
   image to the card (its width/height attributes would
   otherwise hold the 500px height). */
.ba-type img {
  height: auto;
  margin-bottom: 16px;
}

.ba-type > .btn {
  margin-top: 20px;
  align-self: flex-start;
}

@media (max-width: 1024px) {
  .ba-type-row {
    --spi-scroll-w: 240px;
  }

  .ba-panel {
    padding: 24px 20px 4px;
  }
}

/* ---------------------------------------------------------
   5. THE PARTS COME OUT OF EACH OTHER
   When the parts scroll into view: the cover drops in, the
   core slides down out from behind the ball, then the weight
   block slides down out from behind the core, and each part's
   copy drops in as its picture lands.

   The script measures how far apart the three pictures sit and
   hands each its starting offset (--ba-from, and --ba-mid for
   the weight block's stop behind the core), then adds
   .is-armed (everything parked) and, on scroll-in, .is-out
   (play). Both classes come off when it finishes. Only
   transform and opacity move, so the layout never shifts.
   Without the script, or with reduced motion, none of this
   applies and the page simply shows the parts.
--------------------------------------------------------- */
.ba-parts {
  position: relative;   /* the pictures measure from here */
}

/* Parked: the core and weight block behind the cover, the
   copy of parts 2 and 3 up and out of sight. Copy is not
   clickable while it can't be seen. */
.ba-parts.is-armed .ba-part-img {
  position: relative;
}

.ba-parts.is-armed .ba-part:nth-child(1) .ba-part-img { z-index: 3; }
.ba-parts.is-armed .ba-part:nth-child(2) .ba-part-img { z-index: 2; }
.ba-parts.is-armed .ba-part:nth-child(3) .ba-part-img { z-index: 1; }

.ba-parts.is-armed .ba-part-img,
.ba-parts.is-armed .ba-part-text {
  opacity: 0;
}

.ba-parts.is-armed .ba-part-text {
  transform: translateY(-24px);
  pointer-events: none;
}

/* Play, side-by-side layout. Cover 0-0.5s; core 0.5-1.4s;
   weight block rides hidden behind the core for the same
   0.9s, then comes out of it, 1.4-2.3s. */
.ba-parts.is-out .ba-part:nth-child(1) .ba-part-img {
  animation: ba-drop-in 0.5s ease-out both;
}

.ba-parts.is-out .ba-part:nth-child(2) .ba-part-img {
  animation: ba-out-of-cover 0.9s ease-in-out 0.5s both;
}

.ba-parts.is-out .ba-part:nth-child(3) .ba-part-img {
  animation: ba-out-of-core 1.8s 0.5s both;
}

.ba-parts.is-out .ba-part-text {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.ba-parts.is-out .ba-part:nth-child(1) .ba-part-text { transition-delay: 0.1s; }
.ba-parts.is-out .ba-part:nth-child(2) .ba-part-text { transition-delay: 1.1s; }
.ba-parts.is-out .ba-part:nth-child(3) .ba-part-text { transition-delay: 2s; }

@keyframes ba-drop-in {
  from { transform: translateY(-40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* starts exactly behind the cover, fades up as it clears it */
@keyframes ba-out-of-cover {
  0%   { transform: translateY(var(--ba-from, 0px)); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* first leg: hidden, travelling with the core to sit behind it;
   second leg: out of the core and down to its own row */
@keyframes ba-out-of-core {
  0%   { transform: translateY(var(--ba-from, 0px)); opacity: 0; animation-timing-function: ease-in-out; }
  50%  { transform: translateY(var(--ba-mid, 0px)); opacity: 0; animation-timing-function: ease-in-out; }
  60%  { opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* Stacked layout (1024 down): each picture sits above its own
   copy, so a core travelling up the page would cross the
   cover's text. Here the parts simply drop in, one after
   another. */
@media (max-width: 1024px) {
  .ba-parts.is-out .ba-part:nth-child(n) .ba-part-img {
    animation: ba-drop-in 0.6s ease-out both;
  }

  .ba-parts.is-out .ba-part:nth-child(2) .ba-part-img { animation-delay: 0.35s; }
  .ba-parts.is-out .ba-part:nth-child(3) .ba-part-img { animation-delay: 0.7s; }

  .ba-parts.is-out .ba-part:nth-child(1) .ba-part-text { transition-delay: 0.15s; }
  .ba-parts.is-out .ba-part:nth-child(2) .ba-part-text { transition-delay: 0.5s; }
  .ba-parts.is-out .ba-part:nth-child(3) .ba-part-text { transition-delay: 0.85s; }
}
