/* Advent Calendar: extra holiday magic (ornaments, candy canes, garlands, big snowflakes,
   Christmas lettering). Loaded after advent.css. Animations only run when the visitor
   hasn't asked their device to reduce motion. */

.advent-page {
  --xmas-red: #c8233a;
  --xmas-red-dark: #7a1222;
  --xmas-green: #1f7a4d;
  --xmas-green-dark: #0f3d27;
  --xmas-gold: #f3d97a;
  --candy-cane: repeating-linear-gradient(-45deg, #d42a40 0 14px, #ffffff 14px 28px);
  --xmas-font: 'Mountains of Christmas', var(--font-family-primary);
}

/* ---------- Candy-cane strips ---------- */

.candy-strip {
  height: 14px;
  background: var(--candy-cane);
  background-size: 40px 40px;
  box-shadow: inset 0 -3px 4px rgba(0, 0, 0, 0.15);
}

/* ---------- Hero ---------- */

.advent-hero {
  min-height: 520px;
  background-color: var(--xmas-green-dark);
}

.advent-hero .hero-overlay {
  background:
    radial-gradient(ellipse at 50% 110%, rgba(243, 217, 122, 0.35), transparent 60%),
    linear-gradient(180deg, rgba(122, 18, 34, 0.72) 0%, rgba(15, 61, 39, 0.8) 100%);
}

.advent-hero .hero-content {
  z-index: 3;
}

.advent-hero .hero-title {
  font-family: var(--xmas-font);
  font-size: clamp(3.2rem, 11vw, 6.5rem);
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 10px rgba(243, 217, 122, 0.9),
    0 0 28px rgba(243, 217, 122, 0.6),
    0 4px 0 var(--xmas-red-dark),
    0 8px 20px rgba(0, 0, 0, 0.5);
}

.advent-hero .hero-subtitle {
  color: var(--xmas-gold);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-md);
}

/* Hanging ornaments swinging along the top of the hero. */
.ornaments {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-around;
  pointer-events: none;
}

.ornament {
  --len: 70px;
  --c1: var(--xmas-red);
  --c2: var(--xmas-red-dark);
  position: relative;
  width: 2px;
  height: var(--len);
  background: rgba(243, 217, 122, 0.8);
  transform-origin: top center;
}

.ornament::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 12px;
  height: 9px;
  margin-left: -6px;
  border-radius: 2px;
  background: linear-gradient(90deg, #a98422, #f3d97a, #a98422);
}

.ornament::after {
  content: '';
  position: absolute;
  left: 50%;
  top: calc(var(--len) + 3px);
  width: 40px;
  height: 40px;
  margin-left: -20px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.85) 0 4px, rgba(255, 255, 255, 0) 12px),
    radial-gradient(circle at 50% 50%, var(--c1), var(--c2));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
}

