/* ============================================================
   HOW IT WORKS — four step cards on a light section.
   Cards alternate left and right, slightly tilted and overlapping,
   joined by a dotted line that curves from the side of one card into
   the top of the next. The tilt is on the card, the connector on the
   list item, so the line stays put while the card sits crooked.
   That layout is the fallback (no JS / reduced motion). js/how.js adds
   .is-deck for the "Deck" version at the end of this file.
   ============================================================ */

.how {
  position: relative;
  padding: 90px 0 110px;
  background: var(--off-white);
}
.how-head { margin-bottom: 3.5rem; }

.how-steps {
  container-type: inline-size;
  list-style: none;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0;
  display: grid;
}
.how-step {
  --card-w: min(26rem, 44cqw);
  --overlap: 3rem;
  position: relative;
  width: var(--card-w);
  min-width: 0;
}
.how-step:nth-child(odd)  { justify-self: start; }
.how-step:nth-child(even) { justify-self: end; }
.how-step + .how-step { margin-top: calc(var(--overlap) * -1); }

/* --- The step card --- */
.how-card {
  padding: 1.75rem 1.75rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow);
  transition: rotate 0.35s ease, translate 0.35s ease, box-shadow 0.35s ease;
}
.how-step:nth-child(1) .how-card { rotate: -2deg; }
.how-step:nth-child(2) .how-card { rotate: 1.6deg; }
.how-step:nth-child(3) .how-card { rotate: -1.2deg; }
.how-step:nth-child(4) .how-card { rotate: 2deg; }
.how-step .how-card:hover { rotate: 0deg; translate: 0 -4px; box-shadow: var(--shadow-lg); }

.how-num {
  display: block;
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--light-blue);
}
.how-card h3 { margin: 1.25rem 0 0.4rem; font-size: 1.35rem; font-weight: 800; }
.how-card p { margin: 0; }

/* Ads / Websites lines under each step */
.how-split { display: grid; gap: 0.6rem; margin: 1.1rem 0 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.how-split div { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr); gap: 0.75rem; align-items: baseline; }
.how-split dt { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--blue); }
.how-split dd { margin: 0; font-size: 0.92rem; line-height: 1.5; color: var(--text); }

/* Reassurance line at the foot of each card, with a tick */
.how-card .how-note {
  position: relative;
  margin: 1.1rem 0 0;
  padding: 0.85rem 1rem 0.85rem 2.6rem;
  border-radius: var(--radius);
  background: var(--off-white);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--text);
}
.how-note::before {
  content: "";
  position: absolute;
  top: 0.95rem;
  left: 0.9rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 72% no-repeat;
}

/* --- The dotted connector: leaves the side of this card at its middle, runs
   across the gap and turns down into the top of the next card --- */
.how-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(100cqw - var(--card-w) * 1.5);
  height: calc(50% - var(--overlap) + 1.5rem);
  border: 0 dotted var(--light-blue);
  border-top-width: 4px;
  pointer-events: none;
}
.how-step:nth-child(odd)::after  { left: 100%;  border-right-width: 4px; border-top-right-radius: 5rem; }
.how-step:nth-child(even)::after { right: 100%; border-left-width: 4px;  border-top-left-radius: 5rem; }


/* ============ Smaller screens: one column, path straight down ============ */
@media (max-width: 900px) {
  .how { padding: 70px 0 80px; }
  .how-head { margin-bottom: 2.5rem; }
  .how-num { font-size: 3.2rem; }

  .how-step { --gap: 2.5rem; width: 100%; justify-self: stretch; }
  .how-step:nth-child(n) { justify-self: stretch; }
  .how-step + .how-step { margin-top: var(--gap); }
  .how-step:nth-child(1) .how-card { rotate: -1deg; }
  .how-step:nth-child(2) .how-card { rotate: 0.8deg; }
  .how-step:nth-child(3) .how-card { rotate: -0.7deg; }
  .how-step:nth-child(4) .how-card { rotate: 1deg; }
  .how-step:nth-child(n):not(:last-child)::after {
    top: 100%;
    left: 2.5rem;
    right: auto;
    width: 0;
    height: var(--gap);
    border-width: 0 0 0 4px;
    border-radius: 0;
  }
}

/* ============================================================
   DECK (Mark's pick, 2026-10-20). js/how.js adds .is-deck: the section
   is pinned and the four cards are dealt onto one pile, alternately from
   the left and right. Cards already on the pile shrink a touch and darken
   as new ones land, so their edges peek out above. js/how.js sets on each
   step: --x --y offset, --r tilt, --s scale, --b brightness, and hides
   cards that are still waiting off screen.
   ============================================================ */
.how-pin { position: relative; }

