/* =========================================================
   ADVENT CALENDAR 2025 — CLEAN RESPONSIVE STYLESHEET
   ========================================================= */

/* 🎨 Google Font Import */
@import url('https://fonts.googleapis.com/css2?family=Henny+Penny&display=swap');

/* =========================================================
   BASE + LAYOUT
   ========================================================= */

/* Ensure full-height coverage and smooth scrolling */
html {
  height: 100%;
  background-color: #f6faff;
  scroll-behavior: smooth;
}

/* Global body styles (mobile-first) */
body {
  min-height: 100vh;
  min-height: 100svh; /* iOS Safari fix */
  font-family: 'Henny Penny', cursive, sans-serif;
  text-align: center;
  color: #333;
  margin: 0;
  padding: 0;
  font-size: 1rem;
  line-height: 1.5;
  background-color: #f6faff;
  background-image: url('assets/bg_christmas-5195815_640.webp');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-attachment: scroll; /* scroll for mobile performance */
}

/* Responsive background image upgrades */
@media (min-width: 48rem) { /* 768px */
  body {
    background-image: url('assets/bg_christmas-5195815_1280.webp');
  }
}

@media (min-width: 80rem) { /* 1280px */
  body {
    background-image: url('assets/bg_christmas-5195815_1920.webp');
  }
}

/* Custom candy-cane cursor for pointer devices */
@media (pointer: fine) {
  body {
    cursor: url('assets/candycane_32x32.png') 4 4, auto;
  }
}

/* =========================================================
   SNOW CANVAS ANIMATION
   ========================================================= */
  #snowCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
  }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  #snowCanvas {
    display: none !important;
  }
}

/* =========================================================
   PAGE HEADING
   ========================================================= */
h1 {
  margin-block-start: 0;
  margin-block-end: 1rem;
  padding-top: clamp(1rem, 4vh, 2rem);
  font-family: "Henny Penny", cursive;
  font-size: 2.25rem; /* mobile base */
  background: repeating-linear-gradient(
    -45deg,
    #ff2b2b 0 10px,
    #fffaf7 10px 20px
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: brightness(1.3) contrast(1.2);
  text-shadow:
    0 0 6px rgba(255, 255, 255, 0.4),
    2px 2px 6px rgba(0, 0, 0, 0.7);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Progressive font scaling */
@media (min-width: 48rem) { /* tablet */
  h1 { font-size: 3rem; }
}

@media (min-width: 64rem) { /* small desktop */
  h1 { font-size: 3.5rem; }
}

@media (min-width: 80rem) { /* large desktop */
  h1 { font-size: 4rem; }
}

/* =========================================================
   CALENDAR GRID + DOORS
   ========================================================= */
#calendar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(3.75rem, 1fr));
  gap: 0.75rem;
  max-width: 90%;
  margin: 0 auto;
  padding: 0.625rem;
}

.door {
  background: linear-gradient(145deg, #e74c3c, #c0392b); /* still red */
  color: #fff;
  font-size: 1.2rem;
  font-weight: bold;
  border: 0.25rem solid #2e8b57; /* keep your green */
  border-radius: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 5rem;
  min-width: 3.75rem;
  padding: 0.5rem;
  cursor: inherit;
  position: relative;          /* needed for pseudo-elements later */
  overflow: visible;           /* so snow can sit “on top” */
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.25),              /* outer shadow */
    inset 0 0 8px rgba(255, 255, 255, 0.35);     /* inner soft glow */
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    opacity 0.3s ease;
}

/* Snow sitting on top of each door */
.door::before {
  content: "";
  position: absolute;
  top: -0.45rem;
  left: 12%;
  right: 12%;
  height: 0.9rem;
  background: #ffffff;
  border-radius: 999px 999px 0.4rem 0.4rem;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.15),
    inset 0 -3px 4px rgba(230, 230, 230, 0.9);
}

/* Little snow “drips” */
.door::after {
  content: "";
  position: absolute;
  top: -0.1rem;
  left: 18%;
  width: 0.6rem;
  height: 0.9rem;
  background: #ffffff;
  border-radius: 0 0 0.6rem 0.6rem;
  box-shadow:
    0.9rem -0.2rem 0 0 #ffffff,
    1.8rem 0.1rem 0 0 #ffffff;
}

/* Hover animation only on non-touch devices */
@media (hover: hover) and (pointer: fine) {
  .door:hover {
    transform: scale(1.05);
    animation: doorGlow 2s infinite alternate;
  }
}

/* Glow animation for opened doors (touch devices) */
body.touch-device .door.opened {
  animation: doorGlow 2s infinite alternate;
}

