/* The hero (src/partials/hero.html, assets/js/hero.js): the quiet opening of the page. One headline, one line
   and one button, centred on the first screen over the page's space of dots. Everything else is explained
   further down, so the hero only makes the promise, and the headline itself is the picture.

   Taken from the logo: its blues, and the return stroke of its q. hero.js wraps each word of the headline
   (.hero__word, with --i its place in the line) and the key phrase inside its words (.hero__accent).
   - Each word arrives on its own line of the logo's blue: the line draws in from the left, then lifts and
     dissolves into the word, which rises out of a soft blur. The words come one after another, like a
     sentence being written, then the line under the button's way in follows softly.
   - The key phrase keeps the logo's gradient, the return stroke draws itself under it, and a slow light
     passes over it now and then.
   Every plain style is the FINISHED, still headline: without JavaScript it is the plain headline, and with
   reduced motion it is the finished one with its accent, still. The arrival plays only where motion is
   allowed, once hero.js has set .is-playing. */

.hero {
  --hero-line-a: #3b7d9a;
  --hero-line-b: #a7d8ef;
  --hero-accent-a: #245d76;
  --hero-accent-b: #3b7d9a;
  /* The light that passes over the key phrase: still 3:1 on the light page, as large text needs. */
  --hero-accent-light: #4f93b2;
  --hero-start: #7fbfdd;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .hero {
    --hero-line-a: #a7d8ef; --hero-line-b: #3b7d9a;
    --hero-accent-a: #a7d8ef; --hero-accent-b: #e5f3f9; --hero-accent-light: #ffffff; --hero-start: #3b7d9a;
  }
}
:root[data-theme='dark'] .hero {
  --hero-line-a: #a7d8ef; --hero-line-b: #3b7d9a;
  --hero-accent-a: #a7d8ef; --hero-accent-b: #e5f3f9; --hero-accent-light: #ffffff; --hero-start: #3b7d9a;
}

.hero {
  position: relative; display: flex; align-items: center;
  min-height: 100vh; min-height: 100svh;
  padding: calc(var(--header-h) + clamp(32px, 6vh, 72px)) 0 clamp(48px, 9vh, 112px);
}
.hero__inner { display: flex; flex-direction: column; align-items: center; text-align: center; width: 100%; }

.hero__title {
  max-width: 14ch;
  font-size: clamp(2.875rem, min(1.4rem + 5.4vw, 11vh), 7rem); font-weight: 650; line-height: 0.98; letter-spacing: -0.045em;
  text-wrap: balance;
}
:lang(el) .hero__title, :lang(de) .hero__title, :lang(fr) .hero__title, :lang(es) .hero__title {
  max-width: 16ch; font-size: clamp(2.375rem, min(1.1rem + 4.4vw, 9vh), 5.75rem);
}
.hero__lead {
  max-width: 40ch; margin-top: clamp(20px, 3vh, 32px);
  font-size: clamp(1.125rem, min(1rem + 0.45vw, 2.7vh), 1.375rem); line-height: 1.5; letter-spacing: -0.01em; color: var(--text-2); text-wrap: balance;
}
.hero__actions { display: flex; justify-content: center; margin-top: clamp(28px, 4.4vh, 44px); }
@media (max-width: 559px) {
  .hero__actions { align-self: stretch; }
  .hero__actions .button { width: 100%; }
}

/* ------------------------------------------------------------------ words */

.hero__word { position: relative; display: inline-block; }
.hero__word-text { display: inline-block; }
/* The line each word arrives on: at rest it is gone. */
.hero__line {
  position: absolute; left: 0.02em; right: 0.02em; bottom: 0.06em; height: 0.055em; border-radius: 999px;
  background: linear-gradient(90deg, var(--hero-line-a), var(--hero-line-b));
  transform-origin: 0 50%; opacity: 0; pointer-events: none;
}

