/* ============================================================
   GLOBAL.CSS — Variables, reset, typography, shared components
   FULLY FIXED with proper success overlay background
============================================================ */

/* ── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Lato:wght@300;400;700&family=Dancing+Script:wght@400;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --rose:          #C38EB4;
  --blush:         #E1CBD7;
  --deep:          #8B5E7E;
  --gold:          #F0C67A;
  --ivory:         #FDF6F0;
  --white:         #FFFFFF;
  --text-dark:     #3a2535;
  --text-mid:      #7a5068;
  --glass-bg:      rgba(255,255,255,0.18);
  --glass-border:  rgba(195,142,180,0.35);
  --shadow:        0 8px 32px rgba(139,94,126,0.18);
  --shadow-lg:     0 20px 60px rgba(139,94,126,0.28);
  --radius-card:   24px;
  --radius-btn:    50px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Lato', sans-serif;
  background: var(--ivory);
  color: var(--text-dark);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── Background Canvas ─────────────────────────────────────── */
#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Chapter Screen System ─────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* Scrollable inner wrapper for each chapter */
.chapter-scroll {
  width: 100%;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 20px 60px;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--rose) transparent;
}
.chapter-scroll::-webkit-scrollbar { width: 5px; }
.chapter-scroll::-webkit-scrollbar-track { background: transparent; }
.chapter-scroll::-webkit-scrollbar-thumb { background: var(--rose); border-radius: 10px; }

/* Chapter-specific backgrounds */
#screen-intro  { background: linear-gradient(135deg, #f9eef5 0%, #ede0f0 50%, #fbe8f1 100%); }
#screen-ch1    { background: linear-gradient(160deg, #fbeaf5 0%, #e8d5f0 60%, #f5e0e8 100%); }
#screen-ch2    { background: linear-gradient(160deg, #f0e8f5 0%, #fde8ef 60%, #ede0f0 100%); }
#screen-ch3    { background: linear-gradient(160deg, #fde8f0 0%, #eadaf5 60%, #fce8e0 100%); }
#screen-ch4    { background: linear-gradient(160deg, #ede0f5 0%, #fbe8f0 60%, #e8d5ee 100%); }
#screen-final  { background: linear-gradient(160deg, #2a1a2e 0%, #4a2040 50%, #6b2a4a 100%); }
#screen-bonus  { background: linear-gradient(160deg, #1a0d2e 0%, #3d1a5c 50%, #5c2060 100%); }

/* ── Typography ────────────────────────────────────────────── */
.title-script {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  color: var(--deep);
  text-shadow: 0 2px 18px rgba(195,142,180,0.35);
  line-height: 1.15;
  text-align: center;
}
.title-serif {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.5rem, 5vw, 3rem);
  color: var(--deep);
  line-height: 1.25;
  text-align: center;
}
.ch-strip {
  font-family: 'Dancing Script', cursive;
  font-size: 0.95rem;
  color: var(--rose);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
  text-align: center;
}
.body-text {
  font-family: 'Lato', sans-serif;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  color: var(--text-mid);
  line-height: 1.85;
  max-width: 600px;
  text-align: center;
}

/* ── Glassmorphism Card ─────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 36px 40px;
  max-width: 680px;
  width: 100%;
  text-align: center;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 40px;
  background: linear-gradient(135deg, var(--rose) 0%, var(--deep) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-btn);
  font-family: 'Lato', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(139,94,126,0.4);
  transition: transform 0.25s, box-shadow 0.25s, filter 0.25s;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), transparent);
  border-radius: var(--radius-btn);
  pointer-events: none;
}
.btn-primary:hover  { transform: translateY(-3px) scale(1.04); box-shadow: 0 12px 36px rgba(139,94,126,0.55); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; filter: none !important; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 30px;
  background: transparent;
  color: var(--deep);
  border: 2px solid var(--rose);
  border-radius: var(--radius-btn);
  font-family: 'Lato', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--rose); color: white; transform: translateY(-2px); }

/* ── Progress Bar ───────────────────────────────────────────── */
#progressBar {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
#progressBar.visible { opacity: 1; pointer-events: all; }
#progressBar .chapter-label {
  font-family: 'Dancing Script', cursive;
  color: var(--rose);
  font-size: 0.95rem;
  white-space: nowrap;
  min-width: 90px;
}
#progressTrack {
  flex: 1;
  height: 6px;
  background: var(--blush);
  border-radius: 10px;
  overflow: hidden;
}
#progressFill {
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--gold));
  border-radius: 10px;
  transition: width 0.9s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}
