/* ==========================================================================
   PRISMHALL 3D: JEWEL GOTHIC REFRACTION SANCTUARY & ASMR LIGHT HALL
   Styles for WebGL App Mount, HUD, and Anti-Thin Content Layout
   ========================================================================== */

:root {
  --prism-bg: #07010f;
  --prism-card: #0f051e;
  --prism-accent: #c084fc;
  --prism-gold: #ffd875;
  --prism-magenta: #ff5eb5;
  --prism-teal: #2dd4bf;
  --prism-border: rgba(255, 218, 128, 0.22);
  --prism-border-subtle: rgba(255, 255, 255, 0.08);
  --prism-text: #f6eefc;
  --prism-muted: #c4b5d6;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  background-color: var(--prism-bg);
  color: var(--prism-text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.65;
  scroll-behavior: smooth;
}

/* --------------------------------------------------------------------------
   Interactive 3D WebGL App Container
   -------------------------------------------------------------------------- */
#prismhall-app-container {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 90vh;
  min-height: 580px;
  max-height: 960px;
  overflow: hidden;
  background: var(--prism-bg);
  border-bottom: 2px solid var(--prism-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 35px rgba(168, 85, 247, 0.15);
}

#prismhall-app-container:fullscreen,
#prismhall-app-container:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: none !important;
  border-bottom: none;
}

@media (max-width: 768px) {
  #prismhall-app-container {
    height: 82vh;
    min-height: 520px;
  }
}

#canvas-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  filter: saturate(1.1) contrast(1.04);
  touch-action: none;
}

#canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(7, 1, 15, 0) 48%, rgba(7, 1, 15, 0.52) 82%, rgba(5, 0, 12, 0.88) 100%);
}

/* --------------------------------------------------------------------------
   Intro / Loading Screen Overlay
   -------------------------------------------------------------------------- */
#intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 38%, rgba(164, 34, 130, 0.32) 0%, rgba(36, 8, 68, 0.82) 48%, rgba(7, 1, 15, 0.98) 100%);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.9s;
}

#intro-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-card {
  max-width: 460px;
  width: 100%;
  text-align: center;
  padding: 36px 28px;
  border-radius: 20px;
  background: rgba(16, 4, 30, 0.88);
  border: 1px solid var(--prism-border);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85), 0 0 48px rgba(196, 45, 145, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.intro-kicker {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--prism-gold);
  margin-bottom: 10px;
  font-weight: 600;
}

.intro-title {
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #fff6e5;
  text-shadow: 0 0 28px rgba(255, 105, 195, 0.55), 0 2px 10px rgba(0, 0, 0, 0.8);
  margin-bottom: 12px;
}

.intro-desc {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(242, 228, 255, 0.85);
  margin-bottom: 24px;
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 214, 118, 0.25);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #a82482, #ff4da6, #ffd86b, #28e0b8);
  box-shadow: 0 0 16px rgba(255, 190, 92, 0.75);
  transition: width 0.18s ease-out;
}

.progress-status {
  font-size: 12px;
  color: rgba(255, 224, 166, 0.85);
  min-height: 18px;
  margin-bottom: 20px;
  font-variant-numeric: tabular-nums;
}

#enter-btn {
  appearance: none;
  border: 1px solid rgba(255, 220, 130, 0.7);
  background: linear-gradient(135deg, rgba(168, 28, 112, 0.95) 0%, rgba(88, 18, 128, 0.95) 55%, rgba(194, 126, 28, 0.95) 100%);
  color: #fff9ec;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2em;
  padding: 15px 34px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(255, 92, 178, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease, opacity 0.25s ease;
}

#enter-btn:disabled {
  opacity: 0.38;
  cursor: default;
  box-shadow: none;
}

#enter-btn:not(:disabled):hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 36px rgba(255, 196, 92, 0.75), inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

#enter-btn:not(:disabled):active {
  transform: translateY(0) scale(0.99);
}

.intro-controls-hint {
  margin-top: 18px;
  font-size: 12px;
  color: rgba(226, 206, 245, 0.7);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   HUD & Dock Controls
   -------------------------------------------------------------------------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  transition: opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

#hud.auto-hidden .hud-fade {
  opacity: 0;
  pointer-events: none;
}

.hud-fade {
  transition: opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#top-bar {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 14px));
  left: max(16px, env(safe-area-inset-left, 16px));
  right: max(16px, env(safe-area-inset-right, 16px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.brand-badge {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(14, 4, 26, 0.85);
  border: 1px solid var(--prism-border);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: #ffefc8;
  backdrop-filter: blur(8px);
}

.mood-label {
  font-weight: 400;
  letter-spacing: 0.04em;
  color: rgba(240, 215, 255, 0.85);
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  appearance: none;
  background: rgba(16, 5, 30, 0.85);
  color: #f8edff;
  border: 1px solid var(--prism-border);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.hud-btn:hover {
  background: rgba(42, 12, 68, 0.92);
  border-color: rgba(255, 218, 130, 0.6);
  transform: translateY(-1px);
}

.hud-btn.active {
  background: linear-gradient(135deg, rgba(168, 30, 114, 0.9), rgba(112, 24, 145, 0.9));
  border-color: rgba(255, 222, 138, 0.8);
  color: #fff8e6;
  box-shadow: 0 0 18px rgba(235, 72, 168, 0.4);
}

/* --------------------------------------------------------------------------
   Bottom Dock & Settings Panel
   -------------------------------------------------------------------------- */
#bottom-dock {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom, 18px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(560px, 92vw);
  pointer-events: none;
}

#settings-panel {
  width: 100%;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(14, 4, 26, 0.95);
  border: 1px solid var(--prism-border);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.85);
  pointer-events: auto;
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 18px;
  backdrop-filter: blur(12px);
}

#settings-panel.open {
  display: grid;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: rgba(246, 234, 255, 0.9);
  min-height: 36px;
}

