/* =====================================================================
 *  Kalendarz Adwentowy – widok odbiorcy
 *  Paleta: głęboka czerwień, butelkowa zieleń, złoto, granat, biel
 * ===================================================================== */
:root {
  --navy: #0b1630;
  --navy-2: #13234a;
  --navy-3: #1c3263;
  --red: #7a1020;
  --red-2: #9b1b2e;
  --green: #0f3b2c;
  --green-2: #17543f;
  --gold: #d4af5a;
  --gold-2: #f1d78f;
  --gold-dark: #9c7a2e;
  --cream: #fbf7ee;
  --ink: #1d1a17;
  --white: #ffffff;
  --radius: 14px;
  --serif: "Cormorant Garamond", "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--cream);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(212, 175, 90, .16), transparent 60%),
    radial-gradient(900px 700px at 100% 100%, rgba(122, 16, 32, .28), transparent 60%),
    radial-gradient(900px 700px at 0% 90%, rgba(15, 59, 44, .35), transparent 60%),
    var(--navy);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

#snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 3;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(64px, calc(env(safe-area-inset-top) + 52px)) max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}

/* ---------- Nagłówek ---------- */
.hero { text-align: center; margin: 12px auto 28px; }

.ornament { color: var(--gold); width: 140px; margin: 0 auto 6px; }
.ornament svg { display: block; width: 100%; height: auto; }

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  line-height: 1.05;
  margin: 0;
  letter-spacing: .01em;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 24px rgba(212, 175, 90, .15);
}

.subtitle {
  margin: 10px auto 0;
  max-width: 34em;
  color: rgba(251, 247, 238, .78);
  font-size: clamp(.95rem, 2.4vw, 1.08rem);
}

.progress {
  margin: 14px 0 0;
  font-size: .85rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  min-height: 1.2em;
}

.preview-banner {
  margin: 0 auto 20px;
  max-width: 720px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px dashed var(--gold);
  background: rgba(212, 175, 90, .12);
  color: var(--gold-2);
  text-align: center;
  font-size: .9rem;
}
.preview-banner a { color: var(--white); margin-left: 8px; }

/* ---------- Siatka ---------- */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
@media (min-width: 880px) { .grid { grid-template-columns: repeat(6, 1fr); gap: 16px; } }

.grid > li { perspective: 900px; }

.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform-style: preserve-3d;
  animation: tile-in .6s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(var(--i, 0) * 25ms);
}
@supports not (aspect-ratio: 1 / 1) { .tile { height: 0; padding-bottom: 100%; } }

@keyframes tile-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.tile:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 3px; }

/* Wnętrze okienka (widoczne po otwarciu) */
.tile-inside {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 40%, rgba(241, 215, 143, .35), transparent 65%),
    linear-gradient(160deg, #1a2c58, #0e1a38);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 90, .55), inset 0 6px 18px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  text-align: center;
  overflow: hidden;
}
.tile-inside .star {
  width: 38%;
  max-width: 54px;
  color: var(--gold);
  filter: drop-shadow(0 0 10px rgba(241, 215, 143, .6));
}
.tile-inside .inside-num {
  font-family: var(--serif);
  font-size: clamp(1rem, 3vw, 1.2rem);
  color: var(--gold-2);
  font-weight: 600;
}
.tile-inside .inside-title {
  overflow-wrap: anywhere;
  font-size: clamp(.62rem, 1.8vw, .74rem);
  line-height: 1.2;
  color: rgba(251, 247, 238, .85);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
}

/* Drzwiczki */
.tile-door {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: left center;
  transition: transform .9s cubic-bezier(.3, .7, .2, 1), box-shadow .3s ease;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, .06);
  overflow: hidden;
  z-index: 2;
}
.tile-door::before { /* złota ramka */
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(212, 175, 90, .55);
  border-radius: calc(var(--radius) - 6px);
  pointer-events: none;
}
.tile-door::after { /* subtelny połysk */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, .14), transparent 45%, rgba(0, 0, 0, .18));
  pointer-events: none;
}

.tile--red   .tile-door { background: radial-gradient(circle at 30% 20%, var(--red-2), var(--red) 70%); }
.tile--green .tile-door { background: radial-gradient(circle at 30% 20%, var(--green-2), var(--green) 70%); }
.tile--navy  .tile-door { background: radial-gradient(circle at 30% 20%, var(--navy-3), var(--navy-2) 70%); }
.tile--cream .tile-door { background: radial-gradient(circle at 30% 20%, #ffffff, #efe6d2 75%); }

.tile-num {
  position: relative;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 8vw, 2.9rem);
  line-height: 1;
  color: var(--gold-2);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.tile--cream .tile-num { color: var(--red); text-shadow: none; }

.tile-lock {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 14px;
  height: 14px;
  color: rgba(241, 215, 143, .7);
}
.tile--cream .tile-lock { color: rgba(122, 16, 32, .55); }

.tile-knob {
  position: absolute;
  right: 14%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .15);
  opacity: .8;
}

@media (hover: hover) {
  .tile:not(.is-open):hover .tile-door {
    transform: rotateY(-14deg);
    box-shadow: 0 16px 34px rgba(0, 0, 0, .45);
  }
}
.tile:not(.is-open):active .tile-door { transform: rotateY(-8deg) scale(.98); }

.tile.is-open .tile-door { transform: rotateY(-108deg); box-shadow: none; }
.tile.is-open .tile-door { pointer-events: none; }

/* Dzisiejszy dzień */
.tile.is-today:not(.is-open) .tile-door {
  box-shadow: 0 0 0 2px var(--gold), 0 0 26px rgba(241, 215, 143, .45), var(--shadow);
  animation: glow 2.6s ease-in-out infinite;
}
.tile.is-today::after {
  content: "dziś";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) translateZ(1px);
  z-index: 3;
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
}
@keyframes glow {
  50% { box-shadow: 0 0 0 2px var(--gold-2), 0 0 38px rgba(241, 215, 143, .7), var(--shadow); }
}

