/* ========================================
   Henris Weihnachtskalender - Stylesheet
   ======================================== */

/* CSS Custom Properties */
:root {
  --color-red: #c41e3a;
  --color-red-dark: #8b0000;
  --color-gold: #ffd700;
  --color-gold-dark: #b8860b;
  --color-green: #165b33;
  --color-green-dark: #0d3d22;
  --color-cream: #fffef5;
  --color-snow: #f8f8ff;

  --font-display: 'Mountains of Christmas', cursive;
  --font-body: 'Nunito', sans-serif;

  /* Responsive Türchen-Größe */
  --door-size: clamp(40px, 9%, 100px);
  --door-radius: 18%;
  --transition-door: 0.6s ease-out;

  /* Responsive Abstände */
  --spacing: clamp(10px, 3vw, 40px);
  --border-outer: clamp(6px, 1.5vw, 12px);
  --border-inner: clamp(4px, 1vw, 8px);

  --image-aspect-ratio: 1898 / 1239;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--color-green-dark) 0%, var(--color-green) 50%, var(--color-red-dark) 100%);
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height für iOS Safari */
  color: var(--color-cream);
  overflow: hidden;
}

/* ========================================
   Snowflakes Animation
   ======================================== */
.snowflakes {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -20px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.5rem;
  animation: fall linear infinite;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.snowflake:nth-child(1) { left: 5%; animation-duration: 10s; animation-delay: 0s; font-size: 1.2rem; }
.snowflake:nth-child(2) { left: 15%; animation-duration: 12s; animation-delay: 1s; font-size: 1.8rem; }
.snowflake:nth-child(3) { left: 25%; animation-duration: 8s; animation-delay: 2s; font-size: 1rem; }
.snowflake:nth-child(4) { left: 35%; animation-duration: 14s; animation-delay: 0.5s; font-size: 1.5rem; }
.snowflake:nth-child(5) { left: 45%; animation-duration: 11s; animation-delay: 3s; font-size: 2rem; }
.snowflake:nth-child(6) { left: 55%; animation-duration: 9s; animation-delay: 1.5s; font-size: 1.3rem; }
.snowflake:nth-child(7) { left: 65%; animation-duration: 13s; animation-delay: 2.5s; font-size: 1.7rem; }
.snowflake:nth-child(8) { left: 75%; animation-duration: 10s; animation-delay: 4s; font-size: 1.1rem; }
.snowflake:nth-child(9) { left: 85%; animation-duration: 15s; animation-delay: 0.8s; font-size: 1.6rem; }
.snowflake:nth-child(10) { left: 95%; animation-duration: 11s; animation-delay: 2s; font-size: 1.4rem; }

@keyframes fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0.3;
  }
}

/* ========================================
   Calendar Layout
   ======================================== */
.calendar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing);
  padding-top: calc(var(--spacing) + 25px); /* Extra Platz für Banderole */
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height für iOS Safari */
  width: 100vw;
  overflow: hidden;
  box-sizing: border-box;
}

.calendar-title {
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 3.5vw, 2.5rem);
  color: var(--color-cream);
  text-shadow:
    1px 1px 0 var(--color-red-dark),
    2px 2px 4px rgba(0, 0, 0, 0.5);
  text-align: center;
  letter-spacing: clamp(1px, 0.2vw, 2px);
  white-space: nowrap;

  /* Banderole Styling */
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;

  background: linear-gradient(180deg,
    var(--color-red) 0%,
    var(--color-red-dark) 50%,
    var(--color-red) 100%);
  padding: clamp(6px, 1.5vw, 12px) clamp(15px, 4vw, 40px);
  border-radius: clamp(4px, 1vw, 8px);
  border: clamp(2px, 0.4vw, 3px) solid var(--color-gold);
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.2),
    inset 0 -2px 4px rgba(0, 0, 0, 0.2);

  /* Ribbon ends */
  &::before,
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    width: clamp(10px, 2vw, 20px);
    height: clamp(8px, 1.5vw, 15px);
    background: var(--color-red-dark);
  }

  &::before {
    left: clamp(5px, 1vw, 10px);
    clip-path: polygon(0 0, 100% 0, 100% 100%);
  }

  &::after {
    right: clamp(5px, 1vw, 10px);
    clip-path: polygon(0 0, 100% 0, 0 100%);
  }
}

.calendar-container {
  position: relative;

  /* Immer 100% des verfügbaren Platzes nutzen */
  width: calc(100vw - (var(--spacing) * 2) - (var(--border-outer) * 2));
  height: calc(100vh - (var(--spacing) * 2) - (var(--border-outer) * 2) - 25px);
  height: calc(100dvh - (var(--spacing) * 2) - (var(--border-outer) * 2) - 25px); /* iOS Safari */

  background-color: var(--color-green-dark);
  background-image: url('../images/henri.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: clamp(10px, 2vw, 20px);
  box-shadow:
    0 0 0 var(--border-inner) var(--color-gold),
    0 0 0 var(--border-outer) var(--color-red),
    0 clamp(10px, 2vw, 20px) clamp(30px, 5vw, 60px) rgba(0, 0, 0, 0.5);
  overflow: visible;
}

/* ========================================
   Door Styling
   ======================================== */
.door-wrapper {
  position: absolute;
  width: var(--door-size);
  aspect-ratio: 1 / 1;
  perspective: 800px;
}

.door-front {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, var(--color-red) 0%, var(--color-red-dark) 100%);
  border: clamp(2px, 0.4vw, 3px) solid var(--color-gold);
  border-radius: var(--door-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 2px 10px rgba(255, 255, 255, 0.2),
    0 4px 15px rgba(0, 0, 0, 0.4);
  transition: transform var(--transition-door), box-shadow 0.3s ease;
  transform-origin: left center;
  z-index: 1;
  cursor: pointer;
}

.door-front::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px dashed var(--color-gold);
  border-radius: calc(var(--door-radius) - 4px);
  opacity: 0.5;
}

