/* ============================================================
   how-it-works.css — HowItWorksSection

   Three layouts:
   - Desktop (≥ 1360px):  CardRow with 3 StepCard instances side by side
   - Tablet  (768–1359px): StepCardMobile tablet variant (750 × 1038)
   - Mobile  (< 768px):   StepCardMobile mobile variant  (450 × 683)

   overflow: visible on section — cups extend above into hero area.
   overflow: hidden on .hiw-card-row only — clips desktop cup bleed.
   Section negative margin-top applied when HeroSection added (Step 8).
   ============================================================ */


/* ============================================================
   Section container
   ============================================================ */

.how-it-works-section {
  position: relative;
  width: 100%;
  height: 629px;          /* desktop — matches Figma section frame */
  overflow: visible;      /* cups must be visible above section top */
  /* margin-top: -140px; — uncomment when HeroSection is added (Step 8) */
}

@media (max-width: 1359px) and (min-width: 768px) {
  .how-it-works-section {
    height: 1135px;       /* tablet */
    /* margin-top: -200px; — uncomment when HeroSection is added */
  }
}

@media (max-width: 767px) {
  .how-it-works-section {
    height: 740px;        /* mobile — must accommodate container (820px - 100px top offset) */
    /* margin-top: -190px; — uncomment when HeroSection is added */
  }
}


/* ============================================================
   CardRow — desktop only
   1555px wide (108% of 1440px section), centred, top cropped by
   155px to anchor the visible cup zone to the bottom of the section.
   overflow: hidden clips cup content to row bounds.
   ============================================================ */

.hiw-card-row {
  position: absolute;
  width: 1508px;                 /* 97% of 1555 */
  height: 760px;                 /* 97% of 784 */
  left: 48.3%;
  transform: translateX(-50%);
  top: -150px;                   /* 97% of -155 */
  overflow: visible;
  display: flex;
  flex-direction: row;
  align-items: flex-end;         /* bottom-aligns cards of different heights */
  gap: 0;
}

@media (max-width: 1359px) {
  .hiw-card-row {
    display: none;
  }
}


/* ============================================================
   StepCard — desktop variant
   Three cards, equal flex width. Each variant has unique positioning
   for its cup background, Content frame, Step-Title, and step-body.
   DO NOT normalise across variants — each is intentionally different.
   ============================================================ */

.step-card {
  position: relative;
  flex: 1;                       /* equal width: 1555 / 3 ≈ 518px */
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;       /* centres D3 Content (in-flow) */
}

.step-card--1 { height: 760px; }   /* 97% of 784 */
.step-card--2,
.step-card--3 { height: 755px; }   /* 97% of 778 */


/* ----------------------------------------------------------
   Cup background — wrapper + clip + image per variant
   Wrapper defines the clip boundary (can extend beyond card).
   Clip div enforces overflow:hidden within that boundary.
   Image sized with % relative to wrapper.
   ---------------------------------------------------------- */

.step-card__bg-wrapper {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 0;
}

/* D1: cup extends 98px to the left (shows left handle) */
.step-card--1 .step-card__bg-wrapper { left: -95px; }   /* 97% of -98 */

/* D2: cup extends 24px right, 2px left */
.step-card--2 .step-card__bg-wrapper { right: -24px; left: -2px; }

/* D3: no wrapper element in HTML — bg-clip sits directly on card at inset:0 */
.step-card__bg-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.step-card__bg {
  position: absolute;
  height: 100%;
  max-width: none;
  display: block;
  filter: drop-shadow(var(--shadow-card));
}

.step-card--1 .step-card__bg { left: -5.46%;  top: 0;       width: 135.81%; }
.step-card--2 .step-card__bg { left: -23.01%; top: -0.03%;  width: 151.86%; }
.step-card--3 .step-card__bg { left: -23.4%;  top: -0.05%;  width: 157.41%; }


