/* ==========================================================================
   Hannan Istiwak Clock - Auto Day/Night Theme, NASA 3D Earth & 3D Flip CSS
   Auto Theme: Dark Mode (Night: Maghrib..Subuh) | Light Mode (Day: Subuh..Maghrib)
   Domain: hannan.app
   ========================================================================== */

:root {
  --bg-gradient-1: #030712;
  --bg-gradient-2: #0a1224;
  --bg-accent-1: rgba(16, 185, 129, 0.14);
  --bg-accent-2: rgba(56, 189, 248, 0.15);
  --bg-accent-3: rgba(245, 158, 11, 0.1);

  --glass-bg: rgba(15, 23, 42, 0.58);
  --glass-bg-hover: rgba(30, 41, 59, 0.76);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 22px 55px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-emerald: #10b981;
  --accent-sky: #38bdf8;
  --accent-amber: #f59e0b;

  --input-bg: rgba(15, 23, 42, 0.76);
  --input-border: rgba(148, 163, 184, 0.25);

  --clock-glow-emerald: 0 0 44px rgba(16, 185, 129, 0.45), 0 0 14px rgba(16, 185, 129, 0.28);
  --clock-glow-sky: 0 0 44px rgba(56, 189, 248, 0.42), 0 0 14px rgba(56, 189, 248, 0.25);

  --earth-canvas-opacity: 0.82;
  --atmo-halo-color: rgba(56, 189, 248, 0.24);
}

html.light {
  --bg-gradient-1: #eaf1f8;
  --bg-gradient-2: #d8e4f2;
  --bg-accent-1: rgba(16, 185, 129, 0.14);
  --bg-accent-2: rgba(56, 189, 248, 0.16);
  --bg-accent-3: rgba(245, 158, 11, 0.12);

  --glass-bg: rgba(255, 255, 255, 0.68);
  --glass-bg-hover: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(255, 255, 255, 0.88);
  --glass-highlight: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 18px 44px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --input-bg: rgba(255, 255, 255, 0.88);
  --input-border: rgba(148, 163, 184, 0.36);

  --clock-glow-emerald: 0 8px 30px rgba(16, 185, 129, 0.26);
  --clock-glow-sky: 0 8px 30px rgba(14, 165, 233, 0.24);

  --earth-canvas-opacity: 0.54;
  --atmo-halo-color: rgba(14, 165, 233, 0.26);
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-gradient-1);
  color: var(--text-primary);
  transition: background-color 0.45s ease, color 0.3s ease;
}

.font-arabic {
  font-family: 'Amiri', 'Scheherazade New', serif;
  line-height: 1.4;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Ambient Mesh Background */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 14% 18%, var(--bg-accent-1), transparent 45%),
    radial-gradient(circle at 86% 22%, var(--bg-accent-2), transparent 48%),
    radial-gradient(circle at 52% 88%, var(--bg-accent-3), transparent 50%),
    linear-gradient(145deg, var(--bg-gradient-1), var(--bg-gradient-2));
  transition: background 0.55s ease;
}

/* ==========================================================================
   NASA-STYLE 3D EARTH WEBGL STAGE & ATMOSPHERIC HALO
   ========================================================================== */

.nasa-cosmic-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#nasaEarthCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: var(--earth-canvas-opacity);
  transition: opacity 0.45s ease;
}

/* Subtle Atmospheric Outer Halo behind 3D Globe */
@keyframes pulseAtmosphere {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.75;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.04);
    opacity: 1;
  }
}

.nasa-atmosphere-halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(68vw, 660px);
  height: min(68vw, 660px);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle,
    rgba(56, 189, 248, 0.08) 42%,
    var(--atmo-halo-color) 64%,
    transparent 74%
  );
  filter: blur(8px);
  animation: pulseAtmosphere 9s ease-in-out infinite;
}

/* Distant Sun Flare Accent */
@keyframes sunFlareDrift {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.8;
  }
  50% {
    transform: translate3d(-24px, 14px, 0) scale(1.1);
    opacity: 1;
  }
}

