/* ======================================================================================================
   Sticky Scroll — one side stays put while the other side scrolls past it. Root .section-rstk.

   MOBILE-FIRST ON PURPOSE. `.rstk` on its own is the stacked arrangement — each step followed by its
   own visual — and that is also the no-JavaScript state and the reduced-motion state. The pin block at
   the foot of this file is the ONLY thing that adds the two columns and the pin, from 1025px up (the
   theme's own desktop breakpoint). Nothing else in this file pins anything.
   ====================================================================================================== */

/* ------------------------------------------------------------------------------------------------------
   THE ONE LINE WITHOUT WHICH THE PIN DOES NOTHING.
   The theme's shared `.section-panel` sets `overflow: hidden` (layout.css) to clip its own rounded
   corners. A `position: sticky` child inside an `overflow: hidden` ancestor measures against THAT box
   instead of the viewport, so it never sticks — measured at −440px past the section instead of parked at
   its offset. `overflow: clip` clips identically (the radius and background-clip keep working) but does
   NOT create a scroll container. Two classes beat the theme's one, so this changes no other panel on the
   site by a pixel, and it travels with the module instead of living in a shared stylesheet.
   ------------------------------------------------------------------------------------------------------ */
.section-rstk.section-panel { overflow: clip; }

.section-rstk {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
  align-items: stretch;
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  /* The pin parks below the theme's sticky header. module.js measures the real header once and writes
     --rstk-head; the fallback is the header's own height at desktop, so a page with JavaScript off
     still parks the panel clear of it. */
  --rstk-air: 28px;
  --rstk-top: calc(var(--rstk-head, 96px) + var(--rstk-air));
}
@media (min-width: 1025px) { .section-rstk { padding: var(--rstk-padding, var(--spacing-2xl)); } }
.section-rstk--has-bg::before { content: ""; position: absolute; inset: 0; background: var(--rstk-tint, transparent); pointer-events: none; }
.section-rstk > * { position: relative; }
.section-rstk--full { border: 0; border-radius: 0; box-shadow: none; background: transparent !important; padding-left: 0; padding-right: 0; backdrop-filter: unset !important; -webkit-backdrop-filter: unset !important; }
.section-rstk--transparent { background: transparent; box-shadow: none; }
.section-rstk--text-dark .section-title, .section-rstk--text-dark .section-description, .section-rstk--text-dark .section-description p { color: var(--color-dark-purple) !important; }
.section-rstk--text-light .section-title, .section-rstk--text-light .section-description, .section-rstk--text-light .section-description p { color: var(--color-white) !important; }

.section-rstk__head { display: flex; flex-direction: column; gap: var(--spacing-md); max-width: 70ch; }
.section-rstk__title { font-size: var(--title-size, var(--font-size-h2)); }
.section-rstk--balance .section-rstk__title { text-wrap: balance; }
.section-rstk__description, .section-rstk__description p { font-size: var(--desc-size, var(--font-size-body)); }

/* ------------------------------------------------------------------ the stacked arrangement (every width) */
.rstk { display: grid; gap: var(--rstk-gap, 34px); }
.rstk__pinin { display: grid; gap: var(--spacing-md); align-content: start; }
.rstk__pinhead { display: grid; gap: 12px; }
.rstk__pint { font-size: var(--pin-title-size, var(--font-size-h3)); line-height: var(--line-height-tight); text-wrap: balance; }
.rstk__pinb, .rstk__pinb p { font-size: var(--font-size-body-card); line-height: var(--line-height-loose); max-width: 52ch; }
.rstk__pincta, .rstk__foot { display: flex; }

.rstk__steps { display: grid; gap: var(--rstk-step-gap, 60px); }
/* Round 3 — Header Placement = With the scrolling steps. The header becomes the first block of the
   step column, so the pinned visual starts level with the title instead of under it. It is not a step:
   it never dims in a swap section and it never takes the swap band's height. The step gap under it is
   closed back to the header's own rhythm, so the title and its first step read as one opening. */
.rstk__steps > .section-rstk__head--incol { max-width: none; margin-bottom: calc(var(--spacing-lg) - var(--rstk-step-gap, 60px)); }
@media (max-width: 1024px) { .rstk__steps > .section-rstk__head--incol { margin-bottom: 0; } }
/* WCAG 2.2 2.4.11 Focus Not Obscured: a step the browser scrolls to — because a keyboard user tabbed
   into it, or followed a step-list link — lands clear of both the theme's sticky header and the pin. */
