/* Background music: fixed toggle, intro prompt and the visible YouTube player card.
   Shared by index.html and atlas.html. Never touches overflow or the scrolling roots. */

/* ---------- fixed toggle (top right) ---------- */
.bgm-control {
  position: fixed; z-index: 30;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  pointer-events: none;
}
.bgm-control > * { pointer-events: auto; }
/* The unboxing overlay sits at z-index:9999. Keep the toggle accessible over it. */
body.opening .bgm-control { z-index: 10010; }
/* A non-opening exclusion zone around the control; the real toggle stays above it. */
body.opening .bgm-control::before {
  content: ''; position: absolute; inset: -10px; pointer-events: auto;
}
body.opening .bgm-control > * { position: relative; z-index: 1; }
.atlas-page .bgm-control { top: calc(16px + env(safe-area-inset-top, 0px)); } /* centred on the Atlas header */

.bgm-toggle {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 0 13px 0 11px;
  border: 1px solid rgba(21, 43, 45, .2); border-radius: 999px;
  background: rgba(248, 247, 243, .86);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #152b2d; font: 600 10px/1 var(--sans, 'DM Sans', Arial, sans-serif); letter-spacing: .14em;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: color .2s ease, border-color .2s ease;
}
.bgm-toggle::after { content: ''; position: absolute; inset: -5px -4px; } /* 46px tall touch target */
.bgm-toggle[aria-pressed="true"] { color: #1f7f79; border-color: rgba(31, 127, 121, .42); }
.bgm-toggle.is-pending .bgm-label { opacity: .5; }
.bgm-icon { width: 17px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.2;
  stroke-linecap: round; stroke-linejoin: round; }
.bgm-toggle[aria-pressed="true"] .bgm-mute,
.bgm-toggle[aria-pressed="false"] .bgm-wave { display: none; }

.bgm-hint {
  margin: 0; max-width: min(240px, calc(100vw - 24px)); padding: 6px 11px; border-radius: 999px;
  background: rgba(21, 43, 45, .78); color: #f8f7f3;
  font: italic 400 12px/1.35 var(--serif, Georgia, serif); letter-spacing: .01em; text-align: right;
  opacity: 0; visibility: hidden; transform: translateY(-3px);
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}
.bgm-hint.is-visible { opacity: 1; visibility: visible; transform: none; transition: opacity .35s ease, transform .35s ease; }

/* ---------- invitation intro: minimal transparent Korean tap prompt ---------- */
.unbox-choices {
  position: absolute; z-index: 3; left: 50%;
  bottom: 42svh;
  transform: translateX(-50%); width: min(260px, calc(100vw - 48px));
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.unbox-overlay.is-armed .unbox-choices {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: opacity .7s ease .4s, visibility 0s;
}
/* Skip is available only after the box starts opening. */
.unbox-overlay.is-armed .unbox-skip { display: none; }
.unbox-tap {
  display: inline-flex; justify-content: center; align-items: center;
  min-height: 44px; min-width: 0; padding: 8px 14px;
  border: none; border-radius: 0; background: transparent;
  box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  color: #152b2d; text-shadow: 0 1px 3px rgba(248, 247, 243, .28);
  font: 500 16px/1.5 var(--kr, 'Noto Serif KR', serif);
  letter-spacing: -.03em; white-space: nowrap; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.unbox-tap:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* ---------- visible YouTube player card ---------- */
.bgm-card { margin: 0; display: grid; gap: 14px; }
.bgm-card-caption { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
/* At least 200 x 200 px, as the YouTube embed policy requires. */
.bgm-frame { position: relative; width: 100%; max-width: 480px; min-width: 200px;
  aspect-ratio: 16 / 9; min-height: 200px; background: #0f2224; overflow: hidden; }
.bgm-frame iframe, .bgm-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Shared music card. It stays in one place in the DOM while the invitation and the Atlas swap
   around it, so the player is never moved or hidden.
   Invitation order: body copy -> J & S. (.site-footer-signature) -> Music (.bgm-dock) -> footer links.
   Atlas order: Atlas content -> Return button -> Music. */
.bgm-dock { display: flow-root; background: #192f31; padding-top: 55px; } /* flow-root keeps the card margin inside the dark band */
.bgm-dock .bgm-card { max-width: 480px; margin-bottom: 52px; color: rgba(248, 247, 243, .9); }
.bgm-dock .bgm-card .micro { color: rgba(248, 247, 243, .55); }
.invitation-page .site-footer-signature { display: flow-root; padding-bottom: 0; }
.invitation-page .site-footer-signature .footer-title { margin-bottom: 40px; }
.invitation-page .bgm-dock { padding-top: 0; } /* continues straight under J & S. */
.invitation-page .bgm-dock .bgm-card { margin-bottom: 44px; }
.invitation-page .bgm-dock + .site-footer { padding-top: 0; display: flow-root; } /* footer links continue the band */
/* The return button now precedes the shared music card in both mounting modes. */
.atlas-page .atlas-footer { padding-bottom: 12px; }
.atlas-page .bgm-dock { background: #193535; padding-top: 16px; }
.atlas-page .bgm-dock .bgm-card { margin-bottom: 36px; }
@media (max-width: 700px) { .atlas-page .atlas-footer { padding-bottom: 8px; } .atlas-page .bgm-dock { padding-top: 12px; } }

/* App shell: only the active view is displayed (no overflow changes anywhere). */
[data-shell-view][hidden] { display: none !important; }
body.shell-loading, body.shell-loading a { cursor: progress; }

@media (prefers-reduced-motion: reduce) {
  .bgm-hint, .bgm-hint.is-visible, .unbox-choices, .unbox-overlay.is-armed .unbox-choices { transition: none; }
  .unbox-overlay.is-armed .unbox-tap { animation: none; }
}
