@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=Inter:wght@300;400;500&display=swap");

:root {
  --gold: #c9a86a;
  --gold-bright: #e3c48a;
  --cream: #f6efe2;
  --ink: #1c1a16;
  --glass-bg: rgba(20, 18, 14, 0.38);
  --glass-border: rgba(255, 244, 222, 0.22);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  /* Fallback chain: 100% for very old browsers, 100dvh for browsers
     that support it but where the inline script hasn't run yet, then
     --app-height (set by that script from visualViewport, kept live on
     resize) wins once it's available — the most reliable of the three
     against Safari's floating address-bar bubble not being reflected
     by dvh alone on every version. */
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: #0c1018;
  font-family: "Inter", sans-serif;
  color: var(--cream);
  -webkit-tap-highlight-color: transparent;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  /* Guests drag to rotate the camera (see initGuestRotate in main.js) —
     this stops the browser's own touch-scroll/gesture handling from
     fighting with that custom pointer-drag logic. */
  touch-action: none;
}

/* ---------------------------------------------------------------- */
/* Loading screen                                                    */
/* ---------------------------------------------------------------- */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 30%, #2a2115 0%, #0c1018 70%);
  transition: opacity 0.8s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#loading-screen[hidden] {
  display: none;
}

.loading-content {
  text-align: center;
}

.loading-names {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: clamp(2rem, 6vw, 3.2rem);
  letter-spacing: 0.04em;
  color: var(--gold-bright);
}

.loading-spinner {
  margin: 1.4rem auto 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(227, 196, 138, 0.25);
  border-top-color: var(--gold-bright);
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------- */
/* Token warning (only shown if Mapbox token is missing)             */
/* ---------------------------------------------------------------- */

#token-warning {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #0c1018;
  text-align: center;
}

#token-warning[hidden] {
  display: none;
}

#token-warning .box {
  max-width: 480px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.03);
}

#token-warning h2 {
  font-family: "Cormorant Garamond", serif;
  color: var(--gold-bright);
  margin-top: 0;
}

#token-warning code {
  display: block;
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
  word-break: break-all;
}

/* ---------------------------------------------------------------- */
/* Overlay card                                                      */
/* ---------------------------------------------------------------- */

#overlay {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 14vh 1.5rem 2.4rem;
  text-align: center;
  /* Fades transparently into the map at the top edge, solidifying toward
     the bottom so the 3D scene stays visible while the text stays legible. */
  background: linear-gradient(
    to bottom,
    rgba(10, 12, 18, 0) 0%,
    rgba(10, 12, 18, 0.35) 35%,
    rgba(10, 12, 18, 0.72) 65%,
    rgba(10, 12, 18, 0.86) 100%
  );
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* backdrop-filter blurs its whole box uniformly — without a mask the
     blur has a hard on/off edge even though the background color above
     is transparent. Masking the element fades the blur itself too, so
     there's no seam where the band begins. */
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.25) 25%,
    rgba(0, 0, 0, 0.65) 45%,
    black 70%,
    black 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.25) 25%,
    rgba(0, 0, 0, 0.65) 45%,
    black 70%,
    black 100%
  );
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 1.1s ease, transform 1.1s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: max(2.4rem, calc(env(safe-area-inset-bottom) + 1.4rem));
  pointer-events: none;
}

#overlay.visible {
  opacity: 1;
  transform: translateY(0);
}

#overlay > * {
  pointer-events: auto;
}

.kicker {
  font-size: 0.68rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.6rem;
}

.couple-names {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: clamp(2rem, 7vw, 2.7rem);
  letter-spacing: 0.02em;
  color: var(--cream);
  margin: 0 0 0.5rem;
}

.wedding-date {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.15rem, 3.6vw, 1.4rem);
  color: var(--gold-bright);
  margin: 0 0 0.15rem;
  letter-spacing: 0.03em;
}