.ornament:nth-child(2) { --len: 110px; --c1: var(--xmas-gold); --c2: #a98422; }
.ornament:nth-child(3) { --len: 50px;  --c1: #3aa36d; --c2: var(--xmas-green-dark); }
.ornament:nth-child(4) { --len: 130px; --c1: #5b8fd6; --c2: var(--color-bourbon-dark); }
.ornament:nth-child(5) { --len: 80px;  --c1: var(--xmas-red); --c2: var(--xmas-red-dark); }
.ornament:nth-child(6) { --len: 120px; --c1: var(--xmas-gold); --c2: #a98422; }
.ornament:nth-child(7) { --len: 60px;  --c1: #3aa36d; --c2: var(--xmas-green-dark); }

@media (max-width: 640px) {
  .ornament:nth-child(n + 5) { display: none; }
  .ornament { --len: 40px; }
  .ornament:nth-child(2) { --len: 70px; }
  .ornament:nth-child(4) { --len: 55px; }
}

/* ---------- Countdown ---------- */

.xmas-countdown {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(243, 217, 122, 0.5);
  color: #fff;
  font-family: var(--font-family-secondary);
  font-weight: var(--font-weight-semibold);
}

.xmas-countdown strong {
  font-family: var(--xmas-font);
  font-size: 1.8rem;
  color: var(--xmas-gold);
  line-height: 1;
}

/* ---------- Big tumbling snowflakes (added by advent-festive.js) ---------- */

.flake-field {
  position: fixed;
  inset: 0;
  z-index: 51;
  overflow: hidden;
  pointer-events: none;
}

.flake {
  position: absolute;
  top: -40px;
  color: #fff;
  text-shadow: 0 0 3px rgba(80, 110, 160, 0.9);
  user-select: none;
  animation: flake-fall linear infinite;
}

@keyframes flake-fall {
  0%   { transform: translate(0, 0) rotate(0deg); }
  50%  { transform: translate(var(--drift), 55vh) rotate(180deg); }
  100% { transform: translate(0, 110vh) rotate(360deg); }
}

/* ---------- Garland ---------- */

.garland {
  height: 46px;
  background:
    radial-gradient(circle at 50% 55%, var(--xmas-red) 0 6px, transparent 7px) 0 0 / 70px 46px repeat-x,
    radial-gradient(circle at 50% 55%, var(--xmas-gold) 0 5px, transparent 6px) 35px 8px / 70px 46px repeat-x,
    radial-gradient(ellipse 60% 40% at 50% 40%, #1f7a4d 0 60%, transparent 62%) 0 0 / 26px 30px repeat-x,
    radial-gradient(ellipse 60% 40% at 50% 60%, #155c39 0 60%, transparent 62%) 13px 6px / 26px 30px repeat-x;
}

/* ---------- Section titles and holly dividers ---------- */

.advent-page .section-title.xmas {
  font-family: var(--xmas-font);
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  color: var(--xmas-red);
  text-shadow: 0 2px 0 rgba(243, 217, 122, 0.8);
}

.holly-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: var(--space-sm) auto var(--space-md);
}

.holly-divider::before,
.holly-divider::after {
  content: '';
  width: min(120px, 25vw);
  height: 10px;
  border-radius: 5px;
  background: repeating-linear-gradient(-45deg, #d42a40 0 6px, #ffffff 6px 12px);
  box-shadow: 0 0 0 1.5px #d42a40;
}

.holly-divider svg {
  width: 54px;
  height: 30px;
}

/* ---------- Closing "join" banner, in Christmas red ---------- */

.advent-cheers {
  background:
    radial-gradient(circle, rgba(243, 217, 122, 0.25) 0 1.6px, transparent 2.2px) 0 0 / 22px 22px,
    linear-gradient(160deg, var(--xmas-red) 0%, var(--xmas-red-dark) 100%);
  color: #fff;
}

.advent-cheers .heading-2 {
  font-family: var(--xmas-font);
  font-size: clamp(2.4rem, 7vw, 4rem);
  color: var(--xmas-gold);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.advent-cheers .body-large {
  color: #fff;
}

.advent-cheers .divider {
  background: repeating-linear-gradient(-45deg, #ffffff 0 6px, var(--xmas-gold) 6px 12px);
  height: 10px;
  border-radius: 5px;
}

.advent-cheers .btn {
  border: 7px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(-45deg, #d42a40 0 8px, #ffffff 8px 16px) border-box;
  color: var(--xmas-red-dark);
  font-weight: var(--font-weight-bold);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), 0 0 0 3px var(--xmas-gold);
}

.advent-cheers .btn:hover,
.advent-cheers .btn:focus-visible {
  transform: translateY(-3px) scale(1.04);
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .ornament {
    animation: swing 3.2s ease-in-out infinite alternate;
  }

  .ornament:nth-child(2n) { animation-duration: 2.6s; animation-delay: -1s; }
  .ornament:nth-child(3n) { animation-duration: 3.8s; animation-delay: -2s; }

  .advent-hero .hero-title {
    animation: title-glow 2.4s ease-in-out infinite;
  }

  .candy-strip {
    animation: cane-scroll 2s linear infinite;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flake-field {
    display: none;
  }
}

@keyframes swing {
  from { transform: rotate(6deg); }
  to   { transform: rotate(-6deg); }
}

@keyframes title-glow {
  0%, 100% {
    text-shadow:
      0 0 10px rgba(243, 217, 122, 0.9),
      0 0 28px rgba(243, 217, 122, 0.6),
      0 4px 0 #7a1222,
      0 8px 20px rgba(0, 0, 0, 0.5);
  }
  50% {
    text-shadow:
      0 0 16px rgba(243, 217, 122, 1),
      0 0 48px rgba(243, 217, 122, 0.85),
      0 4px 0 #7a1222,
      0 8px 20px rgba(0, 0, 0, 0.5);
  }
}

@keyframes cane-scroll {
  to { background-position: 40px 0; }
}

/* ---------- Strings of Christmas lights that flicker on and off ----------
   Bulbs are added by advent-festive.js to fill the width. Each bulb gets its own
   random timing so the string blinks unevenly, like real lights. */

.xmas-lights {
  display: flex;
  justify-content: center;
  height: 54px;
  margin: 0;
  padding: 0 10px;
  overflow: visible;
  list-style: none;
  pointer-events: none;
}

.xmas-lights-hero {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
}

.xmas-lights-inline {
  max-width: 900px;
  margin: 0 auto var(--space-sm);
}

.xmas-lights li {
  --bulb: #ff3b4f;
  --glow: rgba(255, 59, 79, 0.9);
  position: relative;
  flex: 0 0 auto;
  width: 13px;
  height: 24px;
  margin: 20px 22px 0;
  border-radius: 50%;
  background: var(--bulb);
  box-shadow: 0 4px 18px 4px var(--glow);
}

/* Socket. */
.xmas-lights li::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 1px;
  width: 11px;
  height: 8px;
  border-radius: 3px;
  background: #2a2a2a;
}

/* Wire swooping to the next bulb. */
.xmas-lights li::after {
  content: '';
  position: absolute;
  top: -16px;
  left: 6px;
  width: 57px;
  height: 18px;
  border-bottom: 2px solid #2a2a2a;
  border-radius: 50%;
}

.xmas-lights li:last-child::after {
  display: none;
}

.xmas-lights li:nth-child(5n + 2) { --bulb: #ffd34d; --glow: rgba(255, 211, 77, 0.9); }
.xmas-lights li:nth-child(5n + 3) { --bulb: #3ddc84; --glow: rgba(61, 220, 132, 0.85); }
.xmas-lights li:nth-child(5n + 4) { --bulb: #4fa3ff; --glow: rgba(79, 163, 255, 0.9); }
.xmas-lights li:nth-child(5n + 5) { --bulb: #ff8a3d; --glow: rgba(255, 138, 61, 0.9); }

/* On the dark hero the wire shows better in a lighter green. */
.xmas-lights-hero li::before { background: #1d3b2a; }
.xmas-lights-hero li::after { border-bottom-color: #3f6b4f; }

@media (prefers-reduced-motion: no-preference) {
  .xmas-lights li {
    animation: bulb-blink var(--dur, 1.6s) steps(1, end) var(--delay, 0s) infinite;
  }

  /* A few bulbs stutter like a loose connection. */
  .xmas-lights li.is-flicker {
    animation: bulb-flicker var(--dur, 3s) linear var(--delay, 0s) infinite;
  }
}

@keyframes bulb-blink {
  0%, 100% { background: var(--bulb); box-shadow: 0 4px 18px 4px var(--glow); }
  50%      { background: color-mix(in srgb, var(--bulb) 30%, #333); box-shadow: none; }
}

@keyframes bulb-flicker {
  0%, 18%, 22%, 25%, 53%, 57%, 100% { background: var(--bulb); box-shadow: 0 4px 18px 4px var(--glow); }
  20%, 24%, 55%, 70%, 74%           { background: color-mix(in srgb, var(--bulb) 30%, #333); box-shadow: none; }
}