/* ----------------------------------------------------------
   Content frame — positioned differently per variant
   D1: absolute (contains Step-Title only — step-body is a card sibling)
   D2: absolute (contains both Step-Title + step-body, both absolute)
   D3: in-flow (centred by card flex; contains both, both absolute)
   ---------------------------------------------------------- */

.step-card__content {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.step-card--1 .step-card__content {
  left: 192px;                   /* 97% of 198 */
  top: 71px;                     /* 97% of 73 */
  /* no width/height — hugs Step-Title */
}

.step-card--2 .step-card__content {
  left: 107px;                   /* 97% of 110 */
  top: 37px;                     /* 97% of 38 */
  width: 310px;                  /* 97% of 320 */
  height: 687px;                 /* 97% of 708 */
}

/* D3: in-flow, centred by card flex */
.step-card--3 .step-card__content {
  position: relative;
  height: 753px;                 /* 97% of 776 */
  width: 326px;                  /* 97% of 336 */
  overflow: visible;   /* Step-Title overflows 14px left — do not clip */
}


/* ----------------------------------------------------------
   Step-Title — icon + heading, 24px gap
   D1: in-flow within Content
   D2: absolute at top-left of Content
   D3: absolute, overflows 14px left
   ---------------------------------------------------------- */

.step-card__title-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-component-lg);  /* 24px */
}

.step-card--1 .step-card__title-area {
  position: relative;
  flex-shrink: 0;
}

.step-card--2 .step-card__title-area {
  position: absolute;
  left: 0;
  top: 0;
}

.step-card--3 .step-card__title-area {
  position: absolute;
  left: -13px;                   /* 97% of -13.5 */
  top: 20px;                     /* 97% of 20.5 */
}

.step-card__icon {
  display: block;
  width: 120px;
  height: 120px;
  max-width: none;
  filter: drop-shadow(var(--shadow-card));
}

.step-card__heading {
  font-family: var(--type-family-display);
  letter-spacing: 0.03em;
  font-size: var(--type-size-h2);
  font-weight: var(--type-weight-regular);
  line-height: normal;
  color: var(--color-text-default);
  text-align: center;
  margin: 0;
}

.step-card--1 .step-card__heading { width: 135px; }   /* 97% of 139 */
.step-card--2 .step-card__heading { width: 310px; }   /* 97% of 320 */
.step-card--3 .step-card__heading { width: 353px; }   /* 97% of 364 */


/* ----------------------------------------------------------
   step-body — absolutely positioned per variant
   D1: on the card directly (left:122px top:405px)
   D2: inside Content (left:25px top:414px)
   D3: inside Content (left:109px top:432px)
   ---------------------------------------------------------- */

.step-card__body {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  font-family: var(--type-family-body);
  font-size: var(--type-size-h3);    /* 24px desktop */
  font-weight: var(--type-weight-regular);
  line-height: normal;
  color: var(--color-text-default);
}

.step-card__body p { margin: 0; }

/* D1: inside Content, centred text.
   Card-level coords were left:122 top:405; Content is at left:198 top:73,
   so relative to Content: left = 122-198 = -76px, top = 405-73 = 332px */
.step-card--1 .step-card__body {
  left: -74px;                   /* 97% of -76 */
  top: 322px;                    /* 97% of 332 */
  width: 283px;                  /* 97% of 292 */
  height: 245px;                 /* 97% of 253 */
  justify-content: center;
  text-align: center;
}

/* D2: inside Content, left-aligned */
.step-card--2 .step-card__body {
  left: 0;
  top: 404px;                    /* 97% of 416 */
  width: 262px;                  /* 97% of 270 */
  height: 207px;                 /* 97% of 213 */
  text-align: left;
}

/* D3: inside Content, right-aligned */
.step-card--3 .step-card__body {
  left: 106px;                   /* 97% of 109 */
  top: 419px;                    /* 97% of 432 */
  width: 221px;                  /* 97% of 228 */
  height: 175px;                 /* 97% of 180 */
  justify-content: flex-end;
  text-align: right;
}


