/*
 * Immersive motion layer. The boot script in each page head adds motion-pending and
 * is-arriving, and immersive.js adds immersive. Neither happens with reduced motion.
 */

.motion-pending :is(.page-intro, .landing-intro, .breadcrumb) { opacity: 0; }

/* Page transitions: a tide rises before navigation and drains on the next page. */
.tide {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  visibility: hidden;
  background: #102a35;
  translate: 0 calc(100% + 12vh);
}
.tide::before {
  content: "";
  position: absolute;
  inset: auto 0 calc(100% - 1px);
  height: 12vh;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 120' preserveAspectRatio='none'%3E%3Cpath fill='%23102a35' d='M0 60C360 0 360 0 720 60S1080 120 1440 60V120H0Z'/%3E%3C/svg%3E") 0 100% / 50vw 100% repeat-x;
  animation: tide-drift 1.2s linear infinite;
}
.tide::after, html.is-arriving::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3rem;
  height: 3rem;
  margin: -1.5rem 0 0 -1.5rem;
  border-radius: 50%;
  background: conic-gradient(from 30deg, #5bc2e7, #3d819a, #3d819a 61%, #5bc2e7 88%, #5bc2e7);
  -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%);
  mask: radial-gradient(circle, transparent 52%, #000 54%);
}
.tide::after { opacity: 0; }
.tide.is-rising { visibility: visible; animation: tide-rise .34s cubic-bezier(.7, 0, .25, 1) forwards; }
.tide.is-rising::after { animation: tide-spin 1s linear infinite, tide-fade-in .2s .25s forwards; }