.door-number {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--color-cream);
  text-shadow:
    1px 1px 0 var(--color-red-dark),
    2px 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.door-back {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, var(--color-cream) 0%, #e8e8d8 100%);
  border: clamp(2px, 0.4vw, 3px) solid var(--color-gold-dark);
  border-radius: var(--door-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(3px, 0.8vw, 6px);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 0;
  overflow: hidden;
  cursor: pointer;
}

.door-back:hover {
  background: linear-gradient(145deg, #fff 0%, var(--color-cream) 100%);
}

.door-song-title {
  font-family: var(--font-body);
  font-size: clamp(0.45rem, 1.5vw, 0.7rem);
  font-weight: 700;
  color: var(--color-green-dark);
  text-align: center;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  word-break: break-word;
  padding: 2px;
}

/* Door States */
.door-wrapper:not(.door--locked):not(.door--open):hover .door-front {
  box-shadow:
    inset 0 2px 10px rgba(255, 255, 255, 0.3),
    0 6px 25px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(255, 215, 0, 0.4);
  transform: scale(1.05);
}

.door-wrapper.door--open .door-front {
  transform: rotateY(-160deg);
  box-shadow: none;
  pointer-events: none;
}

.door-wrapper.door--locked {
  cursor: not-allowed;
}

.door-wrapper.door--locked .door-front {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.door-wrapper.door--locked .door-front::before {
  display: none;
}

.door-wrapper.door--locked .door-number {
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}

/* ========================================
   Lightbox
   ======================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.lightbox--active {
  opacity: 1;
  visibility: visible;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
  position: relative;
  width: auto;
  max-width: 90vw;
  max-height: 90vh;
  background: linear-gradient(145deg, var(--color-green-dark) 0%, var(--color-red-dark) 100%);
  border-radius: 20px;
  padding: 20px;
  box-shadow:
    0 0 0 4px var(--color-gold),
    0 20px 60px rgba(0, 0, 0, 0.8);
  transform: scale(0.9);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox.lightbox--active .lightbox-content {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 40px;
  height: 40px;
  background: var(--color-red);
  border: 3px solid var(--color-gold);
  border-radius: 50%;
  color: var(--color-cream);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 10;
}

.lightbox-close:hover {
  transform: scale(1.1) rotate(90deg);
  background: var(--color-red-dark);
}

.lightbox-title {
  font-family: var(--font-display);
  font-size: clamp(1rem, 3vw, 1.5rem);
  color: var(--color-cream);
  text-align: center;
  text-shadow:
    1px 1px 0 var(--color-red-dark),
    2px 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;

  /* Banderole Styling */
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;

  background: linear-gradient(180deg,
    var(--color-red) 0%,
    var(--color-red-dark) 50%,
    var(--color-red) 100%);
  padding: 10px 30px;
  border-radius: 8px;
  border: 3px solid var(--color-gold);
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.2),
    inset 0 -2px 4px rgba(0, 0, 0, 0.2);

  /* Ribbon ends */
  &::before,
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    width: 15px;
    height: 12px;
    background: var(--color-red-dark);
  }

  &::before {
    left: 8px;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
  }

  &::after {
    right: 8px;
    clip-path: polygon(0 0, 100% 0, 0 100%);
  }
}

.lightbox-video-container {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  max-height: calc(90vh - 100px);
}

.lightbox-video-container video {
  display: block;
  max-width: min(400px, 80vw);
  max-height: calc(90vh - 100px);
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Video Controls: Versteckt bei Autoplay, sichtbar bei Hover/Touch */
.lightbox-video-container video.hide-controls::-webkit-media-controls {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox-video-container video.hide-controls:hover::-webkit-media-controls,
.lightbox-video-container video.hide-controls:focus::-webkit-media-controls {
  opacity: 1;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Mobile Landscape - weniger Platz für Banderole */
@media (max-height: 500px) and (orientation: landscape) {
  .calendar-wrapper {
    padding-top: var(--spacing);
  }

  .calendar-container {
    height: calc(100vh - (var(--spacing) * 2) - (var(--border-outer) * 2));
  }

  .calendar-title {
    font-size: clamp(0.7rem, 2vw, 1rem);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .snowflake {
    animation: none;
    display: none;
  }

  .door-front {
    transition: none;
  }

  .lightbox,
  .lightbox-content {
    transition: none;
  }
}

/* Focus States */
.door:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 4px;
}

.lightbox-close:focus-visible {
  outline: 3px solid var(--color-cream);
  outline-offset: 2px;
}
