/* christmas.css — Christmas accents for the main page.
   Every rule waits for an accent name in <html data-accents>. The script in
   index.html's <head> fills it from data-season-accents from Nov 26 through
   Dec 26 (America/New_York), so outside those dates nothing here applies.
   The art in christmas/ comes from scripts/make-christmas-art.mjs and stays
   with the page's navy, amber, and white, plus one red and one green. */

:root {
  --xmas-red: #e5484d;
  --xmas-red-deep: #b8333a;
}

/* ========================================================================
   The truck: presents on the flatbed, lights on the cab, a wreath on the
   cab side. The art sits inside the truck SVG with display="none".
   ======================================================================== */

[data-accents~='gifts'] .truck-load {
  display: none;
}

[data-accents~='gifts'] .xmas-gifts,
[data-accents~='lights'] .xmas-lights,
[data-accents~='wreath'] .xmas-wreath {
  display: inline;
}

.xmas-glow {
  opacity: 0.85;
}

/* The cab lights flicker like old C9 bulbs: each one burns steady, then dips
   for a split second at its own odd moment. Three cycle lengths and a
   per-bulb offset keep any two bulbs from flickering in step. The glass
   stays lit through a dip; mostly the glow drops out. */
@media (prefers-reduced-motion: no-preference) {
  .xmas-glow,
  .xmas-lamp {
    animation: xmas-flicker-glow 3.3s linear infinite;
    animation-delay: calc(var(--i) * -0.73s);
  }

  .xmas-lamp {
    animation-name: xmas-flicker-lamp;
  }

  .xmas-bulb:nth-child(3n) .xmas-glow,
  .xmas-bulb:nth-child(3n) .xmas-lamp {
    animation-duration: 2.7s;
  }

  .xmas-bulb:nth-child(3n + 1) .xmas-glow,
  .xmas-bulb:nth-child(3n + 1) .xmas-lamp {
    animation-duration: 4.1s;
  }
}

@keyframes xmas-flicker-glow {
  0%,
  17%,
  21%,
  52%,
  55%,
  58.5%,
  61%,
  100% {
    opacity: 0.95;
  }

  19% {
    opacity: 0.08;
  }

  53.5% {
    opacity: 0.35;
  }

  56.5% {
    opacity: 0.85;
  }

  59.5% {
    opacity: 0.05;
  }
}

@keyframes xmas-flicker-lamp {
  0%,
  17%,
  21%,
  52%,
  55%,
  58.5%,
  61%,
  100% {
    opacity: 1;
  }

  19% {
    opacity: 0.5;
  }

  53.5% {
    opacity: 0.7;
  }

  56.5% {
    opacity: 0.95;
  }

  59.5% {
    opacity: 0.45;
  }
}

/* ========================================================================
   Snow: two layers fall through the night hero and the navy Apply section.
   Each layer is one tile taller than its section and slides down by exactly
   one tile, so the loop has no seam. Snow banks line both road shoulders.
   ======================================================================== */

/* styles.css gives .hero::before and ::after a size for its light-page glows;
   width and height go back to auto so the insets set the size here. */
[data-accents~='snow'] .hero.drivers-hero::before,
[data-accents~='snow'] .hero.drivers-hero::after,
[data-accents~='snow'] .apply:not(.night-hero--ascii)::after {
  content: '';
  position: absolute;
  inset: -520px -24px 0;
  z-index: 0;
  width: auto;
  height: auto;
  pointer-events: none;
  background-repeat: repeat;
  will-change: transform;
}

[data-accents~='snow'] .hero.drivers-hero::before {
  background-image: url('christmas/snow-far.svg');
  background-size: 360px 360px;
  animation: xmas-fall-far 26s linear infinite;
}

[data-accents~='snow'] .hero.drivers-hero::after,
[data-accents~='snow'] .apply:not(.night-hero--ascii)::after {
  background-image: url('christmas/snow-near.svg');
  background-size: 520px 520px;
  animation:
    xmas-fall-near 15s linear infinite,
    xmas-sway 4.5s ease-in-out infinite alternate;
}

[data-accents~='snow'] .apply:not(.night-hero--ascii)::after {
  opacity: 0.75;
}

[data-accents~='snow'] .apply {
  overflow: hidden;
}

[data-accents~='snow'] .apply-layout {
  position: relative;
  z-index: 1;
}

@keyframes xmas-fall-far {
  to {
    transform: translateY(360px);
  }
}

@keyframes xmas-fall-near {
  to {
    transform: translateY(520px);
  }
}

@keyframes xmas-sway {
  from {
    translate: -14px 0;
  }

  to {
    translate: 14px 0;
  }
}

[data-accents~='snow'] .road::before,
[data-accents~='snow'] .road::after {
  content: '';
  position: absolute;
  right: 0;
  left: 0;
  pointer-events: none;
  background: url('christmas/snowbank.svg') 0 0 / auto 100% repeat-x;
}

/* The far shoulder sits behind the truck; the near one rides in front. */
[data-accents~='snow'] .road::before {
  top: -12px;
  height: 12px;
  opacity: 0.8;
}

