:root {
  --sky-top: #0b1035;
  --sky-mid: #16215c;
  --sky-bottom: #23306e;
  --gold: #ffd166;
  --red: #ef476f;
  --green: #2ec27e;
  --ice: #cfe6ff;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.18);
  /* how much of Jose Mari Chan is on screen (0–1), set from JS */
  --p: 0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: #fff;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 209, 102, 0.12), transparent 60%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-bottom) 100%);
  min-height: 100svh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

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

/* ---------- String lights ---------- */
#lights {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  border-top: 3px solid rgba(255, 255, 255, 0.25);
  z-index: 4;
  pointer-events: none;
}

#lights .bulb {
  width: 12px;
  height: 16px;
  border-radius: 50% 50% 60% 60%;
  margin-top: 8px;
  position: relative;
  animation: twinkle 2.2s ease-in-out infinite;
}

#lights .bulb::before {
  /* the little socket connecting the bulb to the wire */
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 8px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
}

.bulb.c0 { background: var(--red);   box-shadow: 0 0 12px 2px var(--red); }
.bulb.c1 { background: var(--gold);  box-shadow: 0 0 12px 2px var(--gold); }
.bulb.c2 { background: var(--green); box-shadow: 0 0 12px 2px var(--green); }
.bulb.c3 { background: #4cc9f0;      box-shadow: 0 0 12px 2px #4cc9f0; }

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; box-shadow: none; }
}

/* ---------- Layout ---------- */
main {
  position: relative;
  z-index: 5;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: clamp(56px, 9vh, 90px) 20px 16px;
  text-align: center;
  flex: 1;
}

.eyebrow {
  display: inline-block;
  background: rgba(239, 71, 111, 0.2);
  border: 1px solid rgba(239, 71, 111, 0.5);
  color: #ffb3c6;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}

h1 {
  font-family: "Mountains of Christmas", "Nunito", cursive;
  font-size: clamp(2.6rem, 8vw, 4.4rem);
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25), 0 0 30px rgba(255, 209, 102, 0.35);
}

.tagline {
  margin-top: 10px;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  color: var(--ice);
}

.tagline strong { color: var(--gold); }

/* ---------- Countdown ---------- */
.countdown { margin-top: clamp(22px, 4vh, 40px); }

#countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 2vw, 16px);
  max-width: 560px;
  margin: 0 auto;
}

