/* ==========================================================================
   Christmas Theme - Seasonal Decorations for PinePaper Studio
   Active: December 1 - January 1
   ========================================================================== */

/* ─── Christmas Theme Variables ─── */
:root.christmas-theme {
  /* Override accent colors with festive palette */
  --christmas-red: #dc2626;
  --christmas-green: #16a34a;
  --christmas-gold: #fbbf24;
  --christmas-snow: #f0f9ff;
  --christmas-night: #0a1628;
  --christmas-pine: #14532d;

  /* Subtle color shifts for primary UI elements */
  --color-primary: #dc2626;
  --color-primary-hover: #b91c1c;
  --color-primary-light: #ef4444;
  --color-accent: #16a34a;
  --color-accent-hover: #15803d;
}

/* ─── Snowfall Animation ─── */
@keyframes snowfall {
  0% {
    transform: translateY(-10vh) translateX(0);
    opacity: 1;
  }
  50% {
    transform: translateY(50vh) translateX(20px);
  }
  100% {
    transform: translateY(110vh) translateX(-20px);
    opacity: 0.3;
  }
}

@keyframes snowfallSlow {
  0% {
    transform: translateY(-10vh) translateX(0) rotate(0deg);
    opacity: 0.8;
  }
  100% {
    transform: translateY(110vh) translateX(-30px) rotate(360deg);
    opacity: 0.2;
  }
}

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes christmasGlow {
  0%, 100% {
    box-shadow: 0 0 5px var(--christmas-red), 0 0 10px var(--christmas-gold);
  }
  50% {
    box-shadow: 0 0 15px var(--christmas-green), 0 0 25px var(--christmas-gold);
  }
}

@keyframes lightBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Snowfall Container ─── */
.christmas-theme .snowfall-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.christmas-theme .snowflake {
  position: absolute;
  color: white;
  font-size: 1rem;
  user-select: none;
  animation: snowfall linear infinite;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

.christmas-theme .snowflake:nth-child(odd) {
  animation-name: snowfallSlow;
}

/* Individual snowflake positioning and timing */
.christmas-theme .snowflake:nth-child(1) { left: 5%; animation-duration: 15s; animation-delay: 0s; font-size: 0.8rem; }
.christmas-theme .snowflake:nth-child(2) { left: 15%; animation-duration: 12s; animation-delay: 2s; font-size: 1.2rem; }
.christmas-theme .snowflake:nth-child(3) { left: 25%; animation-duration: 18s; animation-delay: 4s; font-size: 0.9rem; }
.christmas-theme .snowflake:nth-child(4) { left: 35%; animation-duration: 14s; animation-delay: 1s; font-size: 1rem; }
.christmas-theme .snowflake:nth-child(5) { left: 45%; animation-duration: 16s; animation-delay: 3s; font-size: 0.7rem; }
.christmas-theme .snowflake:nth-child(6) { left: 55%; animation-duration: 13s; animation-delay: 5s; font-size: 1.1rem; }
.christmas-theme .snowflake:nth-child(7) { left: 65%; animation-duration: 17s; animation-delay: 2s; font-size: 0.85rem; }
.christmas-theme .snowflake:nth-child(8) { left: 75%; animation-duration: 11s; animation-delay: 0s; font-size: 1.3rem; }
.christmas-theme .snowflake:nth-child(9) { left: 85%; animation-duration: 19s; animation-delay: 4s; font-size: 0.75rem; }
.christmas-theme .snowflake:nth-child(10) { left: 95%; animation-duration: 14s; animation-delay: 1s; font-size: 1rem; }
.christmas-theme .snowflake:nth-child(11) { left: 10%; animation-duration: 20s; animation-delay: 6s; font-size: 0.9rem; }
.christmas-theme .snowflake:nth-child(12) { left: 30%; animation-duration: 15s; animation-delay: 3s; font-size: 1.15rem; }
.christmas-theme .snowflake:nth-child(13) { left: 50%; animation-duration: 13s; animation-delay: 7s; font-size: 0.8rem; }
.christmas-theme .snowflake:nth-child(14) { left: 70%; animation-duration: 16s; animation-delay: 2s; font-size: 1.05rem; }
.christmas-theme .snowflake:nth-child(15) { left: 90%; animation-duration: 18s; animation-delay: 5s; font-size: 0.95rem; }

/* ─── Christmas Lights Border ─── */
.christmas-theme .christmas-lights {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 9998;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0,0,0,0.3) 10%,
    rgba(0,0,0,0.3) 90%,
    transparent 100%
  );
}

