/* The dive (js/dive.js): where things rest above and below the water, and the Depths layer.
   js/dive.js animates from wherever things are to these rest positions, so this file is the
   single source of truth for both states. Desktop only. Owner: atmosphere workstream (A). */

@media (min-width: 921px) {
  /* Under the water: the page above has floated up and out of view; the city, being far
     away, moves less and fades. */
  html[data-depths] .shell,
  html[data-depths] .meta-bar {
    translate: 0 -100svh;
  }

  html[data-depths] .fx-skyline {
    translate: 0 -55svh;
    opacity: 0;
  }

  /* The red slash belongs to the page above: it leaves with it. */
  html[data-depths] .fx-slash {
    translate: 0 -100svh;
    opacity: 0;
  }
}

/* ------------------------------------------------------------------ layer */

.depths {
  --depths-gutter: clamp(var(--s-5), 3.6vw, var(--s-8));
  position: fixed;
  inset: 0;
  z-index: var(--z-shell);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--s-9) + var(--s-5)) var(--depths-gutter) var(--s-7);
  overflow: hidden;
  isolation: isolate;
  translate: 0 100svh;
  visibility: hidden;
}

.depths[hidden] {
  display: none;
}

html[data-depths] .depths {
  translate: 0 0;
  visibility: visible;
}

/* Without WebGL (or with ?nofx) the shader is not there to draw the water: paint it. */
.depths--solid {
  background:
    radial-gradient(ellipse 60% 30% at 40% 0%, color-mix(in srgb, var(--cyan) 16%, transparent), transparent 70%),
    linear-gradient(180deg, var(--deep) 0%, var(--night) 28%, var(--abyss) 62%, var(--ink) 100%);
}

@media (max-width: 920px) {
  .depths,
  .hint-action[data-dive] {
    display: none;
  }
}

/* Big outlined watermark word along the bottom, like the page above. */
.depths-stamp {
  position: absolute;
  left: calc(var(--depths-gutter) * -0.5);
  bottom: calc(var(--fs-mega) * -0.2);
  z-index: -1;
  margin: 0;
  color: transparent;
  -webkit-text-stroke: 1px color-mix(in srgb, var(--blue-soft) 14%, transparent);
  font-family: var(--font-display);
  font-size: calc(var(--fs-mega) * 1.12);
  line-height: 0.86;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
  rotate: -4deg;
  transform-origin: 0 100%;
  pointer-events: none;
}

/* ------------------------------------------------------------ light, bubbles */

/* Soft shafts from the surface at the major angle. They sway by 1.5deg, slowly. */
.depths-light {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.depths-light i {
  position: absolute;
  top: -12%;
  left: var(--x);
  width: var(--w);
  height: 96%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ice) 8%, transparent) 50%, transparent);
  -webkit-mask-image: linear-gradient(180deg, #000 10%, transparent 92%);
  mask-image: linear-gradient(180deg, #000 10%, transparent 92%);
  rotate: var(--tilt-major);
  transform-origin: 50% 0;
}

.depths-light i:nth-child(1) { --x: 30%; --w: 9vw; --delay: 0s; }
.depths-light i:nth-child(2) { --x: 52%; --w: 15vw; --delay: -3s; }
.depths-light i:nth-child(3) { --x: 74%; --w: 7vw; --delay: -6s; }

html[data-depths] .depths-light i {
  animation: depths-sway 9s ease-in-out var(--delay) infinite alternate;
}

@keyframes depths-sway {
  from { rotate: -9.5deg; }
  to { rotate: -6.5deg; }
}

.depths-bubbles {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* True circles (the only rounded shapes allowed). */
.depths-bubbles i {
  position: absolute;
  bottom: -24px;
  left: var(--x);
  width: var(--size);
  height: var(--size);
  border: 1px solid color-mix(in srgb, var(--ice) 45%, transparent);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--ice) 35%, transparent), transparent 60%);
  opacity: 0;
}

html[data-depths] .depths-bubbles i {
  animation: depths-rise var(--dur) linear var(--delay) infinite;
}

.depths-bubbles i:nth-child(1) { --x: 8%; --size: 6px; --dur: 11s; --delay: -2s; --drift: 14px; }
.depths-bubbles i:nth-child(2) { --x: 19%; --size: 4px; --dur: 8s; --delay: -6s; --drift: -10px; }
.depths-bubbles i:nth-child(3) { --x: 33%; --size: 9px; --dur: 13s; --delay: -9s; --drift: 18px; }
.depths-bubbles i:nth-child(4) { --x: 47%; --size: 5px; --dur: 9s; --delay: -1s; --drift: -16px; }
.depths-bubbles i:nth-child(5) { --x: 58%; --size: 7px; --dur: 12s; --delay: -4s; --drift: 12px; }
.depths-bubbles i:nth-child(6) { --x: 69%; --size: 4px; --dur: 7s; --delay: -5s; --drift: -8px; }
.depths-bubbles i:nth-child(7) { --x: 78%; --size: 10px; --dur: 14s; --delay: -11s; --drift: 20px; }
.depths-bubbles i:nth-child(8) { --x: 88%; --size: 5px; --dur: 10s; --delay: -7s; --drift: -12px; }
.depths-bubbles i:nth-child(9) { --x: 95%; --size: 6px; --dur: 12s; --delay: -3s; --drift: 10px; }

