/* Headline lines are always blocks; the roll below only runs during the intro. */
.hero-line { display: block; overflow: hidden; padding-bottom: .12em; margin-bottom: -.12em; }
.hero-line > span { display: block; }
.hero-roll-word {
  display: inline-block; overflow: hidden; vertical-align: top;
  /* Allow italic overhang without changing the word's layout width. */
  padding-inline: .12em; margin-inline: -.12em;
}
.hero-roll-word > span { display: block; }

/* Entry animation: shown once per visit, while <html data-intro> is set.
   Everything is on fixed timing and ends by itself, so nothing depends on
   JavaScript finishing. The cover uses the opposite colour to the site theme.

   Timeline (s): logo and letters in 0-1.3 | letters merge into the mark 1.25-1.85 |
   waves run 1.1-2.73, with the orange on screen during the merge | mark glides to the header 1.9-2.55 |
   hero and header settle by 3.5. */
@property --intro-sweep { syntax: "<angle>"; inherits: false; initial-value: 360deg; }

.site-intro { display: none; }
html[data-intro] .site-intro {
  --intro-cover: #f1f0eb;
  --intro-ink: #101010;
  --intro-word: min(760px, 78vw);
  --intro-l-x: calc(-50vw + 34px);
  --intro-l-y: calc(-50vh + 22px);
  --intro-l-scale: .25;
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  animation: intro-gone 1ms linear 3.2s forwards;
}
html[data-intro][data-theme="light"] .site-intro { --intro-cover: #101010; --intro-ink: #f1f0eb; }

/* Two layers: the cover clears first and the orange follows just behind it,
   so from top to bottom the screen reads cover, orange, hero. */
.site-intro-layer {
  --layer: var(--intro-cover);
  --start: 1.1s;
  position: absolute;
  inset: 0;
  background: var(--layer);
  animation: intro-rise 1.5s cubic-bezier(.76, 0, .24, 1) var(--start) both;
}
.site-intro-layer-orange { --layer: #ff5000; --start: 1.23s; }
.site-intro-wave {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  width: 100%;
  height: min(18vh, 22vw);
  fill: var(--layer);
  transform-origin: top;
  animation: intro-wave 1.5s ease-in-out var(--start) both;
}

.site-intro-word { position: relative; width: var(--intro-word); }
.site-intro-rest { position: absolute; top: 25%; height: 50%; overflow: hidden; fill: var(--intro-ink); }
.site-intro-rest path {
  transform-box: fill-box;
  transform-origin: center;
  animation:
    intro-letter-in .8s cubic-bezier(.16, 1, .3, 1) calc(.1s + .08s * var(--i)) both,
    intro-letter-merge .5s cubic-bezier(.7, 0, .3, 1) calc(1.25s + .02s * (5 - var(--i))) forwards;
}
/* Three nested moves: to the centre, then sideways, then up and shrinking.
   Starting the upward move a little later bends the path into a curve. */
.site-intro-merge {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  animation: intro-mark-merge .6s cubic-bezier(.65, 0, .35, 1) 1.25s both;
}
.site-intro-mark-x {
  position: absolute;
  inset: 0;
  animation:
    intro-l-x .65s cubic-bezier(.65, 0, .35, 1) 1.9s both,
    intro-l-fade .15s linear 3s forwards;
}
.site-intro-mark {
  display: block;
  max-width: none;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  animation:
    intro-mark-in .8s cubic-bezier(.16, 1, .3, 1) both,
    intro-l-y .58s cubic-bezier(.76, 0, .24, 1) 1.97s forwards;
}

@keyframes intro-letter-in { from { transform: translateY(105%); } to { transform: none; } }
@keyframes intro-letter-merge {
  75% { opacity: 1; }
  to { transform: translateX(var(--to-centre)) scale(.12); opacity: 0; }
}
@keyframes intro-mark-in { from { opacity: 0; transform: translateY(14%); } to { opacity: 1; transform: none; } }
@keyframes intro-mark-merge { to { transform: translateX(var(--merge)); } }
@keyframes intro-l-x { to { transform: translateX(var(--intro-l-x)); } }
@keyframes intro-l-y { to { transform: translateY(var(--intro-l-y)) scale(var(--intro-l-scale)); } }
@keyframes intro-l-fade { to { opacity: 0; } }
@keyframes intro-rise { to { transform: translateY(calc(-100% - 20vh)); } }
@keyframes intro-wave { 0% { transform: scaleY(0); } 45% { transform: scaleY(1); } 100% { transform: scaleY(.25); } }
@keyframes intro-gone { to { visibility: hidden; } }

/* The hero drifts up behind the waves, as if they pull the page. */
html[data-intro] #inicio { animation: intro-hero-rise 1.25s cubic-bezier(.16, 1, .3, 1) 1.55s both; }
@keyframes intro-hero-rise { from { transform: translateY(70px); } to { transform: none; } }

/* Each headline line rolls through copies of itself, slot-machine style. */
html[data-intro] .hero-line > span:not(.hero-roll-text),
html[data-intro] .hero-roll-word > span {
  animation: intro-line-roll .8s cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: var(--hero-roll-delay, 0s);
}
html[data-intro] .hero-line:nth-child(1) > span { --hero-roll-delay: 2.3s; }
html[data-intro] .hero-line:nth-child(2) > span { --hero-roll-delay: 2.4s; }
html[data-intro] .hero-line:nth-child(3) > span { --hero-roll-delay: 2.5s; }
html[data-intro] #inicio > div:first-of-type > :not(h1) { animation: intro-fade-up .45s ease 2.65s both; }
/* Set by SiteIntro once that fade has ended: the copy is already in its final
   state, and switching the animation off makes the browser repaint it. */
html[data-intro][data-intro-settled] #inicio > div:first-of-type > :not(h1) { animation: none; }
/* Keep the copies' offsets fixed while fading them out. Animating to `none`
   also moves their offsets to zero, flashing a second roll over settled text. */
@keyframes intro-line-roll {
  0% { transform: translateY(-2.6em); }
  0%, 80% { text-shadow: 0 1.3em currentColor, 0 2.6em currentColor; }
  100% { transform: none; text-shadow: 0 1.3em transparent, 0 2.6em transparent; }
}
@keyframes intro-fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes intro-fade { from { opacity: 0; } to { opacity: 1; } }

/* The form card appears, its orange border traces round it, then the fields arrive. */
html[data-intro] #inicio .lead-column { animation: intro-fade .3s ease 2.35s both; }
html[data-intro] #inicio .lead-card::before {
  inset: -50%;
  transform: none;
  background: conic-gradient(var(--orange, #ff5000) var(--intro-sweep), transparent 0);
  animation: intro-border .85s ease-in-out 2.4s both;
}
html[data-intro] #inicio .lead-card > * { animation: intro-fade-up .4s ease 2.9s both; }
@keyframes intro-border {
  0% { --intro-sweep: 0deg; opacity: 1; }
  80% { --intro-sweep: 360deg; opacity: 1; }
  100% { --intro-sweep: 360deg; opacity: 0; }
}

/* The background texture lights up last. */
html[data-intro] [data-hero-network] { animation: intro-fade .6s ease 2.85s both; }

/* Header: the logo takes over from the flying L, then the rest drops in left to right. */
html[data-intro] .hdr-in > a:first-child { animation: intro-fade .2s ease 2.9s both; }
html[data-intro] :is(.hdr-nav > *, .hdr-in > div:last-child > *) {
  animation: intro-drop .3s cubic-bezier(.16, 1, .3, 1) var(--drop, 2.92s) both;
}
html[data-intro] .hdr-nav > :nth-child(2) { --drop: 2.95s; }
html[data-intro] .hdr-nav > :nth-child(3) { --drop: 2.98s; }
html[data-intro] .hdr-nav > :nth-child(4) { --drop: 3.01s; }
html[data-intro] .hdr-nav > :nth-child(5) { --drop: 3.04s; }
html[data-intro] .hdr-in > div:last-child > :nth-child(1) { --drop: 3.04s; }
html[data-intro] .hdr-in > div:last-child > :nth-child(2) { --drop: 3.07s; }
html[data-intro] .hdr-in > div:last-child > :nth-child(3) { --drop: 3.10s; }
html[data-intro] .hdr-in > div:last-child > :nth-child(4) { --drop: 3.13s; }
html[data-intro] .hdr-in > div:last-child > :nth-child(5) { --drop: 3.16s; }
html[data-intro] .hdr-in > div:last-child > :nth-child(6) { --drop: 3.17s; }
@keyframes intro-drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
