/* ── Seasonal themes ───────────────────────────────────────────────────────
   Which theme is active is decided by the server (seasonal_themes.py); the
   theme is rendered only through html[data-seasonal-theme="<key>"], which
   static/js/seasonal-init.js sets in <head> before the first paint - and
   only when the viewer has not switched themes off on this device.

   Ground rules for everything in here:
   - status colours (--ok / --warn / --crit), charts and print/PDF output are
     never themed;
   - decorations sit behind page content (.seasonal-scene) or behind the
     text inside a tile (z-index -1 in an isolated tile), never on top of
     data. Only the short particle burst (canvas) passes over the page.
   Asset URLs are relative to this file: ../themes/<key>/... */

/* ── Theme colours ─────────────────────────────────────────────────────── */
html[data-seasonal-theme] {
  --seasonal-brand-rgb: 227, 6, 19;
  --seasonal-rgb: 227, 6, 19;
}

html[data-seasonal-theme="winter"] { --seasonal-rgb: 125, 196, 228 }
html[data-seasonal-theme="autumn"] { --seasonal-rgb: 217, 128, 54 }
html[data-seasonal-theme="spring"] { --seasonal-rgb: 236, 140, 172 }
html[data-seasonal-theme="summer"] { --seasonal-rgb: 246, 192, 70 }

