/* hero.css -- the header of every page: ONE hero, the same on all of them.
 *
 * Structure (markup contract, checked by test/hero-is-shared.js):
 *   <section class="hero">                       exactly one per page, the first thing in <main>
 *     <div class="hero-text">                    dissolves: its children take their place in the column
 *       <h1>                                     the title, the only h1 of the page
 *       <p class="hero-lede">                    the sentence under it
 *       <p class="hero-route">                   optional: the action row, a primary button and at most one secondary
 *     </div>
 *     <div class="hero-tiles"> ... </div>        optional: the row of three tiles (partials/page-hero.html)
 *   </section>
 * Alignment, type scale, paddings, background, buttons and breakpoints are set here and nowhere else: no page restyles its hero (no rule of any other sheet
 * mentions .hero), and the colour of the hero comes from the tokens of the universe of the page (assets/colour.css: --hero-accent), never from a literal.
 * The panel carries the site's tinted gradient atmosphere, the two accent rings and the road-light trails that chrome.js draws behind it, with the pause
 * button of motion.js; reduced motion is honoured by them. */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  overflow: hidden;
  /* the top clears the navigation pill (about 72 px) whether or not a campaign banner pushes the page down */
  padding: clamp(var(--space-10), 10vh, var(--space-10)) clamp(var(--space-5), 4vw, var(--space-8)) calc(var(--space-6) * 2.5);
  text-align: center;
  color: var(--hero-text);
  background:
    radial-gradient(ellipse at 78% 15%, color-mix(in srgb, var(--hero-accent) 26%, transparent), transparent 34%),
    linear-gradient(145deg, var(--hero-bg), var(--hero-bg-2));
  border-radius: var(--radius-1);
  --accent: var(--hero-accent);
}
/* the rings sit low and to the right, behind the type; the trails and the rings stay behind the content */
.hero::before {
  content: "";
  position: absolute;
  right: -22%;
  bottom: -78%;
  width: min(66vw, 51.25rem);
  aspect-ratio: 1;
  border: var(--line-1) solid var(--hero-ring);
  border-radius: var(--radius-round);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  right: 2%;
  bottom: -52%;
  width: min(42vw, 32.5rem);
  aspect-ratio: 1;
  border: var(--line-1) solid color-mix(in srgb, var(--hero-accent) 30%, transparent);
  border-radius: var(--radius-round);
  pointer-events: none;
}
.hero-text { display: contents; }

.hero h1,
.hero-lede,
.hero-route,
.hero-tiles { position: relative; z-index: 2; }

.hero h1 {
  order: 1;
  max-width: 54rem;
  margin: 0;
  font-size: var(--fs-7);
  font-weight: var(--fw-3);
  line-height: var(--lh-1);
  letter-spacing: -.03em;
  text-wrap: balance;
  overflow-wrap: anywhere;
  hyphens: auto;
  color: var(--hero-text);
}
.hero h1 em { color: var(--hero-text); font-style: normal; }
.hero h1 em::after { content: none; }

.hero-lede {
  order: 2;
  margin: var(--space-4) auto var(--space-4);
  max-width: 38rem;
  font-size: var(--fs-6);
  line-height: var(--lh-2);
  color: var(--hero-muted);
}
.hero-lede strong, .hero-lede a { color: var(--hero-text); }
.hero-lede a { display: inline-block; text-decoration: underline; text-underline-offset: .18em; }
.hero-lede a:focus-visible { outline-color: var(--hero-text); }

/* the action row: the site's primary button, then at most one secondary, centred under the sentence */
.hero-route { order: 3; margin: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); }
.hero .btn-primary { color: var(--hero-action-ink); background: var(--hero-action); }
.hero .btn-primary:hover { color: var(--hero-action-ink); background: var(--hero-action); }
.hero .btn-outline { color: var(--hero-on-glass); background: var(--hero-outline); border-color: var(--hero-outline-edge); }
.hero .btn-outline:hover { background: var(--hero-outline-hover); }

/* the three tiles, in the order a visitor meets them, each with what it delivers: a plain typographic sequence. Every word is text of
   the page; the arrows between the names are decoration. */
