/* ==========================================================================
   MISTIK ALAM MELAYU NUSANTARA - STYLESHEET
   Aesthetics: Scary, Eerie, Mystical, Dark Ambient + Glassmorphism Light UI
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Cinzel+Decorative:wght@700;900&family=Inter:wght@300;400;600;700&display=swap');

:root {
  --font-title: 'Cinzel Decorative', serif;
  --font-arabic: 'Amiri', serif;
  --font-body: 'Inter', sans-serif;

  /* Color Palette */
  --bg-dark: #05070a;
  --blood-red: #8b0000;
  --crimson-glow: #ff1a40;
  --mystic-green: #00ffaa;
  --mystic-purple: #9d4edd;
  --gold-runes: #dfb15b;
  
  /* Glassmorphism Light Theme Variables */
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-bg-hover: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.22);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --glass-text: #ffffff;
  --glass-subtext: rgba(255, 255, 255, 0.75);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--glass-text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Three.js Canvas Container */
#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Noise Texture Overlay */
.vignette-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 30%, rgba(5, 7, 10, 0.85) 80%, rgba(2, 3, 5, 0.98) 100%),
              linear-gradient(to bottom, rgba(139, 0, 0, 0.15), transparent 40%, rgba(0, 0, 0, 0.4));
}

/* UI Overlay Wrapper */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 2rem;
  pointer-events: none;
}

.interactive {
  pointer-events: auto;
}

/* Header Section */
header {
  text-align: center;
  margin-top: 1rem;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.site-title {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 4vw, 3.5rem);
  text-transform: uppercase;
  letter-spacing: 4px;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 26, 64, 0.7), 0 0 20px rgba(139, 0, 0, 0.8);
  animation: eeriePulse 4s infinite alternate;
}

.site-subtitle {
  font-family: var(--font-arabic);
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  color: var(--gold-runes);
  letter-spacing: 2px;
  margin-top: 0.3rem;
  text-shadow: 0 0 8px rgba(223, 177, 91, 0.5);
}

/* Sound Control Widget (Glassmorphism Light) */
.sound-widget {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 20;
  background: var(--glass-bg);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  padding: 0.6rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sound-widget:hover {
  background: var(--glass-bg-hover);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 20px rgba(255, 26, 64, 0.4);
  transform: translateY(-2px);
}

.sound-icon {
  width: 20px;
  height: 20px;
  fill: #ffffff;
}

.sound-text {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Door Instruction Prompt */
.door-prompt {
  position: absolute;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  padding: 1.2rem 2.5rem;
  border-radius: 40px;
  box-shadow: var(--glass-shadow);
  transition: opacity 0.6s ease, transform 0.6s ease;
  cursor: pointer;
  animation: floatBounce 3s infinite ease-in-out;
}

.door-prompt:hover {
  background: var(--glass-bg-hover);
  border-color: var(--crimson-glow);
  box-shadow: 0 0 30px rgba(255, 26, 64, 0.6);
}

.door-prompt h2 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: #fff;
  letter-spacing: 2px;
}

.door-prompt p {
  font-size: 0.85rem;
  color: var(--glass-subtext);
  margin-top: 0.3rem;
}

/* Main Hub Content (Hidden by default until Door Opens) */
.hub-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.2s ease 0.5s, transform 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.5s, visibility 1.2s;
  z-index: 15;
}

.hub-content.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* Glassmorphic Cards */
.realm-card {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 2.2rem 1.8rem;
  text-align: center;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.05);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.realm-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.6s ease;
}

.realm-card:hover::before {
  left: 100%;
}

.realm-card:hover {
  transform: translateY(-10px) scale(1.02);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8), 0 0 25px var(--card-glow, rgba(255, 26, 64, 0.5));
}

