/* Pirate Walk — full-bleed 2D FP walk (bob/roll; center always filled) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050403;
  color: #c8b89a;
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #050403;
  transform-origin: 50% 62%;
  will-change: transform;
  /* Following-sea roll driven on #stage (JS); plate dolly stays on .plate */
}

.camera {
  position: absolute;
  inset: 0;
  transform-origin: 50% 55%;
  will-change: transform;
  overflow: hidden;
}

.world {
  position: absolute;
  inset: 0;
  will-change: transform;
  background: #0a0604;
  overflow: hidden;
}

/* Full-bleed scene plates — CENTER of viewport IS the scene */
.plate {
  position: absolute;
  inset: -2%;
  width: auto;
  height: auto;
  left: -2%;
  top: -2%;
  right: -2%;
  bottom: -2%;
  background-position: center center;
  background-size: cover;
  transition: opacity 90ms linear;
  background-repeat: no-repeat;
  opacity: 0;
  will-change: transform, opacity;
  transform-origin: 50% 50%;
  filter: contrast(1.08) saturate(0.88) brightness(0.92);
  pointer-events: none;
}

/* Walking silhouette arms removed (Thomas: bowling-pin look) — soft-break photoreal hands only */

/* Soft-break photoreal FP arm+hand — JS drives continuous raise from below */
.hand {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 0;
  width: min(78vw, 720px);
  max-width: 96vw;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 70%) scale(0.96);
  will-change: transform, opacity;
}
.hand.show {
  opacity: 1;
  pointer-events: auto;
}
.hand.subtle { width: min(52vw, 420px); filter: brightness(0.75) contrast(1.05); }
.hand.compass { width: min(80vw, 740px); }
.hand.handoff { width: min(80vw, 740px); }
.hand.wheel { width: min(88vw, 820px); max-width: 98vw; }


.hand-btn {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  box-shadow: none;
  border-radius: 0;
  backdrop-filter: none;
  animation: none;
}
.hand-btn:active { transform: scale(0.985); }
.hand-btn:focus { outline: none; }
.hand-btn:focus-visible {
  outline: 1px solid rgba(180, 140, 80, 0.35);
  outline-offset: 4px;
}

.hand-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(72vh, 640px);
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  filter: drop-shadow(0 14px 32px rgba(0, 0, 0, 0.8));
  mix-blend-mode: normal;
}

.hud {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  padding: 0.5rem 1rem calc(0.65rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(4,3,2,0.95), rgba(4,3,2,0.4) 70%, transparent);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.35rem 0.75rem;
  align-items: end;
}

.beat {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9a8868;
  text-shadow: 0 1px 4px #000;
}

.scrub {
  flex: 1;
  min-width: 0;
}
.scrub input[type="range"] {
  width: 100%;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #1e1410, #4a3220 50%, #6a4020);
  outline: none;
  cursor: pointer;
}
.scrub input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #a89060;
  border: 2px solid #2a1a10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.scrub-marks {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: #6a5a48;
  margin-top: 0.15rem;
  text-transform: uppercase;
}

.mute-btn {
  align-self: center;
  background: rgba(12, 8, 5, 0.85);
  border: 1px solid rgba(140, 100, 50, 0.35);
  color: #c8b89a;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}
.mute-btn[aria-pressed="false"] {
  border-color: rgba(100, 160, 100, 0.45);
  color: #a8c8a0;
}

.attr {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: 0.4rem 0.75rem calc(0.35rem + env(safe-area-inset-top));
  font-size: 0.58rem;
  line-height: 1.35;
  color: rgba(160, 140, 110, 0.5);
  background: linear-gradient(to bottom, rgba(4,3,2,0.8), transparent);
  pointer-events: none;
}
.attr a {
  color: rgba(180, 150, 100, 0.7);
  pointer-events: auto;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 520px) {
  .hand { width: min(88vw, 480px); bottom: 8%; }
  .hand-img { max-height: min(50vh, 400px); }
  .attr { font-size: 0.52rem; }
  .beat { font-size: 0.68rem; }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .hand-btn { animation: none; }
}

/* Closing ship: clickable links painted into the sails */
.sail-links {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}
.sail-hot {
  position: absolute;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.6rem;
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(0.7rem, 1.8vw, 1.05rem);
  letter-spacing: 0.04em;
  color: rgba(35, 28, 18, 0.92);
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(220, 200, 160, 0.35);
  background: rgba(210, 190, 150, 0.12);
  border: 1px solid rgba(60, 45, 25, 0.25);
  border-radius: 2px;
  transform: rotate(-4deg);
  transition: background 0.2s ease, color 0.2s ease;
}
.sail-hot:hover,
.sail-hot:focus-visible {
  background: rgba(230, 210, 170, 0.35);
  color: #1a1208;
  outline: none;
}
.sail-hot-a {
  left: 38%;
  top: 22%;
  width: min(28vw, 320px);
  height: min(14vh, 110px);
  transform: rotate(-6deg);
}
.sail-hot-b {
  left: 58%;
  top: 28%;
  width: min(22vw, 260px);
  height: min(11vh, 90px);
  transform: rotate(3deg);
  font-size: clamp(0.6rem, 1.4vw, 0.9rem);
}
@media (max-width: 520px) {
  .sail-hot-a { left: 32%; top: 20%; width: 42vw; }
  .sail-hot-b { left: 55%; top: 30%; width: 34vw; }
}


/* Quarters: base framing leaves room for left-table → door pan */
.plate[data-id="quarters"] {
  background-position: 35% 55%;
  background-size: cover;
}
@media (max-width: 900px) {
  .plate[data-id="quarters"] {
    background-position: 30% 58%;
    background-size: 112% auto;
  }
}
@media (max-width: 600px) and (orientation: portrait) {
  .plate[data-id="quarters"] {
    background-position: 28% 56%;
    background-size: 128% auto;
  }
}


/* Closing ship: subtle sail billow (whole plate, origin on sails) */
@keyframes sailBillow {
  0%   { filter: brightness(1); }
  50%  { filter: brightness(1.03); }
  100% { filter: brightness(1); }
}
.plate[data-id="ship"].sails-live {
  will-change: transform;
}
.sail-links.sails-live .sail-hot {
  transition: transform 0.4s ease-out;
}