.cosmic-sun-flare {
  position: absolute;
  top: -110px;
  right: -80px;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 42% 42%,
    rgba(251, 191, 36, 0.25) 0%,
    rgba(245, 158, 11, 0.1) 36%,
    transparent 70%
  );
  filter: blur(12px);
  animation: sunFlareDrift 15s ease-in-out infinite;
}

/* ==========================================================================
   3D CARD FLIP SCENE & FACES
   ========================================================================== */

.flip-scene {
  width: 100vw;
  height: 100vh;
  perspective: 1200px;
  overflow: hidden;
}

.flip-card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.82s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.flip-card.is-flipped {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-face-front {
  transform: rotateY(0deg);
  z-index: 2;
  pointer-events: auto;
}

.flip-card.is-flipped .flip-face-front {
  pointer-events: none;
}

.flip-face-back {
  transform: rotateY(180deg);
  z-index: 1;
  pointer-events: none;
}

.flip-card.is-flipped .flip-face-back {
  pointer-events: auto;
  z-index: 3;
}

/* ==========================================================================
   HERO FULLSCREEN CLOCK TYPOGRAPHY
   ========================================================================== */

.hero-clock-istiwak {
  font-size: clamp(3.2rem, 7.6vw, 7.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
  text-shadow: var(--clock-glow-emerald);
}

.hero-clock-local {
  font-size: clamp(3.2rem, 7.6vw, 7.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
  text-shadow: var(--clock-glow-sky);
}

/* Glassmorphism Surfaces */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(165%);
  -webkit-backdrop-filter: blur(18px) saturate(165%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-subcard {
  background: var(--glass-highlight);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s ease;
}

.glass-subcard:hover {
  background: var(--glass-bg-hover);
}

.glass-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.glass-input:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

/* Flip Action Button Glow */
.flip-action-btn {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(56, 189, 248, 0.18));
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.18);
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.flip-action-btn:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: rgba(16, 185, 129, 0.7);
  box-shadow: 0 12px 32px rgba(16, 185, 129, 0.28);
}

.flip-action-btn:active {
  transform: scale(0.98);
}

/* Dashboard Calendar Cell */
.cal-cell {
  min-height: 58px;
  padding: 0.35rem 0.45rem !important;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1),
              background-color 0.16s ease,
              border-color 0.16s ease;
}

.cal-cell:hover {
  transform: translateY(-2px);
}

.cal-cell:active {
  transform: scale(0.97);
}

/* Modal Bounce Animation */
@keyframes modalBounceIn {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(14px);
  }
  65% {
    opacity: 1;
    transform: scale(1.015) translateY(-2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalFadeOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.94) translateY(6px);
  }
}

.modal-open .modal-panel {
  animation: modalBounceIn 0.34s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-closing .modal-panel {
  animation: modalFadeOut 0.18s ease forwards;
}

/* Hand-drawn Today Circle Animation */
@keyframes drawCircle {
  from {
    stroke-dashoffset: 260;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.hand-drawn-circle path {
  stroke-dasharray: 260;
  stroke-dashoffset: 0;
  animation: drawCircle 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Prayer Row Active Pulse */
@keyframes softPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.32);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0);
  }
}

.prayer-next {
  border-color: rgba(16, 185, 129, 0.65) !important;
  background: rgba(16, 185, 129, 0.15) !important;
  animation: softPulse 2.4s infinite;
}

/* Audio Equalizer Bars */
@keyframes eqBounce {
  0%, 100% { height: 6px; }
  50% { height: 22px; }
}

.eq-bar {
  width: 4px;
  border-radius: 999px;
  background: #10b981;
  animation: eqBounce 0.85s ease-in-out infinite;
}

.eq-bar:nth-child(2) { animation-delay: 0.15s; }
.eq-bar:nth-child(3) { animation-delay: 0.3s; }
.eq-bar:nth-child(4) { animation-delay: 0.45s; }
.eq-bar:nth-child(5) { animation-delay: 0.2s; }

/* Compass Needle Smooth Rotation */
.compass-dial {
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.32);
  border-radius: 999px;
}
