/* ==========================================================================
   ELF SMITH 2026 - Stylesheet & Design System
   ========================================================================== */

/* Modern Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* Default Night Theme Tokens - Twilight Magical Forest */
  --bg-sky-top: #090715;
  --bg-sky-mid: #140d2d;
  --bg-sky-bottom: #2b1442;
  --color-accent-gold: #ffd269;
  --color-accent-teal: #4df0d2;
  --color-accent-pink: #ff6bb5;
  --color-text-primary: #fcfbfe;
  --color-text-secondary: rgba(252, 251, 254, 0.7);
  --color-text-muted: rgba(252, 251, 254, 0.4);
  
  /* Glassmorphism details */
  --glass-bg: rgba(20, 15, 45, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(16px);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  /* Scenery colors */
  --mountain-back: rgba(30, 15, 60, 0.8);
  --mountain-mid: rgba(18, 9, 41, 0.9);
  --mountain-front: #0d061f;
  
  /* Background Titles gradient colors */
  --title-color-1: rgba(255, 255, 255, 0.12);
  --title-color-2: rgba(255, 210, 105, 0.04);
  --title-color-3: rgba(255, 107, 181, 0.08);
  --title-year-1: rgba(255, 210, 105, 0.15);
  --title-year-2: rgba(255, 107, 181, 0.05);
  --title-year-3: rgba(77, 240, 210, 0.12);

  /* Fonts */
  --font-primary: 'Outfit', sans-serif;
  --font-serif: 'Playfair Display', serif;
}

body[data-theme="day"] {
  /* Day Theme Tokens - GORGEOUS bright fantasy dreamscape */
  --bg-sky-top: #93ccf5;
  --bg-sky-mid: #bcd8f9;
  --bg-sky-bottom: #fff0d4;
  --color-accent-gold: #ff9e2c; /* Sunny gold */
  --color-accent-teal: #16a085;
  --color-accent-pink: #d93d72;
  --color-text-primary: #1c1538;
  --color-text-secondary: rgba(28, 21, 56, 0.75);
  --color-text-muted: rgba(28, 21, 56, 0.45);
  
  /* Bright Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(28, 21, 56, 0.08);
  --glass-blur: blur(16px);
  --glass-shadow: 0 8px 32px 0 rgba(28, 21, 56, 0.1);
  
  /* Scenery colors */
  --mountain-back: rgba(75, 137, 158, 0.55);
  --mountain-mid: rgba(43, 98, 115, 0.82);
  --mountain-front: #1a3c4a;
  
  /* Background Titles gradient colors */
  --title-color-1: rgba(28, 21, 56, 0.07);
  --title-color-2: rgba(255, 158, 44, 0.04);
  --title-color-3: rgba(217, 61, 114, 0.05);
  --title-year-1: rgba(255, 158, 44, 0.08);
  --title-year-2: rgba(217, 61, 114, 0.04);
  --title-year-3: rgba(22, 160, 133, 0.06);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  touch-action: none; /* Block default double-tap, zoom, pull-to-refresh */
  -webkit-user-select: none;
  user-select: none;
  font-family: var(--font-primary);
  background-color: var(--bg-sky-top);
  color: var(--color-text-primary);
  transition: background-color 1.2s cubic-bezier(0.25, 1, 0.3, 1), color 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}
  color: var(--color-text-primary);
}

/* ==========================================================================
   Scenic Background & Parallax Elements
   ========================================================================== */

.scenic-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
}

/* Sky gradient backdrop */
.sky-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    var(--bg-sky-top) 0%,
    var(--bg-sky-mid) 45%,
    var(--bg-sky-bottom) 100%
  );
  transition: opacity 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}

/* Sky layer pseudo-element background transition support */
.scenic-background::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    #090715 0%,
    #140d2d 45%,
    #2b1442 100%
  );
  opacity: 1;
  transition: opacity 1.2s cubic-bezier(0.25, 1, 0.3, 1);
  z-index: -1;
}

body[data-theme="day"] .scenic-background::before {
  opacity: 0;
}