/* --- Deck mode --- */
.how.is-deck {
  height: 540vh;               /* one pinned screen plus scroll for four cards */
  padding: 0;
  /* no overflow clip here: it made Safari judder the pinned pile. The page-wide
     clip on <html> (style.css) already stops the fly-in cards scrolling sideways. */
}
.how.is-deck .how-pin {
  position: sticky;
  top: 0;
  height: calc(100vh - 8px);
  height: calc(100svh - 8px);   /* stops short of the bottom edge so Safari's toolbar stays glass (see style.css RULE) */
  padding-top: calc(var(--nav-height) + 0.75rem);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  /* Cards waiting to fly in sit off screen to the sides. Clip them here, on the
     pinned box itself: a clip on a box AROUND the pin (.how, body) made Safari
     judder it, and without any clip iPhone let a sideways swipe drag the page. */
  overflow-x: clip;
}
/* centred with auto margins, so on short screens the heading never slides up under the menu bar */
.how.is-deck .how-pin > .container { margin-block: auto; }
.how.is-deck .how-head { margin-bottom: 2.5rem; }

.how.is-deck .how-steps {
  max-width: none;
  grid-template-areas: "deck";
  justify-items: center;
  align-items: start;
  padding-top: 3rem;           /* room for the edges of the cards underneath */
}
.how.is-deck .how-steps .how-step,
.how.is-deck .how-steps .how-step + .how-step {
  grid-area: deck;
  justify-self: center;
  width: min(28rem, 100%);
  margin: 0;
  opacity: 1;
  translate: none;
  transform-origin: 50% 0;       /* js/how.js sets transform directly each frame */
  will-change: transform;
  backface-visibility: hidden;   /* keeps each card on its own GPU layer in Safari */
}
.how.is-deck .how-steps .how-step::after { display: none; }
.how.is-deck .how-steps .how-card,
.how.is-deck .how-steps .how-step .how-card:hover {
  position: relative;
  rotate: 0deg;
  translate: none;
  transition: none;              /* the hover/tilt transition fought the per-frame updates */
  box-shadow: 0 10px 40px rgba(14, 32, 64, 0.16);
}
/* Darkens cards lower in the pile (js/how.js sets its opacity). Opacity is
   cheap to animate; the old brightness filter redrew the card every frame. */
.how.is-deck .how-shade {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: #000;
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}

/* Phones and short screens: tighten the heading so the pile fits */
@media (max-width: 900px) {
  .how.is-deck .how-head { margin-bottom: 1.5rem; }
  .how.is-deck .how-steps { padding-top: 2rem; }
  .how.is-deck .how-card { padding: 1.25rem 1.25rem 1.1rem; }
  .how.is-deck .how-num { font-size: 2.4rem; }
  .how.is-deck .how-card h3 { margin-top: 0.75rem; }
}
@media (max-height: 820px) {
  .how.is-deck .how-head .section-subtitle { display: none; }
  .how.is-deck .how-head { margin-bottom: 1.25rem; }
}

/* ============================================================
   SCROLL-DRIVEN DECK (Safari 26+, Chrome). js/how.js adds .is-scroll-deck
   when the browser supports it. The cards' movement is tied straight to the
   scroll, so the browser runs it in step with scrolling with no script
   per frame (the script version updated each card every frame and couldn't
   keep up on iPhone, so the motion looked low frame rate).
   Same motion as the script version: keyframes generated from the same maths
   Regenerate with: python assets-source/how-deck-keyframes.py (paste over the
   @keyframes how-deal-* / how-shade-* below).
   Timeline: progress starts when the section top is 60% of a screen from the
   top and ends when the pin releases (animation-range below).
   js/how.js still sets --fly (how far off screen a card starts) on resize.
   ============================================================ */
.how.is-scroll-deck {
  view-timeline: --how-deck block;
  --peek: 16px;
  --tilt: 1;
}
@media (max-width: 599px) {
  .how.is-scroll-deck { --peek: 10px; --tilt: 0.5; }   /* phones: smaller peek and gentler tilt */
}
.how.is-scroll-deck .how-steps .how-step {
  animation: linear both;
  animation-timeline: --how-deck;
  animation-range: cover 40vh cover 540vh;   /* same span as js/how.js: starts with the section top 60% down the screen, ends as the pin (540vh tall section) releases */
}
.how.is-scroll-deck .how-shade {
  animation: linear both;
  animation-timeline: --how-deck;
  animation-range: cover 40vh cover 540vh;   /* same span as js/how.js: starts with the section top 60% down the screen, ends as the pin (540vh tall section) releases */
}
.how.is-scroll-deck .how-step:nth-child(1) { animation-name: how-deal-1; }
.how.is-scroll-deck .how-step:nth-child(2) { animation-name: how-deal-2; }
.how.is-scroll-deck .how-step:nth-child(3) { animation-name: how-deal-3; }
.how.is-scroll-deck .how-step:nth-child(4) { animation-name: how-deal-4; }
.how.is-scroll-deck .how-step:nth-child(1) .how-shade { animation-name: how-shade-1; }
.how.is-scroll-deck .how-step:nth-child(2) .how-shade { animation-name: how-shade-2; }
.how.is-scroll-deck .how-step:nth-child(3) .how-shade { animation-name: how-shade-3; }
.how.is-scroll-deck .how-step:nth-child(4) .how-shade { animation-name: how-shade-4; }

