:root {
  --ink: #2a2f36;
  --surface: #f3f5f7;
  --blue: #4098d1;
  --shallow: #0b2d52;
  --mid: #061428;
  --deep: #020609;
  --fg: rgba(215, 228, 240, 0.85);
  --fg-dim: rgba(170, 195, 220, 0.8);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

.sprite { position: absolute; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--deep);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* --- canvas behind everything below the surface --- */
#ocean {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
}

/* --- brand: fixed, split at the waterline --- */
.brand {
  --cut: 100%;               /* px from logo top to the waterline; set by JS */
  --brand-w: min(460px, 72vw);
  --brand-top: 34vh;
  position: fixed;
  left: 50%;
  top: var(--brand-top);
  transform: translate(-50%, -50%);
  width: var(--brand-w);
  z-index: 3;
  pointer-events: none;
}
.brand .logo { display: block; width: 100%; height: auto; }
.brand .ink {
  color: var(--ink);
  clip-path: inset(0 0 calc(100% - var(--cut)) 0);
}
.brand .pale {
  position: absolute;
  inset: 0;
  color: rgba(215, 228, 240, 0.92);
  clip-path: inset(var(--cut) 0 0 0);
}

/* --- surface: short of the viewport so the waves show without scrolling --- */
.surface {
  position: relative;
  z-index: 2;
  height: 88vh;
  height: 88svh;
  background: var(--surface);
  color: var(--ink);
}

.surface .mail {
  --fade: 1;                 /* 1 at the top, 0 once scrolling starts; set by JS */
  position: fixed;
  left: 50%;
  /* below the fixed logo: its centre + half its height (aspect 4.5:1) + gap */
  top: calc(34vh + min(460px, 72vw) / 9 + 3vh);
  transform: translateX(-50%);
  z-index: 3;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  color: var(--ink);
  opacity: calc(var(--fade) * 0.85);
  border-bottom: 1px solid transparent;
  transition: opacity 0.25s, border-color 0.25s;
}
.surface .mail:hover { opacity: var(--fade); border-color: var(--blue); }

/* --- waterline: the moment of submersion --- */
.waterline {
  position: relative;
  z-index: 2;
  height: 150vh;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(64, 152, 209, 0.28), transparent 70%),
    linear-gradient(to bottom, var(--shallow) 0%, var(--mid) 40%, var(--deep) 68%, rgba(2, 6, 9, 0) 100%);
}
/* living surface: two wave layers (inline SVG, so no mask sampling seams)
   with different wavelengths drifting in opposite directions, plus a slow
   vertical bob. Both are surface-coloured; the rear one half-transparent.
   The svg starts 9px inside the surface so the bob never exposes the seam. */
.waves {
  position: absolute;
  left: 0;
  top: -9px;
  width: 4800px;
  height: 44px;
  display: block;
  fill: var(--surface);
}
.waves .b { opacity: 0.55; animation: bob 9s ease-in-out -4s infinite; }
.waves .a { animation: bob 7s ease-in-out infinite; }
.waves .drift-a { animation: drift-a 17s linear infinite; }
.waves .drift-b { animation: drift-b 11s linear infinite; }
@keyframes drift-a { to { transform: translateX(-400px); } }
@keyframes drift-b { to { transform: translateX(260px); } }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(3px); }
}

/* --- the deep --- */
.deep {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 0 6vw 1.8vh;
}

.deep .mail {
  position: fixed;
  left: 50%;
  top: calc(34vh + min(460px, 72vw) / 9 + 3vh); /* same spot as the surface email */
  transform: translateX(-50%);
  z-index: 3;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  color: var(--fg-dim);
  opacity: 0;
  pointer-events: none;
  border-bottom: 1px solid transparent;
  transition: color 0.25s, border-color 0.25s;
}
.deep .mail:hover { color: #fff; border-color: var(--blue); }

.deep footer {
  grid-row: 2;
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em 1.6em;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: rgba(160, 185, 210, 0.45);
}

/* no JavaScript: nothing is scroll-driven, so let the layout carry it.
   The logo scrolls with the surface; the deep shows its email statically. */
.no-js .brand { position: absolute; }
.no-js .surface .mail { position: absolute; }
.no-js .deep .mail { position: static; transform: none; opacity: 1; pointer-events: auto; justify-self: center; align-self: center; }

/* --- 404 --- */
.page-404 { background: var(--surface); color: var(--ink); }
.lost {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  text-align: center;
  padding: 6vh 6vw;
}
.lost .mark { width: 72px; height: auto; display: block; }
.lost p { margin: 0; font-size: 1.05rem; letter-spacing: 0.02em; opacity: 0.85; }
.lost .mail {
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  opacity: 0.85;
  border-bottom: 1px solid var(--blue);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .waves g { animation: none; }
}