html[data-seasonal-theme="new-year"] {
  --seasonal-rgb: 201, 155, 54;
  /* gold foil: the two asset golds (#c99b36, #ead6a0) plus light and dark
     edges so it reads as metal rather than flat yellow */
  --seasonal-gold-foil: linear-gradient(90deg, #9c7425 0%, #e9cf7f 22%, #c99b36 45%, #f6e7b0 62%, #b8892c 82%, #e9cf7f 100%);
}

/* St. Patrick's Day is the one theme that recolours the brand accent
   (buttons, active tabs, sidebar marker) - matching its green logo. */
html[data-seasonal-theme="st-patricks"] {
  --seasonal-brand-rgb: 33, 134, 75;
  --seasonal-rgb: 50, 161, 25;
  --ibh-red: #21864b;
  --ibh-red-2: #176a3a;
}

/* ...but this bar *means* "danger" - keep it red. */
html[data-seasonal-theme="st-patricks"] .device-status-bar-fill--danger {
  background: color-mix(in srgb, #e30613 70%, transparent)
}

html[data-seasonal-theme="st-patricks"] .sidebar {
  border-right-color: rgba(33, 134, 75, 0.2)
}

html[data-seasonal-theme="st-patricks"] .sidebar::after {
  background: linear-gradient(90deg, rgba(33, 134, 75, 0.25) 0px, transparent 120px)
}

html[data-seasonal-theme="st-patricks"] .nav-item.active::before,
html[data-seasonal-theme="st-patricks"] .nav-subitem.active::before,
html[data-seasonal-theme="st-patricks"] .sidebar-button.active::before {
  box-shadow: 0 0 0 4px rgba(33, 134, 75, 0.18)
}

/* Sidebar: the brand glow (top) stays, the second glow takes the season's
   colour. Same layers as uranos.css, light and dark. */
html[data-seasonal-theme] .sidebar {
  background:
    radial-gradient(800px 600px at 0% 0%, rgba(var(--seasonal-brand-rgb), 0.38), transparent 65%),
    radial-gradient(900px 700px at 0% 100%, rgba(var(--seasonal-rgb), 0.30), transparent 70%),
    linear-gradient(180deg, #0b0f1a 0%, #0a0e18 40%, #070a14 100%);
}

html[data-seasonal-theme] body.dark-mode .sidebar {
  background:
    radial-gradient(800px 600px at 0% 0%, rgba(var(--seasonal-brand-rgb), 0.24), transparent 65%),
    radial-gradient(900px 700px at 0% 100%, rgba(var(--seasonal-rgb), 0.20), transparent 70%),
    linear-gradient(180deg, #060913 0%, #09101d 42%, #0b1424 100%);
}

html[data-seasonal-theme] body.login-body {
  background:
    radial-gradient(800px 600px at 30% 20%, rgba(var(--seasonal-brand-rgb), 0.12), transparent 65%),
    radial-gradient(700px 480px at 70% 80%, rgba(var(--seasonal-rgb), 0.16), transparent 60%),
    var(--bg);
}

/* ── Logo ──────────────────────────────────────────────────────────────────
   The default logo keeps its layout box; the themed logo is laid over it.
   Themed canvas 623x137 holds the original 606.67x109.33 logo at offset
   (8, 20), so relative to the default logo's box it starts at
   -8/606.67 = -1.3187% / -20/109.33 = -18.2927% and is 623/606.67 =
   102.6923% wide, 137/109.33 = 125.3049% high. object-fit: contain on both
   keeps them aligned even where mobile CSS letterboxes the default logo. */
.brand-logo {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  vertical-align: baseline
}

.topbar-brand > .brand-logo {
  display: block
}

.login-brand > .brand-logo {
  margin-bottom: 12px
}

.brand-logo > .login-logo {
  margin: 0
}

.seasonal-logo {
  display: none
}

.brand-logo > .seasonal-logo {
  position: absolute;
  left: -1.3187%;
  top: -18.2927%;
  width: 102.6923%;
  height: 125.3049%;
  max-width: none;
  max-height: none;
  margin: 0;
  object-fit: contain;
  pointer-events: none
}

html[data-seasonal-theme] .brand-logo > .seasonal-logo[src] {
  display: block
}

html[data-seasonal-theme] .brand-logo:has(> .seasonal-logo[src]) > .brand-logo-default {
  visibility: hidden
}

@media (max-width:660px) {
  .topbar-brand > .brand-logo {
    width: 100%
  }
}

/* ── Per-device switch (sidebar / login utility bar) ───────────────────── */
.seasonal-toggle {
  display: none
}

html[data-seasonal-available] .seasonal-toggle {
  display: flex;
  justify-content: center;
  padding: 0;
  width: 44px;
  min-width: 44px;
  height: 42px
}

html[data-seasonal-available] .login-utility-controls .seasonal-toggle {
  height: auto
}

.seasonal-toggle .nav-left {
  justify-content: center;
  gap: 0
}

.seasonal-toggle-icon {
  display: block;
  width: 22px;
  height: 22px;
  background: no-repeat center / contain;
  transition: filter var(--anim), opacity var(--anim)
}

html[data-seasonal-available="winter"] .seasonal-toggle-icon { background-image: url(../themes/winter/favicon.svg) }
html[data-seasonal-available="spring"] .seasonal-toggle-icon { background-image: url(../themes/spring/favicon.svg) }
html[data-seasonal-available="st-patricks"] .seasonal-toggle-icon { background-image: url(../themes/st-patricks/favicon.svg) }
html[data-seasonal-available="summer"] .seasonal-toggle-icon { background-image: url(../themes/summer/favicon.svg) }
html[data-seasonal-available="autumn"] .seasonal-toggle-icon { background-image: url(../themes/autumn/favicon.svg) }
html[data-seasonal-available="new-year"] .seasonal-toggle-icon { background-image: url(../themes/new-year/favicon.svg) }

/* "without animation": small pause sign */
html[data-seasonal-mode="static"] .seasonal-toggle::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 8px;
  height: 9px;
  border-radius: 1px;
  background: linear-gradient(90deg, currentColor 0 3px, transparent 3px 5px, currentColor 5px 8px);
  opacity: .85
}

/* "off": greyed out and struck through */
html[data-seasonal-mode="off"] .seasonal-toggle-icon {
  filter: grayscale(1);
  opacity: .45
}

html[data-seasonal-mode="off"] .seasonal-toggle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(-45deg);
  opacity: .75
}

/* ── Scene: fixed layer behind all page content ────────────────────────────
   z-index -1 in the root stacking context: above the page background, below
   the sidebar, top bar, tiles and panels - so it only shows in free space.
   Everything sits in the bottom-right corner (the sidebar covers the left,
   the dashboard toolbar the top). */
.seasonal-scene {
  display: none
}

html[data-seasonal-theme] .seasonal-scene {
  display: block;
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none
}

.seasonal-deco,
.seasonal-deco::before {
  position: absolute;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain
}

/* Rotated decorations: the element has the rotated footprint, ::before
   carries the artwork and is turned 90° clockwise around its centre. */
.seasonal-deco::before {
  left: 50%;
  top: 50%
}

/* Winter: frost corner (drawn for a top-right corner) turned into the
   bottom-right one. */
html[data-seasonal-theme="winter"] .seasonal-deco {
  right: 18px;
  bottom: 8px;
  width: 154px;
  height: 205px
}

html[data-seasonal-theme="winter"] .seasonal-deco::before {
  content: "";
  width: 205px;
  height: 154px;
  transform: translate(-50%, -50%) rotate(90deg);
  background-image: url(../themes/winter/frost-corner.svg)
}

/* Spring / St. Patrick's: branch / sprig grow out of the bottom-left of
   their artwork - mirrored so they grow out of the bottom-right corner. */
html[data-seasonal-theme="spring"] .seasonal-deco {
  right: 0;
  bottom: 0;
  width: 260px;
  height: 188px;
  transform: scaleX(-1);
  background-image: url(../themes/spring/blossom-branch.svg)
}

html[data-seasonal-theme="st-patricks"] .seasonal-deco {
  right: 4px;
  bottom: 0;
  width: 202px;
  height: 173px;
  transform: scaleX(-1);
  background-image: url(../themes/st-patricks/shamrock-sprig.svg)
}

/* Summer: warm sun glow in the corner (light), fireflies (dark). */
html[data-seasonal-theme="summer"] .seasonal-deco {
  right: 16px;
  bottom: 0;
  width: 200px;
  height: 300px
}

html[data-seasonal-theme="summer"] .seasonal-deco::before {
  content: "";
  width: 300px;
  height: 200px;
  transform: translate(-50%, -50%) rotate(90deg);
  background-image: url(../themes/summer/sun-glow-corner.svg)
}

html[data-seasonal-theme="summer"] body.dark-mode .seasonal-deco {
  right: 24px;
  bottom: 12px;
  width: 260px;
  height: 146px;
  background-image: url(../themes/summer/firefly-cluster.svg)
}

html[data-seasonal-theme="summer"] body.dark-mode .seasonal-deco::before {
  content: none
}

/* Autumn: leaves settled along the bottom edge. */
html[data-seasonal-theme="autumn"] .seasonal-deco {
  left: 0;
  right: 0;
  bottom: 0;
  height: 62px;
  background-image: url(../themes/autumn/settled-leaves-edge.svg);
  background-repeat: repeat-x;
  background-position: left bottom;
  background-size: auto 100%
}

/* ── Tiles and the login card ──────────────────────────────────────────────
   isolation makes z-index -1 paint above the tile's own background but
   below its text and values. The tile's ::before is its status stripe and
   is left alone; decorations use ::after. */
html[data-seasonal-theme] .tiles-grid > .tile,
html[data-seasonal-theme] .login-card {
  isolation: isolate
}

html[data-seasonal-theme] .login-card {
  position: relative
}

/* Winter: a snow cap on every tile and on the login card. */
html[data-seasonal-theme="winter"] .tiles-grid > .tile::after,
html[data-seasonal-theme="winter"] .login-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 22px;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  background: url(../themes/winter/tile-snow-edge.svg) repeat-x left top / auto 100%;
  z-index: -1;
  pointer-events: none
}

/* Autumn / spring / St. Patrick's: a small corner decoration on some
   tiles (every 5th, starting with the 2nd) and on the login card, in the
   bottom-right corner, which is the emptiest part of a tile. */
html[data-seasonal-theme="autumn"] .tiles-grid > .tile:nth-child(5n+2)::after,
html[data-seasonal-theme="autumn"] .login-card::after,
html[data-seasonal-theme="spring"] .tiles-grid > .tile:nth-child(5n+2)::after,
html[data-seasonal-theme="spring"] .login-card::after,
html[data-seasonal-theme="st-patricks"] .tiles-grid > .tile:nth-child(5n+2)::after,
html[data-seasonal-theme="st-patricks"] .login-card::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 84px;
  height: 72px;
  background: no-repeat right bottom / contain;
  z-index: -1;
  pointer-events: none
}

