/* Ruang Tenang — Full-bleed editorial nature sanctuary (anti-slop craft floor). */
:root {
  color-scheme: dark;
  --ink: #0f1813;
  --ink-surface: rgba(15, 24, 19, 0.78);
  --paper: #f2eee2;
  --paper-muted: rgba(242, 238, 226, 0.74);
  --sage: #8fc4b2;
  --line: rgba(242, 238, 226, 0.2);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
::selection { background: var(--sage); color: var(--ink); }

html, body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
}
body {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

/* Uniform 1.5px stroke SVG icon system */
.ui-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════
   FULL-BLEED EDITORIAL LANDING MENU
   ══════════════════════════════════════════ */
.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--ink);
  transition: opacity .45s cubic-bezier(.16, 1, .3, 1), transform .45s cubic-bezier(.16, 1, .3, 1);
}
.menu-overlay[hidden] { display: none; }
.menu-exit {
  opacity: 0;
  transform: scale(1.025);
  pointer-events: none;
}

/* Full-bleed crossfading landscape photographs */
.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.menu-backdrop-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity .75s cubic-bezier(.16, 1, .3, 1), transform 1.2s cubic-bezier(.16, 1, .3, 1);
}
.menu-backdrop-img.is-active {
  opacity: 1;
  transform: scale(1);
}

/* Asymmetric directional scrim — mobile rises from bottom so top third breathes */
.menu-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(11, 18, 14, 0.96) 0%,
    rgba(11, 18, 14, 0.88) 48%,
    rgba(11, 18, 14, 0.32) 78%,
    rgba(11, 18, 14, 0.14) 100%
  );
}

.menu-layout {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: max(28px, env(safe-area-inset-top)) 24px calc(28px + var(--safe-bottom));
  gap: 24px;
}

.menu-column {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.menu-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.menu-title {
  margin: 0;
  font: 400 clamp(2.7rem, 9vw, 4.7rem)/0.95 Georgia, "Times New Roman", serif;
  letter-spacing: -0.025em;
  color: var(--paper);
}
.menu-subtitle {
  margin: 0;
  max-width: 36ch;
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--paper-muted);
}

/* Editorial hairline destination index (zero boxed SaaS cards) */
.menu-worlds {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.menu-world-row {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 2px;
  min-height: auto;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--paper);
  text-align: left;
  cursor: pointer;
  transition: padding-left .24s cubic-bezier(.16, 1, .3, 1), border-color .24s ease;
}
.menu-world-row:hover,
.menu-world-row:focus-visible,
.menu-world-row.is-active {
  background: transparent;
  color: var(--paper);
  border-bottom-color: rgba(242, 238, 226, 0.55);
  padding-left: 10px;
}
.menu-world-row:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 4px;
}
.menu-row-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.menu-row-title {
  font: 400 1.55rem/1.15 Georgia, "Times New Roman", serif;
  letter-spacing: -0.015em;
  color: var(--paper);
}
.menu-row-desc {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--paper-muted);
}
.menu-row-arrow {
  width: 18px;
  height: 18px;
  color: var(--paper-muted);
  transition: transform .24s cubic-bezier(.16, 1, .3, 1), color .24s ease;
}
.menu-world-row:hover .menu-row-arrow,
.menu-world-row:focus-visible .menu-row-arrow,
.menu-world-row.is-active .menu-row-arrow {
  transform: translateX(4px);
  color: var(--sage);
}

.menu-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.menu-ar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid rgba(242, 238, 226, 0.36);
  background: rgba(15, 24, 19, 0.48);
  color: var(--paper);
  font: 600 0.84rem/1 inherit;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.menu-ar-btn:hover,
.menu-ar-btn:focus-visible {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

.menu-preview-caption {
  margin: 0;
  font-size: 0.78rem;
  color: var(--paper-muted);
  opacity: 0.85;
}

@media (min-width: 760px) {
  .menu-scrim {
    background: linear-gradient(
      100deg,
      rgba(11, 18, 14, 0.94) 0%,
      rgba(11, 18, 14, 0.78) 38%,
      rgba(11, 18, 14, 0.28) 64%,
      rgba(11, 18, 14, 0.12) 100%
    );
  }
  .menu-layout {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 48px 6vw;
  }
  .menu-preview-caption {
    align-self: flex-end;
    text-align: right;
  }
}

/* ══════════════════════════════════════════
   CAMERA PASSTHROUGH & A-FRAME SCENE
   ══════════════════════════════════════════ */
.ar-camera-feed {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  background: #000;
}
.ar-camera-feed[hidden] { display: none; }

.ar-atmosphere {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: background .45s ease;
}
.ar-atmosphere[hidden] { display: none; }
.ar-atmosphere[data-world="Pantai"] {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 226, 168, 0.16) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(65, 178, 196, 0.22) 0%, transparent 58%);
}
.ar-atmosphere[data-world="Hutan"] {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(206, 238, 168, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(44, 110, 68, 0.24) 0%, transparent 60%);
}
.ar-atmosphere[data-world="Gunung"] {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(188, 219, 238, 0.18) 0%, transparent 58%),
    radial-gradient(ellipse at 50% 100%, rgba(42, 66, 82, 0.22) 0%, transparent 60%);
}

