/* ─────────────────────────────────────────────────────────────
   Basta — pages/how-it-works.css
   Interactive walkthrough with pulsating dots and scroll choreography
   ───────────────────────────────────────────────────────────── */

/* ─── PAGE HERO ─────────────────────────────────────────────── */
.hiw-hero {
  padding: 140px 0 80px;
  background: var(--cream);
  text-align: center;
}
.hiw-hero-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--section-px);
}
.hiw-headline {
  font-family: var(--font-serif);
  font-size: var(--fs-3xl);
  font-weight: 600;
  line-height: 1.05;
  margin-bottom: 24px;
  letter-spacing: -0.005em;
}
.hiw-headline em {
  font-style: italic;
  color: var(--olive);
}
.hiw-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-lg);
  color: var(--warm-grey);
  line-height: 1.5;
  max-width: 580px;
  margin: 0 auto;
}

/* ─── SCENE BLOCK ──────────────────────────────────────────── */
.hiw-scene {
  padding: 96px 0;
  border-top: 1px solid rgba(92, 107, 58, 0.08);
}
.hiw-scene:nth-child(even) {
  background: var(--cream-dark);
}
.hiw-scene-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 var(--section-px);
}
.hiw-scene-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 80px;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
}

/* Phone side and text side - swap order based on scene */
.hiw-scene[data-phone-side="left"] .hiw-phone-side  { order: 1; }
.hiw-scene[data-phone-side="left"] .hiw-text-side   { order: 2; }
.hiw-scene[data-phone-side="right"] .hiw-phone-side { order: 2; }
.hiw-scene[data-phone-side="right"] .hiw-text-side  { order: 1; }

/* ─── TEXT SIDE ────────────────────────────────────────────── */
.hiw-text-side { display: flex; flex-direction: column; }
.hiw-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--terracotta);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.hiw-eyebrow .num {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 22px;
  font-weight: 600;
  color: var(--olive);
  letter-spacing: 0;
  text-transform: none;
}
.hiw-scene-headline {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 28px;
  letter-spacing: -0.005em;
}
.hiw-scene-headline em {
  font-style: italic;
  color: var(--olive);
}
.hiw-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.hiw-body p {
  font-size: var(--fs-base);
  line-height: 1.8;
  color: var(--bark-light);
}
.hiw-body em {
  font-style: italic;
  color: var(--olive);
}
.hiw-body strong {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--bark);
}
.hiw-body ul {
  list-style: none;
  padding: 0;
  margin: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hiw-body ul li {
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--bark-light);
  padding-left: 18px;
  position: relative;
}
.hiw-body ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--olive);
}
.hiw-body ul li strong {
  color: var(--bark);
  font-family: var(--font-serif);
  font-weight: 600;
  font-style: italic;
}

/* Small inset image for Scene 05 (your-plan) */
.hiw-inset-image {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}
.hiw-inset-image .phone-screen-inset {
  width: 220px;
  background: #1A1208;
  border-radius: 32px;
  padding: 6px;
  box-shadow:
    0 24px 50px -16px rgba(42, 35, 24, 0.22),
    0 10px 22px -10px rgba(42, 35, 24, 0.14);
}
.hiw-inset-image .phone-screen-inset img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 26px;
}

/* ─── PHONE SIDE ────────────────────────────────────────────── */
.hiw-phone-side {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.hiw-phone-stage {
  position: relative;
  width: 320px;
}
.hiw-phone {
  width: 100%;
  background: #1A1208;
  border-radius: 48px;
  padding: 8px;
  box-shadow:
    0 30px 60px -20px rgba(42, 35, 24, 0.28),
    0 14px 28px -12px rgba(42, 35, 24, 0.18);
  position: relative;
}
.hiw-phone img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 40px;
}

/* ─── PULSATING DOTS ────────────────────────────────────────── */
.hiw-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  z-index: 10;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
}
.hiw-dot::before {
  content: '';
  position: absolute;
  inset: 6px;
  width: 10px;
  height: 10px;
  background: var(--olive);
  border-radius: 50%;
  border: 2px solid var(--cream);
  box-shadow: 0 0 0 1px rgba(42, 35, 24, 0.15);
}
.hiw-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--olive);
  opacity: 0.4;
  animation: hiw-pulse 2.2s infinite ease-out;
}
@keyframes hiw-pulse {
  0%   { transform: scale(0.5); opacity: 0.5; }
  60%  { transform: scale(1.6); opacity: 0;   }
  100% { transform: scale(1.6); opacity: 0;   }
}
.hiw-dot:hover::before,
.hiw-dot.active::before {
  background: var(--olive-light);
  transform: scale(1.15);
  transition: transform var(--transition);
}
.hiw-dot.active::after {
  animation-play-state: paused;
  opacity: 0;
}