html[data-seasonal-theme="autumn"] .tiles-grid > .tile:nth-child(5n+2)::after,
html[data-seasonal-theme="autumn"] .login-card::after {
  background-image: url(../themes/autumn/tile-leaf-corner.svg)
}

html[data-seasonal-theme="spring"] .tiles-grid > .tile:nth-child(5n+2)::after,
html[data-seasonal-theme="spring"] .login-card::after {
  background-image: url(../themes/spring/tile-petal-corner.svg)
}

html[data-seasonal-theme="st-patricks"] .tiles-grid > .tile:nth-child(5n+2)::after,
html[data-seasonal-theme="st-patricks"] .login-card::after {
  background-image: url(../themes/st-patricks/tile-shamrock-corner.svg)
}

/* ── New Year: gold and shine ──────────────────────────────────────────────
   Fireworks are particles (seasonal-themes.js); everything here is gold
   detail: foil-gold sidebar title and active marker, a gold foil edge on
   tiles and the login card, sparkles in tile corners, a firework corner
   with a sparkle strip behind the content, and a light glint that sweeps
   across the logo every few seconds (only when animation is on). */
html[data-seasonal-theme="new-year"] .brand h1 {
  background: var(--seasonal-gold-foil);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent
}

/* Darker gold on the white login card so the title stays readable. */
html[data-seasonal-theme="new-year"] .login-brand h1 {
  background: linear-gradient(90deg, #7d5c17, #b8892c 35%, #8a6a1f 60%, #b8892c 85%, #7d5c17);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent
}

html[data-seasonal-theme="new-year"] body.dark-mode .login-brand h1 {
  background-image: var(--seasonal-gold-foil)
}

html[data-seasonal-theme="new-year"] .nav-item.active::before,
html[data-seasonal-theme="new-year"] .nav-subitem.active::before,
html[data-seasonal-theme="new-year"] .sidebar-button.active::before {
  background: linear-gradient(180deg, #f6e7b0, #c99b36 55%, #9c7425);
  box-shadow: 0 0 0 4px rgba(201, 155, 54, 0.22), 0 0 12px rgba(233, 207, 127, 0.45)
}

/* Gold foil edge on every tile, plus sparkles in the corner of every 5th
   tile and of the login card (same tiles as the other themes). */
html[data-seasonal-theme="new-year"] .tiles-grid > .tile::after,
html[data-seasonal-theme="new-year"] .login-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--seasonal-gold-foil) left top / 100% 3px no-repeat;
  z-index: -1;
  pointer-events: none
}

