/**
 * MyCSSLab Dynamic Theme Engine
 * Real-time theme switching based on time, weather, location, and user behavior
 * Version: 3.0.2
 */

/* ========================================
   DYNAMIC THEME CORE VARIABLES
   ======================================== */

:root {
  /* Time-based theme variables */
  --theme-time: 12; /* Current hour (0-23) */
  --theme-time-intensity: 1; /* How much time affects theme (0-1) */
  
  /* Weather-based theme variables */
  --theme-weather: 'sunny'; /* sunny, cloudy, rainy, snowy, stormy */
  --theme-weather-intensity: 1; /* How much weather affects theme (0-1) */
  
  /* Location-based theme variables */
  --theme-location: 'urban'; /* urban, rural, coastal, mountain, desert */
  --theme-location-intensity: 1; /* How much location affects theme (0-1) */
  
  /* User preference variables */
  --theme-mood: 'neutral'; /* happy, sad, energetic, calm, creative, professional */
  --theme-mood-intensity: 1; /* How much mood affects theme (0-1) */
  
  /* Dynamic color calculations */
  --theme-hue: 240;
  --theme-saturation: 70%;
  --theme-lightness: 50%;
  --theme-contrast: 1;
  --theme-brightness: 1;
  
  /* Theme transition settings */
  --theme-transition: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --theme-smooth-transition: 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ========================================
   TIME-BASED THEMES
   ======================================== */

/* Dawn Theme (5-7 AM) */
.my-theme-dawn {
  --theme-hue: 30;
  --theme-saturation: 60%;
  --theme-lightness: 70%;
  --theme-contrast: 0.8;
  --theme-brightness: 0.9;
}

/* Morning Theme (7-11 AM) */
.my-theme-morning {
  --theme-hue: 45;
  --theme-saturation: 80%;
  --theme-lightness: 60%;
  --theme-contrast: 1;
  --theme-brightness: 1.1;
}

/* Afternoon Theme (11 AM-3 PM) */
.my-theme-afternoon {
  --theme-hue: 60;
  --theme-saturation: 90%;
  --theme-lightness: 55%;
  --theme-contrast: 1.1;
  --theme-brightness: 1.2;
}

/* Evening Theme (3-7 PM) */
.my-theme-evening {
  --theme-hue: 15;
  --theme-saturation: 85%;
  --theme-lightness: 45%;
  --theme-contrast: 1.2;
  --theme-brightness: 0.9;
}

/* Night Theme (7 PM-5 AM) */
.my-theme-night {
  --theme-hue: 240;
  --theme-saturation: 70%;
  --theme-lightness: 30%;
  --theme-contrast: 1.3;
  --theme-brightness: 0.7;
}

/* ========================================
   WEATHER-BASED THEMES
   ======================================== */

.my-theme-sunny {
  --theme-hue: 45;
  --theme-saturation: 90%;
  --theme-lightness: 65%;
  --theme-contrast: 1.2;
  --theme-brightness: 1.3;
}

.my-theme-cloudy {
  --theme-hue: 200;
  --theme-saturation: 40%;
  --theme-lightness: 60%;
  --theme-contrast: 0.9;
  --theme-brightness: 0.8;
}

.my-theme-rainy {
  --theme-hue: 220;
  --theme-saturation: 60%;
  --theme-lightness: 45%;
  --theme-contrast: 1.1;
  --theme-brightness: 0.7;
}

.my-theme-snowy {
  --theme-hue: 200;
  --theme-saturation: 20%;
  --theme-lightness: 85%;
  --theme-contrast: 0.8;
  --theme-brightness: 1.1;
}

.my-theme-stormy {
  --theme-hue: 240;
  --theme-saturation: 80%;
  --theme-lightness: 25%;
  --theme-contrast: 1.4;
  --theme-brightness: 0.6;
}

/* ========================================
   LOCATION-BASED THEMES
   ======================================== */

.my-theme-urban {
  --theme-hue: 0;
  --theme-saturation: 30%;
  --theme-lightness: 50%;
  --theme-contrast: 1.1;
  --theme-brightness: 0.9;
}

.my-theme-rural {
  --theme-hue: 120;
  --theme-saturation: 60%;
  --theme-lightness: 55%;
  --theme-contrast: 1;
  --theme-brightness: 1;
}

.my-theme-coastal {
  --theme-hue: 200;
  --theme-saturation: 70%;
  --theme-lightness: 60%;
  --theme-contrast: 1.1;
  --theme-brightness: 1.1;
}

.my-theme-mountain {
  --theme-hue: 160;
  --theme-saturation: 50%;
  --theme-lightness: 45%;
  --theme-contrast: 1.2;
  --theme-brightness: 0.8;
}

.my-theme-desert {
  --theme-hue: 30;
  --theme-saturation: 80%;
  --theme-lightness: 70%;
  --theme-contrast: 1.3;
  --theme-brightness: 1.2;
}

/* ========================================
   MOOD-BASED THEMES
   ======================================== */

.my-theme-happy {
  --theme-hue: 60;
  --theme-saturation: 90%;
  --theme-lightness: 65%;
  --theme-contrast: 1.1;
  --theme-brightness: 1.2;
}

.my-theme-sad {
  --theme-hue: 240;
  --theme-saturation: 40%;
  --theme-lightness: 40%;
  --theme-contrast: 0.9;
  --theme-brightness: 0.7;
}

.my-theme-energetic {
  --theme-hue: 0;
  --theme-saturation: 95%;
  --theme-lightness: 55%;
  --theme-contrast: 1.3;
  --theme-brightness: 1.3;
}

.my-theme-calm {
  --theme-hue: 200;
  --theme-saturation: 50%;
  --theme-lightness: 70%;
  --theme-contrast: 0.8;
  --theme-brightness: 0.9;
}

.my-theme-creative {
  --theme-hue: 300;
  --theme-saturation: 80%;
  --theme-lightness: 60%;
  --theme-contrast: 1.2;
  --theme-brightness: 1.1;
}

.my-theme-professional {
  --theme-hue: 220;
  --theme-saturation: 30%;
  --theme-lightness: 50%;
  --theme-contrast: 1.1;
  --theme-brightness: 1;
}

/* ========================================
   DYNAMIC THEME APPLICATIONS
   ======================================== */

.my-dynamic-theme {
  background: hsl(var(--theme-hue), var(--theme-saturation), var(--theme-lightness));
  color: hsl(calc(var(--theme-hue) + 180), var(--theme-saturation), calc(100% - var(--theme-lightness)));
  transition: all var(--theme-transition);
}

.my-dynamic-theme-bg {
  background: linear-gradient(135deg,
    hsl(var(--theme-hue), var(--theme-saturation), var(--theme-lightness)) 0%,
    hsl(calc(var(--theme-hue) + 30), var(--theme-saturation), calc(var(--theme-lightness) + 10%)) 50%,
    hsl(calc(var(--theme-hue) + 60), var(--theme-saturation), calc(var(--theme-lightness) + 20%)) 100%);
  transition: all var(--theme-smooth-transition);
}

.my-dynamic-theme-text {
  color: hsl(calc(var(--theme-hue) + 180), var(--theme-saturation), calc(100% - var(--theme-lightness)));
  text-shadow: 0 2px 4px rgba(0, 0, 0, calc(0.3 * var(--theme-contrast)));
  transition: all var(--theme-transition);
}

.my-dynamic-theme-border {
  border: 2px solid hsl(var(--theme-hue), var(--theme-saturation), calc(var(--theme-lightness) - 20%));
  transition: all var(--theme-transition);
}

.my-dynamic-theme-shadow {
  box-shadow: 0 4px 8px rgba(0, 0, 0, calc(0.2 * var(--theme-contrast))),
              0 8px 16px rgba(0, 0, 0, calc(0.1 * var(--theme-contrast)));
  transition: all var(--theme-transition);
}

/* ========================================
   SMART THEME ADAPTATION
   ======================================== */

.my-smart-theme {
  background: hsl(var(--theme-hue), var(--theme-saturation), var(--theme-lightness));
  filter: brightness(var(--theme-brightness)) contrast(var(--theme-contrast));
  transition: all var(--theme-smooth-transition);
}

.my-smart-theme:hover {
  --theme-hue: calc(var(--theme-hue) + 30);
  --theme-saturation: calc(var(--theme-saturation) + 10%);
  --theme-lightness: calc(var(--theme-lightness) + 10%);
}

.my-smart-theme-adaptive {
  background: linear-gradient(45deg,
    hsl(var(--theme-hue), var(--theme-saturation), var(--theme-lightness)) 0%,
    hsl(calc(var(--theme-hue) + 60), var(--theme-saturation), calc(var(--theme-lightness) + 15%)) 100%);
  transition: all var(--theme-smooth-transition);
}

/* ========================================
   THEME TRANSITION ANIMATIONS
   ======================================== */

.my-theme-transition {
  animation: theme-shift 3s ease-in-out infinite;
}

@keyframes theme-shift {
  0%, 100% { 
    --theme-hue: var(--theme-hue);
  }
  50% { 
    --theme-hue: calc(var(--theme-hue) + 60);
  }
}

.my-theme-pulse {
  animation: theme-pulse 2s ease-in-out infinite;
}

@keyframes theme-pulse {
  0%, 100% { 
    --theme-lightness: var(--theme-lightness);
  }
  50% { 
    --theme-lightness: calc(var(--theme-lightness) + 20%);
  }
}

.my-theme-breathe {
  animation: theme-breathe 4s ease-in-out infinite;
}

@keyframes theme-breathe {
  0%, 100% { 
    --theme-saturation: var(--theme-saturation);
  }
  50% { 
    --theme-saturation: calc(var(--theme-saturation) + 20%);
  }
}

/* ========================================
   CONTEXTUAL THEME SWITCHING
   ======================================== */

.my-context-time[data-hour="0-5"] { @extend .my-theme-night; }
.my-context-time[data-hour="5-7"] { @extend .my-theme-dawn; }
.my-context-time[data-hour="7-11"] { @extend .my-theme-morning; }
.my-context-time[data-hour="11-15"] { @extend .my-theme-afternoon; }
.my-context-time[data-hour="15-19"] { @extend .my-theme-evening; }
.my-context-time[data-hour="19-24"] { @extend .my-theme-night; }

.my-context-weather[data-weather="sunny"] { @extend .my-theme-sunny; }
.my-context-weather[data-weather="cloudy"] { @extend .my-theme-cloudy; }
.my-context-weather[data-weather="rainy"] { @extend .my-theme-rainy; }
.my-context-weather[data-weather="snowy"] { @extend .my-theme-snowy; }
.my-context-weather[data-weather="stormy"] { @extend .my-theme-stormy; }

.my-context-location[data-location="urban"] { @extend .my-theme-urban; }
.my-context-location[data-location="rural"] { @extend .my-theme-rural; }
.my-context-location[data-location="coastal"] { @extend .my-theme-coastal; }
.my-context-location[data-location="mountain"] { @extend .my-theme-mountain; }
.my-context-location[data-location="desert"] { @extend .my-theme-desert; }

.my-context-mood[data-mood="happy"] { @extend .my-theme-happy; }
.my-context-mood[data-mood="sad"] { @extend .my-theme-sad; }
.my-context-mood[data-mood="energetic"] { @extend .my-theme-energetic; }
.my-context-mood[data-mood="calm"] { @extend .my-theme-calm; }
.my-context-mood[data-mood="creative"] { @extend .my-theme-creative; }
.my-context-mood[data-mood="professional"] { @extend .my-theme-professional; }

/* ========================================
   THEME UTILITY CLASSES
   ======================================== */

.my-theme-auto {
  background: hsl(var(--theme-hue), var(--theme-saturation), var(--theme-lightness));
  color: hsl(calc(var(--theme-hue) + 180), var(--theme-saturation), calc(100% - var(--theme-lightness)));
  transition: all var(--theme-transition);
}

.my-theme-auto-bg {
  background: hsl(var(--theme-hue), var(--theme-saturation), var(--theme-lightness));
}

.my-theme-auto-text {
  color: hsl(calc(var(--theme-hue) + 180), var(--theme-saturation), calc(100% - var(--theme-lightness)));
}

.my-theme-auto-border {
  border-color: hsl(var(--theme-hue), var(--theme-saturation), calc(var(--theme-lightness) - 20%));
}

.my-theme-auto-shadow {
  box-shadow: 0 4px 8px hsla(var(--theme-hue), var(--theme-saturation), var(--theme-lightness), 0.3);
}

/* ========================================
   RESPONSIVE THEME ADAPTATION
   ======================================== */

@media (max-width: 768px) {
  .my-theme-mobile {
    --theme-contrast: calc(var(--theme-contrast) * 1.1);
    --theme-brightness: calc(var(--theme-brightness) * 0.9);
  }
}

@media (prefers-color-scheme: dark) {
  .my-theme-auto {
    --theme-lightness: calc(100% - var(--theme-lightness));
    --theme-contrast: calc(var(--theme-contrast) * 1.2);
    --theme-brightness: calc(var(--theme-brightness) * 0.8);
  }
}

@media (prefers-reduced-motion: reduce) {
  .my-theme-transition,
  .my-theme-pulse,
  .my-theme-breathe {
    animation: none;
  }
  
  .my-dynamic-theme,
  .my-smart-theme {
    transition: none;
  }
}