.christmas-theme .christmas-light {
  width: 8px;
  height: 12px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: 0 0 8px currentColor, 0 0 16px currentColor;
  animation: lightBlink 1s ease-in-out infinite;
}

.christmas-theme .christmas-light.red {
  background: var(--christmas-red);
  color: var(--christmas-red);
  animation-delay: 0s;
}
.christmas-theme .christmas-light.green {
  background: var(--christmas-green);
  color: var(--christmas-green);
  animation-delay: 0.2s;
}
.christmas-theme .christmas-light.gold {
  background: var(--christmas-gold);
  color: var(--christmas-gold);
  animation-delay: 0.4s;
}
.christmas-theme .christmas-light.blue {
  background: #3b82f6;
  color: #3b82f6;
  animation-delay: 0.6s;
}

/* Wire connecting lights */
.christmas-theme .christmas-lights::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  height: 2px;
  background: #1f2937;
  z-index: -1;
}

/* ─── Holiday Banner ─── */
.christmas-theme .holiday-banner {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9997;
  background: linear-gradient(135deg, var(--christmas-red) 0%, #991b1b 100%);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: christmasGlow 3s ease-in-out infinite;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.christmas-theme .holiday-banner:hover {
  transform: scale(1.05);
}

.christmas-theme .holiday-banner .banner-icon {
  font-size: 1.25rem;
}

.christmas-theme .holiday-banner .banner-close {
  margin-left: 8px;
  opacity: 0.7;
  cursor: pointer;
  font-size: 1rem;
}

.christmas-theme .holiday-banner .banner-close:hover {
  opacity: 1;
}

/* ─── Featured Template Badge ─── */
.christmas-theme .template-card[data-category="seasonal"] {
  border: 2px solid var(--christmas-gold);
  position: relative;
}

.christmas-theme .template-card[data-category="seasonal"]::before {
  content: '🎄 Featured';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--christmas-red);
  color: white;
  padding: 2px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 10;
}

/* ─── Festive Button Accents ─── */
.christmas-theme .btn-primary {
  background: linear-gradient(135deg, var(--christmas-red) 0%, #b91c1c 100%);
  border: none;
}

.christmas-theme .btn-primary:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

/* Success/secondary buttons get green treatment */
.christmas-theme .btn-success,
.christmas-theme .export-btn {
  background: linear-gradient(135deg, var(--christmas-green) 0%, #15803d 100%);
}

/* ─── Logo Festive Treatment ─── */
.christmas-theme .site-logo::after {
  content: ' 🎄';
}

/* ─── Footer Decoration ─── */
.christmas-theme footer,
.christmas-theme .footer {
  position: relative;
}

.christmas-theme footer::before,
.christmas-theme .footer::before {
  content: '❄️ Happy Holidays from PinePaper Studio! ❄️';
  display: block;
  text-align: center;
  padding: 8px;
  background: linear-gradient(90deg, var(--christmas-pine), var(--christmas-red), var(--christmas-pine));
  color: white;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ─── Cursor Trail (Optional - Performance Heavy) ─── */
.christmas-theme.cursor-sparkle * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ctext y='20' font-size='20'%3E❄️%3C/text%3E%3C/svg%3E") 12 12, auto;
}

/* ─── Seasonal Category Highlight ─── */
.christmas-theme [data-filter="seasonal"],
.christmas-theme .category-seasonal {
  background: linear-gradient(135deg, var(--christmas-red) 0%, var(--christmas-green) 100%);
  color: white;
  font-weight: 600;
}

.christmas-theme [data-filter="seasonal"]::before,
.christmas-theme .category-seasonal::before {
  content: '🎅 ';
}

/* ─── Festive Scrollbar ─── */
.christmas-theme ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--christmas-red), var(--christmas-green));
}

.christmas-theme ::-webkit-scrollbar-track {
  background: var(--christmas-night);
}

