/**
 * Hero Highlight (home) — centred hero with a colour-highlighted rotating word.
 * @author Salama Malek
 *
 * Display font: the design calls for Roobert. It is not self-hosted yet, so the
 * family is behind a variable and falls back to the current heading stack until
 * the licensed .woff2 files are added to the theme. Swapping it later is a
 * one-line change here (or a global override on :root).
 */

.section-hero-highlight {
  --nm-hero-display-font: "Roobert", "Archivo", "Arial", sans-serif;
  --nm-highlight-color: #73d2f8;

  position: relative;
  color: #121212;
}

/* Full-bleed, exactly like the original home hero: pull the section out by the
   wrapper padding so the brand gradient reaches both viewport edges, then put
   that padding back on the inside so the text still lines up with the rest of
   the page. The theme carries the same rule for .section-hero-panel, but it
   loses the cascade here, so it is restated at this widget's specificity rather
   than left to chance. Values track the theme's own padding variables. */
.section-hero-highlight.section-hero-panel {
  margin-right: calc(var(--body-wrapper-padding-mobile) * -1);
  margin-left: calc(var(--body-wrapper-padding-mobile) * -1);
  padding: 40px var(--body-wrapper-padding-mobile);
}

@media screen and (min-width: 681px) {
  .section-hero-highlight.section-hero-panel {
    margin-right: calc(var(--body-wrapper-padding-tablet) * -1);
    margin-left: calc(var(--body-wrapper-padding-tablet) * -1);
    padding: 40px var(--body-wrapper-padding-tablet);
  }
}

@media screen and (min-width: 1081px) {
  .section-hero-highlight.section-hero-panel {
    margin-right: calc(var(--body-wrapper-padding-desktop) * -1);
    margin-left: calc(var(--body-wrapper-padding-desktop) * -1);
    padding: 56px var(--body-wrapper-padding-desktop) 40px;
  }
}

/* Content must clear the theme's hero background image, which is absolutely
   positioned inside this section at z-index 1. */
.section-hero-highlight .section-hero-highlight__wrapper {
  position: relative;
  z-index: 5;
}

.section-hero-highlight__wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 1120px;
  margin: 0 auto;
  text-align: center;
}

.section-hero-highlight .ratings-panel--hero-highlight {
  justify-content: center;
}

/* The heading + description come from the shared section-header-v2 component;
   only the hero-specific centring lives here. */
.section-hero-highlight .section-header-v2__title,
.section-hero-highlight .section-header-v2__description {
  text-align: center;
}

.section-hero-highlight .section-header-v2__description {
  max-width: 720px;
  margin-inline: auto;
}

/* ---------------------------------------------------------------------------
   Rotating highlight
   --------------------------------------------------------------------------- */

/* The coloured pill. Padding and radius live here, so the clipping window
   inside can animate its width without ever cutting into the padding. */
