/* ====================================================================
   Desert Country — World v1.0
   ====================================================================
   CSS-only desert dusk scene. No external assets.
   Layers (back→front):
     sky → sun glow → mesas → motel → road → dashes → dust → sheen → grain → vignette
   Palette is warm: --rik-gold (#C89B2C) + --rik-dust (#A98A63) +
   deep warm black (#0f0a06) + sunset orange (#b8541a).
   ==================================================================== */

/* ---------- Tokens specific to Desert Country (override or extend root) ---------- */
:root {
  --dc-sky-top: #1a1208;
  --dc-sky-mid: #4a2a18;
  --dc-sky-horizon: #c46d24;
  --dc-sky-glow: #f4c272;
  --dc-foreground: #0a0604;
  --dc-road: #1f1410;
  --dc-road-edge: #3a2618;
  --dc-dash: #c89b2c;
  --dc-motel-light: #f4e4b4;
  --dc-dust-haze: rgba(212, 160, 23, 0.18);
}

/* ---------- Base ---------- */
html.from-atlas, html.from-atlas body { background: #0a0604; }
html.from-atlas body { animation: dc-fade-in 700ms ease-out 80ms both; }
@keyframes dc-fade-in { from { opacity: 0; } to { opacity: 1; } }

.world-body {
  margin: 0;
  background: #0a0604;
  color: var(--paper);
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.world-skiplink {
  position: absolute; top: -100px; left: 0;
  background: var(--rik-gold); color: var(--bg-deep);
  padding: 0.5rem 1rem; z-index: 10000; text-decoration: none;
  font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em;
  text-transform: uppercase;
}
.world-skiplink:focus { top: 0; }

/* ---------- Header ---------- */
.world-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.8rem 1.5rem;
  background: rgba(10, 6, 4, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(200, 155, 44, 0.08);
}

.world-header-brand, .world-header-back {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--paper); text-decoration: none;
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  transition: color 0.2s;
}
.world-header-brand:hover, .world-header-back:hover { color: var(--rik-gold); }
.world-header-brand .tri { color: var(--rik-gold); font-style: normal; line-height: 1; }
.world-header-brand .brand-name { font-weight: 700; letter-spacing: 0.2em; }
.world-header-back .back-arrow { color: var(--rik-gold); }

/* ---------- Main scene wrapper ---------- */
#world-main { position: relative; }

.world-scene {
  position: relative;
  width: 100%;
  height: calc(100vh - 60px);
  min-height: 540px;
  overflow: hidden;
}

/* ---------- Scene background (v1.1 master image + atmospheric overlays) ---------- */
.scene-bg { position: absolute; inset: 0; overflow: hidden; }

/* Master image — fills the viewport, object-position keeps key anchors visible on portrait */
.scene-image-wrap {
  position: absolute; inset: 0;
  display: block;
}
.scene-image {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  /* Desktop: center · Mobile: bottom-center to preserve road + mailbox + motel base */
  object-position: center center;
  display: block;
  background: var(--dc-foreground);
}

/* Dust haze — atmospheric layer (preserved from v1.0, sits on top of master) */
.scene-dust {
  position: absolute; inset: 0;
  background:
    radial-gradient(
      ellipse 80% 35% at 50% 65%,
      var(--dc-dust-haze),
      transparent 70%
    );
  mix-blend-mode: screen;
  pointer-events: none;
  opacity: 0.45;
}

/* Grain texture — subtle film noise */
.scene-grain {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(rgba(200, 155, 44, 0.02) 1px, transparent 1px),
    radial-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 3px 3px, 5px 5px;
  background-position: 0 0, 1px 1px;
  opacity: 0.4;
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* Vignette */
.scene-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 35%,
    rgba(10, 6, 4, 0.35) 75%,
    rgba(10, 6, 4, 0.65) 100%
  );
  pointer-events: none;
}

/* v1.1.1 · Subtle bird silhouettes drifting across the dusk sky.
   Pure CSS, inline SVG via data URI, no external assets, no JS.
   Curve-style "M" silhouette — classic watercolor / illustration style, not cartoon. */