a-scene { position: fixed; inset: 0; z-index: 1; touch-action: none; }
#scene canvas { display: block; background: transparent !important; touch-action: none; }

.scene-veil {
  position: fixed;
  inset: 0;
  z-index: 3;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity .32s cubic-bezier(.16, 1, .3, 1);
}
.scene-veil.is-flashing {
  opacity: 0.42;
  transition: none;
}

/* ══════════════════════════════════════════
   IN-EXPERIENCE UI OVERLAY
   ══════════════════════════════════════════ */
#ui {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(16px + var(--safe-bottom));
  pointer-events: none;
}
#ui[hidden] { display: none; }
#ui > * { pointer-events: none; }
#ui .topbar-row > *,
#ui .control-dock { pointer-events: auto; }

.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}
.topbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.topbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.top-mini-btn {
  min-height: 38px;
  padding: 0 13px;
  font-size: 0.8rem;
  background: var(--ink-surface);
  backdrop-filter: blur(8px);
}
.world-name {
  margin: 0;
  max-width: 12ch;
  font: 400 clamp(1.85rem, 6vw, 3rem)/1 Georgia, "Times New Roman", serif;
  letter-spacing: -0.025em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.status {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink-surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--paper-muted);
  max-width: 42ch;
}

.control-dock {
  display: grid;
  gap: 11px;
  max-width: 510px;
  width: 100%;
  margin: auto auto 0;
  padding: 14px 16px;
  border: none;
  border-radius: 16px;
  background: rgba(13, 21, 17, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
  max-height: 52svh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.control-dock.is-collapsed { display: none; }

.control-dock > * { min-width: 0; }
.controls { display: grid; gap: 10px; width: 100%; min-width: 0; }

.world-switch {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0;
  margin: 0;
  border: none;
}
.world-switch::-webkit-scrollbar { display: none; }
.world-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  min-height: 44px;
}
.world-option img {
  width: 44px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}
.world-option span { font-size: 0.82rem; }

body.ar-active .world-option { padding: 4px 10px 4px 4px; min-height: 36px; }
body.ar-active .world-option img { width: 32px; height: 24px; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(24, 37, 30, 0.72);
  color: var(--paper);
  font: 600 0.84rem/1 inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s ease, border-color .18s ease, transform .15s ease;
}
button[aria-pressed="true"], button.is-selected {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }
button[hidden] { display: none; }

.primary-button {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
  font-weight: 700;
}
.text-button {
  background: rgba(24, 37, 30, 0.5);
  border-color: var(--line);
}
.icon-button { padding: 0 14px; }
.ar-button {
  background: var(--sage);
  color: var(--ink);
  border: none;
  font-weight: 700;
}
.ar-button:hover { background: #a2d3c2; }
.ar-button:disabled { opacity: 0.45; cursor: not-allowed; }

.session-actions { display: flex; gap: 8px; grid-column: 1 / -1; }
.session-actions button { flex: 1; min-height: 40px; }

.control-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.volume-controls {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  padding: 2px 0;
}
.vol-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--paper-muted);
  flex: 1;
  min-width: 135px;
}
.vol-slider {
  flex: 1;
  min-width: 65px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--line);
  border-radius: 4px;
  outline: none;
  accent-color: var(--sage);
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--paper);
  cursor: pointer;
}
.vol-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--paper);
  cursor: pointer;
  border: none;
}

.menu-back-btn {
  font-size: 0.8rem;
  min-height: 38px;
  padding: 0 13px;
  background: var(--ink-surface);
  backdrop-filter: blur(8px);
}

/* ===== PANEL EDUKASI BALITA (0–6 TAHUN) ===== */
.edu-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.edu-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.edu-tabs {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.edu-tab {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(242, 238, 226, 0.08);
  border: 1px solid var(--line);
  color: var(--paper-muted);
}
.edu-tab.is-active,
.edu-tab[aria-selected="true"] {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}
.star-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(245, 204, 108, 0.16);
  color: #f6d57f;
  font-size: 0.84rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.star-icon {
  width: 15px;
  height: 15px;
  fill: #f6d57f;
  stroke: #f6d57f;
}
.edu-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(242, 238, 226, 0.06);
}
.edu-card-text {
  min-width: 0;
  flex: 1;
}
.edu-title {
  margin: 0 0 3px;
  font: 400 1.12rem/1.2 Georgia, "Times New Roman", serif;
  color: var(--paper);
}
.edu-fact {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.42;
  color: var(--paper-muted);
}
.edu-action-btn {
  min-height: 38px;
  padding: 0 13px;
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}
.edu-action-btn:hover {
  background: #ffffff;
}
#gyroToggleBtn[aria-pressed="true"] {
  background: var(--sage);
  color: var(--ink);
  border-color: var(--sage);
}