[data-accents~='snow'] .road::after {
  bottom: -2px;
  height: 9px;
  background-position: -97px 0;
}

/* ========================================================================
   Light strings: under the navy page strip at the top, and along the top
   edge of the navy Apply section (hung from its amber lane stripe).
   ======================================================================== */

[data-accents~='garland'] .page-switch {
  position: relative;
}

/* Room under the strip for the bulbs, so they clear the logo. */
[data-accents~='garland'] .site-header .drivers-bar {
  padding-top: calc(0.45rem + 12px);
}

[data-accents~='garland'] .page-switch::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: 1;
  height: 20px;
  pointer-events: none;
  background: url('christmas/lights-on-light.svg') 0 0 / auto 100% repeat-x;
}

[data-accents~='applylights'] .apply::before {
  z-index: 2;
  height: 28px;
  background:
    var(--lane) 0 0 / 100% 4px no-repeat,
    url('christmas/lights-on-navy.svg') -40px 1px / auto 27px repeat-x;
}

/* ========================================================================
   Bows: each section heading's amber bar ends in a bow, like a ribbon.
   ======================================================================== */

[data-accents~='bows'] .section-heading h2::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: calc(3.5rem - 13px);
  width: 27px;
  height: 18px;
  background: url('christmas/bow-amber.svg') center / contain no-repeat;
}

/* ========================================================================
   Ornaments: the two pay stops hang as glass ornaments on the route.
   ======================================================================== */

/* The ball's center lands where the plain stop's center was. */
[data-accents~='ornaments'] .pay-stop::before {
  top: calc(0.675rem - 28px);
  left: calc(0.675rem - 16px);
  width: 32px;
  height: 43.4px;
  border-radius: 0;
  background: url('christmas/ornament-navy.svg') center / contain no-repeat;
  box-shadow: none;
}

[data-accents~='ornaments'] .pay-stop:last-child::before {
  background-image: url('christmas/ornament-amber.svg');
}

/* ========================================================================
   Presents: the home days on the schedule calendars are wrapped.
   ======================================================================== */

[data-accents~='presents'] .cell.is-home,
[data-accents~='presents'] .key.is-home {
  background-image: url('christmas/day-ribbon.svg');
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* ========================================================================
   Wrap: a red ribbon runs down the amber CDL band between its two columns,
   with a bow on the band's top edge, so the band reads as a present.
   ======================================================================== */

[data-accents~='wrap'] .cdl-band {
  --xmas-w: min(100% - 2rem, var(--max-width));
  --xmas-g: clamp(2rem, 4vw, 3.5rem);
  --xmas-x: calc((100% - var(--xmas-w)) / 2 + (var(--xmas-w) - var(--xmas-g)) * 1.9 / 2.9 + var(--xmas-g) / 2);
  position: relative;
}

[data-accents~='wrap'] .cdl-band::before,
[data-accents~='wrap'] .cdl-band::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

[data-accents~='wrap'] .cdl-band::before {
  top: 0;
  bottom: 0;
  left: calc(var(--xmas-x) - 11px);
  width: 22px;
  background: linear-gradient(
    90deg,
    var(--xmas-red-deep) 0 2px,
    var(--xmas-red) 2px calc(100% - 2px),
    var(--xmas-red-deep) calc(100% - 2px)
  );
}

/* The bow's knot sits on the ribbon, right at the band's top edge. */
[data-accents~='wrap'] .cdl-band::after {
  top: -24px;
  left: calc(var(--xmas-x) - 60px);
  width: 120px;
  height: 80px;
  background: url('christmas/bow-red-big.svg') center / contain no-repeat;
}

/* ========================================================================
   Narrow screens and reduced motion
   ======================================================================== */

@media (max-width: 900px) {
  /* The CDL band stacks into one column here, so the ribbon would cross the
     words. The bow stays, at the band's top right. */
  [data-accents~='wrap'] .cdl-band::before {
    content: none;
  }

  [data-accents~='wrap'] .cdl-band::after {
    top: -18px;
    right: 0.75rem;
    left: auto;
    width: 90px;
    height: 60px;
  }
}

@media (max-width: 760px) {
  [data-accents~='ornaments'] .pay-stop::before {
    top: calc(0.875rem - 28px);
  }
}

@media (max-width: 640px) {
  [data-accents~='garland'] .page-switch::after {
    height: 16px;
  }

  [data-accents~='garland'] .site-header .drivers-bar {
    padding-top: calc(0.35rem + 10px);
  }
}

/* Visitors who ask for less motion get still snow and steady lights. */
@media (prefers-reduced-motion: reduce) {
  [data-accents~='snow'] .hero.drivers-hero::before,
  [data-accents~='snow'] .hero.drivers-hero::after,
  [data-accents~='snow'] .apply:not(.night-hero--ascii)::after {
    animation: none;
  }

  [data-accents~='garland'] .page-switch::after {
    background-image: url('christmas/lights-on-light-still.svg');
  }

  [data-accents~='applylights'] .apply::before {
    background-image: var(--lane), url('christmas/lights-on-navy-still.svg');
  }
}