#chapterDots {
  display: flex;
  gap: 6px;
}
.cdot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--blush);
  border: 2px solid var(--rose);
  transition: background 0.4s, transform 0.3s;
}
.cdot.done { background: var(--rose); transform: scale(1.2); }

/* ── Control Buttons (Music only) ─────────────────────────── */
.control-buttons {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#musicBtn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), var(--deep));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139,94,126,0.5);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.5s;
  font-size: 1.3rem;
  color: white;
  opacity: 0;
  pointer-events: none;
}

#musicBtn.visible {
  opacity: 1;
  pointer-events: all;
}

#musicBtn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(139,94,126,0.7);
}

/* ── SUCCESS OVERLAY - FIXED with proper dark blurred background ── */
#successOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(30, 10, 40, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 30px 20px;
  text-align: center;
  gap: 20px;
}

#successOverlay.show {
  opacity: 1;
  pointer-events: all;
}

#successOverlay h2 {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: var(--gold);
  text-shadow: 0 0 30px rgba(240,198,122,0.8);
  margin: 0;
  animation: fadeInUp 0.5s ease;
}

#successOverlay p {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.15rem;
  max-width: 400px;
  line-height: 1.8;
  margin: 0;
  animation: fadeInUp 0.6s ease;
}

#successOverlay .btn-primary {
  margin-top: 10px;
  padding: 12px 32px;
  font-size: 1rem;
  animation: fadeInUp 0.7s ease;
}

/* ── Confetti Canvas ────────────────────────────────────────── */
#confettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 250;
  display: none;
}

/* ── Wipe Transition Overlay ────────────────────────────────── */
#wipe {
  position: fixed;
  inset: 0;
  z-index: 500;
  pointer-events: none;
  overflow: hidden;
}
#wipe svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Secret Hearts ──────────────────────────────────────────── */
.secret-heart {
  position: absolute;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.12;
  transition: opacity 0.4s, transform 0.3s;
  z-index: 50;
  user-select: none;
  line-height: 1;
}
.secret-heart:hover { opacity: 1; transform: scale(1.6); }
.secret-heart.found { opacity: 0; pointer-events: none; }

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-sm  { margin-top: 12px; }
.mt-md  { margin-top: 24px; }
.mt-lg  { margin-top: 36px; }
.text-center { text-align: center; }

@keyframes fadeInUp { 
  from { opacity: 0; transform: translateY(20px); } 
  to { opacity: 1; transform: translateY(0); } 
}
@keyframes fadeIn { 
  from { opacity: 0; } 
  to { opacity: 1; } 
}
@keyframes pulse { 
  0%,100% { transform: scale(1); } 
  50% { transform: scale(1.06); } 
}
@keyframes floatY { 
  0%,100% { transform: translateY(0); } 
  50% { transform: translateY(-10px); } 
}
@keyframes glowPulse {
  0%,100% { filter: drop-shadow(0 0 8px rgba(240,198,122,0.7)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 22px rgba(240,198,122,1)); transform: scale(1.15); }
}
@keyframes blink { 
  0%,100% { opacity: 1; } 
  50% { opacity: 0; } 
}

.fade-in { animation: fadeInUp 0.8s ease forwards; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .glass-card { padding: 24px 18px; }
  .btn-primary { padding: 14px 28px; font-size: 0.95rem; }
  #successOverlay h2 { font-size: 1.8rem; }
  #successOverlay p { font-size: 0.95rem; }
  
  .control-buttons {
    bottom: 15px;
    right: 15px;
    gap: 8px;
  }

  #musicBtn {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
}
/* ── RTL & Kurdish font improvements ──────────────────────── */
body {
  direction: rtl;
}

/* Ensure LTR for canvas/game areas */
canvas, #puzzleContainer, #memTrailArea, #ch2-hunt, .chapter-scroll {
  direction: ltr;
}

/* Better touch targets on mobile */
@media (max-width: 768px) {
  .btn-primary {
    min-height: 50px;
    font-size: 1rem;
    padding: 14px 28px;
  }
  .btn-ghost {
    min-height: 46px;
  }
  #progressBar {
    padding: 8px 12px;
    gap: 7px;
  }
  #progressBar .chapter-label {
    font-size: 0.8rem;
    min-width: 70px;
  }
  .cdot {
    width: 8px;
    height: 8px;
  }
}