.hint {
  max-width: 44ch;
  font-size: 0.8rem;
  line-height: 1.45;
  margin: 0;
  color: var(--paper-muted);
}
.hint[hidden] { display: none; }
.fine-print {
  font-size: 0.74rem;
  color: var(--paper-muted);
  opacity: 0.8;
  margin: 2px 0 0;
  text-align: center;
}
#placementHint { max-width: 44ch; font-size: 0.8rem; line-height: 1.45; }
#reticle { pointer-events: none; }

.toast {
  position: fixed;
  top: calc(74px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(13, 21, 17, 0.94);
  color: var(--paper);
  border: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
  font-size: 0.82rem;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.visible { opacity: 1; }

/* ===== Bounded exploration D-pad ===== */
.move-pad {
  position: fixed;
  right: 14px;
  top: calc(84px + env(safe-area-inset-top));
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(3, 42px);
  gap: 4px;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
body.dock-collapsed .move-pad {
  top: auto;
  bottom: calc(20px + var(--safe-bottom));
}
.move-pad[hidden],
body.is-mobile .move-pad { display: none !important; }
.move-btn {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 12px;
  background: var(--ink-surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  color: var(--paper);
}
.move-btn.is-active,
.move-btn:active {
  background: var(--sage);
  color: var(--ink);
  border-color: var(--sage);
}
.move-up     { grid-column: 2; grid-row: 1; }
.move-left   { grid-column: 1; grid-row: 2; }
.move-center { grid-column: 2; grid-row: 2; }
.move-right  { grid-column: 3; grid-row: 2; }
.move-down   { grid-column: 2; grid-row: 3; }

@media (max-width: 560px) {
  #ui { padding: max(10px, env(safe-area-inset-top)) 10px calc(10px + var(--safe-bottom)); }
  .topbar-row { flex-wrap: wrap; gap: 6px; }
  .topbar { flex: 1 1 auto; min-width: 0; gap: 4px; }
  .world-name { font-size: 1.75rem; }
  .status {
    font-size: 0.71rem;
    padding: 4px 9px;
    border-radius: 10px;
    max-width: calc(100vw - 24px);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .topbar-actions { gap: 5px; }
  .top-mini-btn, .menu-back-btn { padding: 0 9px; min-height: 34px; font-size: 0.74rem; }
  .control-dock { padding: 10px 12px; gap: 7px; border-radius: 14px; max-height: 42svh; overflow-x: hidden; }
  .world-switch { gap: 5px; width: 100%; }
  .world-option { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 3px 6px 3px 4px; gap: 5px; justify-content: flex-start; }
  .world-option img { width: 26px; height: 20px; border-radius: 5px; flex-shrink: 0; }
  .world-option span { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .edu-panel { padding: 7px 0; gap: 7px; }
  .edu-tabs { gap: 4px; }
  .edu-tab { min-height: 30px; padding: 0 8px; font-size: 0.71rem; flex: 1; }
  .star-badge { min-height: 30px; padding: 0 9px; font-size: 0.78rem; }
  .edu-card { padding: 8px 10px; gap: 8px; }
  .edu-title { font-size: 0.96rem; }
  .edu-fact { font-size: 0.73rem; line-height: 1.35; }
  .edu-action-btn { min-height: 34px; padding: 0 10px; font-size: 0.72rem; }
  .control-row { gap: 6px; flex-wrap: nowrap; width: 100%; }
  .control-row button { flex: 1 1 auto; min-width: 0; min-height: 36px; padding: 0 9px; font-size: 0.74rem; white-space: nowrap; }
  #soundToggle { flex: 0 0 38px; width: 38px; padding: 0; }
  #soundToggle #soundLabel { display: none; }
  .volume-controls { gap: 8px; width: 100%; }
  .vol-label { font-size: 0.71rem; min-width: 0; flex: 1 1 45%; gap: 6px; }
  .vol-slider { min-width: 40px; }
  .fine-print { display: none; }
  .toast { top: calc(134px + env(safe-area-inset-top)); }
  .move-pad { right: 10px; top: calc(84px + env(safe-area-inset-top)); grid-template-columns: repeat(3, 36px); grid-template-rows: repeat(3, 36px); gap: 3px; }
  .move-btn { width: 36px; height: 36px; min-height: 36px; border-radius: 10px; }
}
@media (min-width: 760px) {
  #ui { padding-left: 4vw; padding-right: 4vw; }
  .control-dock { margin-left: 0; }
  .move-pad {
    top: auto;
    right: max(18px, 3vw);
    bottom: calc(18px + var(--safe-bottom));
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
