/* ========================================
   GABIS ADVENTSKALENDER 2025 - MAIN STYLES
   Design-Tokens, Layout, Doors, Modal, A11y, Reduced-Motion, Breakpoints
   ======================================== */

/* ========================================
   1) DESIGN TOKENS & CSS VARIABLES
   ======================================== */
:root {
  /* Colors */
  --primary: #C1121F;
  --secondary: #0A3D62;
  --accent: #FDC70B;
  --bg: #0B1220;
  --panel: #0F1A2B;
  --text: #FFFFFF;
  --muted: #C5D0E0;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  
  /* Border Radius */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 16px;
  
  /* Shadows */
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-hard: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-focus: 0 0 0 2px var(--accent);
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;
  --font-weight-black: 800;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.2, 0.7, 0.2, 1);
  --transition-door: 700ms cubic-bezier(0.2, 0.7, 0.2, 1);
  
  /* Z-Index Scale */
  --z-parallax: 1;
  --z-calendar: 10;
  --z-doors: 20;
  --z-modal-backdrop: 100;
  --z-modal: 110;
  --z-dev-badge: 200;
}

/* ========================================
   2) RESET & BASE STYLES
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-weight: var(--font-weight-normal);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

button, input, textarea, select {
  font: inherit;
}

/* ========================================
   3) FOCUS MANAGEMENT & ACCESSIBILITY
   ======================================== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

button:focus-visible,
a:focus-visible {
  box-shadow: var(--shadow-focus);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-lg);
  z-index: 999;
  padding: var(--space-md) var(--space-xl);
  background: var(--primary);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-bold);
}

.skip-link:focus {
  top: var(--space-lg);
}

/* ========================================
   4) LAYOUT & STRUCTURE
   ======================================== */
.app-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

/* ========================================
   4) BACKGROUND SCENE (bg-anim.js)
   ======================================== */
.bg-scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-parallax);
  pointer-events: none;
}

.bg-scene .layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
  will-change: transform;
}

.bg-scene .layer.sky {
  z-index: 1;
}

.bg-scene canvas.stars {
  z-index: 2;
}

.bg-scene .layer.trees-far {
  z-index: 3;
}

.bg-scene .layer.town {
  z-index: 4;
}

.bg-scene .layer.trees-near {
  z-index: 5;
}

.bg-scene .layer.snow-fore {
  z-index: 6;
}

.bg-scene canvas.snow {
  z-index: 7;
}

.bg-scene .layer.lights {
  z-index: 8;
  height: 80px;
  background-size: auto 100%;
  background-repeat: repeat-x;
  opacity: 0.9;
}

.bg-scene .layer.glow {
  z-index: 9;
  opacity: 0.6;
  mix-blend-mode: screen;
}

.bg-scene .layer.chain {
  z-index: 10;
  transform-origin: 50% 0;
}

/* Main content wrapper */
.main-content {
  position: relative;
  z-index: var(--z-calendar);
  max-width: 980px;
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-xl);
}

/* Header */
.calendar-header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.calendar-title {
  font-family: 'Mountains of Christmas', 'Cormorant Garamond', serif; /* Festive font if available */
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  color: #D90429; /* Bright Christmas Red */
  margin-bottom: var(--space-md);
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(217, 4, 41, 0.6),
    0 0 40px rgba(255, 215, 0, 0.2);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.title-icon {
  font-size: 0.8em;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(5deg); }
}

.calendar-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: var(--font-weight-medium);
  color: var(--muted);
  opacity: 0.9;
}

.logo-container {
  margin-bottom: var(--space-xl);
}

.logo {
  max-width: 180px;
  margin: 0 auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* ========================================
   5) CALENDAR GRID & FRAME
   ======================================== */
.calendar-wrapper {
  position: relative;
  max-width: 980px;
  margin: 0 auto;
  aspect-ratio: 1.1 / 1;
  transform-style: preserve-3d; /* 3D context */
}