.setting-row label {
  color: rgba(238, 220, 252, 0.88);
  font-size: 12px;
}

.setting-select, .setting-range {
  pointer-events: auto;
  background: rgba(34, 10, 56, 0.9);
  color: #fff6e5;
  border: 1px solid rgba(255, 214, 122, 0.35);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  min-height: 34px;
}

.setting-range {
  width: 115px;
  padding: 0;
  accent-color: #ff5eb5;
  cursor: pointer;
}

.dock-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(14, 4, 26, 0.88);
  border: 1px solid var(--prism-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

/* --------------------------------------------------------------------------
   Touch Joystick & Overlays
   -------------------------------------------------------------------------- */
#joystick-zone {
  position: absolute;
  left: max(20px, env(safe-area-inset-left, 20px));
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 1px solid rgba(255, 214, 122, 0.25);
  background: rgba(16, 4, 30, 0.45);
  z-index: 14;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

#joystick-zone.active {
  opacity: 1;
}

#joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 218, 128, 0.9), rgba(212, 48, 148, 0.8));
  border: 1px solid rgba(255, 245, 215, 0.8);
  box-shadow: 0 0 16px rgba(255, 108, 192, 0.6);
  transform: translate3d(0, 0, 0);
}

#debug-overlay {
  position: absolute;
  top: 64px;
  left: 16px;
  z-index: 25;
  background: rgba(8, 2, 16, 0.88);
  border: 1px solid var(--prism-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  color: #ffe8b6;
  pointer-events: none;
  display: none;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

#debug-overlay.visible {
  display: block;
}

#bookmark-toast {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 22;
  background: rgba(18, 5, 34, 0.94);
  border: 1px solid var(--prism-border);
  color: #fff4dc;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
  max-width: 90vw;
  text-align: center;
}

#bookmark-toast.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

#sleep-screen, #webgl-error {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: #040008;
  color: rgba(245, 228, 255, 0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

#sleep-screen.visible, #webgl-error.visible {
  display: flex;
}

#sleep-screen h2, #webgl-error h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #ffe8b3;
  margin-bottom: 10px;
}

#sleep-screen p, #webgl-error p {
  font-size: 14px;
  max-width: 380px;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   Editorial & Anti-Thin Content Layout (.article-wrap)
   -------------------------------------------------------------------------- */
.article-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 20px 80px;
  line-height: 1.78;
  color: #cbd5e1;
}

.editorial-header {
  margin-bottom: 36px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 24px;
}

.editorial-header h1 {
  font-size: 2.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.editorial-header p {
  font-size: 1.05rem;
  color: var(--prism-muted);
  max-width: 860px;
}

/* Quick Navigation Anchor Ribbon */
.anchor-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.anchor-pill {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  text-decoration: none;
  transition: all 0.2s ease;
}

.anchor-pill:hover, .anchor-pill.active {
  background: rgba(192, 132, 252, 0.18);
  border-color: var(--prism-accent);
  color: #fff;
  transform: translateY(-1px);
}

.editorial-section {
  margin-bottom: 48px;
}

.editorial-section h2 {
  font-size: 1.65rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--prism-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.editorial-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--prism-gold);
  margin: 22px 0 10px;
}

.editorial-section p {
  margin-bottom: 16px;
  color: #cbd5e1;
  text-align: justify;
}

.guide-callout {
  background: rgba(255, 218, 128, 0.08);
  border-left: 4px solid var(--prism-gold);
  border-radius: 0 12px 12px 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 0.95rem;
  color: #fff6e5;
  line-height: 1.7;
}

.guide-table-wrap {
  overflow-x: auto;
  margin: 20px 0 28px;
  border-radius: 14px;
  border: 1px solid var(--prism-border);
  background: rgba(12, 4, 24, 0.8);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.guide-table th {
  background: rgba(255, 218, 128, 0.14);
  color: var(--prism-gold);
  padding: 14px 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--prism-border);
  white-space: nowrap;
}

.guide-table td {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #f1e5fc;
}

.guide-table tr:last-child td {
  border-bottom: none;
}

.faq-box {
  background: rgba(20, 8, 38, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 14px;
  transition: border-color 0.2s ease;
}

.faq-box:hover {
  border-color: rgba(255, 218, 128, 0.35);
}

.faq-box h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--prism-gold);
  margin-bottom: 8px;
}

.faq-box p {
  font-size: 0.92rem;
  color: #d1bfe3;
  margin: 0;
  line-height: 1.65;
}

/* Related Calm Tools Grid */
.related-calm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin: 20px 0 28px;
}

.related-calm-card {
  display: block;
  background: rgba(20, 8, 38, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px 18px;
  text-decoration: none;
  color: #f1e5fc;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.related-calm-card:hover {
  background: rgba(38, 14, 70, 0.88);
  border-color: var(--prism-accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 18px rgba(192, 132, 252, 0.2);
}

.related-calm-card strong {
  display: block;
  font-size: 0.96rem;
  margin-bottom: 6px;
  color: #fff;
}

.related-calm-card span {
  font-size: 0.8rem;
  color: var(--prism-gold);
}

@media (max-width: 768px) {
  .editorial-header h1 { font-size: 1.85rem; }
  .editorial-section h2 { font-size: 1.35rem; }
  .article-wrap { padding: 32px 14px 60px; }
  .related-calm-grid { grid-template-columns: 1fr; }
}