/* Glowing Mystic Moon / Sun */
.celestial-body {
  position: absolute;
  top: 15%;
  right: 15%;
  width: clamp(100px, 20vw, 240px);
  height: clamp(100px, 20vw, 240px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #ffe9b5 40%, var(--color-accent-gold) 100%);
  box-shadow: 
    0 0 60px 10px rgba(255, 210, 105, 0.4),
    0 0 120px 30px rgba(255, 107, 181, 0.2);
  filter: blur(1px);
  opacity: 0.85;
  animation: floatCelestial 15s ease-in-out infinite alternate;
  transition: background 1.2s cubic-bezier(0.25, 1, 0.3, 1), box-shadow 1.2s cubic-bezier(0.25, 1, 0.3, 1), opacity 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}

body[data-theme="day"] .celestial-body {
  background: radial-gradient(circle at 35% 35%, #ffffff 10%, #ffdf94 45%, var(--color-accent-gold) 100%);
  box-shadow: 
    0 0 80px 20px rgba(255, 158, 44, 0.55),
    0 0 160px 45px rgba(255, 107, 107, 0.25);
  opacity: 0.95;
}

/* Starfield Generator */
.stars-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.6;
  transition: opacity 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}

body[data-theme="day"] .stars-container {
  opacity: 0;
}

.star {
  position: absolute;
  background-color: #ffffff;
  border-radius: 50%;
  animation: twinkle var(--twinkle-dur, 3s) infinite ease-in-out alternate;
}

/* Parallax Mountains */
.mountain-ridge {
  position: absolute;
  bottom: 0;
  left: -10%;
  width: 120%;
  height: 40%;
  background-repeat: repeat-x;
  transform-origin: bottom center;
}

/* Beautiful dynamic shapes of hills/ridges */
.back-ridge {
  height: 45%;
  background: linear-gradient(170deg, transparent 55%, var(--mountain-back) 55%),
              linear-gradient(190deg, transparent 48%, var(--mountain-back) 48%);
  opacity: 0.4;
  filter: blur(3px);
  animation: subtleSwayBack 40s ease-in-out infinite alternate;
  transition: background 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}

.middle-ridge {
  height: 32%;
  background: linear-gradient(160deg, transparent 60%, var(--mountain-mid) 60%),
              linear-gradient(205deg, transparent 52%, var(--mountain-mid) 52%);
  opacity: 0.75;
  filter: blur(1.5px);
  animation: subtleSwayMid 30s ease-in-out infinite alternate;
  transition: background 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}

.front-ridge {
  height: 20%;
  background: linear-gradient(150deg, transparent 65%, var(--mountain-front) 65%),
              linear-gradient(215deg, transparent 58%, var(--mountain-front) 58%);
  opacity: 0.95;
  filter: drop-shadow(0 -10px 20px rgba(0, 0, 0, 0.5));
  transition: background 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}

/* ==========================================================================
   Background Typography (ELF SMITH 2026)
   ========================================================================== */

.title-container {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  text-align: center;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.2em;
}

.background-title {
  font-size: clamp(3rem, 11vw, 8rem);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: transparent;
  background: linear-gradient(135deg, var(--title-color-1) 0%, var(--title-color-2) 50%, var(--title-color-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 
    0 0 20px rgba(255, 255, 255, 0.02),
    0 0 80px rgba(255, 210, 105, 0.03);
  animation: titlePulse 8s ease-in-out infinite alternate;
  line-height: 0.9;
  transition: background 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}

.background-title.year {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0.35em;
  margin-left: 0.35em;
  font-size: clamp(2rem, 8vw, 5.5rem);
  background: linear-gradient(135deg, var(--title-year-1) 0%, var(--title-year-2) 50%, var(--title-year-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  opacity: 0.8;
  animation: yearPulse 8s ease-in-out infinite alternate-reverse;
  transition: background 1.2s cubic-bezier(0.25, 1, 0.3, 1);
}

/* ==========================================================================
   Canvas (The Game Layer)
   ========================================================================== */

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: auto;
}

/* ==========================================================================
   Heads Up Display Overlay (HUD)
   ========================================================================== */

.hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none; /* Let canvas capture touch clicks */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 24px) 24px env(safe-area-inset-bottom, 24px) 24px;
}

/* Top Nav Elements */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.top-nav-controls {
  display: flex;
  gap: 12px;
}

/* Sun/Moon Theme Toggle */
body:not([data-theme="day"]) .sun-icon {
  display: none;
}
body[data-theme="day"] .moon-icon {
  display: none;
}

.game-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 50px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  pointer-events: auto;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-accent-pink);
  box-shadow: 0 0 10px var(--color-accent-pink);
  transition: all 0.5s ease;
}

.status-dot.walking {
  background-color: var(--color-accent-gold);
  box-shadow: 0 0 10px var(--color-accent-gold);
  animation: statusPulse 1.5s infinite;
}

.status-dot.flying {
  background-color: var(--color-accent-teal);
  box-shadow: 0 0 10px var(--color-accent-teal);
  animation: statusPulse 1s infinite;
}

.status-text {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  transition: color 0.5s ease;
}

/* Restart Button */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  pointer-events: auto;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.icon-btn:hover {
  transform: scale(1.1) rotate(45deg);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--color-accent-gold);
  box-shadow: 0 0 15px var(--color-accent-gold);
}

.icon-btn:active {
  transform: scale(0.9) rotate(90deg);
}

/* Help / Interaction Hints */
.control-hints {
  align-self: center;
  text-align: center;
  padding: 16px 24px;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  max-width: 280px;
  margin-bottom: clamp(10px, 5vh, 40px);
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
  transition: all 0.8s cubic-bezier(0.19, 1, 0.22, 1);
}

.control-hints.fade-out {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.hint-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-accent-gold);
  margin-bottom: 4px;
}

.hint-desc {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   Animations CSS
   ========================================================================== */

@keyframes floatCelestial {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-15px) scale(1.02); }
}

@keyframes twinkle {
  0% { opacity: 0.2; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.2); }
}

@keyframes titlePulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.04); opacity: 1; }
}

@keyframes yearPulse {
  0% { transform: scale(0.98); opacity: 0.75; }
  100% { transform: scale(1.02); opacity: 0.9; }
}

@keyframes statusPulse {
  0% { opacity: 0.5; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0.5; transform: scale(0.9); }
}

@keyframes subtleSwayBack {
  0% { transform: translateX(-1%) scaleY(1); }
  100% { transform: translateX(1%) scaleY(1.03); }
}

@keyframes subtleSwayMid {
  0% { transform: translateX(1%) scaleY(1.02); }
  100% { transform: translateX(-1%) scaleY(0.98); }
}