.calendar-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Prefer .jpg, fallback to .jpeg, then legacy PNG; paths are relative to this CSS file */
  background-image: url('../../kalenderfoto.jpg'), url('../../kalenderfoto.jpeg'), url('../overlays/calendar-frame.png');
  /* Fill the square frame while keeping the motif visible */
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: var(--z-doors);
  will-change: transform;
  transform-origin: center center;
}

/* Pendulum animation (desktop only) */
@keyframes pendulum {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg); }
}

.calendar-frame.pendulum { animation: none; }

/* Clean grid container - no visual bugs */
.doors-container {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  grid-auto-flow: dense;
  gap: clamp(10px, 1.5vw, 18px);
  width: 100%;
  height: 100%;
  align-items: stretch;
  justify-items: stretch;
  z-index: var(--z-doors);
  perspective: 1000px;
  perspective-origin: center center;
  transform-style: preserve-3d;
  isolation: isolate;
  /* Optimization: Help browser optimize rendering */
  contain: layout paint style;
  will-change: transform;
}

/* Soft floor shadow under calendar */
.calendar-wrapper::after{
  content: "";
  position: absolute;
  bottom: -30px;
  left: 50%;
  width: 80%;
  height: 60px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.4), rgba(0,0,0,0));
  filter: blur(25px);
  z-index: 1;
  pointer-events: none;
}

/* ========================================
   6) INDIVIDUAL DOOR STYLING - CLEAN & BEAUTIFUL
   ======================================== */

/* Base door container - Transparent mit Glaseffekt */
.door {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* MORE OPAQUE BACKGROUND - Less glassy, more solid */
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(20, 35, 55, 0.85));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  padding: 0;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  min-height: 0;
  overflow: hidden;
  perspective: 1000px;
  perspective-origin: center center;
  transform-style: preserve-3d;
  transform: translateZ(0) rotateX(0deg) rotateY(0deg);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  will-change: transform;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Subtle highlight gradient - Glaseffekt */
.door::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  /* Subtle paper texture overlay */
  background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 3h1v1H1V3zm2-2h1v1H3V1z' fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-color: rgba(255, 255, 255, 0.1);
  opacity: 0.6;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.3s ease;
}

/* Perforated edge effect */
.door::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  pointer-events: none;
  z-index: 2;
}

.door-shape-classic { border-radius: 22px; }
.door-shape-rounded { border-radius: 34px; }
.door-shape-arched { border-radius: 30px 30px 18px 18px; }
.door-shape-tilt { border-radius: 18px 30px 26px 20px; }
.door-shape-scalloped { border-radius: 22px; }
.door-shape-scalloped::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at top, rgba(255, 240, 220, 0.12) 0%, rgba(255, 240, 220, 0) 60%);
  pointer-events: none;
}
.door-shape-notched {
  border-radius: 22px;
  clip-path: polygon(10% 0%, 90% 0%, 100% 12%, 100% 88%, 90% 100%, 10% 100%, 0% 88%, 0% 12%);
  -webkit-clip-path: polygon(10% 0%, 90% 0%, 100% 12%, 100% 88%, 90% 100%, 10% 100%, 0% 88%, 0% 12%);
}

