/* ----------------------------------------------------------------------------
 * Jultema for the public site
 *
 * Everything here hangs on body.season-christmas, which the layout sets
 * while SeasonalTheme.current is "christmas" (bin/rails seasonal:on / off).
 * Switched off, none of these rules match and nothing is fetched.
 *
 * It decorates through pseudo-elements and one optional block of markup
 * (shared/_seasonal_snow, the hero's snowfall), and swaps one photograph
 * (the homepage hero's, for the same street in snow). No layout, colour or
 * size of the site itself changes, with two exceptions: the header bar is
 * its paper colour outright and loses its hairline, so the snow can
 * continue it without a seam, and the hero's text is white over the
 * winter photograph. Taking the theme away leaves the pages exactly as
 * they were.
 *
 *   1. Tomteluva on the logo
 *   2. Snow along the header's lower edge
 *   3. Snow on the header's button
 *   4. Snow on the footer's upper edge
 *   5. The homepage hero's photograph in winter
 *   6. Snowfall in the homepage hero
 *
 * The drawings are in app/assets/images/seasonal/.
 * ------------------------------------------------------------------------- */

body.landing.season-christmas {
  /* White snow on the cream paper needs an edge to be seen at all. */
  --season-snow-shadow: drop-shadow(0 1px 1.5px rgba(26, 27, 31, 0.2));
}

/* ============================================================
 * 1. Tomteluva on the logo
 *
 * Sized from the logo's width, so it follows if the logo is resized. The
 * fur trim sits across the box's top left corner. On the lower mobile bar
 * the luva is smaller: the full one would reach past the top of the screen.
 * ============================================================ */
body.landing.season-christmas .site-header__brand {
  --season-hat-w: calc(var(--sh-logo-w) * 0.5);
  position: relative;
}

body.landing.season-christmas .site-header__brand::before {
  content: "";
  position: absolute;
  left: calc(var(--season-hat-w) * -0.42);
  top: calc(var(--season-hat-w) * -0.6);
  width: var(--season-hat-w);
  aspect-ratio: 64 / 52;
  background: url("/assets/seasonal/santa_hat-1da41b9b.svg") center / contain no-repeat;
  transform: rotate(-17deg);
  filter: var(--season-snow-shadow);
  pointer-events: none;
}

@media (max-width: 1080px) {
  body.landing.season-christmas .site-header__brand {
    --season-hat-w: calc(var(--sh-logo-w) * 0.42);
  }
}

/* ============================================================
 * 2. Snow along the header's lower edge
 *
 * Outside the bar's own height, so --sh-h and every hero's margin stay as
 * they are. Hidden while the mobile panel is open: it would lie across
 * the panel's first link.
 *
 * The snow continues the bar: it begins in the bar's own paper colour and
 * turns white only towards the tips (snow_edge_paper.svg). For no seam to
 * show between bar and snow, the bar's hairline is taken away and the bar
 * is the paper colour outright, not 92 % of it over a blurred backdrop
 * (which a dark hero tints a shade greyer than the snow below it).
 * ============================================================ */
body.landing.season-christmas .site-header {
  background: var(--sh-paper);
}

body.landing.season-christmas .site-header:not(.is-open) {
  border-bottom-color: transparent;
}

body.landing.season-christmas .site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 1px);
  height: 13px;
  background: url("/assets/seasonal/snow_edge_paper-f102bcb8.svg") 0 0 / 240px 13px repeat-x;
  filter: var(--season-snow-shadow);
  /* The shadow belongs under the drifts only: its blur also reaches up
     over the bar, where it draws the very line this is rid of. */
  clip-path: inset(0 0 -8px 0);
  pointer-events: none;
}

body.landing.season-christmas .site-header.is-open::after {
  display: none;
}

/* ============================================================
 * 3. Snow on the header's button
 * ============================================================ */
body.landing.season-christmas .site-nav__cta {
  position: relative;
}