/* The key phrase: the logo's blue, and its return stroke underneath. The gradient is the same at both of its
   ends (only its middle holds the light), so at rest the phrase is one even colour and the passing light
   leaves it exactly as it found it. It stays an inline box, so the headline reads as one unbroken word to
   assistive technology ("d’exister", not "d’ exister"); its padding only widens the painted background
   around the descenders and moves no line. The return stroke is drawn under the whole word. */
.hero__accent {
  position: relative; padding-bottom: 0.06em;
  background: linear-gradient(100deg, var(--hero-accent-a) 0% 38%, var(--hero-accent-b) 44%, var(--hero-accent-light) 50%, var(--hero-accent-b) 56%, var(--hero-accent-a) 62% 100%);
  background-size: 260% 100%; background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__word.is-accent::after {
  /* The logo's return stroke: a soft curve that dips and rises, painted in the line colour through its shape.
     It belongs to the word's box, not to the text inside it, so the headline is still announced exactly as
     it reads. */
  content: ''; position: absolute; left: -0.04em; right: -0.04em; bottom: -0.2em; height: 0.26em; pointer-events: none;
  background: var(--hero-line-a);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 16' preserveAspectRatio='none'%3E%3Cpath d='M2 5 C 22 14, 62 15, 98 3' fill='none' stroke='%23000' stroke-width='3.6' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 16' preserveAspectRatio='none'%3E%3Cpath d='M2 5 C 22 14, 62 15, 98 3' fill='none' stroke='%23000' stroke-width='3.6' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* ---------------------------------------------------------------- arrival */

@media (prefers-reduced-motion: no-preference) {
  /* Split before the first paint, the hero waits in its starting state for one frame, until the arrival
     starts, so nothing is ever shown and then taken away. */
  .is-split:not(.is-playing) .hero__word-text,
  .is-split:not(.is-playing) .hero__lead,
  .is-split:not(.is-playing) .hero__actions { opacity: 0; }
  .is-split:not(.is-playing) .hero__word.is-accent::after { opacity: 0; }

  .is-playing .hero__line { animation: hero-line 1.05s cubic-bezier(0.65, 0, 0.35, 1) calc(0.15s + var(--i) * 0.11s) both; }
  .is-playing .hero__word-text { animation: hero-word 1s cubic-bezier(0.22, 1, 0.36, 1) calc(0.55s + var(--i) * 0.11s) both; }
  .is-playing .hero__accent { animation: hero-shine 7s ease-in-out calc(1.8s + var(--words) * 0.11s) infinite; }
  .is-playing .hero__word.is-accent::after { animation: hero-stroke 1.2s cubic-bezier(0.65, 0, 0.35, 1) calc(1.1s + var(--words) * 0.11s) both; }
  .is-playing .hero__lead { animation: hero-follow 1s cubic-bezier(0.22, 1, 0.36, 1) calc(0.9s + var(--words) * 0.11s) both; }
  .is-playing .hero__actions { animation: hero-follow 1s cubic-bezier(0.22, 1, 0.36, 1) calc(1.05s + var(--words) * 0.11s) both; }
}
/* The line draws in from the left, then lifts and dissolves into its word. */
@keyframes hero-line {
  0% { opacity: 1; transform: translateY(0) scaleX(0); }
  45% { opacity: 1; transform: translateY(0) scaleX(1); }
  100% { opacity: 0; transform: translateY(-0.45em) scaleX(1); filter: blur(2px); }
}
/* The word rises out of the line, from a soft blur and the logo's light blue into its own colour. */
@keyframes hero-word {
  0% { opacity: 0; transform: translateY(0.38em); filter: blur(10px); color: var(--hero-start); }
  60% { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: none; filter: none; }
}
/* The stroke draws itself from left to right. */
@keyframes hero-stroke { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes hero-shine { 0%, 70% { background-position: 100% 0; } 100% { background-position: 0% 0; } }
@keyframes hero-follow { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (forced-colors: active) {
  .hero__accent { background: none; color: CanvasText; }
  .hero__word.is-accent::after { background: CanvasText; }
  .hero__line { display: none; }
}
