/* =========================================================================
   Component — the season's decoration (U-2303)
   -------------------------------------------------------------------------
   Linked by the frontend server ONLY while an occasion is active, together
   with `data-season` and `data-season-surface` on <html>; without one, no
   document names this file and nothing here loads. The motifs are decided in
   code (`assets/img/seasonal/`, our own drawings), the dates are kept in the
   API's calendar.

   Three pieces, none of which moves the layout or catches a pointer:
   - the ornament beside a working page's title in the top bar (PORTAL,
     ADMIN), a flex item of the bar that gives way before the title;
   - the hat on the top-left corner of the sign-in and registration card
     (SIGN_IN), drawn here on the card's own box;
   - the snow over the sign-in pages and the public site (SIGN_IN, PUBLIC),
     never over a working page; off under reduced motion and in print.
   ========================================================================= */

/* ---- Christmas: the sleigh with its reindeer, beside the title ------------ *
 * 80 × 28 px at the title's line height (`--text-page-title-lh`, 28 px). A
 * flex item of the top bar of its own, between the title and the tools: the
 * bar is built by script, and this needs none. It never shortens the title and
 * never moves a tool — it gives way first: `flex-shrink: 100000` against the
 * title's 1, so a tight bar takes the sleigh's width to nothing before the
 * title loses a pixel, and the negative margin hands back the gap it adds.
 * Below 768 px the bar is the burger's and the ornament stays away. */
html[data-season="CHRISTMAS"] .portal-topbar::after {
  content: "";
  order: 1;
  flex: 0 100000 96px;
  min-width: 0;
  height: 28px;
  margin-left: calc(-1 * var(--space-md));
  background: url("../../img/seasonal/christmas-sleigh.svg") right center / 80px 28px no-repeat;
  pointer-events: none;
}

html[data-season] .portal-topbar-utils {
  order: 2;
}

@media (max-width: 767px) {
  html[data-season] .portal-topbar::after {
    content: none;
  }
}

/* ---- A greeting behind the sleigh (U-2315) ------------------------------ *
 * With a greeting (`data-season-greeting`, written by the frontend server on a
 * working page), the sleigh is a BUTTON the portal shell draws in the
 * pseudo-element's place — the same flex rules, so it still gives way before the
 * title — and the click opens the greeting in the site's lightbox. */
html[data-season-greeting] .portal-topbar::after {
  content: none;
}

.seasonal-greeting-open {
  order: 1;
  flex: 0 100000 96px;
  min-width: 0;
  height: 28px;
  margin-left: calc(-1 * var(--space-md));
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}

/* The occasion's own picture, as the plain ornament above draws it. */
html[data-season="CHRISTMAS"] .seasonal-greeting-open {
  background: url("../../img/seasonal/christmas-sleigh.svg") right center / 80px 28px no-repeat;
}

.seasonal-greeting-open:focus-visible {
  outline: 2px solid var(--sd-primary);
  outline-offset: 2px;
}

@media (max-width: 767px) {
  .seasonal-greeting-open {
    display: none;
  }
}

/* A greeting's paragraphs keep their single line breaks. */
.seasonal-greeting p {
  white-space: pre-line;
}

/* ---- The hat on the card's top-left corner -------------------------------- *
 * About 112 px on the 420 px card, tilted 21 degrees, sitting on the corner
 * itself with its brim across the corner point (the owner, 2026-12-04: „um 3
 * Grad nach links drehen und etwas höher platzieren, mehr auf die Ecke“). A
 * pseudo-element of the card and not an element in it: `register.js` replaces
 * the card's children when it starts, and an element there would be gone at
 * once. The card is already the hat's containing block (`pages/login.css`).
 *
 * It rises above the card by more than `.auth-wrap`'s top padding, and the
 * wrapper clips: a registration card taller than the window starts right under
 * that padding. So while the season decorates the sign-in surface, the wrapper's
 * top padding grows to hold the hat; without a season it is as before. */
html[data-season="CHRISTMAS"][data-season-surface="SIGN_IN"] .auth-card::before {
  content: "";
  position: absolute;
  top: -58px;
  left: -48px;
  z-index: 1;
  width: 112px;
  height: 86px;
  background: url("../../img/seasonal/christmas-hat.svg") center / contain no-repeat;
  transform: rotate(-21deg);
  pointer-events: none;
}