/* ─── POPOVER (TOOLTIP STYLE) ───────────────────────────────── */
.hiw-popover {
  position: absolute;
  z-index: 20;
  width: 240px;
  background: var(--bark);
  border-radius: 8px;
  padding: 16px 18px 18px;
  box-shadow:
    0 16px 40px -12px rgba(42, 35, 24, 0.42),
    0 0 0 1px rgba(245, 240, 232, 0.04);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s 0.25s;
  pointer-events: none;
}
.hiw-popover.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s 0s;
  pointer-events: auto;
}
.hiw-popover-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 14px;
  color: var(--cream);
  line-height: 1.3;
  margin-bottom: 6px;
}
.hiw-popover-body {
  font-size: 12px;
  line-height: 1.55;
  color: var(--olive-muted);
}

/* Popover positioning - defaults to "above the dot" */
.hiw-popover[data-position="top"] {
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translate(-50%, 4px);
}
.hiw-popover[data-position="top"].open {
  transform: translate(-50%, 0);
}
.hiw-popover[data-position="top"]::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--bark);
}

/* Below the dot */
.hiw-popover[data-position="bottom"] {
  top: calc(100% + 14px);
  left: 50%;
  transform: translate(-50%, -4px);
}
.hiw-popover[data-position="bottom"].open {
  transform: translate(-50%, 0);
}
.hiw-popover[data-position="bottom"]::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--bark);
}

/* Right of the dot */
.hiw-popover[data-position="right"] {
  left: calc(100% + 14px);
  top: 50%;
  transform: translate(-4px, -50%);
}
.hiw-popover[data-position="right"].open {
  transform: translate(0, -50%);
}
.hiw-popover[data-position="right"]::after {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--bark);
}

/* Left of the dot */
.hiw-popover[data-position="left"] {
  right: calc(100% + 14px);
  top: 50%;
  transform: translate(4px, -50%);
}
.hiw-popover[data-position="left"].open {
  transform: translate(0, -50%);
}
.hiw-popover[data-position="left"]::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: var(--bark);
}

/* ─── SCENE 03 — RESULTS CYCLE ──────────────────────────────── */
.hiw-scene-results {
  padding: 96px 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
}
.hiw-results-stage {
  position: relative;
  width: 320px;
}
.hiw-results-stack {
  position: relative;
  width: 100%;
}
.hiw-results-stack .hiw-phone {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.hiw-results-stack .hiw-phone.active {
  position: relative;
  opacity: 1;
}
.hiw-results-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}
.hiw-results-tab {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--warm-grey);
  padding: 6px 12px;
  border-radius: 100px;
  background: rgba(92, 107, 58, 0.06);
  transition: all var(--transition);
}
.hiw-results-tab.active {
  color: var(--cream);
  background: var(--olive);
}
.hiw-results-tab.active.muscle { background: var(--gold); }
.hiw-results-tab.active.lean   { background: var(--terracotta); }
/* Hide dots during the cycle, show only at rest on Balanced */
.hiw-scene-results .hiw-dot {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.hiw-scene-results.dots-visible .hiw-dot {
  opacity: 1;
  pointer-events: auto;
}

/* ─── CLOSER ───────────────────────────────────────────────── */
.hiw-closer {
  background: var(--bark);
  color: var(--cream);
  padding: 104px 0 96px;
  text-align: center;
}
.hiw-closer-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--section-px);
}
.hiw-closer .eyebrow {
  color: var(--gold);
  margin-bottom: 18px;
}
.hiw-closer-headline {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 28px;
  color: var(--cream);
  letter-spacing: -0.005em;
}
.hiw-closer-headline em {
  font-style: italic;
  color: var(--olive-muted);
}
.hiw-closer-body {
  font-size: var(--fs-md);
  line-height: 1.75;
  color: rgba(245, 240, 232, 0.72);
  margin-bottom: 48px;
  max-width: 580px;
  margin-left: auto;
  margin-right: auto;
}
.hiw-closer .store-badges {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ─── MOBILE ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hiw-hero { padding: 110px 0 56px; }
  .hiw-scene { padding: 64px 0; }
  .hiw-scene-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  /* On mobile, phone always comes first, text second */
  .hiw-scene .hiw-phone-side  { order: 1; }
  .hiw-scene .hiw-text-side   { order: 2; }
  .hiw-phone-stage,
  .hiw-results-stage { width: 280px; }
  .hiw-scene-results { min-height: auto; }

  /* Popover on mobile: positioned absolutely below the dot, centered horizontally on stage */
  .hiw-popover[data-position="top"],
  .hiw-popover[data-position="bottom"],
  .hiw-popover[data-position="left"],
  .hiw-popover[data-position="right"] {
    position: fixed;
    bottom: 16px;
    top: auto;
    left: 16px;
    right: 16px;
    width: auto;
    transform: translateY(8px);
  }
  .hiw-popover[data-position="top"].open,
  .hiw-popover[data-position="bottom"].open,
  .hiw-popover[data-position="left"].open,
  .hiw-popover[data-position="right"].open {
    transform: translateY(0);
  }
  /* Hide arrow on mobile - popover is no longer anchored to dot */
  .hiw-popover::after { display: none; }

  .hiw-inset-image .phone-screen-inset { width: 200px; }

  .hiw-closer { padding: 72px 0; }
  .hiw-closer .store-badges {
    flex-direction: column;
    align-items: stretch;
    max-width: 320px;
    margin: 0 auto;
  }
}
