/* ==========================================================================
   Datadog Advent Calendar
   ========================================================================== */
:root {
  --dd-purple: #632ca6;
  --dd-purple-dark: #3b1a66;
  --dd-purple-deep: #22103d;
  --dd-purple-light: #a06ae0;
  --gold: #ffd76a;
  --red: #e3342f;
  --white: #ffffff;

  --gap: clamp(6px, 1vw, 12px);
  --cols: 6;
  --cell: clamp(64px, 12.5vw, 150px);
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--white);
  /* Same colors as the Bits holiday illustration (coral -> magenta). */
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 255, 255, 0.18), transparent 60%),
    linear-gradient(45deg, #fe6c56 0%, #bd1a5f 50%, #a90062 100%);
  background-color: #bd1a5f;
  background-attachment: fixed;
  overflow-x: hidden;
}

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

header, main, footer { position: relative; z-index: 1; }

/* ---------------------------------------------------------------- Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 40px);
}
.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.95rem;
  opacity: 0.9;
}
.top-actions { display: inline-flex; align-items: center; gap: 10px; }
.music-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.music-toggle:hover { background: rgba(255, 255, 255, 0.22); transform: scale(1.06); }
.music-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.music-toggle[aria-pressed='true'] { background: var(--white); }
.music-note {
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 0.9rem;
  color: var(--gold);
  opacity: 0;
  pointer-events: none;
}
.music-toggle[aria-pressed='true'] .music-note { animation: note-float 1.8s ease-out infinite; }
@keyframes note-float {
  0% { opacity: 0; transform: translate(0, 4px) rotate(-10deg); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(8px, -16px) rotate(15deg); }
}

/* ---------------------------------------------------------------- Hero */
.hero {
  text-align: center;
  padding: 8px 16px 0;
}
.hero h1 {
  font-family: 'Mountains of Christmas', 'Poppins', cursive;
  font-weight: 700;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 1;
  margin: 0;
  text-shadow: 0 0 24px rgba(255, 215, 106, 0.45), 0 4px 0 rgba(0, 0, 0, 0.2);
}
/* "Datadog's" / "for Amadeus" – part of the title, a bit smaller */
.title-accent {
  font-size: 0.68em;
  white-space: nowrap;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 215, 106, 0.55), 0 3px 0 rgba(0, 0, 0, 0.25);
}
.subtitle {
  margin: 10px 0 0;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  opacity: 0.9;
}
.countdown, .preview-badge {
  display: inline-block;
  margin: 14px 6px 0;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
}
.countdown { background: var(--gold); color: var(--dd-purple-dark); }
.preview-badge { background: var(--red); color: var(--white); }

/* ---------------------------------------------------------------- Board */
.board-wrap {
  display: flex;
  justify-content: center;
  padding: clamp(24px, 4vw, 48px) 12px 24px;
}
.board {
  position: relative;
  width: calc(var(--cell) * var(--cols) + var(--gap) * (var(--cols) + 1) + 4px);
  padding: var(--gap);
  border-radius: calc(var(--radius) + 8px);
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35), inset 0 0 60px rgba(160, 106, 224, 0.25);
}

/* Giant Bits (with holly) behind the doors */
.mascot {
  position: absolute;
  inset: 4% 6%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
}
.mascot .logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: float 6s ease-in-out infinite;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.35));
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---------------------------------------------------------------- Grid & doors */
.grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-auto-rows: var(--cell);
  grid-auto-flow: dense;
  gap: var(--gap);
}
.door.size-w { grid-column: span 2; }
.door.size-t { grid-row: span 2; }
.door.size-b { grid-column: span 2; grid-row: span 2; }

.door {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  perspective: 1600px;
  border-radius: var(--radius);
  opacity: 0;
  transform: scale(0.85);
}
body.ready .door {
  animation: pop-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
  animation-delay: calc(var(--i) * 35ms);
}
@keyframes pop-in {
  to { opacity: 1; transform: scale(1); }
}
.door:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* What's behind the door (revealed once opened) */
.door-inside {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: rgba(34, 16, 61, 0.35);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  text-align: center;
}
.door-inside > * { opacity: 0; transition: opacity 0.3s; }
.door.is-open .door-inside > * { opacity: 1; transition-delay: 0.35s; }
.inside-icon { font-size: clamp(1.2rem, 2.6vw, 2rem); }
.inside-title {
  font-size: clamp(0.62rem, 1.1vw, 0.85rem);
  font-weight: 700;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* The door leaf */
.door-front {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.5, 0, 0.2, 1), background 0.3s, box-shadow 0.3s;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02)),
    rgba(99, 44, 166, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(0.5px);
  -webkit-backdrop-filter: blur(0.5px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25), inset 0 0 0 4px rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* little "handle" */
.door-front::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px rgba(255, 215, 106, 0.8);
}
.door-number {
  font-family: 'Mountains of Christmas', 'Poppins', cursive;
  font-weight: 700;
  font-size: clamp(1.8rem, 4.2vw, 3.2rem);
  line-height: 1;
  text-shadow: 0 0 3px rgba(34, 16, 61, 0.95), 0 2px 8px rgba(34, 16, 61, 0.85), 0 0 18px rgba(99, 44, 166, 0.6);
}
.size-b .door-number { font-size: clamp(3rem, 8vw, 6rem); }
.door-lock {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s;
}