/* ============================================================
   Ultra-wide breakpoint (≥ 2600px) — 1.3× scale
   ============================================================ */

@media (min-width: 2600px) {
  .how-it-works-section {
    height: 818px;
  }

  .hiw-card-row {
    width: 2022px;
    height: 1019px;
    top: -202px;
  }

  .step-card--1 { height: 1019px; }
  .step-card--2,
  .step-card--3 { height: 1011px; }

  .step-card--1 .step-card__bg-wrapper { left: -127px; }
  .step-card--2 .step-card__bg-wrapper { right: -33px; left: -3px; }

  .step-card__icon {
    width: 156px;
    height: 156px;
  }

  .step-card--1 .step-card__content {
    left: 257px;
    top: 95px;
  }

  .step-card--2 .step-card__content {
    left: 143px;
    top: 49px;
    width: 416px;
    height: 920px;
  }

  .step-card--3 .step-card__content {
    height: 1009px;
    width: 437px;
  }

  .step-card--3 .step-card__title-area {
    left: -18px;
    top: 27px;
  }

  .step-card--1 .step-card__heading { width: 181px; }
  .step-card--2 .step-card__heading { width: 416px; }
  .step-card--3 .step-card__heading { width: 473px; }

  .step-card--1 .step-card__body {
    left: -99px;
    top: 432px;
    width: 380px;
    height: 329px;
  }

  .step-card--2 .step-card__body {
    top: 541px;
    width: 351px;
    height: 277px;
  }

  .step-card--3 .step-card__body {
    left: 142px;
    top: 562px;
    width: 296px;
    height: 234px;
  }
}


/* ============================================================
   StepCardMobile — tablet + mobile (hidden on desktop)
   Single cup illustration, 3 step rows stacked absolutely.
   overflow: visible — cup handle extends above section top.
   ============================================================ */

.step-card-mobile {
  display: none;             /* shown on tablet/mobile via media queries below */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  overflow: visible;         /* cup handle must be visible above section */
}

/* bg-window: the "frame" that defines where the cup body sits.
   Centred within the step-card-mobile container. overflow: visible
   lets the handle extend beyond the window edges. */
.step-card-mobile__bg-window {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  /* no bottom — window grows with the image, avoids clipping */
  z-index: 0;
  overflow: visible;
}

/* The actual cup image — full natural aspect ratio, no distortion.
   Positioned within the window via left/top to frame the cup body. */
.step-card-mobile__bg {
  position: absolute;
  max-width: none;             /* override base.css img { max-width: 100% } */
  display: block;
  filter: drop-shadow(var(--shadow-card));
}


/* ============================================================
   StepRow — shared base styles (tablet + mobile)
   Horizontal flex: icon + text. Row 2 reverses order (icon right).
   Zigzag: rows 1 & 3 icon LEFT, row 2 icon RIGHT — intentional.
   ============================================================ */

.step-row {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
}

.step-row--2 {
  flex-direction: row-reverse;   /* icon on RIGHT for zigzag rhythm */
}

.step-row__icon {
  display: block;
  max-width: none;
  object-fit: fill;
  flex-shrink: 0;
  filter: drop-shadow(var(--shadow-card));
}

.step-row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-row__heading {
  font-family: var(--type-family-display);
  letter-spacing: 0.03em;
  font-size: var(--type-size-h2);    /* 40px tablet / 24px mobile (token switch) */
  font-weight: var(--type-weight-regular);
  line-height: normal;
  color: var(--color-text-default);
  margin: 0;
}

.step-row__body {
  font-family: var(--type-family-body);
  font-size: var(--type-size-body-lg);    /* 24px desktop+tablet / 16px mobile */
  font-weight: var(--type-weight-regular);
  line-height: normal;
  color: var(--color-text-default);
  margin: 0;
}


