/* motion.css: reveal masks, cover, dive water, is-arming. Loaded last.
   Contract (SPEC 8.9): every hide rule lives under html.has-js and is guarded so that html.is-failsafe undoes it. */

/* ---------- Reveal ---------- */
/* Transparent, never visibility: hidden: pending content stays in the Tab order and the accessibility tree. main.js draws it on focus. */
html.has-js:not(.is-failsafe) .rv-pending {
  opacity: 0;
  pointer-events: none;
}

/* The mask grows around the line box and gives the room back: descenders, accents and side bearings stay uncut at line-height < 1.1. */
.rv-word-mask,
.rv-char-mask {
  padding: .12em .06em .14em;
  margin: -.12em -.06em -.14em;
}

/* Line masks are stacked blocks and their margins would collapse, adding .12em per line that revert() then takes back:
   the whole allowance goes on one margin, and `top` lifts the box so that the text stays where it was. */
.rv-line-mask {
  top: -.12em;
  padding: .12em .06em .14em;
  margin: 0 -.06em -.26em;
}

.rv-line,
.rv-word,
.rv-char {
  will-change: transform;
}

/* V.scrollTo moves focus to sections: they are landing points, not controls, so they draw no ring. */
[tabindex="-1"]:focus-visible {
  outline: none;
  box-shadow: none;
}

/* ---------- Arming: no flash of the finished scene before the intro starts ---------- */
html.is-arming:not(.is-failsafe) .hero-stage,
html.is-arming:not(.is-failsafe) .hero-copy,
html.is-arming:not(.is-failsafe) .hero-note {
  visibility: hidden;
}

/* ---------- Cover ---------- */
.cover {
  display: none;
}

/* The aqua is there before the cover element paints: a first frame can never be part aqua, part page. */
html.has-cover:not(.is-failsafe),
html.has-cover:not(.is-failsafe) body {
  background: var(--aqua-200);
}

html.has-cover:not(.is-failsafe) .cover {
  position: fixed;
  inset: 0;
  z-index: var(--z-cover);
  display: grid;
  place-items: center;
  background: var(--aqua-200);
  color: var(--ink);
  pointer-events: none;
}

/* Stays hidden until main.js has rendered the from-states: the logo must not flash before it rises. The whole cover goes with the failsafe. */
.cover-brand {
  visibility: hidden;
  display: grid;
  justify-items: center;
  gap: var(--s-3);
  padding-inline: var(--gutter);
}

.cover-logo,
.cover-tag {
  margin: 0;
}

.cover-logo {
  position: relative;
  display: flex;
  align-items: baseline;
  font-family: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  font-size: clamp(2.5rem, 7.4vw, 6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.cover-valjo {
  color: var(--teal);
}

/* The real logo rises from the same mask the text used. */
.cover-logo--image .cover-mask {
  padding: 0 6px 8px;
  margin: 0 -6px -8px;
}

.cover-img {
  display: block;
  width: clamp(250px, 46vw, 560px);
  height: auto;
}

.cover-mask {
  display: block;
  overflow: clip;
  padding: .1em .05em .16em;
  margin: -.1em -.05em -.16em;
}

.cover-line {
  display: block;
}

.cover-dot {
  display: block;
  flex: none;
  width: .2em;
  height: .2em;
  margin-left: .1em;
  border-radius: 50% 50% 50% 50%;
  background: var(--coral);
}

.cover-tag {
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: .16em;
  color: var(--teal-deep);
}

.cover-edge {
  position: absolute;
  top: calc(100% - 1px);
  left: -6%;
  width: 112%;
  max-width: none;
  height: 9vh;
  height: 9svh;
  overflow: visible;
}

/* ---------- Dive ---------- */
/* What the pin needs from the hero: a full frame that clips (the water and the scaled planes run past it).
   :where() has no specificity, so anything hero.css declares wins even though this file loads last. */
:where(.hero) {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
}

:where(.hero-stage, .hero-plane-wrap) {
  position: absolute;
  inset: 0;
}

.dive-water {
  display: none;
}

html.has-js.can-dive .dive-water {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  visibility: hidden;
  pointer-events: none;
}

/* The meniscus: a thin band on the top edge of the body, the line the hero's own water collapses into. */
.dive-wave {
  position: absolute;
  bottom: calc(100% - 2px);
  left: -120px;
  display: block;
  width: calc(100% + 240px);
  max-width: none;
  height: clamp(20px, 3.4vh, 30px);
}

/* Taller than the frame, because the line ends far above it. Colour only goes from bright to --d0, the colour .sec--plunge
   has, so that any row of the frame gets darker as the body rises. The depth is carried by the drawing inside (under.css). */
.dive-body {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 200vh;
  height: 200svh;
  overflow: hidden;
  background: linear-gradient(180deg, #F4FEFE 0, var(--d-surface) 12px, var(--d0) 34%, var(--d0) 100%);
}

/* Soft shafts: across, a gradient with no edge; along, a mask that reaches nothing above the end of the frame at the release. */
.dive-rays {
  position: absolute;
  top: -4%;
  height: 58%;
  opacity: 0;
  transform-origin: 50% 0;
  background: linear-gradient(90deg, rgba(244, 254, 254, 0) 0, rgba(244, 254, 254, .34) 50%, rgba(244, 254, 254, 0) 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 0, rgba(0, 0, 0, .72) 55%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0, rgba(0, 0, 0, .72) 55%, transparent 100%);
}

.dive-rays--a {
  left: 12%;
  width: 20%;
  transform: rotate(11deg);
}

.dive-rays--b {
  left: 44%;
  width: 28%;
  transform: rotate(13deg);
}

.dive-rays--c {
  left: 80%;
  width: 18%;
  transform: rotate(15deg);
}

.dive-bubble {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--foam);
  opacity: .72;
  box-shadow: inset -2px -2px 0 rgba(10, 132, 168, .24);
}

/* Its place comes from dive.js: x on the lane axis of the diver, y from the frame, whatever the body is doing. */
.dive-swimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: clamp(280px, 46vh, 460px);
  overflow: visible;
}

/* Static wave where there is no dive (no JS, reduced motion, failsafe, short viewport). Same colour as the top of .sec--plunge. */
.dive-edge {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: clamp(28px, 5vw, 56px);
  pointer-events: none;
}

html.has-js.can-dive .dive-edge {
  display: none;
}

/* With a dive the strip starts in the colour the water ends in, so the release of the pin has no seam. */
html.has-js.can-dive .sec--plunge {
  background: var(--d0);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html.has-cover .cover,
  html.has-js.can-dive .dive-water {
    display: none;
  }

  html.has-js.can-dive .dive-edge {
    display: block;
  }

  .rv-line,
  .rv-word,
  .rv-char {
    will-change: auto;
  }
}

/* ---------- Print: the whole page as a document, wherever the visitor had scrolled to ---------- */
@media print {
  html.has-js .rv-pending,
  html.has-js .hero-copy,
  html.has-js .hero-note {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
  }

  html.has-js .cover,
  html.has-js .dive-water {
    display: none !important;
  }

  html.has-js .pin-spacer {
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
  }

  html.has-js .hero {
    position: relative !important;
    inset: auto !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
  }
}
