/* Black Pearl Ventures: homepage descent and captain's quarters.
   Loaded only by index.html, after styles.css.
   The page becomes one tall scroll (.voyage). The hero stays pinned to the screen
   while descent.js turns scroll position into: wordmark out, the descent video
   scrubbing from the surface to black, then the cabin scrolling up from the bottom
   of the screen out of the darkness, with its markers.
   Tweak knobs: --voyage-length (how much scrolling the whole trip takes) and
   --gold (the marker color). */

:root{
  --voyage-length:590vh;
  --gold:#d4af6a;
}

/* styles.css locks the page to one screen; the homepage needs to scroll. */
html{height:auto}
body{height:auto;overflow-x:hidden;overflow-y:auto}

.voyage{position:relative;height:var(--voyage-length)}
.voyage .hero{position:sticky;top:0}
/* The wordmark fades out but still sits across the middle of the screen; let clicks through to the markers under it. */
.voyage .wordmark{pointer-events:none}

/* The descent video sits on top of the ship loop and shares its framing
   (same .hero-video class, so it gets the same crop, brightness and portrait strip). */
.descent-video{
  background:#000;
  opacity:0;
  z-index:1;
  pointer-events:none;
}
/* The clip drawn through WebGL (descent.js). It takes the same framing as the video because
   it shares the .hero-video class; the script hides the plain video once this is running. */
.descent-gl{
  background:#000;
  opacity:0;
  z-index:1;
  pointer-events:none;
}
/* Specks drifting in the water once you are under, drawn by the script; they move with how fast you scroll. */
.sea-dust{
  position:absolute;
  inset:0;
  z-index:1;
  width:100%;
  height:100%;
  display:block;
  pointer-events:none;
}
.descent-black{
  position:absolute;
  inset:0;
  z-index:1;
  background:#000;
  opacity:0;
  pointer-events:none;
}

/* Captain's quarters */
.cabin{
  position:absolute;
  inset:0;
  z-index:2;
  visibility:hidden;
  pointer-events:none;
  overflow:hidden;
  --spots:0;
}
.cabin.is-open{pointer-events:auto}

/* The plate is sized like "cover" but never crops more than 9% off each side,
   so every marker stays on screen. Markers are placed in % of this frame,
   which keeps them glued to their objects at any screen size. */
