/* Wondermaths - Halloween hero v2 (staging build, 2026-09-26).
   Scope: every rule below is limited to .hw-hero-v2, the single hero
   <section class="hw-hero hw-hero-v2">. The approved portal header/footer and
   the material sections under the hero are not touched.
   Media: existing Vela intro loops + posters (games/vela-pumpkin-glow/assets),
   existing transparent Buki cut-out (assets/halloween/buki-hero.webp) is the
   decorative foreground friend; he deliberately steps outside the rounded
   picture at the bottom-left while the faces of Vela and Ori stay clear. */

.hw-hero-v2 {
  position: relative;
  isolation: isolate;
  overflow: clip;
  /* The 48px floor keeps Buki's down-step clear of the hero's clipped bottom
     edge at desktop widths; phones have their own two-value override below. */
  padding-block: clamp(22px, 3.2vw, 56px) max(48px, clamp(26px, 3.2vw, 52px));
  color: var(--hw-cream);
  background:
    radial-gradient(115% 82% at 82% 6%, rgb(122 74 168 / 82%) 0%, rgb(122 74 168 / 0%) 62%),
    linear-gradient(178deg, var(--hw-plum-900) 0%, var(--hw-plum-800) 46%, #4a2270 80%, #63338c 100%);
}

/* Faint star dust so the plum field is never flat. */
.hw-hero-v2::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .5;
  background-repeat: repeat;
  background-size: 420px 320px;
  background-image:
    radial-gradient(1.6px 1.6px at 16% 24%, rgb(255 247 234 / 62%), transparent 58%),
    radial-gradient(1.4px 1.4px at 63% 11%, rgb(255 247 234 / 45%), transparent 58%),
    radial-gradient(1.5px 1.5px at 88% 33%, rgb(255 247 234 / 52%), transparent 58%),
    radial-gradient(1.3px 1.3px at 39% 7%, rgb(255 247 234 / 38%), transparent 58%);
}

.hw-hero-v2 .hw2-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 39fr) minmax(0, 61fr);
  gap: clamp(20px, 2.8vw, 46px);
  align-items: center;
}

.hw-hero-v2 .hw2-copy { min-width: 0; max-width: 620px; }

.hw-hero-v2 .hw2-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  font: 600 12px/1.2 'Segoe UI', system-ui, sans-serif;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--hw-orange-soft);
}

.hw-hero-v2 .hw2-kicker::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--hw-orange);
  box-shadow: 0 0 12px 2px rgb(242 116 12 / 62%);
}

.hw-hero-v2 .hw2-title {
  margin: 0 0 14px;
  color: var(--hw-cream);
  font: 900 clamp(34px, 3.8vw, 58px)/1.06 'Poppins', system-ui, sans-serif;
  letter-spacing: -.03em;
  text-wrap: balance;
}

.hw-hero-v2 .hw2-lead {
  max-width: 44ch;
  margin: 0;
  font: 400 clamp(16px, 1.35vw, 18px)/1.7 'Segoe UI', system-ui, sans-serif;
  color: #f3e6ff;
}

.hw-hero-v2 .hw2-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 24px 0 0;
}

.hw-hero-v2 .hw2-actions .button { margin: 0; }

/* Bright, visible focus ring on the plum field (beats the global !important pair). */
.hw-hero-v2 a:focus-visible,
.hw-hero-v2 button:focus-visible { outline-color: var(--hw-gold) !important; }

.hw-hero-v2 .hw2-motion-row { margin: 18px 0 0; }

.hw-hero-v2 .hw2-motion {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1.5px solid rgb(255 247 234 / 45%);
  border-radius: 100px;
  background: rgb(37 16 59 / 42%);
  color: var(--hw-cream);
  font: 600 13px/1.3 'Segoe UI', system-ui, sans-serif;
}

.hw-hero-v2 .hw2-motion:hover {
  background: rgb(37 16 59 / 68%);
  border-color: var(--hw-cream);
}

/* ---------- The animated scene ---------- */

.hw-hero-v2 .hw2-stage {
  position: relative;
  min-width: 0;
  height: clamp(340px, 40vw, 560px);
  border-radius: 30px;
  overflow: visible;
  pointer-events: none;
  background: #2b1140;
  box-shadow: 0 26px 70px rgb(9 3 18 / 46%), inset 0 0 0 1px rgb(255 247 234 / 12%);
}

.hw-hero-v2 .hw2-poster,
.hw-hero-v2 .hw2-poster img,
.hw-hero-v2 .hw2-video,
.hw-hero-v2 .hw2-glow,
.hw-hero-v2 .hw2-vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The stage no longer clips, so the media keeps the picture's rounded corners
   on its own. The friend below is intentionally left out. */
.hw-hero-v2 .hw2-poster,
.hw-hero-v2 .hw2-poster img,
.hw-hero-v2 .hw2-video,
.hw-hero-v2 .hw2-vignette {
  border-radius: inherit;
}

.hw-hero-v2 .hw2-poster img,
.hw-hero-v2 .hw2-video {
  object-fit: cover;
  object-position: 50% 46%;
}