.hero-tiles {
  order: 4;
  width: min(100%, 62rem);
  margin: clamp(var(--space-6), 6vh, var(--space-7)) auto 0;
  text-align: center;
  color: var(--hero-text);
}
/* the group is named for assistive technology; the columns say the rest */
.hero-tiles-title { position: absolute; width: var(--line-1); height: var(--line-1); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hero-tiles-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--space-4); margin: 0; padding: 0; list-style: none; }
.hero-tile {
  padding: var(--space-4) var(--space-4) var(--space-4);
  background: var(--hero-glass);
  border: var(--line-1) solid var(--hero-glass-edge);
  border-radius: var(--radius-3);
  -webkit-backdrop-filter: blur(1.25rem);
  backdrop-filter: blur(1.25rem);
}
.hero-tile-name { margin: 0 0 var(--space-2); font-size: var(--fs-5); font-weight: var(--fw-3); color: var(--hero-text); }
.hero-tile:not(:last-child) .hero-tile-name::after { content: "\2192"; margin-inline-start: var(--space-5); color: var(--hero-accent); }
.hero-tile-gets { margin: 0 auto; max-width: 20rem; font-size: var(--fs-3); line-height: var(--lh-2); color: var(--hero-muted); }


/* the road-light backdrop that chrome.js draws behind the content, its pause button, the scroll cue */
.hero-backdrop { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; opacity: .5; }
.hero-backdrop svg { display: block; width: 100%; height: 100%; }
.hero .ha-trail { stroke-dasharray: 12 88; stroke-dashoffset: 100; }
.hero .ha-trail { stroke: var(--hero-accent); }
.hero-scroll { position: absolute; z-index: 3; bottom: 1.25rem; left: 50%; transform: translateX(-50%); }
.hero-motion-toggle { position: absolute; right: clamp(var(--space-5), 4vw, var(--space-8)); bottom: 1rem; z-index: 3; min-height: 2.75rem; padding: var(--space-2) var(--space-4); border: var(--line-1) solid var(--hero-toggle-edge); border-radius: var(--radius-2); color: var(--hero-text); background: var(--hero-bg); font-size: var(--fs-1); cursor: pointer; }
.hero-motion-toggle[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  @keyframes heroTrailFlow { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
  .hero .ha-trail { animation-name: heroTrailFlow; animation-timing-function: var(--motion-ease-flow); animation-iteration-count: infinite; animation-play-state: paused; }
  .hero.hero-motion-running .ha-trail { animation-play-state: running; }
}
/* a still hero (the preference, or the pause control) keeps the trails as faint full lines */
@media (prefers-reduced-motion: reduce) {
  .hero .ha-trail { animation: none; stroke-dasharray: none; opacity: var(--motion-opacity-dim); }
  .hero-motion-toggle { display: none; }
}
html[data-motion="still"] .hero .ha-trail { stroke-dasharray: none; opacity: var(--motion-opacity-dim); }

/* on a narrow screen the three tiles stack */
@media (max-width: 56rem) {
  .hero-tiles-list { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-4); }
}

/* on a phone the headline and the sentence are a little smaller and closer, so that the action stays above the consent notice
   (about 200 px) even in a month that carries the awareness banner */
@media (max-width: 40rem) {
  .hero { padding-top: calc(var(--space-6) * 2.625); }
  .hero h1 { font-size: var(--fs-7); }
  .hero-lede { margin: var(--space-3) auto var(--space-2); font-size: var(--fs-5); }
}
@media (max-width: 30rem) {
  .hero-route { flex-direction: column; align-items: stretch; }
  .hero-route > * { width: 100%; }
}

/* a page without a hero starts lower, clear of the navigation pill */
body.comp main:not(:has(> .hero)) { padding-top: var(--space-7); }

/* the focus ring on the hero takes the light colour of its text, so it keeps 3:1 against the band */
.hero :where(a, button, input, textarea, select, summary, [tabindex]):focus-visible { outline-color: var(--hero-text); }