@keyframes how-deal-1 {
  0.000% { transform: translate3d(calc(var(--fly) * -1), calc(60px - var(--peek) * 0), 0) rotate(calc(-3deg * var(--tilt) + -28deg)) scale(1.000); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  23.256% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 0), 0) rotate(calc(-3deg * var(--tilt) + 0deg)) scale(1.000); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  46.512% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 1), 0) rotate(calc(-3deg * var(--tilt) + 0deg)) scale(0.955); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  69.767% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 2), 0) rotate(calc(-3deg * var(--tilt) + 0deg)) scale(0.910); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  93.023% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 3), 0) rotate(calc(-3deg * var(--tilt) + 0deg)) scale(0.865); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  100% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 3), 0) rotate(calc(-3deg * var(--tilt) + 0deg)) scale(0.865); }
}
@keyframes how-shade-1 {
  0% { opacity: 0; }
  23.256% { opacity: 0; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  46.512% { opacity: 0.05; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  69.767% { opacity: 0.10; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  93.023% { opacity: 0.15; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  100% { opacity: 0.15; }
}
@keyframes how-deal-2 {
  0% { transform: translate3d(calc(var(--fly) * 1), calc(60px - var(--peek) * 0), 0) rotate(calc(2.5deg * var(--tilt) + 28deg)) scale(1.000); }
  23.256% { transform: translate3d(calc(var(--fly) * 1), calc(60px - var(--peek) * 0), 0) rotate(calc(2.5deg * var(--tilt) + 28deg)) scale(1.000); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  46.512% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 0), 0) rotate(calc(2.5deg * var(--tilt) + 0deg)) scale(1.000); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  69.767% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 1), 0) rotate(calc(2.5deg * var(--tilt) + 0deg)) scale(0.955); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  93.023% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 2), 0) rotate(calc(2.5deg * var(--tilt) + 0deg)) scale(0.910); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  100% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 2), 0) rotate(calc(2.5deg * var(--tilt) + 0deg)) scale(0.910); }
}
@keyframes how-shade-2 {
  0% { opacity: 0; }
  46.512% { opacity: 0; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  69.767% { opacity: 0.05; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  93.023% { opacity: 0.10; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  100% { opacity: 0.10; }
}
@keyframes how-deal-3 {
  0% { transform: translate3d(calc(var(--fly) * -1), calc(60px - var(--peek) * 0), 0) rotate(calc(-1.5deg * var(--tilt) + -28deg)) scale(1.000); }
  46.512% { transform: translate3d(calc(var(--fly) * -1), calc(60px - var(--peek) * 0), 0) rotate(calc(-1.5deg * var(--tilt) + -28deg)) scale(1.000); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  69.767% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 0), 0) rotate(calc(-1.5deg * var(--tilt) + 0deg)) scale(1.000); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  93.023% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 1), 0) rotate(calc(-1.5deg * var(--tilt) + 0deg)) scale(0.955); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  100% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 1), 0) rotate(calc(-1.5deg * var(--tilt) + 0deg)) scale(0.955); }
}
@keyframes how-shade-3 {
  0% { opacity: 0; }
  69.767% { opacity: 0; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  93.023% { opacity: 0.05; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  100% { opacity: 0.05; }
}
@keyframes how-deal-4 {
  0% { transform: translate3d(calc(var(--fly) * 1), calc(60px - var(--peek) * 0), 0) rotate(calc(2deg * var(--tilt) + 28deg)) scale(1.000); }
  69.767% { transform: translate3d(calc(var(--fly) * 1), calc(60px - var(--peek) * 0), 0) rotate(calc(2deg * var(--tilt) + 28deg)) scale(1.000); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  93.023% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 0), 0) rotate(calc(2deg * var(--tilt) + 0deg)) scale(1.000); animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  100% { transform: translate3d(calc(var(--fly) * 0), calc(0px - var(--peek) * 0), 0) rotate(calc(2deg * var(--tilt) + 0deg)) scale(1.000); }
}
@keyframes how-shade-4 {
  0% { opacity: 0; }
  93.023% { opacity: 0; animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); }
  100% { opacity: 0.00; }
}