/* Poster stays visible until the single chosen loop really plays,
   so a blocked or failed video never leaves an empty box. */
.hw-hero-v2 .hw2-video {
  opacity: 0;
  transition: opacity .6s ease;
}

.hw-hero-v2 .hw2-stage.is-playing .hw2-video { opacity: 1; }

/* Warm lantern light on the house side of the courtyard. */
.hw-hero-v2 .hw2-glow {
  inset: 4% 2% auto auto;
  width: 46%;
  height: 90%;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: .42;
  background: radial-gradient(closest-side, rgb(255 196 110 / 62%), rgb(255 168 70 / 0%) 72%);
  animation: hw2-lantern 7.5s ease-in-out infinite alternate;
}

@keyframes hw2-lantern {
  from { opacity: .3; }
  to { opacity: .56; }
}

.hw-hero-v2 .hw2-vignette {
  pointer-events: none;
  background:
    linear-gradient(180deg, rgb(24 8 40 / 32%) 0%, rgb(24 8 40 / 0%) 30%),
    linear-gradient(0deg, rgb(24 8 40 / 58%) 0%, rgb(24 8 40 / 0%) 44%);
}

/* Buki as the foreground side friend: he steps out of the rounded picture at
   the bottom-left (negative offsets) so he reads as a real cut-out beside the
   scene, not a small sticker inside it, while staying below the faces of Vela
   and Ori. */
.hw-hero-v2 .hw2-friend {
  position: absolute;
  left: -55px;
  bottom: -36px;
  width: clamp(200px, 34%, 260px);
  height: auto;
  z-index: 3;
  filter: drop-shadow(0 16px 20px rgb(9 3 18 / 55%));
  transform-origin: 50% 88%;
  animation: hw2-bob 6s ease-in-out infinite alternate;
}

@keyframes hw2-bob {
  from { transform: translateY(0) rotate(-1.4deg); }
  to { transform: translateY(-10px) rotate(1.6deg); }
}

/* ---------- Tablet and phone ---------- */

@media (max-width: 1024px) {
  .hw-hero-v2 .hw2-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .hw-hero-v2 .hw2-copy { max-width: none; }
  .hw-hero-v2 .hw2-title { font-size: clamp(32px, 5.4vw, 46px); }
  /* Tablet keeps Buki's out-of-frame pose; the margin below leaves room for his
     down-step so the hero padding never clips him and nothing scrolls sideways. */
  .hw-hero-v2 .hw2-stage {
    height: clamp(300px, 46vw, 440px);
    border-radius: 26px;
    margin-bottom: 36px;
  }

  /* Single column: the desktop -55px left offset would push Buki past the
     page edge, so the tablet pose uses the phone's inside-the-edge bound. */
  .hw-hero-v2 .hw2-friend { left: -10px; }
}

@media (max-width: 760px) {
  .hw-hero-v2 { padding-block: 20px 30px; }

  /* Phone reading order: title + short lead, then the scene, then the actions
     and the motion control. display:contents drops the .hw2-copy wrapper so its
     children become grid items of the single column and can be placed in
     explicit rows around the 260px stage - the copy block never pushes the
     whole scene under itself. */
  .hw-hero-v2 .hw2-copy { display: contents; }
  .hw-hero-v2 .hw2-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  /* The kicker only repeats the title on phones. */
  .hw-hero-v2 .hw2-kicker { display: none; }

  .hw-hero-v2 .hw2-title {
    grid-row: 1;
    font-size: clamp(28px, 8.6vw, 40px);
    line-height: 1.08;
    margin: 0 0 8px;
  }

  .hw-hero-v2 .hw2-lead {
    grid-row: 2;
    max-width: none;
    font-size: 15px;
    line-height: 1.55;
    margin: 0 0 14px;
  }

  /* short title, scenic 260px stage, compact actions - all above the fold.
     The margin-bottom gives Buki's step below the picture its own room. */
  .hw-hero-v2 .hw2-stage { grid-row: 3; height: 260px; border-radius: 22px; margin-bottom: 35px; }
  .hw-hero-v2 .hw2-poster img,
  .hw-hero-v2 .hw2-video { object-position: 50% 42%; }

  .hw-hero-v2 .hw2-actions { grid-row: 4; margin: 14px 0 0; gap: 10px 14px; }
  .hw-hero-v2 .hw2-actions .button {
    font-size: 16px;
    padding: 13px 22px;
    min-height: 48px;
  }

  .hw-hero-v2 .hw2-draw { font-size: 14.5px; }
  .hw-hero-v2 .hw2-motion-row { grid-row: 5; margin: 12px 0 0; }

  /* Buki keeps the same out-of-frame bottom-left pose on phones, just smaller;
     the 10px left margin is what stays visible at the page edge. */
  .hw-hero-v2 .hw2-friend {
    width: 140px;
    left: -10px;
    bottom: -35px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hw-hero-v2 .hw2-video { opacity: 0 !important; }
  .hw-hero-v2 .hw2-friend,
  .hw-hero-v2 .hw2-glow { animation: none; }
}