/* States */
.door.is-locked .door-front { background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.01)), rgba(59, 26, 102, 0.32); }
.door.is-locked .door-number { opacity: 0.75; }
.door.is-locked .door-lock { opacity: 0.85; }
.door.is-locked { cursor: not-allowed; }

.door.is-available .door-front { animation: glow 2.4s ease-in-out infinite; }
.door.is-available:hover .door-front { transform: rotateY(-18deg); }

.door.is-today .door-front {
  border-color: var(--gold);
  background:
    linear-gradient(145deg, rgba(255, 215, 106, 0.32), rgba(255, 255, 255, 0.03)),
    rgba(227, 52, 47, 0.38);
}
.door.is-today::before {
  content: '★';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  color: var(--gold);
  font-size: 1.3rem;
  text-shadow: 0 0 10px rgba(255, 215, 106, 0.9);
  animation: twinkle 1.6s ease-in-out infinite;
}

.door.is-open .door-front {
  transform: rotateY(-78deg);
  box-shadow: -8px 6px 16px rgba(0, 0, 0, 0.3);
  animation: none;
}
.door.is-open .door-front .door-number,
.door.is-open .door-front .door-lock { opacity: 0; transition: opacity 0.2s 0.3s; }
.door.is-open .door-inside { border-style: solid; border-color: rgba(255, 215, 106, 0.6); }

@keyframes glow {
  0%, 100% { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(255, 215, 106, 0); }
  50% { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25), 0 0 22px 4px rgba(255, 215, 106, 0.55); }
}
@keyframes twinkle {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.6; transform: translateX(-50%) scale(0.8); }
}

.door.shake { animation: shake 0.45s; opacity: 1; transform: none; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(6px) rotate(2deg); }
  60% { transform: translateX(-4px) rotate(-1deg); }
  80% { transform: translateX(4px) rotate(1deg); }
}

.hint {
  text-align: center;
  opacity: 0.8;
  margin: 8px 16px 0;
}

/* ---------------------------------------------------------------- Footer */
.footer {
  text-align: center;
  padding: 32px 16px 28px;
  font-size: 0.9rem;
  opacity: 0.8;
}
.footer a { color: var(--white); }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 70;
  transform: translate(-50%, 20px);
  opacity: 0;
  background: var(--white);
  color: var(--dd-purple-dark);
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s, opacity 0.25s;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------------------------------------------------------------- Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 8, 40, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s;
}
.modal-card {
  position: relative;
  width: min(600px, 100%);
  background: var(--white);
  color: #1f1530;
  border-radius: 22px;
  padding: 36px 32px 30px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  border-top: 8px solid var(--red);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  transform: translateY(20px) scale(0.92);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.2, 1.3, 0.4, 1), opacity 0.2s;
  outline: none;
}
.modal.show .modal-backdrop { opacity: 1; }
.modal.show .modal-card { transform: none; opacity: 1; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: transparent;
  font-size: 1.8rem;
  line-height: 1;
  color: #7a6a95;
  cursor: pointer;
}
.modal-close:focus-visible { outline: 2px solid var(--dd-purple); border-radius: 6px; }
.modal-day {
  margin: 0 0 14px;
  line-height: 1.1;
  font-family: 'Mountains of Christmas', 'Poppins', cursive;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--red);
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  text-align: left;
  line-height: 1.6;
  font-size: 1.02rem;
}
.modal-body > * { margin: 0; }
.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--dd-purple);
}
.modal-text { white-space: pre-line; /* line breaks typed in the CSV are kept */ }
.modal-takeaway strong { color: var(--dd-purple); }
.modal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.cta {
  display: inline-block;
  background: var(--dd-purple);
  color: var(--white);
  text-decoration: none;
  font-weight: 700;
  padding: 12px 26px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(99, 44, 166, 0.35);
  transition: transform 0.15s, background 0.15s;
}
.cta:hover { background: #7b3fc4; transform: translateY(-2px); }
.cta:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 820px) {
  :root { --cols: 4; --cell: clamp(64px, 20vw, 150px); }
}
@media (max-width: 520px) {
  :root { --cols: 3; --cell: calc((100vw - 24px - 4 * var(--gap) - 4px) / 3); }
  .modal-card { padding: 30px 20px 24px; }
  /* Tall board on phones: keep Bits at the top. */
  .mascot { align-items: flex-start; inset: 2% 4%; }
  .mascot .logo { height: auto; object-position: center top; }
}

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