/**
 * Cape conditions — Coast Guard Beach vignette
 * Easy revert: remove this stylesheet, js/cape.js, and #cape from index.html,
 * contact/index.html, and 404.html.
 *
 * Depth: behind waves → ride wave → boat → fore wave
 */

.cape {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  height: clamp(5.5rem, 12vw, 7.25rem);
  pointer-events: none;
  overflow: hidden;
}

.cape__scene {
  position: absolute;
  inset: 0;
}

.cape__waves {
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: 0;
  width: 104%;
  height: 100%;
  display: block;
}

.cape__waves--behind {
  z-index: 1;
}

.cape__waves--ride {
  z-index: 2;
}

.cape__boat-wrap {
  position: absolute;
  right: clamp(1.25rem, 8vw, 5.5rem);
  bottom: 0;
  width: 4.6rem;
  height: 4.2rem;
  z-index: 3;
  /* --bob from ride surface; --sink from click easter egg */
  transform: translate3d(0, calc(var(--bob, -1.15rem) + var(--sink, 0px)), 0);
  transition: none;
  will-change: transform;
  pointer-events: auto;
  cursor: pointer;
  /* Generous hit target around the boat */
  touch-action: manipulation;
}

.cape__boat-wrap::before {
  content: "";
  position: absolute;
  inset: -55% -70% -25%;
  z-index: -1;
}

.cape__boat-wrap[data-sunk="true"] {
  pointer-events: none;
  cursor: default;
  transition: opacity 1.35s ease;
  opacity: 0.15;
}

.cape__boat-wrap[data-sunk="true"] .cape__boat-pitch {
  transition: transform 1.4s cubic-bezier(0.45, 0.05, 0.55, 1);
}

.cape__boat {
  width: 100%;
  height: 100%;
  transform-origin: 18% 78%;
  transform: scaleX(var(--flip, 1));
}

.cape__boat-pitch {
  width: 100%;
  height: 100%;
  /* Mid-hull waterline — tips with the ride surface */
  transform-origin: 58% 76%;
  transform: rotate(var(--pitch, 0deg));
  transition: none;
  will-change: transform;
}

/* Click splash — expanding ring near the boat */
.cape__splash {
  position: absolute;
  z-index: 3;
  width: 0.55rem;
  height: 0.55rem;
  margin: 0;
  border-radius: 50%;
  border: 2px solid rgba(210, 236, 242, 0.75);
  box-shadow: 0 0 0 1px rgba(125, 184, 196, 0.35);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0.9;
  animation: cape-splash 0.85s ease-out forwards;
}

.cape__splash::after {
  content: "";
  position: absolute;
  inset: -0.35rem;
  border-radius: 50%;
  border: 1.5px solid rgba(232, 246, 244, 0.45);
  animation: cape-splash-ring 0.85s ease-out forwards;
}

@keyframes cape-splash {
  0% {
    transform: translate(-50%, -50%) scale(0.35);
    opacity: 0.95;
  }
  100% {
    transform: translate(-50%, -50%) scale(4.2);
    opacity: 0;
  }
}

@keyframes cape-splash-ring {
  0% {
    transform: scale(0.6);
    opacity: 0.7;
  }
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

.cape__waves--fore {
  z-index: 4;
}

.cape__boat-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cape__meta {
  position: absolute;
  left: clamp(1rem, 4vw, 2.5rem);
  bottom: 0.55rem;
  z-index: 5;
  margin: 0;
  font-family: var(--font-body, "Source Sans 3", "Source Sans 3 Fallback", sans-serif);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(201, 221, 228, 0.55);
  white-space: nowrap;
}

.cape[data-wind="idle"] .cape__meta {
  color: rgba(201, 221, 228, 0.4);
}

/* Keep page content clear of the band.
   Home already clears it (the shell's own padding), so the shared pad
   only added an empty scroll on that page. */
body {
  padding-bottom: clamp(5.5rem, 12vw, 7.25rem);
}

body:has(.shell) {
  padding-bottom: 0;
}

/* Side-by-side home: keep the brand column above the band without
   forcing a scroll. The column is capped to the space above the band and
   only the portrait shrinks to make room. Below ~720px tall even the
   smallest portrait won't fit, so those windows scroll instead (next rule). */
@media (min-width: 900px) and (min-height: 720px) {
  body:has(.shell) .brand {
    max-height: calc(
      100vh - var(--nav-h) - 1.5rem - clamp(5.5rem, 12vw, 7.25rem) - 0.75rem
    );
  }

  body:has(.shell) .brand > * {
    flex-shrink: 0;
  }

  body:has(.shell) .brand > .portrait {
    height: auto;
    flex: 0 1 11.5rem;
    min-height: 6rem;
  }
}

/* Side-by-side home: one band-sized pad for both columns, inside the
   shell's min-height, so the page scrolls only when content would
   otherwise sit under the band. */
@media (min-width: 900px) {
  body:has(.shell) .shell {
    padding-bottom: calc(clamp(5.5rem, 12vw, 7.25rem) + 0.75rem);
  }

  body:has(.shell) .shell .deck {
    padding-bottom: 0;
  }
}

@media (max-width: 560px) {
  .cape__boat-wrap {
    right: 0.85rem;
    width: 3.6rem;
    height: 3.3rem;
  }

  .cape__meta {
    font-size: 0.62rem;
    max-width: calc(100% - 5rem);
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