.rstk__step { scroll-margin-top: calc(var(--rstk-top) + 24px); }
.rstk__se { display: block; font-family: var(--font-primary); font-size: var(--font-size-small); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-wide); text-transform: uppercase; color: #c2410c; line-height: var(--line-height-tight); margin-bottom: 10px; }
/* The step label is a deeper orange than the house --color-orange on light panels: the house value
   measures 3.03:1 on white, under the 4.5:1 WCAG AA needs at this size, and this reads as the same
   orange at 5.18:1. On a dark panel the bright orange already passes (6.4:1), so it keeps it. */
.section--dark .rstk__se { color: var(--color-orange-light); }
.rstk__sh { font-size: var(--step-title-size, var(--font-size-h4)); line-height: var(--line-height-normal); text-wrap: balance; }
.rstk__sb, .rstk__sb p { font-size: var(--font-size-body-card); line-height: var(--line-height-loose); max-width: var(--rstk-measure, 62ch); }
.rstk__sb p + p { margin-top: 0.6em; }
.rstk__sb ul { list-style: disc; padding-left: 1.2em; margin: 0.7em 0; }
.rstk__sb ol { list-style: decimal; padding-left: 1.2em; margin: 0.7em 0; }
.rstk__sb li { margin: 0.35em 0; }
.rstk__sb a, .rstk__pinb a, .pnl__text a { color: var(--color-orange); text-decoration: underline; }
.section--dark .rstk__sh, .section--dark .rstk__sb, .section--dark .rstk__sb p, .section--dark .rstk__pint,
.section--dark .rstk__pinb, .section--dark .rstk__pinb p, .section--dark .pnl__text, .section--dark .pnl__text p { color: var(--color-white); }

/* a panel sits under the step it belongs to until the pinned arrangement lifts it */
.rstk__panel { margin: 20px 0 0; }
.rstk--phone-steps_only .rstk__panel { display: none; }

/* ------------------------------------------------------------------------------------- the panels */
.pnl { border-radius: var(--radius-lg); }
.pnl__media { overflow: hidden; border-radius: var(--radius-lg); background: rgba(72, 16, 49, 0.04); }
.section--dark .pnl__media { background: rgba(255, 255, 255, 0.05); }
.pnl__media > img, .pnl__media > video { display: block; width: 100%; height: auto; max-height: var(--rstk-panel-max, none); }
.pnl__frame { border-radius: var(--radius-lg); overflow: hidden; background: rgba(72, 16, 49, 0.04); }
.section--dark .pnl__frame { background: rgba(255, 255, 255, 0.05); }
.pnl__scene { display: block; width: 100%; aspect-ratio: 1000 / 600; }
.pnl--text .pnl__text { border: 1px solid var(--color-border-light); border-radius: var(--radius-lg); padding: var(--spacing-md); background: rgba(255, 255, 255, 0.55); }
.section--dark .pnl--text .pnl__text { border-color: var(--color-border-dark); background: rgba(255, 255, 255, 0.05); }
.pnl__text, .pnl__text p { font-size: var(--font-size-body-card); line-height: var(--line-height-relaxed); }
.pnl__text p + p { margin-top: 0.5em; }
.pnl__text strong { font-weight: var(--font-weight-semibold); }
/* The caption is plum at 75% rather than the theme's medium grey: grey on a light panel measures 3.5:1,
   under the 4.5:1 WCAG AA needs for text this size. This reads as the same quiet caption and passes. */
.pnl__cap { margin-top: 12px; font-family: var(--font-primary); font-size: var(--font-size-small); line-height: var(--line-height-relaxed); color: rgba(72, 16, 49, 0.78); }
.section--dark .pnl__cap { color: var(--color-white-80); }
.rstk__pinmedia { margin: 0; }

/* -------------------------------------------------------------------------------- the indicators
   They exist ONLY in the pinned arrangement. A progress bar on a phone, where nothing is pinned and
   the observer is off, is a bar that can never fill; a step list there is a table of contents for
   content the reader is about to scroll through anyway. Same reason the empty panel slot is not in
   the stacked arrangement at all. */