@keyframes depths-rise {
  0% { translate: 0 0; opacity: 0; }
  12% { opacity: 0.7; }
  85% { opacity: 0.45; }
  100% { translate: var(--drift) -112svh; opacity: 0; }
}

/* ---------------------------------------------------------------- surface */

.depths-surface {
  position: absolute;
  top: var(--s-6);
  left: var(--depths-gutter);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5) 0 var(--s-4);
  border: 0;
  color: var(--ink);
  background: none;
  font-family: var(--font-hud);
  font-size: var(--fs-sm);
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  isolation: isolate;
}

.depths-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--cyan);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  transition: background-color var(--dur-1) linear;
}

.depths-surface:hover::before,
.depths-surface:focus-visible::before {
  background: var(--hot);
}

.depths-surface:focus-visible {
  outline: none;
}

/* Clipped plate: the focus ring is drawn inside it. */
.depths-surface:focus-visible::before {
  box-shadow: inset 0 0 0 2px var(--ink);
}

.depths-surface-arrow {
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 800;
}

html[data-depths] .depths-surface-arrow {
  animation: depths-bob 4s ease-in-out infinite;
}

@keyframes depths-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -3px; }
}

.depths-key {
  padding: 2px 6px 1px;
  color: var(--cyan);
  background: var(--ink);
  font-family: var(--font-code);
  font-size: var(--fs-xs);
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
  clip-path: polygon(2px 0, 100% 0, calc(100% - 2px) 100%, 0 100%);
}

/* ---------------------------------------------------------------- content */

.depths-inner {
  position: relative;
  display: grid;
  gap: var(--s-4);
  width: min(calc(1080px * var(--k)), 100%);
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}

.depths-kicker {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0;
  color: var(--cyan);
  font-family: var(--font-hud);
  font-size: var(--fs-sm);
  font-weight: 800;
  font-style: italic;
  line-height: 1.1;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.depths-kicker::before {
  content: "";
  width: 12px;
  height: 12px;
  background: var(--red);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.depths-title {
  margin: 0;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 400;
  line-height: 0.86;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 4px 0 color-mix(in srgb, var(--ink) 55%, transparent);
}

.depths-lead {
  max-width: 56ch;
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-lg);
  line-height: 1.65;
}

.depths-plates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
  margin-top: var(--s-2);
}

.depths-plate {
  position: relative;
  padding: var(--s-4) var(--s-6) var(--s-4) var(--s-5);
  isolation: isolate;
}

/* Cyan edge for the colophon, gold for the save file. The right edge leans ~2deg. */
.depths-plate::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--cyan) 70%, transparent) 0 3px, transparent 3px),
    linear-gradient(145deg, color-mix(in srgb, var(--abyss) 86%, transparent), color-mix(in srgb, var(--night) 74%, transparent));
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

.depths-plate--save::before {
  background:
    linear-gradient(90deg, var(--gold) 0 3px, transparent 3px),
    linear-gradient(145deg, color-mix(in srgb, var(--abyss) 86%, transparent), color-mix(in srgb, var(--night) 74%, transparent));
}

.depths-plate-title {
  margin: 0 0 var(--s-3);
  color: var(--paper);
  font-family: var(--font-hud);
  font-size: var(--fs-lg);
  font-weight: 800;
  font-style: italic;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.depths-plate--save .depths-plate-title {
  color: var(--gold);
}

.depths-rows {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.depths-row {
  display: grid;
  grid-template-columns: minmax(9.5em, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--line);
}

.depths-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.depths-row-label {
  color: var(--text-3);
  font-family: var(--font-hud);
  font-size: var(--fs-xs);
  font-weight: 800;
  font-style: italic;
  line-height: 1.1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.depths-row-value {
  color: var(--paper);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

/* The engraving: an invitation to the console, cut into the floor. */
.depths-engraving {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  margin-top: var(--s-2);
  padding: 0 var(--s-3) 0 0;
  border: 0;
  color: var(--text-3);
  background: none;
  font-family: var(--font-hud);
  font-size: var(--fs-sm);
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--dur-1) linear;
}

.depths-engraving:hover,
.depths-engraving:focus-visible {
  color: var(--paper);
}

.depths-engraving:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.depths-engraving .depths-key {
  font-size: var(--fs-sm);
}

/* ------------------------------------------------------- short screens */

@media (min-width: 921px) and (max-height: 760px) {
  .depths {
    padding-top: var(--s-9);
    padding-bottom: var(--s-5);
  }

  .depths-inner {
    gap: var(--s-3);
  }

  .depths-title {
    font-size: var(--fs-2xl);
  }

  .depths-lead {
    font-size: var(--fs-md);
  }

  .depths-rows {
    gap: var(--s-1);
  }

  .depths-row {
    padding-bottom: var(--s-1);
  }
}

/* --------------------------------------------------------- reduced motion */

/* A crossfade instead of a camera move. */
@media (prefers-reduced-motion: reduce) and (min-width: 921px) {
  html[data-depths] .shell,
  html[data-depths] .meta-bar {
    translate: none;
    opacity: 0;
    visibility: hidden;
  }

  html[data-depths] .fx-skyline,
  html[data-depths] .fx-slash {
    translate: none;
  }

  .depths {
    translate: none;
    opacity: 0;
  }

  html[data-depths] .depths {
    opacity: 1;
  }
}