.cabin-frame{
  position:absolute;
  left:50%;
  top:50%;
  width:min(max(100vw,calc(100vh * 1.791)),118vw);
  width:min(max(100vw,calc(100svh * 1.791)),118vw);
  aspect-ratio:1456/813;
  /* descent.js sets --rise (how far below its resting place the cabin sits, in px)
     and --feather (how much of its top edge dissolves into the black) while it scrolls up. */
  transform:translate(-50%,calc(-50% + var(--rise,0px)));
  -webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 var(--feather,7%),#000 93%,transparent 100%);
  mask-image:linear-gradient(to bottom,transparent 0,#000 var(--feather,7%),#000 93%,transparent 100%);
  will-change:transform;
}
.cabin-plate{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
/* Flickering light on the candles and lanterns, so the cabin is never a frozen picture. */
.cabin-glows{position:absolute;inset:0;pointer-events:none;mix-blend-mode:screen}
.glow{
  position:absolute;
  left:var(--x);
  top:var(--y);
  width:var(--s);
  aspect-ratio:1;
  transform:translate(-50%,-50%);
  border-radius:50%;
  background:radial-gradient(circle,rgba(255,170,80,.34) 0,rgba(255,140,50,.14) 35%,rgba(255,120,40,0) 70%);
  animation:glow-flicker var(--d,3s) ease-in-out infinite;
}
@keyframes glow-flicker{
  0%{opacity:.55;transform:translate(-50%,-50%) scale(.96)}
  18%{opacity:.9;transform:translate(-50%,-50%) scale(1.03)}
  31%{opacity:.62;transform:translate(-50%,-50%) scale(.98)}
  47%{opacity:1;transform:translate(-50%,-50%) scale(1.05)}
  63%{opacity:.7;transform:translate(-50%,-50%) scale(1)}
  78%{opacity:.95;transform:translate(-50%,-50%) scale(1.04)}
  100%{opacity:.55;transform:translate(-50%,-50%) scale(.96)}
}
.cabin-shade{
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(to bottom,rgba(0,0,0,.7) 0%,rgba(0,0,0,0) 20%,rgba(0,0,0,0) 74%,rgba(0,0,0,.8) 100%),
    radial-gradient(ellipse 82% 80% at 50% 52%,rgba(0,0,0,0) 48%,rgba(0,0,0,.8) 100%);
}

/* Venture markers: a 44px tap target with a gold dot and a label. */
.spot{
  position:absolute;
  left:var(--x);
  top:var(--y);
  width:44px;
  height:44px;
  margin:-22px 0 0 -22px;
  padding:0;
  border:0;
  background:none;
  color:inherit;
  font:inherit;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:var(--spots);
  -webkit-tap-highlight-color:transparent;
}
.spot:focus-visible{outline:1px solid rgba(255,255,255,.5);outline-offset:2px;border-radius:50%}
.spot-dot{
  display:block;
  width:10px;
  height:10px;
  border-radius:50%;
  background:var(--gold);
  box-shadow:0 0 0 4px rgba(212,175,106,.3),0 0 22px 4px rgba(212,175,106,.55);
  transition:box-shadow .3s ease,transform .3s ease;
  animation:spot-breathe 3.2s ease-in-out infinite;
}
.spot:hover .spot-dot,
.spot:focus-visible .spot-dot,
.spot[aria-pressed="true"] .spot-dot{
  box-shadow:0 0 0 9px rgba(212,175,106,.3),0 0 26px 6px rgba(212,175,106,.7);
  animation:none;
}
@keyframes spot-breathe{
  0%,100%{transform:scale(1)}
  50%{transform:scale(1.25)}
}
.spot-label{
  position:absolute;
  top:100%;
  left:50%;
  transform:translateX(-50%);
  white-space:nowrap;
  font-size:10px;
  letter-spacing:.3em;
  text-transform:uppercase;
  color:#b5b1a9;
  text-shadow:0 0 6px #000,0 0 12px #000;
  transition:color .25s;
}
.spot:hover .spot-label,
.spot:focus-visible .spot-label,
.spot[aria-pressed="true"] .spot-label{color:var(--ink)}

/* Caption for the selected object, bottom center of the screen. */
.cabin-caption{
  position:absolute;
  left:0;
  right:0;
  bottom:calc(30px + env(safe-area-inset-bottom));
  padding:0 20px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  text-align:center;
  opacity:var(--spots);
  min-height:92px;
  justify-content:flex-end;
}
.cabin-object{
  font-size:10px;
  letter-spacing:.36em;
  text-transform:uppercase;
  color:var(--nav);
}
.cabin-name{
  margin:0;
  font-family:'Cormorant Garamond',Georgia,'Times New Roman',serif;
  font-weight:300;
  font-size:clamp(20px,2.4vw,30px);
  line-height:1.1;
  letter-spacing:.24em;
  text-transform:uppercase;
  color:var(--ink);
  text-shadow:0 2px 30px rgba(0,0,0,.9);
}
.cabin-enter{
  font-size:11px;
  letter-spacing:.36em;
  text-transform:uppercase;
  color:var(--gold);
  border-bottom:1px solid var(--gold);
  min-height:44px;
  display:inline-flex;
  align-items:center;
  padding:0 2px;
}
.cabin-enter:hover,.cabin-enter:focus-visible{color:#fff;border-bottom-color:#fff}
.cabin-enter[hidden]{display:none}

/* Small screens: the dots stay, the labels go, and the caption names the object. */
@media (max-width:700px){
  .spot-label{display:none}
}

@media (prefers-reduced-motion:reduce){
  .glow{animation:none;opacity:.75}
  .spot-dot{animation:none;transition:none}
}