.scene-birds {
  position: absolute;
  left: 0; right: 0;
  top: 0; height: 45%;        /* Only fly in the sky region */
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.bird {
  position: absolute;
  width: 14px; height: 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 6' preserveAspectRatio='none'><path d='M 0.5 5 Q 3.5 0.5 7 3 Q 10.5 0.5 13.5 5' fill='none' stroke='%23120a05' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.32;
  will-change: transform;
  /* Anchor off-screen left at start */
  left: -3vw;
}

@keyframes dc-bird-fly {
  0%   { transform: translate(0, 0); opacity: 0; }
  6%   { opacity: 0.32; }
  50%  { transform: translate(55vw, -1.2vh); opacity: 0.28; }
  94%  { opacity: 0.32; }
  100% { transform: translate(110vw, -2vh); opacity: 0; }
}

/* 5 birds with staggered timing + slightly different sizes for natural distribution */
.bird-1 { top: 18%; width: 14px; animation: dc-bird-fly 95s linear infinite; }
.bird-2 { top: 24%; width: 11px; opacity: 0.26; animation: dc-bird-fly 115s linear infinite -22s; }
.bird-3 { top: 14%; width: 16px; animation: dc-bird-fly 78s linear infinite -48s; }
.bird-4 { top: 28%; width: 10px; opacity: 0.24; animation: dc-bird-fly 105s linear infinite -65s; }
.bird-5 { top: 21%; width: 13px; animation: dc-bird-fly 88s linear infinite -82s; }

/* ---------- Scene chrome ---------- */
.scene-chrome {
  position: absolute; top: 1.5rem; left: 1.5rem;
  z-index: 5; pointer-events: none;
}

.scene-eyebrow {
  margin: 0;
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--paper-muted);
}
.scene-eyebrow .tri { color: var(--rik-gold); font-style: normal; margin-right: 0.4rem; }

.scene-byline {
  margin: 0.6rem 0 0 0;
  font-size: 1.4rem; font-weight: 600; color: var(--paper);
}
.scene-byline .by { color: var(--paper-muted); font-weight: 400; }

/* ---------- Hint chip ---------- */
.scene-hint {
  position: absolute; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 1rem;
  background: rgba(10, 6, 4, 0.7);
  border: 1px solid rgba(200, 155, 44, 0.18);
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--paper-muted);
  pointer-events: none;
}
.hint-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rik-gold);
  box-shadow: 0 0 8px var(--rik-gold);
  animation: dc-hint-pulse 1.8s ease-in-out infinite;
}
@keyframes dc-hint-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

/* ---------- Coord chip ---------- */
.scene-coord {
  position: absolute; bottom: 1.5rem; right: 1.5rem;
  z-index: 5;
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--paper-muted);
  pointer-events: none;
}
.scene-coord .coord-key { color: var(--rik-gold); margin-right: 0.5rem; }

/* ---------- Hotspots ---------- */
.world-hotspots {
  position: absolute; inset: 0;
  z-index: 10;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; margin: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  outline: none;
}

.hotspot::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--rik-gold);
  box-shadow:
    0 0 0 4px rgba(200, 155, 44, 0.18),
    0 0 16px 4px rgba(200, 155, 44, 0.45);
  transition: transform 0.25s, box-shadow 0.25s;
  animation: dc-hotspot-pulse 2.4s ease-in-out infinite;
}

.hotspot:hover::before, .hotspot:focus-visible::before {
  transform: scale(1.2);
  box-shadow:
    0 0 0 6px rgba(200, 155, 44, 0.28),
    0 0 28px 10px rgba(200, 155, 44, 0.65);
}

.hotspot-label {
  position: absolute;
  top: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 0.4rem 0.75rem;
  background: rgba(10, 6, 4, 0.92);
  border: 1px solid rgba(200, 155, 44, 0.3);
  border-radius: 2px;
  font-family: var(--font-mono); font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--paper);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease-out;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}
.hotspot-label .label-glyph { color: var(--rik-gold); margin-right: 0.45rem; line-height: 1; }
.hotspot-label .label-text-short { display: none; }

.hotspot:hover .hotspot-label,
.hotspot:focus-visible .hotspot-label {
  opacity: 1;
  /* No translateY — labels stay rigidly anchored to the dot, no float */
}

.hotspot.is-locked::before {
  background: var(--paper-muted);
  box-shadow:
    0 0 0 4px rgba(154, 154, 147, 0.14),
    0 0 12px 2px rgba(154, 154, 147, 0.3);
  animation-duration: 4.5s;
}

@keyframes dc-hotspot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ---------- Drawer ---------- */
.world-drawer {
  position: fixed; inset: 0;
  z-index: 1000;
  pointer-events: none;
}
.world-drawer:not([hidden]) { pointer-events: auto; }

.drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 6, 4, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s;
}
.world-drawer:not([hidden]) .drawer-backdrop { opacity: 1; }

.drawer-panel {
  position: absolute;
  background: #110a06;
  border: 1px solid rgba(200, 155, 44, 0.12);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column;
  /* Mobile: bottom sheet */
  left: 0; right: 0; bottom: 0; top: auto;
  max-height: 78vh;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  border-radius: 12px 12px 0 0;
}
.world-drawer:not([hidden]) .drawer-panel { transform: translateY(0); }

/* Desktop: right sidebar */
@media (min-width: 768px) {
  .drawer-panel {
    left: auto; right: 0; top: 0; bottom: 0;
    width: 420px; max-height: 100vh;
    transform: translateX(100%);
    border-radius: 0;
    border-left: 1px solid rgba(200, 155, 44, 0.15);
  }
  .world-drawer:not([hidden]) .drawer-panel { transform: translateX(0); }
}

.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(200, 155, 44, 0.08);
}