/* ---------- Stopka ---------- */
.footer { text-align: center; margin-top: 34px; }
.link-btn {
  background: none;
  border: 0;
  color: rgba(251, 247, 238, .55);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
}
.link-btn:hover { color: var(--gold-2); }

/* ---------- Modale ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 24, .72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade .25s ease both;
}

.modal-card {
  position: relative;
  width: 100%;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 20px;
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5), 0 0 0 1px rgba(212, 175, 90, .5);
  animation: pop .35s cubic-bezier(.2, .9, .3, 1.2) both;
}
.modal.is-closing .modal-card { animation: pop-out .2s ease both; }
.modal.is-closing .modal-backdrop { animation: fade .2s ease reverse both; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(20px) scale(.94); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(11, 22, 48, .08);
  color: var(--navy);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: rgba(11, 22, 48, .16); }

/* Modal z kodem */
.modal-card--code {
  max-width: 400px;
  padding: 34px 26px 26px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(212, 175, 90, .25), transparent 55%),
    var(--cream);
}
.code-day {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--gold-2);
  background: radial-gradient(circle at 30% 20%, var(--red-2), var(--red));
  box-shadow: 0 6px 16px rgba(122, 16, 32, .35), inset 0 0 0 1px rgba(241, 215, 143, .5);
}
.modal-card--code h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--red);
}
.muted { color: #6b645b; margin: 6px 0 18px; font-size: .95rem; }

#code-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid #ddd2bb;
  background: var(--white);
  color: var(--ink);
  font: 600 1.15rem/1.2 var(--sans);
  letter-spacing: .06em;
  text-align: center;
  text-transform: uppercase;
  transition: border-color .2s, box-shadow .2s;
}
#code-input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 400; color: #aaa094; }
#code-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(212, 175, 90, .25); }
#code-input.is-invalid { border-color: var(--red-2); animation: shake .4s; }

@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.form-error { min-height: 1.4em; margin: 8px 0 10px; color: var(--red-2); font-size: .9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: 0;
  border-radius: 12px;
  font: 600 1rem var(--sans);
  cursor: pointer;
  transition: transform .1s, filter .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-gold {
  color: var(--navy);
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  box-shadow: 0 6px 16px rgba(156, 122, 46, .35);
}
.btn-gold:hover { filter: brightness(1.05); }

/* Modal z zawartością dnia */
.modal-card--day { max-width: 640px; padding: 0; }

.day-content {
  padding: 30px 26px 30px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;   /* długie słowa i linki łamią się zamiast wychodzić poza kafelek */
  word-break: break-word;
}
.day-content * { max-width: 100%; }
.day-title, .day-text, .day-text p, .day-text li, .day-text a, .media-info { overflow-wrap: anywhere; word-break: break-word; hyphens: auto; }
@media (min-width: 600px) { .day-content { padding: 38px 40px 40px; } }

.day-head { text-align: center; margin-bottom: 20px; }
.day-badge {
  width: 56px; height: 56px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 1.7rem; font-weight: 600;
  color: var(--gold-2);
  background: radial-gradient(circle at 30% 20%, var(--green-2), var(--green));
  box-shadow: inset 0 0 0 2px rgba(212, 175, 90, .6);
}
.day-date {
  font-size: .78rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold-dark);
}
.day-title {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.15;
  color: var(--red);
}

.day-image { margin: 0 0 22px; }
.day-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 14px;
  background: #efe6d2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}