.ind, .rstk__stack { display: none; }
.ind--list ol, .ind--numbers ol { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
.ind--numbers ol { grid-auto-flow: column; justify-content: start; gap: 8px; }
.ind__a { display: flex; align-items: baseline; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm); text-decoration: none; font-family: var(--font-primary); font-size: var(--font-size-menu); line-height: var(--line-height-normal); color: rgba(72, 16, 49, 0.62); transition: background var(--transition-fast), color var(--transition-fast); }
.section--dark .ind__a { color: var(--color-white-80); }
.ind__n { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; flex: 0 0 auto; border-radius: var(--radius-round); border: 1px solid var(--color-border-light); font-size: 12px; font-weight: var(--font-weight-semibold); transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast); }
.section--dark .ind__n { border-color: rgba(255, 255, 255, 0.28); }
.ind--numbers .ind__a { justify-content: center; min-width: 38px; border: 1px solid var(--color-border-light); font-weight: var(--font-weight-semibold); }
.section--dark .ind--numbers .ind__a { border-color: rgba(255, 255, 255, 0.28); }
.ind__a:hover { background: rgba(72, 16, 49, 0.05); color: var(--color-dark-purple); }
.section--dark .ind__a:hover { background: rgba(255, 255, 255, 0.08); color: var(--color-white); }
.ind__a:focus-visible { outline: 2px solid var(--color-orange); outline-offset: 2px; }
/* the active step. module.js writes the attribute; everything visual is CSS off it. */
.ind__i.is-on .ind__a { background: rgba(252, 99, 13, 0.1); color: var(--color-dark-purple); font-weight: var(--font-weight-semibold); }
.section--dark .ind__i.is-on .ind__a { background: rgba(254, 148, 38, 0.18); color: var(--color-white); }
.ind__i.is-on .ind__n { background: linear-gradient(180deg, var(--color-orange-light), var(--color-orange)); border-color: transparent; color: var(--color-white); }
.ind--bar { gap: 10px; }
.ind__bar { height: 4px; border-radius: var(--radius-round); background: rgba(72, 16, 49, 0.12); overflow: hidden; }
.section--dark .ind__bar { background: rgba(255, 255, 255, 0.16); }
.ind__fill { display: block; height: 100%; border-radius: var(--radius-round); background: linear-gradient(90deg, var(--color-orange-light), var(--color-orange)); transition: width 420ms cubic-bezier(0.16, 1, 0.3, 1); }
.ind__count { margin: 0; font-family: var(--font-primary); font-size: var(--font-size-small); letter-spacing: 0.04em; color: rgba(72, 16, 49, 0.55); }
.section--dark .ind__count { color: var(--color-white-80); }

/* ======================================================================================================
   THE PIN. Everything below is what the desktop breakpoint adds, and nothing above pins anything.
   Three lines here are load-bearing and look like style:
     align-items: start   a stretched column is as tall as its row, so it has no room inside its
                          containing block to travel — it comes unstuck in the frame it would stick
                          (measured: 2280px tall instead of 58px, −600px instead of parked)
     align-self: start    the same thing said on the item, so a future grid change cannot undo it
     overflow: clip       on the panel ancestor, at the top of this file
   ====================================================================================================== */