html.is-arriving::after {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: 90;
  height: 112vh;
  pointer-events: none;
  background: #102a35;
  -webkit-mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 120' preserveAspectRatio='none'%3E%3Cpath d='M0 0H1440V60C1080 120 1080 120 720 60C360 0 360 0 0 60Z'/%3E%3C/svg%3E") 0 100% / 50vw 12vh repeat-x,
    linear-gradient(#000 0 0) 0 0 / 100% calc(100% - 12vh + 1px) no-repeat;
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 120' preserveAspectRatio='none'%3E%3Cpath d='M0 0H1440V60C1080 120 1080 120 720 60C360 0 360 0 0 60Z'/%3E%3C/svg%3E") 0 100% / 50vw 12vh repeat-x,
    linear-gradient(#000 0 0) 0 0 / 100% calc(100% - 12vh + 1px) no-repeat;
}
html.is-arriving::before { position: fixed; z-index: 91; pointer-events: none; animation: tide-spin 1s linear infinite; }
html.is-arriving:not(.motion-pending)::after { animation: tide-drain .55s cubic-bezier(.7, 0, .25, 1) forwards, tide-mask-drift .55s linear; }
html.is-arriving:not(.motion-pending)::before { animation: tide-spin 1s linear infinite, tide-fade-out .15s forwards; }

@keyframes tide-rise { to { translate: 0 0; } }
@keyframes tide-drain { to { translate: 0 -112vh; } }
@keyframes tide-drift { to { background-position-x: -50vw; } }
@keyframes tide-mask-drift {
  to {
    -webkit-mask-position: -50vw 100%, 0 0;
    mask-position: -50vw 100%, 0 0;
  }
}
@keyframes tide-spin { to { rotate: 1turn; } }
@keyframes tide-fade-in { to { opacity: 1; } }
@keyframes tide-fade-out { to { opacity: 0; } }

/* A drop lands wherever you press. */
.drop-layer { position: fixed; inset: 0; z-index: 80; overflow: hidden; pointer-events: none; }
.drop-ring {
  position: absolute;
  width: 0;
  height: 0;
  border: 1.5px solid #3d819a;
  border-radius: 50%;
  translate: -50% -50%;
  animation: drop-ring .9s cubic-bezier(.15, .65, .3, 1) both;
}
@keyframes drop-ring {
  0% { width: 0; height: 0; opacity: 0; }
  8% { opacity: .85; }
  100% { width: 5.5rem; height: 5.5rem; opacity: 0; }
}

/* Smooth scrolling */
.immersive { scroll-behavior: auto !important; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

/* Headings revealed word by word. The sr-only copy keeps the heading readable as one phrase. */
.split { display: block; }
.split .w {
  display: inline-block;
  overflow: clip;
  vertical-align: top;
  padding-block: .16em .14em;
  margin-block: -.16em -.14em;
}
.split .w > span { display: inline-block; }
.immersive .page-intro > * { animation: none; }

/* Page heroes get a living backdrop and a waterline. */
.immersive .page-hero { position: relative; isolation: isolate; overflow: clip; border-bottom-color: transparent; }
.immersive .page-hero > .wrap {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: clamp(25rem, 62svh, 40rem);
}
.immersive .page-hero .page-intro { margin-block: auto; }
.hero-motif, .hero-wave { position: absolute; z-index: -1; width: 100%; pointer-events: none; }
.hero-motif {
  inset: 0;
  height: 100%;
  -webkit-mask-image: linear-gradient(90deg, transparent 18%, #000 62%);
  mask-image: linear-gradient(90deg, transparent 18%, #000 62%);
}
.hero-wave { inset: auto 0 -1px; z-index: 0; height: 9rem; }

/* Pointer light on cards */
@media (hover: hover) and (pointer: fine) {
  .immersive .has-spot:not(.project-card) {
    background-image: radial-gradient(22rem circle at var(--mx, 50%) var(--my, 50%), rgb(172 223 188 / calc(var(--spot-a, 0) * .34)), transparent 72%);
  }
  .immersive .project-card.has-spot::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(30rem circle at var(--mx, 50%) var(--my, 50%), rgb(190 240 214 / calc(var(--spot-a, 0) * .16)), transparent 70%);
  }
}

/* The header mark turns like a water meter as you read. */

.immersive .contact-strip::after { scale: var(--ripple-scale, 1); transform-origin: 91% 82%; }

@media (width > 52rem) and (min-height: 36rem) {
  .immersive .journey-rings { rotate: calc(var(--ring-turn) + var(--journey-spin, 0deg)); }
  .immersive .journey-drop { animation: journey-bob 3.3s ease-in-out infinite; }
  .journey-pulse {
    grid-area: 1 / 1;
    width: clamp(2rem, 5vw, 4.3rem);
    aspect-ratio: 1;
    border: 1px solid var(--stage-color);
    border-radius: 50%;
    opacity: 0;
    animation: journey-pulse 3.3s cubic-bezier(.15, .6, .3, 1) infinite;
    transition: border-color .55s;
  }
}
@keyframes journey-bob {
  0%, 100% { translate: 0 -5px; }
  50% { translate: 0 5px; }
}
@keyframes journey-pulse {
  0% { scale: .8; opacity: .75; }
  100% { scale: 6; opacity: 0; }
}

@media (max-width: 52rem) {
  .hero-motif {
    opacity: .75;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 85%);
    mask-image: linear-gradient(90deg, transparent, #000 85%);
  }
}

/* Dark header, matching the start page */
body[data-page="index"] .site-header {
  background: #102a35;
  border-bottom: 1px solid #ffffff14;
  color: #dcecf2;
}
body[data-page="index"] .nav a:not(.nav-contact) { color: #dcecf2; }
body[data-page="index"] .nav a:not(.nav-contact):hover,
body[data-page="index"] .nav a[aria-current="page"]:not(.nav-contact) { color: #fff; }
body[data-page="index"] .nav .nav-contact { color: #102a35; background: #5bc2e7; border: 0; }
body[data-page="index"] .nav .nav-contact:hover { background: #8fd6ef; }
body[data-page="index"] .site-header a:focus-visible,
body[data-page="index"] .site-header button:focus-visible { outline: 2px solid #5bc2e7; outline-offset: 3px; }
body[data-page="index"] .site-header .nav-contact:focus-visible { outline: 2px solid #fff; outline-offset: 3px; box-shadow: none; }

@media (hover: hover) {
  body[data-page="index"] .nav a:not(.nav-contact) { background: linear-gradient(#5bc2e7, #5bc2e7) 0 100% / 0 1px no-repeat; }
  body[data-page="index"] .nav a:not(.nav-contact):hover,
  body[data-page="index"] .nav a[aria-current="page"]:not(.nav-contact) { background-size: 100% 1px; }
}

@media (width > 52rem) {
  body[data-page="index"] .site-header.has-scrolled {
    background: #102a35eb;
    backdrop-filter: blur(16px);
    box-shadow: 0 1px 0 #ffffff12, 0 .6rem 1.6rem #0000002e;
  }
  body[data-page="index"] .site-header::after { background: #5bc2e7; }
}

@media (max-width: 52rem) {
  body[data-page="index"] .site-header .menu-toggle:not([hidden]) { color: #fff; border: 1px solid #ffffff33; background: transparent; }
  body[data-page="index"] .site-header .menu-toggle:not([hidden]):hover { background: #ffffff12; }
  body[data-page="index"] .site-header .nav.is-open { background: #102a35; box-shadow: 0 .65rem 1.05rem #0000002e; }
  body[data-page="index"] .site-header .nav.is-open a:not(.nav-contact) { border-bottom: 1px solid #ffffff1a; }
}