.drawer-eyebrow {
  margin: 0;
  font-family: var(--font-mono); font-size: 0.65rem;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--paper-muted);
}
.drawer-eyebrow .tri { color: var(--rik-gold); font-style: normal; margin-right: 0.4rem; }

.drawer-close {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid rgba(200, 155, 44, 0.2);
  border-radius: 50%;
  color: var(--paper);
  font-size: 1.2rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.drawer-close:hover { border-color: var(--rik-gold); color: var(--rik-gold); }

.drawer-body {
  padding: 1.5rem 1.25rem 2rem;
  overflow-y: auto;
  flex: 1;
}

.drawer-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.6rem; font-weight: 700;
  color: var(--paper);
  letter-spacing: -0.01em;
}

.drawer-tagline {
  margin: 0 0 1rem 0;
  font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--rik-gold);
}

.drawer-body-text {
  margin: 0 0 1.25rem 0;
  font-size: 0.95rem; line-height: 1.55;
  color: var(--paper-muted);
}

.drawer-embeds {
  display: flex; flex-direction: column; gap: 0.75rem;
  margin: 0 0 1.5rem 0;
}
.drawer-embed { width: 100%; }
.drawer-embed iframe {
  width: 100%; height: 152px;
  border: 0; display: block;
  border-radius: 8px;
}

.drawer-ctas {
  display: flex; flex-direction: column; gap: 0.5rem;
  margin-top: 1rem;
}

.drawer-cta {
  display: inline-flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1rem;
  background: rgba(200, 155, 44, 0.06);
  border: 1px solid rgba(200, 155, 44, 0.22);
  color: var(--paper); text-decoration: none;
  font-family: var(--font-mono); font-size: 0.72rem;
  letter-spacing: 0.16em; text-transform: uppercase;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.drawer-cta:hover {
  background: rgba(200, 155, 44, 0.15);
  border-color: var(--rik-gold);
  transform: translateY(-1px);
}
.drawer-cta .arrow { color: var(--rik-gold); }
.drawer-cta.is-disabled {
  opacity: 0.5; cursor: not-allowed;
  background: rgba(154, 154, 147, 0.06);
  border-color: rgba(154, 154, 147, 0.18);
}
.drawer-cta.is-disabled:hover { transform: none; background: rgba(154, 154, 147, 0.06); }

.drawer-footnote {
  margin: 1rem 0 0 0;
  font-family: var(--font-mono); font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--paper-muted);
  font-style: italic;
}

/* ---------- Footer ---------- */
.world-footer {
  padding: 1.5rem 2rem;
  background: #050302;
  text-align: center;
  border-top: 1px solid rgba(200, 155, 44, 0.06);
}
.footer-line {
  margin: 0;
  font-family: var(--font-mono); font-size: 0.65rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--paper-muted);
}
.footer-tri { color: var(--rik-gold); font-style: normal; margin-right: 0.4rem; }

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
  .world-scene {
    height: calc(100vh - 56px);
    min-height: 480px;
  }
  .scene-chrome { top: 1rem; left: 1rem; }
  .scene-byline { font-size: 1.1rem; }
  .scene-eyebrow { font-size: 0.6rem; }
  .scene-hint { bottom: 1rem; font-size: 0.6rem; padding: 0.45rem 0.8rem; }
  .scene-coord { bottom: 1rem; right: 1rem; font-size: 0.6rem; }
  .drawer-title { font-size: 1.35rem; }
  .drawer-body { padding: 1.25rem 1rem 1.5rem; }

  /* v1.1 master image crop strategy on portrait:
     anchor right-center to preserve Motel + Rik's Room window + sun.
     The Letter (mailbox) is hidden because its anchor falls in the cropped-out
     left third of the image. Phase 2 will generate a dedicated mobile master. */
  .scene-image { object-position: 78% center; }

  .hotspot[data-place-id="the-letter"] { display: none !important; }

  /* Re-anchor remaining hotspots to where they actually land on portrait crop.
     v1.1.1 polish: tighter snap to motel structure + clear road centerline. */
  .hotspot[data-place-id="the-road"]     { left: 50% !important; top: 78% !important; }
  .hotspot[data-place-id="motel-light"]  { left: 70% !important; top: 52% !important; }
  .hotspot[data-place-id="riks-room"]    { left: 64% !important; top: 44% !important; }

  /* v1.1.1: labels — show short form on mobile for cleaner UX. */
  .hotspot-label .label-text-long  { display: none; }
  .hotspot-label .label-text-short { display: inline; }
  .hotspot-label { font-size: 0.62rem; padding: 0.35rem 0.65rem; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .hotspot::before, .hint-dot { animation: none; }
  html.from-atlas body { animation: none; }
  .drawer-panel { transition: none; }
  /* v1.1.1: birds stop AND hide — silent sky for reduced-motion users */
  .scene-birds .bird { animation: none; opacity: 0; }
}