.day-text { font-size: 1.05rem; line-height: 1.7; color: #2b2622; }
.day-text p { margin: 0 0 1em; }
.day-text h3 { font-family: var(--serif); font-size: 1.35rem; color: var(--green); margin: 1.2em 0 .4em; }
.day-text ul { margin: 0 0 1em; padding-left: 1.3em; }
.day-text li { margin: .25em 0; }
.day-text a { color: var(--red-2); }
.day-text strong { color: var(--ink); }

.day-media { margin-top: 22px; }
.media-label {
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
  font-weight: 600;
}
.day-audio {
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(15, 59, 44, .08), rgba(212, 175, 90, .12));
  border: 1px solid rgba(212, 175, 90, .4);
}
.day-media audio { display: block; width: 100%; }
.day-media video {
  display: block;
  width: 100%;
  max-height: 70vh;
  border-radius: 14px;
  background: #000;
}
.media-error, .media-fallback { font-size: .85rem; color: #7d756b; margin: 8px 0 0; }
.day-empty { text-align: center; color: #6b645b; font-size: 1.05rem; margin: 10px 0 0; }

.loading { text-align: center; padding: 50px 20px; color: #7d756b; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid rgba(212, 175, 90, .3);
  border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* =====================================================================
 *  Efekty tła: zorza, girlanda lampek, zaspy, przycisk muzyki
 * ===================================================================== */
.aurora {
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  filter: blur(60px);
  opacity: .55;
}
.aurora i {
  position: absolute;
  display: block;
  border-radius: 50%;
  mix-blend-mode: screen;
  will-change: transform;
}
.aurora i:nth-child(1) { width: 60vmax; height: 34vmax; left: -10%; top: -6%;  background: radial-gradient(closest-side, rgba(23, 110, 80, .75), transparent); animation: drift1 38s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { width: 50vmax; height: 30vmax; right: -12%; top: 4%;  background: radial-gradient(closest-side, rgba(212, 175, 90, .45), transparent); animation: drift2 46s ease-in-out infinite alternate; }
.aurora i:nth-child(3) { width: 55vmax; height: 40vmax; left: 20%; bottom: -18%; background: radial-gradient(closest-side, rgba(155, 27, 46, .55), transparent); animation: drift3 52s ease-in-out infinite alternate; }
.aurora i:nth-child(4) { width: 40vmax; height: 22vmax; left: 30%; top: 18%;  background: radial-gradient(closest-side, rgba(80, 140, 220, .30), transparent); animation: drift2 60s ease-in-out infinite alternate-reverse; }
@keyframes drift1 { to { transform: translate(18vw, 10vh) rotate(18deg) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vw, 14vh) rotate(-14deg) scale(.9); } }
@keyframes drift3 { to { transform: translate(-10vw, -12vh) rotate(10deg) scale(1.2); } }

#snow { z-index: 1; }

/* Girlanda lampek */
.garland {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 80px;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}
.garland svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.bulb {
  position: absolute;
  width: 11px;
  height: 16px;
  margin: -2px 0 0 -5.5px;
  transform-origin: 50% 0;
  transform: rotate(var(--r, 0deg));
}
.bulb::before { /* oprawka */
  content: "";
  position: absolute;
  top: 0; left: 3px;
  width: 5px; height: 4px;
  border-radius: 1px;
  background: #5b6b55;
}
.bulb::after { /* szkło */
  content: "";
  position: absolute;
  top: 3px; left: 0;
  width: 11px; height: 13px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: var(--c);
  box-shadow: 0 0 6px 2px var(--c), 0 0 18px 4px var(--g);
  animation: twinkle var(--d, 2.4s) ease-in-out var(--delay, 0s) infinite;
}
.effects-off .bulb::after { animation: none; }
@keyframes twinkle {
  0%, 100% { opacity: 1; filter: brightness(1.15); }
  45%      { opacity: .35; filter: brightness(.7); box-shadow: 0 0 2px 0 var(--c); }
}

/* Zaspy śniegu na dole strony */
.snowdrift {
  position: relative;
  z-index: 2;
  height: 120px;
  margin-top: -60px;
  pointer-events: none;
}
.snowdrift svg { display: block; width: 100%; height: 100%; }

/* Przycisk muzyki */
.music-btn {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(255, 255, 255, .4);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s;
}
.music-btn[hidden] { display: none; }
.music-btn:active { transform: scale(.94); }
.music-btn:focus-visible { outline: 3px solid var(--white); outline-offset: 3px; }
.music-btn .mb-note { width: 24px; height: 24px; grid-area: 1 / 1; }
.music-btn .mb-bars { grid-area: 1 / 1; display: none; align-items: flex-end; gap: 3px; height: 20px; }
.music-btn .mb-bars i { width: 4px; height: 100%; border-radius: 2px; background: var(--navy); transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.music-btn .mb-bars i:nth-child(2) { animation-delay: -.3s; }
.music-btn .mb-bars i:nth-child(3) { animation-delay: -.6s; }
.music-btn .mb-bars i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
.music-btn.is-playing .mb-note { display: none; }
.music-btn.is-playing .mb-bars { display: flex; }
.music-btn .mb-off { /* przekreślenie, gdy wyciszone */
  grid-area: 1 / 1;
  width: 30px; height: 3px; border-radius: 2px;
  background: var(--red);
  transform: rotate(-45deg);
  box-shadow: 0 0 0 2px var(--gold-2);
  display: none;
}
.music-btn.is-muted .mb-off { display: block; }
.music-btn.is-waiting::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  animation: ring 1.8s ease-out infinite;
}
@keyframes ring { from { opacity: .9; transform: scale(.9); } to { opacity: 0; transform: scale(1.35); } }

.footer { position: relative; z-index: 3; }