@media (min-width: 1025px) {
  .rstk--canpin { grid-template-columns: var(--rstk-cols, 1fr 1fr); align-items: start; }
  .rstk--canpin.rstk--pin-right .rstk__pin { order: 2; }
  .rstk--canpin.rstk--pin-right .rstk__steps { order: 1; }

  /* Round 3 — Sticky Position. The park is a fraction of the window, but never lower than the panel
     can afford: module.js measures the pinned panel's own height into --rstk-pinh, and the park stops
     at whatever still leaves room for it above the fold. On a tall window the fraction wins; on a
     short one the panel simply parks higher, which is the right answer either way. --rstk-park
     defaults to the header park, so a module that has not asked for this is byte-identical. */
  .section-rstk--park-quarter .rstk--canpin { --rstk-park: max(var(--rstk-top), min(25svh, max(var(--rstk-top), calc(100svh - var(--rstk-air) - var(--rstk-pinh, 0px))))); }
  .section-rstk--park-third   .rstk--canpin { --rstk-park: max(var(--rstk-top), min(33svh, max(var(--rstk-top), calc(100svh - var(--rstk-air) - var(--rstk-pinh, 0px))))); }

  .rstk--canpin > .rstk__pin {
    position: sticky;
    top: var(--rstk-park, var(--rstk-top));
    align-self: start;
    /* Sized by its CONTENT. The guard is the only viewport unit in the file and it is svh — the stable
       small viewport — so it neither clips behind phone chrome nor re-resolves mid-scroll as dvh does.
       A sticky element taller than its container stops sticking, which is what this prevents. */
    max-height: calc(100svh - var(--rstk-park, var(--rstk-top)) - var(--rstk-air));
  }
  /* Pinned Panel Position = Centre: the sticky box takes the screen's height and centres its content
     inside it. (A sticky element cannot be align-self: center — that is the stretch trap again.) */
  .rstk--canpin.rstk--pin-center > .rstk__pin { min-height: calc(100svh - var(--rstk-park, var(--rstk-top)) - var(--rstk-air)); }
  .rstk--canpin.rstk--pin-center > .rstk__pin > .rstk__pinin { min-height: inherit; align-content: center; }
  .rstk--canpin > .rstk__pin > .rstk__pinin { min-height: var(--rstk-minh, auto); }

  .rstk--canpin .ind--list, .rstk--canpin .ind--numbers { display: block; }
  .rstk--canpin .ind--bar { display: grid; }

  /* The lifted panels: one box, every panel in the same grid area, one shown. The swap runs at 420ms
     rather than the house 900–1200ms entrance figure ON PURPOSE — a swap answers the reader's own
     scrolling, and at 900ms step 4 arrives while step 3 is still fading in. Same expo-out curve,
     opacity and a 12px rise only, both compositor properties. */
  .rstk--canpin .rstk__stack { position: relative; display: grid; }
  .rstk--canpin .rstk__stack > .rstk__layer {
    grid-area: 1 / 1; margin: 0;
    opacity: 0; transform: translateY(12px); visibility: hidden;
    transition: opacity 420ms cubic-bezier(0.16, 1, 0.3, 1), transform 420ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 420ms;
  }
  .rstk--canpin .rstk__stack > .rstk__layer.is-on {
    opacity: 1; transform: none; visibility: visible;
    transition: opacity 420ms cubic-bezier(0.16, 1, 0.3, 1), transform 420ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
  }
  /* A swap step takes a band of the screen, so one step is read at a time AND the step column is
     comfortably taller than the pinned panel. That second part is a requirement, not polish: a pin
     with less travel than its own height has nowhere to go and barely moves. The module enforces it
     here rather than hoping an editor writes enough copy. */
  .rstk--canpin[data-mode="swap"] .rstk__step { min-height: var(--rstk-band, min(46svh, 440px)); display: flex; flex-direction: column; justify-content: center; }
  /* a step dims until it is the one being read, so the pinned side and the words agree */
  .rstk--canpin[data-mode="swap"] .rstk__step { opacity: 0.44; transition: opacity 420ms cubic-bezier(0.16, 1, 0.3, 1); }
  .rstk--canpin[data-mode="swap"] .rstk__step.is-on { opacity: 1; }
  /* before the script runs, nothing is dimmed and nothing is hidden */
  .rstk--canpin:not([data-active]) .rstk__step { opacity: 1; }
  .rstk--canpin:not([data-active]) .rstk__stack > .rstk__layer:first-child { opacity: 1; transform: none; visibility: visible; }
}

/* Chrome and Edge 133+ only, and nothing depends on it: the panel gains a soft edge once it is parked. */
@supports (container-type: scroll-state) {
  @media (min-width: 1025px) {
    .rstk--canpin > .rstk__pin { container-type: scroll-state; }
    @container scroll-state(stuck: top) {
      .rstk__pinin { transition: box-shadow 420ms cubic-bezier(0.16, 1, 0.3, 1); }
    }
  }
}

/* Less motion. Where the pinned side SWAPS, the swap is the motion — so the section becomes the
   stacked arrangement at every width, which is the composed phone column, not a broken desktop one.
   Where the pinned side STAYS THE SAME the pin is kept: a panel that holds still is the absence of
   motion, and unpinning it would take away the thing a reader who asked for calm benefits from. */
@media (prefers-reduced-motion: reduce) {
  .section-rstk *, .section-rstk *::before, .section-rstk *::after { transition: none !important; animation: none !important; }
  .rstk--canpin[data-mode="swap"] { grid-template-columns: 1fr !important; }
  .rstk--canpin[data-mode="swap"] > .rstk__pin { position: static !important; max-height: none !important; min-height: 0 !important; }
  .rstk--canpin[data-mode="swap"] .rstk__stack, .rstk--canpin[data-mode="swap"] .ind { display: none !important; }
  .rstk--canpin[data-mode="swap"] .rstk__step { opacity: 1 !important; min-height: 0 !important; }
}

/* Tablets and phones get the same single column with wider type — stacked, never a squeezed
   two-column (the band this theme already treats specially). */
@media (max-width: 1024px) {
  .section-rstk { gap: var(--spacing-lg); }
  .rstk { gap: var(--spacing-lg); }
  .rstk__steps { gap: var(--spacing-xl); }
}
@media (max-width: 768px) {
  .rstk__steps { gap: var(--spacing-lg); }
  .rstk__panel { margin-top: 16px; }
}