.door-theme-berry {
  background-color: #a8203c;
  background-image: linear-gradient(160deg, #a8203c 0%, #8a1028 100%);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.door-theme-ember {
  background-color: #d8661c;
  background-image: linear-gradient(160deg, #d8661c 0%, #b04a0b 100%);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.door-theme-pine {
  background-color: #20705c;
  background-image: linear-gradient(160deg, #20705c 0%, #154a3c 100%);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.door-theme-aurora {
  background-color: #3654b9;
  background-image: linear-gradient(160deg, #3654b9 0%, #243a85 100%);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.door-theme-sugar {
  background-color: #ec8cc4;
  background-image: linear-gradient(160deg, #ec8cc4 0%, #c45a9e 100%);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.door-theme-midnight {
  background-color: #7026a8;
  background-image: linear-gradient(160deg, #7026a8 0%, #521880 100%);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.door-size-grand .num {
  font-size: clamp(3rem, 6vw, 5rem);
}

.door-size-wide .num {
  font-size: clamp(2.4rem, 5.4vw, 4.4rem);
}

.door-size-tall .num {
  font-size: clamp(2.7rem, 5.2vw, 4.3rem);
}

.door-size-grand .door-inner {
  padding: 6% 4%;
}

.door-size-tall .door-inner {
  padding: 5% 6%;
}

.door-size-wide .door-inner {
  padding: 5% 4%;
}

/* Hover state - 3D Tilt Effect (folgt dem Cursor) */
.door:hover:not(.locked):not(.opened):not(.is-opening),
.door:focus-visible:not(.locked):not(.opened):not(.is-opening) {
  /* 3D Tilt wird via JS gesetzt mit --tilt-x und --tilt-y */
  transform: 
    translateY(-6px) 
    translateZ(20px)
    rotateX(calc(var(--tilt-x, 0) * 1deg)) 
    rotateY(calc(var(--tilt-y, 0) * 1deg))
    scale(1.03);
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.5), 
    0 5px 15px rgba(255, 215, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.door:hover:not(.locked):not(.opened):not(.is-opening)::before {
  opacity: 0.85;
}

/* Locked state */
.door.locked {
  cursor: not-allowed;
  opacity: 0.7;
  filter: grayscale(0.4) brightness(0.8);
}

/* Opening state - Lock interaction during animation */
.door.is-opening {
  pointer-events: none;
  cursor: default;
  z-index: calc(var(--z-doors) + 5);
}

/* Opened state - ALLOW CLICKING AGAIN */
.door.opened {
  pointer-events: auto; /* Was none */
}

.door.opened::before {
  opacity: 0.1;
}

/* ========================================
   DOOR INNER - BEAUTIFUL 3D OPENING ANIMATION
   ======================================== */

/* 
  The .door-inner acts as the hinged door panel.
  Beautiful opening animation before modal appears.
*/
.door-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  transform-style: preserve-3d;
  transform: rotateY(0deg) scale(1);
  transition: 
    transform 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55),
    opacity 0.6s ease 0.6s;
  will-change: transform, opacity;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* LEFT HINGE: Door swings open to the left with bounce */
.door.hinge-left .door-inner {
  transform-origin: left center;
}

.door.opened.hinge-left .door-inner {
  transform: rotateY(-125deg) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

/* RIGHT HINGE: Door swings open to the right with bounce */
.door.hinge-right .door-inner {
  transform-origin: right center;
}

.door.opened.hinge-right .door-inner {
  transform: rotateY(125deg) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

/* Opening animation with scale pulse */
.door.is-opening .door-inner {
  animation: doorOpenPulse 0.4s ease-out;
}

@keyframes doorOpenPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ========================================
   DOOR FACE (Front of the door panel)
   ======================================== */

/* The front face of the door - SEHR transparent für Durchsicht */
.door-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  display: none; /* VERSTECKT - nur die Nummer soll sichtbar sein */
  align-items: center;
  justify-content: center;
}

/* door-face ist versteckt - wird nicht mehr verwendet */

/* Door number styling - zentriert und golden */
.door-number,
.door .num {
  font-family: 'Mountains of Christmas', 'Cormorant Garamond', serif;
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  line-height: 1;
  font-weight: 700;
  color: #f0e6d2; /* Off-white/Paper color instead of pure gold */
  letter-spacing: 0.02em;
  /* Embossed/Printed look instead of neon glow */
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.6), 
    0 1px 0 rgba(255, 255, 255, 0.1);
  pointer-events: none;
  z-index: 10;
  /* ZENTRIERT in der Tür */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  text-align: center;
  transition: transform 0.3s ease, color 0.3s ease;
}

.door .num {
  /* Überschreibe position für JS-generierte Türen */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

/* Hover effect auf Nummer */
.door:hover:not(.locked):not(.opened) .num,
.door:hover:not(.locked):not(.opened) .door-number {
  transform: translate(-50%, -50%) scale(1.1);
  color: #fff;
  text-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.8), 
    0 0 15px rgba(255, 215, 0, 0.5);
}

/* "Today" door - Subtle breathing glow (reduced-motion safe) */
.door.today { 
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(255, 210, 90, 0.4);
}

@keyframes todayGlow { 
  0%, 100% { 
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 0 12px 4px rgba(255, 215, 0, 0.3);
  }
  50% { 
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45), 0 0 20px 8px rgba(255, 215, 0, 0.4);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .door.today { 
    animation: todayGlow 2.5s ease-in-out infinite;
  }
}

/* Lock indicator for future doors */
.door.locked .door-number::after,
.door.locked .num::after {
  content: ' 🔒';
  font-size: 0.7em;
  opacity: 0.8;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* ========================================
   DOOR BACK (Revealed after opening)
   ======================================== */

/* The back face - warm golden glow, auch transparent */
.door-back {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  transform: rotateY(180deg);
  background: 
    radial-gradient(circle at center, rgba(255, 215, 0, 0.4), rgba(40, 55, 75, 0.6)),
    rgba(30, 45, 65, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.5rem, 5vw, 4rem);
  text-shadow: 
    0 3px 10px rgba(255, 215, 0, 1),
    0 0 25px rgba(255, 215, 0, 0.8),
    0 0 50px rgba(255, 215, 0, 0.4);
  box-shadow: inset 0 0 50px rgba(255, 215, 0, 0.4);
}

/* Right-hinged doors need opposite back orientation */
.door.hinge-right .door-back {
  transform: rotateY(-180deg);
}

/* ========================================
   7) MODAL / DIALOG - MAGICAL GOLDEN REVEAL
   ======================================== */

/* Modal backdrop - Appears after door opens */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Warm golden radial glow from top */
  background: radial-gradient(
    circle at center top, 
    rgba(255, 215, 0, 0.15), 
    rgba(11, 18, 32, 0.92)
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  opacity: 0;
  visibility: hidden;
  /* Smooth fade-in */
  transition: 
    opacity 0.5s cubic-bezier(0.2, 0.6, 0.2, 1),
    visibility 0.5s cubic-bezier(0.2, 0.6, 0.2, 1),
    backdrop-filter 0.5s ease;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* The modal itself - Christmas Red Theme */
.modal {
  position: relative;
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  /* Warm Christmas Red Gradient */
  background: linear-gradient(
    160deg, 
    #B2001F 0%, 
    #8a0018 100%
  );
  border-radius: 24px; /* Rounded corners */
  border: 2px solid rgba(255, 215, 0, 0.3); /* Subtle golden border */
  /* Soft floating shadow */
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 10px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  overflow: hidden;
  /* Start scaled down and transparent */
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  /* Smooth scale + fade animation */
  transition: 
    transform 0.6s cubic-bezier(0.2, 0.6, 0.2, 1),
    opacity 0.6s cubic-bezier(0.2, 0.6, 0.2, 1);
  transition-delay: 0s;
  color: #fff;
  font-family: 'Playfair Display', 'Cormorant Garamond', 'Georgia', serif;
  will-change: transform, opacity;
}

/* Active state - Scale up and fade in with delay */
.modal-backdrop.active .modal {
  transform: scale(1) translateY(0);
  opacity: 1;
  /* Modal erscheint NACH der Tür-Animation (wird via JS gesteuert) */
  transition-delay: 0s;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  background: rgba(0, 0, 0, 0.1); /* Slight darken for header */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
  color: #FFD700; /* Gold text for title */
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.modal-close {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #fff;
  color: #B2001F;
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.modal-body {
  padding: 0;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
  background: #fff; /* White content background for contrast */
}

.modal-iframe {
  width: 100%;
  min-height: 600px;
  border: none;
  display: block;
  background: #fff;
}

/* ========================================
   8) DEV MODE FEATURES
   ======================================== */
.dev-badge {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-dev-badge);
  padding: var(--space-sm) var(--space-lg);
  background: var(--primary);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.door.dev-mode::before {
  content: attr(data-door-id);
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 0.75rem;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.7);
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 100;
  pointer-events: none;
}

.door.dev-mode {
  outline: 2px dashed rgba(253, 199, 11, 0.5);
  outline-offset: -2px;
}

/* ========================================
   9) FOOTER & LEGAL LINKS
   ======================================== */
.calendar-footer {
  text-align: center;
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.legal-links {
  display: flex;
  gap: var(--space-xl);
  justify-content: center;
  flex-wrap: wrap;
}

.legal-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color var(--transition-fast);
}

.legal-link:hover {
  color: var(--accent);
}

/* ========================================
   10) REDUCED MOTION PREFERENCES - ACCESSIBILITY FIRST
   ======================================== */

/* 
  Reduced motion support - Simplified animations for accessibility
*/
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.2s !important;
    scroll-behavior: auto !important;
  }
  
  /* Disable pendulum */
  .calendar-frame.pendulum {
    animation: none !important;
  }
 
  /* Disable 3D transforms but keep simple transitions */
  .door {
    transform: translateZ(0) !important;
  }
  
  .door-inner {
    transform: rotateY(0deg) !important;
  }
 
  /* Opened doors fade out instead of rotating */
  .door.opened .door-inner {
    opacity: 0.2 !important;
    transform: rotateY(0deg) !important;
  }
  
  /* Disable door pulse animation */
  .door.is-opening .door-inner {
    animation: none !important;
  }

  /* Modal appears with simple fade */
  .modal {
    transform: scale(1) !important;
  }

  .modal-backdrop.active .modal {
    transition-delay: 0.3s !important;
    transform: scale(1) !important;
  }
  
  /* Disable hover 3D transforms */
  .door:hover:not(.locked):not(.opened):not(.is-opening) {
    transform: translateY(-3px) scale(1.01) !important;
  }
  
  /* Disable confetti animation */
  .confetti {
    animation: none !important;
    display: none !important;
  }
}

/* ========================================
   11) RESPONSIVE BREAKPOINTS
   ======================================== */

/* Tablet */
@media (max-width: 768px) {
  :root {
    --space-3xl: 32px;
    --space-2xl: 24px;
  }
  
  .main-content {
    padding: var(--space-2xl) var(--space-lg);
  }
  
  .calendar-wrapper {
    max-width: 100%;
    aspect-ratio: auto;
  }

  .calendar-frame {
    display: none;
  }

  /* Use ID selector to override inline styles */
  #calendar,
  .doors-container {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(120px, 1fr);
    gap: clamp(12px, 3vw, 18px);
    padding: clamp(12px, 3vw, 18px);
    height: auto;
    background: rgba(8, 16, 28, 0.55);
    border-radius: 18px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  
  .door-number,
  .door .num {
    font-size: clamp(1rem, 4vw, 1.8rem);
  }
  
  .modal {
    max-width: 95%;
  }
  
  .modal-header {
    padding: var(--space-lg) var(--space-xl);
  }
  
  .modal-iframe {
    min-height: 400px;
  }
  
  .logo {
    max-width: 140px;
  }
  
  /* Disable pendulum on mobile */
  .calendar-frame.pendulum {
    animation: none;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .app-container {
    padding: var(--space-md) var(--space-sm);
    overflow-x: hidden;
  }

  .calendar-header {
    margin-bottom: var(--space-xl);
    padding-top: var(--space-md);
  }

  .calendar-title {
    font-size: 1.6rem;
    line-height: 1.2;
    padding: 0 var(--space-sm);
  }
  
  .calendar-subtitle {
    font-size: 0.95rem;
    margin-top: var(--space-sm);
    padding: 0 var(--space-md);
  }

  /* Move Dev Badge to avoid overlap */
  .dev-badge {
    top: auto;
    bottom: var(--space-sm);
    right: var(--space-sm);
    font-size: 0.7rem;
    padding: 4px 8px;
    opacity: 0.8;
    z-index: 900;
  }
  
  .door-number,
  .door .num {
    font-size: clamp(1.2rem, 6vw, 1.8rem);
  }
  
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  
  .modal {
    max-width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    transform: translateY(100%);
  }
  
  .modal-backdrop.active .modal {
    transform: translateY(0);
  }
  
  .modal-header {
    padding: var(--space-md);
  }
  
  .modal-title {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .modal-close {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  
  .modal-iframe {
    min-height: calc(100dvh - 70px);
  }

  /* 
     RESPONSIVE MOBILE LAYOUT 
     Fluid width, 3 columns, no scaling hacks.
  */
  .calendar-wrapper {
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    margin-bottom: 20px;
    display: block;
  }

  #calendar,
  .doors-container {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: auto !important;
    
    /* 3 columns for mobile (3x8 grid) */
    grid-template-columns: repeat(3, 1fr) !important;
    grid-auto-rows: minmax(100px, 1fr) !important;
    gap: 10px !important;
    padding: 10px !important;
    
    transform: none !important;
    margin: 0 auto !important;
    
    background: rgba(8, 16, 28, 0.65);
    border-radius: 16px;
  }
  
  .legal-links {
    flex-direction: column;
    gap: var(--space-md);
    padding-bottom: var(--space-3xl);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* Dark mode support (already dark by default) */
@media (prefers-color-scheme: light) {
  /* Optional: adjust if needed for light mode preference */
}

/* ========================================
   12) PRINT STYLES
   ======================================== */
@media print {
  .bg-scene,
  .modal-backdrop,
  .dev-badge {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .calendar-wrapper {
    break-inside: avoid;
  }
}

/* ========================================
   12.5) KONFETTI EFFEKT
   ======================================== */

/* Konfetti Container */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

/* Einzelnes Konfetti - EXPLODIERT IN ALLE RICHTUNGEN */
.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffd700;
  opacity: 1;
  /* Jedes Konfetti bekommt eigene Animation via JS */
}

/* Weihnachtliche Konfetti-Farben */
.confetti:nth-child(6n+1) { background: #ffd700; } /* Gold */
.confetti:nth-child(6n+2) { background: #c41e3a; } /* Rot */
.confetti:nth-child(6n+3) { background: #0f8a5f; } /* Grün */
.confetti:nth-child(6n+4) { background: #ffffff; } /* Weiß */
.confetti:nth-child(6n+5) { background: #ff6b9d; } /* Rosa */
.confetti:nth-child(6n) { background: #4a90e2; } /* Blau */

/* Verschiedene Formen & Animationen kombiniert */
.confetti:nth-child(3n) { 
  border-radius: 50%; 
  width: 8px; 
  height: 8px;
  animation: confettiExplode1 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.confetti:nth-child(3n+1) { 
  width: 12px; 
  height: 4px;
  border-radius: 2px;
  animation: confettiExplode2 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.confetti:nth-child(3n+2) { 
  width: 4px; 
  height: 12px; 
  border-radius: 2px;
  animation: confettiExplode3 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Konfetti EXPLOSION mit Physik */
@keyframes confettiExplode1 {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(720deg) scale(0.3);
  }
}

@keyframes confettiExplode2 {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(-540deg) scale(0.4);
  }
}

@keyframes confettiExplode3 {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(900deg) scale(0.2);
  }
}

/* ========================================
   13) EDITOR MODE STYLES
   ======================================== */
.doors-editor {
  position: absolute;
  inset: 0;
  z-index: 999999;
  pointer-events: none;
}

.doors-editor .edit-box {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(253, 199, 11, 0.1);
  cursor: move;
  pointer-events: all;
  box-sizing: border-box;
  transition: background 0.2s;
}

.doors-editor .edit-box:hover {
  background: rgba(253, 199, 11, 0.2);
}

.doors-editor .edit-box.dragging {
  background: rgba(253, 199, 11, 0.3);
  border-style: solid;
}

.doors-editor .handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%;
  pointer-events: all;
}

.doors-editor .handle.tl { top: -6px; left: -6px; cursor: nwse-resize; }
.doors-editor .handle.tr { top: -6px; right: -6px; cursor: nesw-resize; }
.doors-editor .handle.bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.doors-editor .handle.br { bottom: -6px; right: -6px; cursor: nwse-resize; }

.doors-editor-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: rgba(10, 61, 98, 0.95);
  padding: var(--space-md);
  z-index: 1000000;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  box-shadow: var(--shadow-soft);
}

.doors-editor-bar button {
  padding: var(--space-sm) var(--space-lg);
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.doors-editor-bar button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(253, 199, 11, 0.4);
}

.doors-editor-bar button:active {
  transform: translateY(0);
}