.realm-card[data-realm="ghaib"] { --card-glow: rgba(139, 0, 0, 0.7); }
.realm-card[data-realm="silat"] { --card-glow: rgba(223, 177, 91, 0.7); }
.realm-card[data-realm="batin"] { --card-glow: rgba(157, 78, 221, 0.7); }

.card-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: inline-block;
  text-shadow: 0 0 15px currentColor;
}

.card-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 0.6rem;
  letter-spacing: 1px;
}

.card-subtitle {
  font-family: var(--font-arabic);
  font-size: 1.1rem;
  color: var(--gold-runes);
  margin-bottom: 1rem;
}

.card-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--glass-subtext);
  margin-bottom: 1.5rem;
}

.card-btn {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  padding: 0.7rem 1.6rem;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all 0.3s ease;
}

.realm-card:hover .card-btn {
  background: #ffffff;
  color: #000;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

/* Modal Styling for Deep Lore Exploration */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 5, 8, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  padding: 1.5rem;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  width: 100%;
  max-width: 850px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2.5rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(255, 255, 255, 0.08);
  position: relative;
  color: #ffffff;
  transform: translateY(30px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: rgba(255, 26, 64, 0.8);
  border-color: #ff1a40;
  transform: rotate(90deg);
}

.modal-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 1rem;
}

.modal-title {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--gold-runes);
}

.modal-subtitle {
  font-family: var(--font-arabic);
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.7);
}

.modal-body {
  line-height: 1.8;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.9);
}

.modal-body h3 {
  font-family: var(--font-title);
  color: #ff1a40;
  margin: 1.5rem 0 0.8rem 0;
  font-size: 1.3rem;
  letter-spacing: 1px;
}

.modal-body p {
  margin-bottom: 1rem;
}

.modal-body ul {
  margin: 1rem 0 1.5rem 1.5rem;
}

.modal-body li {
  margin-bottom: 0.5rem;
}

/* Small 3D Skull Close Button (Between Middle Card & Bottom Line) */
.skull-bottom-section {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 0.6rem;
}

.skull-small-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(10, 25, 38, 0.4);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1.5px solid rgba(76, 165, 176, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8), 0 0 20px rgba(76, 165, 176, 0.5);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
}

.skull-glow-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(0, 255, 204, 0.4);
  animation: pulseGlow 2.5s infinite ease-in-out;
  pointer-events: none;
}

.skull-small-btn:hover {
  background: rgba(255, 26, 64, 0.35);
  border-color: #ff1a40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 26, 64, 0.8);
  transform: scale(1.15) rotate(15deg);
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

/* Custom Scrollbar for Modal */
.modal-box::-webkit-scrollbar {
  width: 8px;
}
.modal-box::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
}
.modal-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
}
.modal-box::-webkit-scrollbar-thumb:hover {
  background: var(--crimson-glow);
}

/* Keyframe Animations */
@keyframes eeriePulse {
  0% { text-shadow: 0 0 10px rgba(255, 26, 64, 0.5), 0 0 20px rgba(139, 0, 0, 0.6); }
  50% { text-shadow: 0 0 20px rgba(255, 26, 64, 0.9), 0 0 40px rgba(139, 0, 0, 0.9), 0 0 60px rgba(255, 215, 0, 0.4); }
  100% { text-shadow: 0 0 12px rgba(255, 26, 64, 0.6), 0 0 25px rgba(139, 0, 0, 0.7); }
}

@keyframes floatBounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -10px); }
}

/* Hide initial components when door opened */
body.door-opened header {
  opacity: 0;
  transform: translateY(-30px);
  pointer-events: none;
}

body.door-opened .door-prompt {
  opacity: 0;
  transform: translate(-50%, 40px);
  pointer-events: none;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .ui-layer {
    padding: 1rem;
  }
  .sound-widget {
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 0.9rem;
  }
  .door-prompt {
    bottom: 2rem;
    padding: 1rem 1.5rem;
    width: 90%;
  }
  .modal-box {
    padding: 1.5rem;
  }
}