html[data-seasonal-theme="new-year"] .tiles-grid > .tile:nth-child(5n+2)::after,
html[data-seasonal-theme="new-year"] .login-card::after {
  background:
    url(../themes/new-year/tile-sparkle-corner.svg) right 10px bottom 8px / 84px 72px no-repeat,
    var(--seasonal-gold-foil) left top / 100% 3px no-repeat
}

/* Behind the content: firework corner bottom-right, sparkle strip along
   the bottom edge. */
html[data-seasonal-theme="new-year"] .seasonal-deco {
  left: 0;
  right: 0;
  bottom: 0;
  height: 170px;
  background-image: url(../themes/new-year/firework-corner.svg), url(../themes/new-year/gold-sparkle-edge.svg);
  background-repeat: no-repeat, repeat-x;
  background-position: right 22px bottom 14px, left bottom;
  background-size: 210px auto, auto 44px
}

/* Logo glint: a light band masked to the themed logo's shape, laid exactly
   over it (same box as .seasonal-logo). */
@keyframes seasonal-glint {
  0% { background-position: 130% 0 }
  22%, 100% { background-position: -30% 0 }
}

html[data-seasonal-theme="new-year"][data-seasonal-mode="on"] .brand-logo:has(> .seasonal-logo[src])::after {
  content: "";
  position: absolute;
  left: -1.3187%;
  top: -18.2927%;
  width: 102.6923%;
  height: 125.3049%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 0 38%, rgba(255, 255, 255, 0.9) 50%, transparent 62% 100%) no-repeat;
  background-size: 300% 100%;
  -webkit-mask: url(../themes/new-year/logo.svg) center / contain no-repeat;
  mask: url(../themes/new-year/logo.svg) center / contain no-repeat;
  animation: seasonal-glint 8s ease-in-out 1.5s infinite
}