/* Opened doors */
.door.opened {
  background: linear-gradient(145deg, #2ecc71, #27ae60); /* your green, just with depth */
  opacity: 0.9;
  box-shadow:
    0 0 12px rgba(46, 139, 87, 0.7),
    inset 0 0 10px rgba(255, 255, 255, 0.35);
}

.door.opened img {
  max-height: 10rem;
  object-fit: contain;
}

/* Focus outline (keyboard accessibility) */
.door:focus {
  outline: 3px solid #2e8b57;
  outline-offset: 2px;
}

/* Door glow animation */
@keyframes doorGlow {
  from { box-shadow: 0 0 0.5rem #2e8b57; }
  to   { box-shadow: 0 0 1rem #2e8b57; }
}

/* Responsive grid tuning */
@media (min-width: 30rem) { /* 480px */
  #calendar { max-width: 28rem; gap: 1.5rem; }
  .door { min-height: 5.5rem; font-size: 1.3rem; }
}

@media (min-width: 48rem) { /* 768px */
  #calendar { max-width: 40rem; gap: 1.5rem; grid-template-columns: repeat(6, 1fr); }
  .door { min-height: 6rem; font-size: 1.4rem; }
}

@media (min-width: 64rem) { /* 1024px */
  #calendar { max-width: 50rem; gap: 1.75rem; }
  .door { min-height: 6.5rem; font-size: 1.5rem; }
}

@media (min-width: 80rem) { /* 1280px */
  #calendar { max-width: 60rem; gap: 1.8rem; }
  .door { min-height: 7rem; font-size: 1.6rem; }
}

/* =========================================================
   CONTROLS
   ========================================================= */
#controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 1rem auto;
}

.sound-toggle {
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: rgba(255, 255, 255, 0.85);
  color: #333;
  border-radius: 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

/* Custom checkbox */
.sound-toggle input[type="checkbox"] {
  appearance: none;
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid #2e8b57;
  border-radius: 0.25rem;
  background-color: #fff;
  position: relative;
  cursor: pointer;
}

.sound-toggle input[type="checkbox"]:checked {
  background-color: #2ecc71;
  border-color: #27ae60;
}

.sound-toggle input[type="checkbox"]:checked::after {
  content: '✔';
  color: white;
  font-size: 0.9rem;
  position: absolute;
  top: 0;
  left: 0.15rem;
}

/* Reset button */
#resetButton {
  font-size: 1rem;
  padding: 0.5rem 1.25rem;
  background-color: #2ecc71;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#resetButton:hover,
#resetButton:focus {
  background-color: #27ae60;
  transform: scale(1.05);
  outline: none;
}

/* =========================================================
   MODAL STYLES
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.85);
  padding: 1rem;
  z-index: 10000;
}

.modal[aria-hidden="false"] { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 1;
}

.modal-dialog {
  position: relative;
  z-index: 2;
  width: min(92vw, 760px);
  margin: 6vh auto;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.modal-content {
  display: block;
  width: 100%;
  height: auto;
  max-height: 90vh;
  overflow: hidden;
  border-radius: 0.75rem;
  background-color: transparent;
  padding: 1.25rem;
  box-sizing: border-box;
}

.modal-content img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 0.5rem;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 2rem;
  background: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 0 0.5rem rgba(0, 0, 0, 0.3);
  z-index: 3;
}

/* 16:9 video wrapper */
.modal-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.modal-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@supports not (aspect-ratio: 1 / 1) {
  .modal-video {
    height: 0;
    padding-top: 56.25%;
  }
  .modal-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
}

/* Clean media version (for full-screen images/videos) */
.modal--media .modal-dialog {
  background: transparent;
  box-shadow: none;
}

.modal--media .modal-content {
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.modal--media .modal-close {
  background: rgba(255,255,255,.9);
}

/* Force-hide screen-reader-only text */
h2.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* =========================================================
   STYLE FOR FESTIVE LOCKED POPUP
   ========================================================= */

/* 🔒 Locked popup styling */
.locked-popup {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 20, 60, 0.95); /* festive red */
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 90%;
  text-align: center;
  cursor: pointer;
}

/* Fade in when active */
.locked-popup.visible {
  opacity: 1;
}

/* 💻 Desktop view — center of the screen */
@media (min-width: 768px) {
  .locked-popup {
    top: 50%;
    transform: translate(-50%, -50%);
  }
}

/* 📱 Mobile view — toast style at bottom */
@media (max-width: 767px) {
  .locked-popup {
    bottom: 1.25rem;
    transform: translateX(-50%) translateY(100%);
  }

  .locked-popup.visible {
    transform: translateX(-50%) translateY(0);
  }
}

/* Accessible reset dialog based on locked-popup */
.reset-confirm {
  display: none;
  max-width: 90%;
  width: 22rem;
  text-align: center;
  padding-bottom: 1.2rem;
}

/* Visible state */
.reset-confirm.visible {
  display: block;
}

/* Title inside dialog */
.reset-title {
  margin-top: 0.2rem;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

/* Buttons layout */
.reset-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* Yes button */
.reset-yes {
  background: #2ecc71;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
/* Yes button hover */
.reset-yes:hover,
.reset-yes:focus-visible {
  background: #27ae60;
  outline: none;
}

/* No button */
.reset-no {
  background: #f0f0f0;
  color: #333;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* No button hover */
.reset-no:hover,
.reset-no:focus-visible {
  background: #e0e0e0;
  outline: none;
}