/* ─── Reduce Motion Support ─── */
@media (prefers-reduced-motion: reduce) {
  .christmas-theme .snowflake,
  .christmas-theme .christmas-light {
    animation: none !important;
  }

  .christmas-theme .snowfall-container {
    display: none;
  }
}

/* ─── Print Styles - Remove Decorations ─── */
@media print {
  .christmas-theme .snowfall-container,
  .christmas-theme .christmas-lights,
  .christmas-theme .holiday-banner {
    display: none !important;
  }
}

/* ─── Mobile Optimizations ─── */
@media (max-width: 768px) {
  .christmas-theme .holiday-banner {
    display: none !important; /* Hide banner on mobile - too intrusive */
  }

  .christmas-theme .snowflake {
    font-size: 0.7rem !important;
  }

  /* Reduce number of visible snowflakes on mobile */
  .christmas-theme .snowflake:nth-child(n+8) {
    display: none;
  }

  /* Make lights less prominent on mobile */
  .christmas-theme .christmas-lights {
    opacity: 0.6;
  }
}

/* ─── Christmas Theme Toggle Button ─── */
.christmas-toggle {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

/* Header-positioned toggle (in editor.html header) */
.christmas-toggle.christmas-toggle-header {
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #9ca3af;
}

.christmas-toggle.christmas-toggle-header:hover {
  background: rgba(55, 65, 81, 1);
  color: #fff;
}

.christmas-toggle.christmas-toggle-header .toggle-icon {
  font-size: 1.25rem;
}

/* Legacy fixed-position toggle (for non-editor pages) */
.christmas-toggle:not(.christmas-toggle-header) {
  position: fixed;
  bottom: 60px;
  left: 16px;
  z-index: 9997;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.christmas-toggle:not(.christmas-toggle-header):hover {
  background: var(--color-bg-tertiary);
  transform: translateY(-2px);
}

.christmas-toggle .toggle-icon {
  font-size: 1.25rem;
}

/* When theme is active, show different icon */
.christmas-theme .christmas-toggle .toggle-text::after {
  content: ' (On)';
}

:not(.christmas-theme) .christmas-toggle .toggle-text::after {
  content: ' (Off)';
}

/* ─── Mobile Toggle Button - Less Intrusive (legacy fixed position only) ─── */
@media (max-width: 768px) {
  .christmas-toggle:not(.christmas-toggle-header) {
    /* Move to bottom-right, make it smaller and less intrusive */
    bottom: auto;
    top: 50%;
    left: auto;
    right: -8px;
    transform: translateY(-50%) rotate(-90deg);
    transform-origin: center center;
    padding: 4px 8px;
    font-size: 0.7rem;
    border-radius: 4px 4px 0 0;
    opacity: 0.7;
    box-shadow: none;
    border-right: none;
    gap: 4px;
  }

  .christmas-toggle:not(.christmas-toggle-header):hover,
  .christmas-toggle:not(.christmas-toggle-header):focus {
    opacity: 1;
  }

  .christmas-toggle:not(.christmas-toggle-header) .toggle-icon {
    font-size: 0.9rem;
  }

  .christmas-toggle:not(.christmas-toggle-header) .toggle-text {
    display: none; /* Hide text on mobile, just show icon */
  }

  /* Show text indicator on active state only via icon change */
  .christmas-theme .christmas-toggle:not(.christmas-toggle-header) .toggle-text::after,
  :not(.christmas-theme) .christmas-toggle:not(.christmas-toggle-header) .toggle-text::after {
    content: none;
  }
}

/* Portrait mode - even more subtle (legacy fixed position only) */
@media (max-width: 768px) and (orientation: portrait) {
  .christmas-toggle:not(.christmas-toggle-header) {
    top: 30%;
    opacity: 0.5;
  }
}

/* Landscape mode - hide toggle completely, maximizing screen space (legacy only) */
@media (max-width: 767px) and (orientation: landscape) {
  .christmas-toggle:not(.christmas-toggle-header) {
    display: none !important;
  }

  /* Also reduce snowfall in landscape */
  .christmas-theme .snowflake:nth-child(n+5) {
    display: none;
  }
}