/* ============================================================
   Tablet breakpoint overrides
   ============================================================ */

@media (max-width: 1359px) and (min-width: 768px) {
  .step-card-mobile {
    display: block;
    top: -140px;
    width: 700px;              /* Figma component frame — cup body centred, handle overflows left */
    height: 1038px;
  }

  .step-card-mobile__bg {
    left: -274px;              /* positions cup body centred within the window */
    top: 0;
    width: 1363px;             /* natural aspect ratio: 1284 × (3029/2853) */
    height: 1284px;
  }

  .step-row__icon {
    width: 100px;
    height: 100px;
  }

  /* Tablet step row positions — fallback when PreText JS hasn't loaded */
  .step-row--1 { left: 113px; top: 195px; width: 484px; }
  .step-row--2 { left: 204px; top: 599px; width: 416px; }
  .step-row--3 { left: 113px; top: 932px; width: 482px; }

  /* ── PreText active state (JS adds this class after successful init) ── */

  /* Visually hide step-rows but keep them accessible to screen readers */
  .step-card-mobile--pretext-active .step-row {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  /* Show the PreText visual layer */
  .step-card-mobile--pretext-active .step-card-mobile__pretext-visual {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
  }
}


/* ============================================================
   Desktop PreText active state (JS adds this class per card)
   ============================================================ */

/* Visually hide the semantic content but keep it accessible to screen readers */
.step-card--pretext-active .step-card__content {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Show the PreText visual layer */
.step-card--pretext-active .step-card__pretext-visual {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* Hidden by default */
.step-card__pretext-visual {
  display: none;
}


/* ============================================================
   PreText visual layer — hidden by default (mobile/tablet)
   Activated by JS on mobile and tablet breakpoints.
   ============================================================ */

.step-card-mobile__pretext-visual {
  display: none;
}

/* PreText-rendered text spans and icons */
.pretext-text-line {
  position: absolute;
  white-space: nowrap;
  line-height: 1;
  color: var(--color-text-default);
  pointer-events: none;
}
.pretext-text-line--heading {
  font-family: var(--type-family-display);
  letter-spacing: 0.03em;
  font-weight: var(--type-weight-regular);
}
.pretext-text-line--body {
  font-family: var(--type-family-body);
  font-weight: var(--type-weight-regular);
}
.pretext-icon {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(var(--shadow-card));
}

/* Hidden until HIW animation reveals them */
.how-it-works-section .pretext-text-line,
.how-it-works-section .pretext-icon {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .how-it-works-section .pretext-text-line,
  .how-it-works-section .pretext-icon {
    opacity: 1;
  }
}


/* ============================================================
   Mobile breakpoint overrides
   ============================================================ */

@media (max-width: 767px) {
  .step-card-mobile {
    display: block;
    top: -70px;
    left: 51%;
    width: 398px;
    height: 725px;             /* must be >= image height (716px) to avoid clipping */
  }

  .step-card-mobile__bg {
    left: -177px;              /* positions cup body centred within the window */
    top: 0;
    width: 761px;              /* 95% of 801 */
    height: 716px;             /* 95% of 754 */
  }

  .step-row__icon {
    width: 75px;
    height: 75px;
  }

  /* Fallback step row positions — shown when PreText JS hasn't loaded */
  .step-row--1 { left: 40px;  top: 100px; width: 327px; }
  .step-row--2 { left: 48px;  top: 300px; width: 310px; align-items: flex-end; }
  .step-row--3 { left: 35px;  top: 504px; width: 318px; }

  /* ── PreText active state (JS adds this class after successful init) ── */

  /* Visually hide step-rows but keep them accessible to screen readers */
  .step-card-mobile--pretext-active .step-row {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  /* Show the PreText visual layer */
  .step-card-mobile--pretext-active .step-card-mobile__pretext-visual {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
  }
}