/* ── Particle canvas (created by seasonal-themes.js) ───────────────────────
   Above page content, below dialogs/overlays (z-index 1000+), the kiosk exit
   button (200) and the preview banner. Never catches clicks. */
.seasonal-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60
}

/* ── Super-admin preview banner ────────────────────────────────────────── */
.seasonal-preview-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--divider);
  box-shadow: var(--tile-shadow);
  font-size: .9rem
}

.seasonal-preview-hint {
  color: var(--muted)
}

/* ── Platform admin: "Saisonale Designs" tab ───────────────────────────── */
.seasonal-admin-status {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap
}

.seasonal-admin-status-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto
}

.seasonal-admin-status-text strong {
  font-size: 1.05rem
}

.seasonal-admin-status-text p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .9rem
}

.seasonal-theme-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  white-space: nowrap
}

.seasonal-theme-cell img {
  width: 24px;
  height: 24px;
  flex: 0 0 auto
}

.seasonal-schedule-table input.seasonal-md-input {
  width: 92px
}

.seasonal-schedule-table input.seasonal-priority-input {
  width: 84px
}

.seasonal-schedule-table .seasonal-default-hint {
  display: block;
  margin-top: 4px;
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap
}

.seasonal-schedule-table tr.is-dirty {
  background: color-mix(in srgb, var(--warn) 9%, transparent)
}

.seasonal-schedule-table input.is-invalid {
  border-color: var(--crit)
}

.seasonal-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--text)
}

.seasonal-badge.is-preview {
  background: color-mix(in srgb, var(--belegt) 18%, transparent)
}

.seasonal-org-slug {
  margin-left: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  color: var(--muted)
}

.seasonal-override-form .form-group select,
.seasonal-override-form .form-group input {
  min-width: 0
}

/* ── Print / PDF: never themed ─────────────────────────────────────────── */
@media print {
  .seasonal-canvas,
  .seasonal-scene,
  .seasonal-preview-banner,
  .seasonal-toggle,
  .brand-logo > .seasonal-logo {
    display: none !important
  }

  .brand-logo > .brand-logo-default {
    visibility: visible !important
  }

  .brand-logo::after {
    content: none !important
  }

  html[data-seasonal-theme="new-year"] .brand h1,
  html[data-seasonal-theme="new-year"] .login-brand h1 {
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
    color: inherit !important
  }

  html[data-seasonal-theme] .tiles-grid > .tile::after,
  html[data-seasonal-theme] .login-card::after {
    content: none !important
  }

  html[data-seasonal-theme="st-patricks"] {
    --ibh-red: #e30613;
    --ibh-red-2: #b8000a
  }
}