body.landing.season-christmas .site-nav__cta::before {
  content: "";
  position: absolute;
  left: 22px;
  top: -4px;
  width: 62px;
  height: 12px;
  background: url("/assets/seasonal/snow_cap-dac37dfe.svg") center / 100% 100% no-repeat;
  filter: var(--season-snow-shadow);
  pointer-events: none;
}

/* ============================================================
 * 4. Snow on the footer's upper edge (.footer::before is taken)
 * ============================================================ */
body.landing.season-christmas .footer::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 13px;
  background: url("/assets/seasonal/snow_edge-54e07676.svg") 80px 0 / 240px 13px repeat-x;
  pointer-events: none;
}

/* ============================================================
 * 5. The homepage hero's photograph in winter
 *
 * The same view of Vasastan under snow (hero_home.css has the autumn one).
 * That photo is dark and is lifted by brightness(1.62); this one is
 * already full of sunlit snow and takes only a little, brightness(1.15).
 *
 * On so bright a picture the hero's cream text reads as dull, so its text
 * is white here: the headline and the outline button take --hero-cream,
 * the lead and the row of points under it --hero-cream-soft. That row lies
 * over the sunlit street, the brightest part of the photo, and gets the
 * lead's soft shadow to stay readable.
 * ============================================================ */
body.landing.season-christmas .header.hero-home {
  --hero-cream: #ffffff;
  --hero-cream-soft: #ffffff;
}

body.landing.season-christmas .header.hero-home .hero-home__photo {
  background-image: url("/assets/seasonal/goteborg-vasa-winter-904e37fe.webp");
  filter: brightness(1.15);
}

body.landing.season-christmas .header.hero-home .hero-home__trust {
  text-shadow: 0 1px 14px rgba(14, 16, 20, 0.55);
}

/* ============================================================
 * 6. Snowfall in the homepage hero (shared/_seasonal_snow)
 *
 * Three layers of one tile, the nearer ones larger and faster. Each layer
 * falls exactly one tile per loop, so the loop has no seam, and sways a
 * little sideways on its own clock. Only transforms move, on layers of
 * their own. Behind the hero's text (z-index -1, like its grain and grid).
 * ============================================================ */
body.landing.season-christmas .season-snow {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

body.landing.season-christmas .season-snow__layer {
  position: absolute;
  inset: 0 -24px;
  opacity: var(--season-o);
  animation: season-snow-sway var(--season-sway) ease-in-out infinite alternate;
}

body.landing.season-christmas .season-snow__layer::before {
  content: "";
  position: absolute;
  inset: calc(var(--season-tile) * -1) 0 0 0;
  background: url("/assets/seasonal/snowfall-24ea82c6.svg") 0 0 / var(--season-tile) var(--season-tile) repeat;
  animation: season-snow-fall var(--season-fall) linear infinite;
  will-change: transform;
}

body.landing.season-christmas .season-snow__layer--far {
  --season-tile: 250px;
  --season-fall: 36s;
  --season-sway: 9s;
  --season-o: 0.45;
}

body.landing.season-christmas .season-snow__layer--mid {
  --season-tile: 400px;
  --season-fall: 25s;
  --season-sway: 7s;
  --season-o: 0.7;
}

body.landing.season-christmas .season-snow__layer--near {
  --season-tile: 640px;
  --season-fall: 18s;
  --season-sway: 5.5s;
  --season-o: 0.85;
}

@keyframes season-snow-fall {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, var(--season-tile), 0); }
}

@keyframes season-snow-sway {
  from { transform: translate3d(-12px, 0, 0); }
  to { transform: translate3d(12px, 0, 0); }
}

/* Reduced motion: the snow hangs still. */
@media (prefers-reduced-motion: reduce) {
  body.landing.season-christmas .season-snow__layer,
  body.landing.season-christmas .season-snow__layer::before {
    animation: none;
  }
}