.cell {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: clamp(12px, 2.5vw, 20px) 6px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.num {
  display: block;
  font-size: clamp(1.9rem, 6.5vw, 3.2rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.label {
  display: block;
  margin-top: 6px;
  font-size: clamp(0.65rem, 1.8vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ice);
}

.until {
  margin-top: 14px;
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  font-weight: 700;
}

.christmas-msg {
  margin-top: 14px;
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  font-weight: 900;
  color: var(--gold);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ---------- Visibility meter ---------- */
.meter { margin: clamp(24px, 4.5vh, 44px) auto 0; max-width: 460px; }

.meter-label { font-size: 1rem; color: var(--ice); }
.meter-label strong { color: var(--gold); font-size: 1.15em; }

.meter-bar {
  margin-top: 10px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--card-border);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: repeating-linear-gradient(
    -45deg,
    var(--red) 0 12px,
    #fff 12px 24px
  );
  transition: width 2s ease;
  animation: candy-scroll 1.2s linear infinite;
  background-size: 34px 100%;
}

@keyframes candy-scroll {
  from { background-position: 0 0; }
  to { background-position: 34px 0; }
}

.meter-hint {
  margin-top: 8px;
  font-size: 0.85rem;
  color: rgba(207, 230, 255, 0.75);
  font-style: italic;
  min-height: 1.2em;
}

/* ---------- Music button ---------- */
.music-btn {
  margin-top: clamp(20px, 4vh, 36px);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 900;
  color: #3a0d1f;
  background: linear-gradient(180deg, #ffe29a, var(--gold));
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  box-shadow: 0 6px 0 #b8860b, 0 12px 28px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.music-btn:hover { transform: translateY(-2px); }
.music-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #b8860b; }

.music-btn.playing {
  background: linear-gradient(180deg, #56e39f, var(--green));
  box-shadow: 0 6px 0 #157347, 0 12px 28px rgba(0, 0, 0, 0.35);
  color: #06301c;
}

/* ---------- Fast-forward (time machine) button ---------- */
.ff-btn {
  display: block;
  margin: 14px auto 0;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ice);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.ff-btn:hover { background: rgba(255, 255, 255, 0.16); transform: translateY(-1px); }
.ff-btn:active { transform: translateY(1px); }

/* while time-traveling, the button becomes the way home */
.ff-btn.live {
  background: rgba(239, 71, 111, 0.25);
  border-color: var(--red);
  color: #ffb3c6;
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- Jose Mari Chan ---------- */
#jmc-slide {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 6;
  height: min(74vh, 700px);
  aspect-ratio: 691 / 931;
  pointer-events: none;
  /* Slide him in from the left: at --p:0 fully off-screen, at --p:1 fully on. */
  transform:
    translateX(calc(-100% * (1 - var(--p))))
    rotate(calc(6deg * (1 - var(--p))));
  transform-origin: bottom left;
  transition: transform 2.5s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(6px 0 24px rgba(0, 0, 0, 0.45));
}

#jmc-sway {
  width: 100%;
  height: 100%;
  animation: sway 5s ease-in-out infinite;
  transform-origin: bottom center;
}

@keyframes sway {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50% { transform: rotate(1.2deg) translateY(-6px); }
}

#jmc-sway img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom left;
  user-select: none;
  -webkit-user-drag: none;
}

.bubble {
  position: absolute;
  top: 4%;
  left: 92%;
  background: #fff;
  color: #23306e;
  font-weight: 700;
  font-size: clamp(0.8rem, 2vw, 1rem);
  padding: 10px 14px;
  border-radius: 16px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  animation: bubble-pop 0.5s ease;
}

.bubble::after {
  content: "";
  position: absolute;
  left: -8px;
  top: 55%;
  border: 9px solid transparent;
  border-right-color: #fff;
  border-left: 0;
}

@keyframes bubble-pop {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- Footer ---------- */
footer {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 14px 20px 16px;
  font-size: 0.8rem;
  color: rgba(207, 230, 255, 0.55);
}

footer .disclaimer {
  margin-top: 8px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.72rem;
  color: rgba(207, 230, 255, 0.45);
}

footer .credit {
  margin-top: 10px;
  font-size: 0.85rem;
  color: rgba(207, 230, 255, 0.75);
}

footer .credit strong { color: var(--gold); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  /* Compact everything so the whole page fits one phone screen, no scroll */
  main { padding: 44px 12px 8px; }
  .eyebrow { font-size: 0.66rem; padding: 4px 10px; margin-bottom: 8px; }
  h1 { font-size: clamp(1.9rem, 8.5vw, 2.4rem); }
  .tagline { margin-top: 6px; font-size: 0.92rem; }

  .countdown { margin-top: 14px; }
  #countdown-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 400px; }
  .cell { border-radius: 12px; padding: 10px 2px; }
  .num { font-size: clamp(1.3rem, 6vw, 1.7rem); }
  .label { margin-top: 4px; font-size: 0.55rem; }
  .until { margin-top: 10px; font-size: 0.95rem; }
  .christmas-msg { margin-top: 10px; font-size: 1.1rem; }

  .meter { margin-top: 16px; max-width: 340px; }
  .meter-label { font-size: 0.85rem; }
  .meter-bar { margin-top: 8px; height: 12px; }
  .meter-hint { margin-top: 6px; font-size: 0.72rem; }

  .music-btn { margin-top: 14px; font-size: 0.92rem; padding: 10px 20px; box-shadow: 0 4px 0 #b8860b, 0 8px 18px rgba(0, 0, 0, 0.35); }
  .ff-btn { margin-top: 8px; font-size: 0.78rem; padding: 7px 16px; }

  /* solid footer bar grounds him; he renders in front of it (footer z 5 < JMC z 6) */
  footer {
    padding: 8px 12px 10px;
    font-size: 0.62rem;
    background: rgba(9, 13, 44, 0.94);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.35);
  }
  footer .disclaimer { margin-top: 4px; font-size: 0.58rem; }
  footer .credit { margin-top: 4px; font-size: 0.68rem; }

  /* keep the same amount of him visible above the footer bar */
  #jmc-slide { height: calc(min(42vh, 420px) + var(--footer-h, 0px)); }
  /* no room for the speech bubble next to the centered buttons on phones */
  .bubble { display: none; }
}

/* Very short screens (small phones, landscape-ish) squeeze a bit more */
@media (max-height: 700px) and (max-width: 640px) {
  main { padding-top: 40px; }
  h1 { font-size: 1.7rem; }
  .tagline { font-size: 0.85rem; }
  .num { font-size: 1.25rem; }
  .meter { margin-top: 10px; }
  .music-btn { margin-top: 10px; }
  #jmc-slide { height: calc(min(38vh, 340px) + var(--footer-h, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  #lights .bulb, #jmc-sway, .meter-fill, .christmas-msg { animation: none; }
  #jmc-slide { transition: none; }
}
