/* Tag-/Nacht-Modus – gemeinsame Palette für beide Module */

:root,
html[data-theme="dark"] {
  --bg: #0f1117;
  --bg2: #12151f;
  --card: #151828;
  --muted: #1e2236;
  --border: #2a2d40;
  --border-strong: #3a4055;
  --text: #e8eaf0;
  --text-dim: #6b7a94;
  --heading: #ffffff;
  --accent: #3a8fd4;
  --accent-text: #7ab3e8;
  --accent-soft: #1e3a5f;
  --ok-bg: #1e3a26;
  --ok-fg: #6bcb77;
  --danger: #e05a5a;
  --danger-bg: #2a1818;
  --overlay: rgba(0, 0, 0, 0.55);
  --input-bg: #0f1117;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  --hero-grad: linear-gradient(135deg, rgba(58, 143, 212, 0.16) 0%, rgba(21, 24, 40, 0.9) 45%, #12151f 100%);
  --body-grad:
    radial-gradient(900px 420px at 12% -10%, rgba(58, 143, 212, 0.18), transparent 60%),
    radial-gradient(700px 380px at 90% 0%, rgba(58, 143, 212, 0.08), transparent 55%),
    var(--bg);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #eef2f8;
  --bg2: #e2e8f2;
  --card: #ffffff;
  --muted: #d5deec;
  --border: #a8b6c9;
  --border-strong: #8fa0b8;
  --text: #152033;
  --text-dim: #3d4d66;
  --heading: #0b1220;
  --accent: #1a6fb5;
  --accent-text: #0f5a96;
  --accent-soft: #d6e8f8;
  --ok-bg: #d9f0df;
  --ok-fg: #1a7a38;
  --danger: #c62828;
  --danger-bg: #fde8e8;
  --overlay: rgba(15, 25, 40, 0.35);
  --input-bg: #ffffff;
  --shadow: 0 8px 24px rgba(20, 40, 70, 0.12);
  --hero-grad: linear-gradient(135deg, rgba(26, 111, 181, 0.14) 0%, #ffffff 48%, #e8eef8 100%);
  --body-grad:
    radial-gradient(900px 420px at 12% -10%, rgba(26, 111, 181, 0.12), transparent 60%),
    radial-gradient(700px 380px at 90% 0%, rgba(26, 111, 181, 0.06), transparent 55%),
    var(--bg);
  color-scheme: light;
}

html, body {
  background: var(--body-grad);
  background-color: var(--bg);
  color: var(--text);
}

/* Tabellen / Fokus – greifen auch ohne Inline-Styles */
th { color: var(--text-dim) !important; }
td, th { border-bottom-color: var(--border) !important; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Skip-Link: erst bei Fokus sichtbar */
.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 10000;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  transform: translateY(-120%);
  transition: transform .15s ease;
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

caption.sr-caption {
  caption-side: top;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--heading);
  padding: 0 0 8px;
}

/* ── Layout: volle Breite auf großen Bildschirmen, iPad-optimiert ─────────
   Seitenränder wachsen mit der Bildschirmbreite (16 px am Handy bis 48 px
   am großen Monitor). Container nutzen die volle Breite statt einer festen
   Maximalbreite – Inhalte verteilen sich über Raster (grid auto-fill). */
:root {
  --page-pad: clamp(16px, 2.4vw, 48px);
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Fester Tag-/Nacht-Knopf oben rechts darf Kopfzeilen nicht überdecken */
body:has(> .theme-fab) .topbar,
body:has(> .theme-fab) .wrap > .head { padding-right: 56px; }

/* Touch-Geräte (iPad): kein Doppeltipp-Zoom-Verzug, keine Auto-Vergrößerung
   beim Antippen von Eingabefeldern (iOS zoomt bei Schrift < 16 px),
   Bedienelemente mind. 44 px hoch (Apple-Empfehlung). */
@media (pointer: coarse) {
  a, button, input, select, textarea, label { touch-action: manipulation; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea { font-size: max(16px, 1em) !important; }
  button, select, .btn, [role="button"] { min-height: 44px; }
  button:hover, a:hover { transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   Design-Umschalter (theme.js) – in allen Designs sichtbar
   ══════════════════════════════════════════════════════════════════════════ */
.swk-brand-switch {
  position: fixed; left: 12px; bottom: 12px; z-index: 900;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 6px 12px 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-dim);
  font: 600 12px/1 "Segoe UI", system-ui, sans-serif; cursor: pointer;
  box-shadow: var(--shadow); opacity: .82; transition: opacity .15s, transform .15s;
}
.swk-brand-switch:hover, .swk-brand-switch:focus-visible { opacity: 1; transform: translateY(-1px); }
.swk-dots { display: inline-flex; gap: 3px; }
.swk-dots i { width: 7px; height: 7px; border-radius: 50%; display: block; }
@media (max-width: 700px) { .swk-brand-label { display: none; } .swk-brand-switch { padding: 6px 10px; } }
body.monitor-fs .swk-brand-switch, body.stream-fs .swk-brand-switch { display: none; }
@media print { .swk-brand-switch, .swk-confetti { display: none !important; } }

.swk-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99999; overflow: hidden; }
.swk-confetti i {
  position: absolute; top: -20px; border-radius: 50%; opacity: .95;
  animation-name: swk-fall; animation-timing-function: cubic-bezier(.25,.6,.4,1); animation-fill-mode: forwards;
}
@keyframes swk-fall {
  to { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: .9; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Design "Schul-Olympics": Farben aus dem Schul-Olympics-Logo,
   Logo/Favicon: Schulsport (Ordner brand/). Aktiv mit html[data-brand="olympics"].
   ══════════════════════════════════════════════════════════════════════════ */
html[data-brand="olympics"] {
  --oly-red: #e2001a; --oly-orange: #f39200; --oly-yellow: #ffcc00; --oly-magenta: #e6007e;
  --oly-green: #3aaa35; --oly-cyan: #009fe3; --oly-navy: #1d4f91; --oly-berry: #930850;
  --oly-rainbow: linear-gradient(90deg, #e2001a, #f39200, #ffcc00, #3aaa35, #009fe3, #1d4f91, #e6007e, #e2001a);
}
html[data-brand="olympics"][data-theme="light"] {
  --bg: #fbfafc; --bg2: #f4f1f6; --card: #ffffff; --muted: #f3eef5; --border: #ddd3e3; --border-strong: #c7b8d0;
  --text: #1b1520; --text-dim: #5b5066; --heading: #140d18;
  --accent: #e2001a; --accent-text: #b10015; --accent-soft: #ffe2e6;
  --ok-bg: #dff3dd; --ok-fg: #217a1d;
  --input-bg: #ffffff; --shadow: 0 10px 28px rgba(147, 8, 80, 0.10);
  --hero-grad: linear-gradient(120deg, rgba(226,0,26,.10), rgba(230,0,126,.08) 35%, rgba(255,204,0,.10) 70%, #ffffff);
  --body-grad:
    radial-gradient(14px 14px at 6% 18%, rgba(226,0,26,.22) 50%, transparent 52%),
    radial-gradient(10px 10px at 94% 12%, rgba(0,159,227,.25) 50%, transparent 52%),
    radial-gradient(12px 12px at 88% 78%, rgba(255,204,0,.35) 50%, transparent 52%),
    radial-gradient(9px 9px at 12% 86%, rgba(58,170,53,.28) 50%, transparent 52%),
    radial-gradient(900px 480px at 100% -10%, rgba(230,0,126,.10), transparent 60%),
    radial-gradient(800px 420px at -5% 0%, rgba(226,0,26,.09), transparent 60%),
    var(--bg);
}
html[data-brand="olympics"][data-theme="dark"] {
  --bg: #120c18; --bg2: #170f1f; --card: #1d1527; --muted: #281d34; --border: #3a2b49; --border-strong: #4d3a60;
  --text: #f4eef8; --text-dim: #ad9fbd; --heading: #ffffff;
  --accent: #ff2b45; --accent-text: #ff8b9a; --accent-soft: #3d1020;
  --input-bg: #140e1b; --shadow: 0 10px 30px rgba(0,0,0,.4);
  --hero-grad: linear-gradient(120deg, rgba(255,43,69,.18), rgba(230,0,126,.14) 40%, #1d1527);
  --body-grad:
    radial-gradient(900px 480px at 100% -10%, rgba(230,0,126,.20), transparent 60%),
    radial-gradient(800px 420px at -5% 0%, rgba(255,43,69,.16), transparent 60%),
    var(--bg);
}

/* Regenbogen-Leiste oben, sanft fließend */
html[data-brand="olympics"] body::before {
  content: ""; position: fixed; left: 0; right: 0; top: 0; height: 5px; z-index: 1000; pointer-events: none;
  background: var(--oly-rainbow); background-size: 200% 100%;
  animation: swk-rainbow 8s linear infinite;
}
@keyframes swk-rainbow { to { background-position: 200% 0; } }
@media print { html[data-brand="olympics"] body::before { display: none; } }

/* Logo tauschen: Schulsport statt Standard-Logo (Schullogos der Mandanten bleiben) */
html[data-brand="olympics"] img[src$="/logo.png"]:not(.tenant-logo) {
  content: url("brand/schulsport-logo.png");
  width: auto !important; height: 34px !important; max-width: 190px; object-fit: contain !important;
}
html[data-brand="olympics"] :is(div, span, a):not(.logo-circle):has(> img[src$="/logo.png"]:not(.tenant-logo)) {
  width: auto !important; height: auto !important; min-width: 0 !important;
  border-radius: 12px !important; background: #fff !important; padding: 4px 10px !important;
  box-shadow: 0 0 0 2px rgba(147,8,80,.18), 0 6px 16px rgba(147,8,80,.12) !important; overflow: visible !important;
}
html[data-brand="olympics"] .logo-circle {
  width: auto; height: auto; border-radius: 22px; padding: 16px 26px;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(226,0,26,.25), 0 18px 40px rgba(147,8,80,.18) !important;
}
html[data-brand="olympics"] .logo-circle img[src$="/logo.png"] { height: 96px !important; max-width: 320px; }

/* Überschriften und Akzente */
html[data-brand="olympics"] .wrap > h1 {
  background: linear-gradient(90deg, #e2001a, #e6007e 45%, #f39200 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 800;
}
html[data-brand="olympics"] .wrap > h1::after {
  content: ""; display: block; width: 133px; height: 10px; margin: 10px auto 0;
  background:
    radial-gradient(circle at 5px 5px, #e2001a 4px, transparent 4.5px) 0 0 / 19px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #f39200 4px, transparent 4.5px) 19px 0 / 19px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #ffcc00 4px, transparent 4.5px) 38px 0 / 19px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #e6007e 4px, transparent 4.5px) 57px 0 / 19px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #3aaa35 4px, transparent 4.5px) 76px 0 / 19px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #009fe3 4px, transparent 4.5px) 95px 0 / 19px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #1d4f91 4px, transparent 4.5px) 114px 0 / 19px 10px no-repeat;
}

/* Portal-Karten: jede Karte in einer eigenen Olympics-Farbe */
html[data-brand="olympics"] a.card { position: relative; overflow: hidden; }
html[data-brand="olympics"] a.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--card-c, #e2001a);
}
html[data-brand="olympics"] a.card:nth-child(7n+1) { --card-c: #e2001a; }
html[data-brand="olympics"] a.card:nth-child(7n+2) { --card-c: #009fe3; }
html[data-brand="olympics"] a.card:nth-child(7n+3) { --card-c: #f39200; }
html[data-brand="olympics"] a.card:nth-child(7n+4) { --card-c: #3aaa35; }
html[data-brand="olympics"] a.card:nth-child(7n+5) { --card-c: #e6007e; }
html[data-brand="olympics"] a.card:nth-child(7n+6) { --card-c: #1d4f91; }
html[data-brand="olympics"] a.card:nth-child(7n+7) { --card-c: #ffcc00; }
html[data-brand="olympics"] a.card:hover {
  border-color: var(--card-c); transform: translateY(-4px);
  box-shadow: 0 18px 40px color-mix(in srgb, var(--card-c) 30%, transparent);
}
html[data-brand="olympics"] a.card .go,
html[data-brand="olympics"] .btn-primary,
html[data-brand="olympics"] .invite-card button {
  background: linear-gradient(100deg, #e2001a, #e6007e) !important; border-color: transparent !important; color: #fff !important;
  box-shadow: 0 6px 18px rgba(226,0,26,.28);
}
html[data-brand="olympics"] a.card:hover .go { background: var(--card-c) !important; }

/* Design-Umschalter im Olympics-Design: bunt umrandet */
html[data-brand="olympics"] .swk-brand-switch {
  opacity: 1; color: var(--heading); border: 2px solid transparent;
  background: linear-gradient(var(--card), var(--card)) padding-box, var(--oly-rainbow) border-box;
}

@media (prefers-reduced-motion: reduce) {
  html[data-brand="olympics"] body::before { animation: none; }
}

/* Turn10-Kopfzeile im Design Schul-Olympics: Schulsport-Logo im weißen Rahmen, darunter „Turn10“ */
html[data-brand="olympics"] .topbar h1 img[src$="logo-turn10.png"] {
  content: url("brand/schulsport-logo.png");
  height: 34px !important; width: auto !important; padding: 5px 12px; margin-right: 12px !important;
  background: #fff; border-radius: 12px;
  box-shadow: 0 0 0 2px rgba(147,8,80,.18), 0 6px 16px rgba(147,8,80,.12);
}
html[data-brand="olympics"] .topbar h1:has(img[src$="logo-turn10.png"])::after {
  content: "Turn10"; margin-left: 10px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff;
  background: linear-gradient(100deg, #e2001a, #e6007e); vertical-align: middle;
}