.venue-name {
  font-size: 0.82rem;
  font-weight: 300;
  color: rgba(246, 239, 226, 0.72);
  margin: 0 0 1.5rem;
  letter-spacing: 0.02em;
}

.save-date-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.9rem;
  border-radius: 999px;
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #1c1508;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  box-shadow: 0 8px 24px rgba(201, 168, 106, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.save-date-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(201, 168, 106, 0.45);
}

.save-date-btn:active {
  transform: translateY(0);
}

.save-date-btn:disabled {
  opacity: 0.7;
  cursor: default;
  pointer-events: none;
}

.save-date-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- */
/* Mapbox control tweaks                                             */
/* ---------------------------------------------------------------- */

.mapboxgl-ctrl-logo,
.mapboxgl-ctrl-attrib {
  opacity: 0.55;
}

/* ---------------------------------------------------------------- */
/* Music toggle                                                      */
/* ---------------------------------------------------------------- */

#music-toggle {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 25;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(20, 18, 14, 0.5);
  color: rgba(246, 239, 226, 0.85);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  transition: color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

#music-toggle[hidden] {
  display: none;
}

#music-toggle svg {
  width: 18px;
  height: 18px;
}

#music-toggle:hover {
  transform: translateY(-1px);
}

#music-toggle.playing {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
}

/* Gentle pulse ring inviting a tap, only while muted */
#music-toggle:not(.playing)::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--gold-bright);
  opacity: 0;
  animation: music-pulse 3.2s ease-out infinite;
}

@keyframes music-pulse {
  0% {
    transform: scale(1);
    opacity: 0.45;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- */
/* Debug camera HUD (dev tool — not shown to guests by default)      */
/* ---------------------------------------------------------------- */

#debug-toggle {
  position: fixed;
  right: 14px;
  top: 50px;
  z-index: 50;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(12, 16, 24, 0.55);
  color: rgba(255, 255, 255, 0.55);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

#debug-toggle.active {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
}

#debug-hud {
  position: fixed;
  right: 14px;
  top: 92px;
  z-index: 50;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  width: 240px;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  background: rgba(10, 14, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.72rem;
  color: #e8e8e8;
}

#debug-hud[hidden] {
  display: none;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.15rem 0;
}

.debug-row span {
  color: rgba(255, 255, 255, 0.5);
}

.debug-row.muted {
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  margin-top: 0.3rem;
  padding-top: 0.35rem;
}

#debug-copy,
.debug-btn {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: transparent;
  color: var(--gold-bright);
  font-family: inherit;
  font-size: 0.68rem;
  cursor: pointer;
}

#debug-copy:hover,
.debug-btn:hover {
  background: rgba(201, 168, 106, 0.12);
}

.debug-btn[hidden] {
  display: none;
}

.debug-hint {
  margin-top: 0.7rem;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.4;
}

#debug-copy-status,
.debug-status {
  margin-top: 0.35rem;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.55);
  word-break: break-all;
  max-height: 90px;
  overflow-y: auto;
}

.debug-section-title {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--gold-bright);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.debug-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  margin-top: 0.4rem;
  color: rgba(255, 255, 255, 0.6);
}

.debug-field b {
  color: #e8e8e8;
  font-weight: 500;
}

.debug-checkbox-field input[type="checkbox"] {
  accent-color: var(--gold-bright);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.cart-vertex-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid #1a1208;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: grab;
}

.cart-vertex-marker:active {
  cursor: grabbing;
}

.debug-field input[type="range"] {
  width: 100%;
  height: 14px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.debug-field input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.debug-field input[type="range"]::-moz-range-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.debug-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -5px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: none;
}

.debug-field input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: none;
}

@media (max-width: 640px) {
  #overlay {
    padding-top: 22vh;
    padding-left: 1.2rem;
    padding-right: 1.2rem;
  }

  .venue-name {
    margin-bottom: 1.15rem;
  }
}