.section-hero-highlight__highlight-wrap {
  position: relative;
  display: inline-flex;
  /* Must stay baseline. An inline-flex box with no baseline-aligned item
     synthesises its baseline from its bottom edge, so `align-items: center`
     made vertical-align:baseline line the pill's BOTTOM up with the heading's
     baseline and the whole block floated above the surrounding words. */
  align-items: baseline;
  vertical-align: baseline;
  /* 40% strength, mixed with white rather than with transparency.
     Those two are identical wherever the backdrop is white, because 40% alpha
     over white and a 40% mix with white produce the same value. The difference
     is everything else: the hero sits on a gradient that runs white to purple,
     so a translucent block picked up whatever it happened to be over. A long
     word pushed the right-hand end into the purple and the block came out two
     different colours across its own width, while a short word stayed over
     white and looked correct. Mixing with white pins the result so the block
     is the same colour wherever the rotation puts it.
     `opacity` is still the wrong tool here regardless: it would fade the word
     along with its background. The widget keeps storing plain hex.
     The flat declaration above is the fallback for browsers without
     color-mix, which get the solid colour rather than no colour at all. */
  background-color: var(--nm-highlight-color);
  background-color: color-mix(in srgb, var(--nm-highlight-color) 40%, #fff);
  border-radius: 24px;
  /* Height is pinned to the title's own size rather than left to the padding.
     box-sizing keeps the 8px inside that height, so the number here is the pill
     you actually see. The line box of 88px text is 108px, taller than the pill,
     but the visible ink is only about 63px of that, so centring leaves it well
     inside with roughly even space above and below. */
  box-sizing: border-box;
  /* Height comes from the text, not from a fixed number. 88px type has an 88px
     em box before any padding, so a literal height:88px could never hold it and
     had to be faked with centring. Figma measures the frame by CAP height
     instead (~0.72em, about 63px at 88px), which is why 8 + 63 + 14 came to 88
     in the design. line-height:0.72 makes the box hug the caps the same way, so
     the design's numbers mean here what they meant there.

     Padding and radius are in em so this single rule covers every breakpoint:
     at 88px it resolves to 8 / 28 / 14 and radius 24, and it stays in the same
     proportion at 56px and 38px with no separate blocks to keep in sync. */
  /* Fixed height, top 0, bottom 14, sides 28 — at the 88px desktop title.
     Written in em (100/88, 28/88, 14/88) so the pill holds those proportions at
     the 56px and 38px steps instead of a literal 100px box swallowing a 38px
     word on a phone. One rule still covers every screen.

     line-height is 1 rather than the cap-height 0.72: with a fixed height the
     line box only decides where the word sits inside the pill, and at 0.72 the
     box would be 63px inside an 86px content area, leaving slack at the top that
     would make "top: 0" mean nothing. */
  line-height: 1;
  height: 1.136em;
  padding: 0 0.32em 0.16em;
  border-radius: 0.27em;
}

/* The label is the clipping window for the width animation, so its overflow
   is hidden in both directions. Once the line box hugs the cap height, the
   descenders in "speed" and "hard targets" fall outside it and get sliced off.
   The padding opens the clip box up again; the equal negative margin means it
   costs no layout height, so the pill stays the size set above. */
.section-hero-highlight__label {
  padding-block: 0.25em;
  margin-block: -0.25em;
}

/* The clipping window, and the only thing that animates.

   The word inside is swapped instantly; this box then eases from the old
   word's width to the new one, revealing or trimming the text as it goes.
   Nothing fades, which is what keeps the change feeling mechanical rather
   than blurry.

   `width` needs a real pixel value to animate — a transition from `auto`
   silently does not run — so JS publishes the measured width as
   --nm-highlight-width. The `auto` fallback keeps the block correct in the
   moment before JS runs, and permanently if it never does. */
.section-hero-highlight__label {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  width: var(--nm-highlight-width, auto);
  /* As a flex item this defaults to flex-shrink: 1, which lets it compress a
     few pixels below the width set above and quietly clip the last letter of
     every word — measured at 279px against a 284px word. The width here is a
     measurement, not a suggestion, so nothing may shrink it. */
  flex: none;
}

@media (prefers-reduced-motion: no-preference) {
  .section-hero-highlight__label {
    /* 300ms ease-in-out-quint: slow at both ends, quick through the middle,
       so the box reads as settling into the word rather than sliding. */
    transition: width 300ms cubic-bezier(0.86, 0, 0.07, 1);
  }
}

/* Offscreen twin used to measure the next word at the real font size before
   the swap. Absolute so it never affects layout, and hidden from assistive
   tech so it is not part of the page text. It carries no padding: the pill
   owns that now, so this measures the text alone. */
.section-hero-highlight__measure {
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  white-space: nowrap;
}

.section-hero-highlight__highlight,
.section-hero-highlight__measure {
  white-space: nowrap;
  display: inline-block;
  color: #000000;
}

/* Chinese ideographs fill the em square — with the fallback CJK face the ink
   runs from about -0.12em below the baseline to 0.88em above it, against the
   0-to-0.72em Latin caps the pill's height and padding were tuned to. At full
   size the glyphs poke out of both pill edges. 0.88em brings the tallest
   stroke back inside the same headroom the Latin words get, while staying
   close to the optical size of the heading around it. The measure twin gets
   the same rule so the width animation measures the size actually rendered. */
:lang(zh) .section-hero-highlight__highlight,
:lang(zh) .section-hero-highlight__measure {
  font-size: 0.88em;
}

/* ---------------------------------------------------------------------------
   Description + CTAs
   --------------------------------------------------------------------------- */

.section-hero-highlight__cta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

/* ---------------------------------------------------------------------------
   Responsive — same breakpoints as the internal hero
   --------------------------------------------------------------------------- */

/* 1080/680, matching the breakpoints the title's type scale uses (88 / 56 / 38px
   in the theme's section-header-v2). They were 960/640, which left two bands
   where the pill was padded for a different font size than the one it wrapped:
   961-1080 put the 88px pill padding around 56px text, and 641-680 did the same
   one step down. 1024px landed in the first of those. */
/* No per-breakpoint pill rules any more: the em padding and radius above scale
   with the title's own font size, so the pill keeps its proportions at 88, 56
   and 38px without three sets of numbers drifting apart. */

@media (max-width: 680px) {
  .section-hero-highlight__wrapper {
    gap: 16px;
  }

  .section-hero-highlight__cta {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .section-hero-highlight__cta .b-btn {
    width: 100%;
  }
}

/* Visitors who ask their system for reduced motion get the first word only —
   no rotation, no width easing. The script also stops running for them, so
   this is belt and braces for the case where the width was already pinned. */
@media (prefers-reduced-motion: reduce) {
  .section-hero-highlight__label {
    transition: none;
  }
}