html[data-season="CHRISTMAS"][data-season-surface="SIGN_IN"] .auth-wrap {
  padding-top: 78px;
}

/* A narrow screen has no margin beside the card for the brim: the hat moves in
   and shrinks, so it never widens the page, and the wrapper's padding follows. */
@media (max-width: 479px) {
  html[data-season="CHRISTMAS"][data-season-surface="SIGN_IN"] .auth-card::before {
    top: -42px;
    left: -6px;
    width: 84px;
    height: 64px;
  }

  html[data-season="CHRISTMAS"][data-season-surface="SIGN_IN"] .auth-wrap {
    padding-top: 56px;
  }
}

/* ---- Light snow --------------------------------------------------------- *
 * Sixteen flakes (`snowflakes` in the frontend server's seasonal.go), each
 * placed and timed by its position. Fixed over the viewport, under the tour
 * and over the page, and every pointer goes through. */
.seasonal-snow {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.seasonal-snow i {
  position: absolute;
  top: -12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-on-dark);
  box-shadow: 0 0 2px var(--doc-ink-soft);
  opacity: 0.85;
  animation: seasonal-fall 14s linear infinite;
}

.seasonal-snow i:nth-child(1)  { left: 4%;  animation-duration: 13s; animation-delay: -2s; }
.seasonal-snow i:nth-child(2)  { left: 10%; animation-duration: 17s; animation-delay: -9s; width: 4px; height: 4px; }
.seasonal-snow i:nth-child(3)  { left: 17%; animation-duration: 15s; animation-delay: -5s; }
.seasonal-snow i:nth-child(4)  { left: 23%; animation-duration: 19s; animation-delay: -12s; width: 5px; height: 5px; }
.seasonal-snow i:nth-child(5)  { left: 30%; animation-duration: 14s; animation-delay: -7s; width: 4px; height: 4px; }
.seasonal-snow i:nth-child(6)  { left: 36%; animation-duration: 18s; animation-delay: -1s; }
.seasonal-snow i:nth-child(7)  { left: 43%; animation-duration: 16s; animation-delay: -10s; width: 5px; height: 5px; }
.seasonal-snow i:nth-child(8)  { left: 49%; animation-duration: 20s; animation-delay: -4s; width: 4px; height: 4px; }
.seasonal-snow i:nth-child(9)  { left: 56%; animation-duration: 13s; animation-delay: -11s; }
.seasonal-snow i:nth-child(10) { left: 62%; animation-duration: 17s; animation-delay: -6s; width: 5px; height: 5px; }
.seasonal-snow i:nth-child(11) { left: 69%; animation-duration: 15s; animation-delay: -13s; width: 4px; height: 4px; }
.seasonal-snow i:nth-child(12) { left: 75%; animation-duration: 19s; animation-delay: -3s; }
.seasonal-snow i:nth-child(13) { left: 82%; animation-duration: 14s; animation-delay: -8s; width: 5px; height: 5px; }
.seasonal-snow i:nth-child(14) { left: 88%; animation-duration: 18s; animation-delay: -14s; width: 4px; height: 4px; }
.seasonal-snow i:nth-child(15) { left: 94%; animation-duration: 16s; animation-delay: -5s; }
.seasonal-snow i:nth-child(16) { left: 98%; animation-duration: 21s; animation-delay: -10s; width: 4px; height: 4px; }

@keyframes seasonal-fall {
  from { transform: translate(0, 0); }
  50%  { transform: translate(12px, 52vh); }
  to   { transform: translate(-6px, 104vh); }
}

/* A visitor who asked for less motion gets no snow at all — not slower snow. */
@media (prefers-reduced-motion: reduce) {
  .seasonal-snow {
    display: none;
  }
}

/* Paper gets the page and none of the season. */
@media print {
  .seasonal-snow {
    display: none;
  }

  /* The hat's own selector: a shorter one loses to it on specificity and the
     hat would print. */
  html[data-season="CHRISTMAS"][data-season-surface="SIGN_IN"] .auth-card::before {
    content: none;
  }

  html[data-season] .portal-topbar::after {
    content: none;
  }

  .seasonal-greeting-open {
    display: none;
  }
}
