/*
  SV Vorschlagsbox – ein System für beide Seiten (Einreichung und Moderation).

  Grundlage: Notion DESIGN.md aus voltagent/awesome-design-md – warme Neutraltöne, 1px-Haarlinien,
  8px-Controls, 12px-Karten, pastellfarbene "Property"-Tags für Kategorien. Notions violetter
  Primärton ist nach der Taste-Skill-Regel ("never violet") auf Notions eigenes Link-Blau gedreht.
  Schrift: Funnel Display / Funnel Sans (vom Taste-Skill für "software" gedealt).
  Bewegung: der Micro-Interaction-Layer des Taste-Skills (assets/motion), plus kleine,
  ReactBits-inspirierte Teile in app.js (CountUp, AnimatedList, ClickSpark).
*/

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f6f5f4;
  --card: #ffffff;
  --line: #e5e3df;
  --line-strong: #c8c4be;
  --ink: #1f1e1b;
  --ink-2: #37352f;
  --muted: #66635c;
  --soft: #8f8c85;
  --dot: #d9d6cf;
  --action: #0075de;
  --action-press: #005bab;
  --action-ink: #ffffff;
  --action-soft: #e8f2fc;
  --danger: #c3261f;
  --danger-ink: #ffffff;
  --danger-soft: #fdeceb;
  --pop: 0 1px 2px rgb(15 15 15 / .06), 0 16px 40px -16px rgb(15 15 15 / .22);

  /* status */
  --st-new-bg: #e8f2fc;  --st-new-fg: #0b5cad;  --st-new: #0075de;
  --st-wip-bg: #fdeddf;  --st-wip-fg: #943f00;  --st-wip: #dd5b00;
  --st-done-bg: #dff3e5; --st-done-fg: #176b37; --st-done: #1aae39;

  /* kategorien (Notion property tints) */
  --k-allgemein-bg: #f0eeec; --k-allgemein-fg: #4a4843;
  --k-unterricht-bg: #dcecfa; --k-unterricht-fg: #0b4f8a;
  --k-gelaende-bg: #d9f3e1;   --k-gelaende-fg: #1b6633;
  --k-events-bg: #ffe8d4;     --k-events-fg: #8a3a00;
  --k-pause-bg: #fdf3c8;      --k-pause-fg: #6b5100;
  --k-sonstiges-bg: #fde0ec;  --k-sonstiges-fg: #8f2a62;

  --font-display: "Funnel Display", "Funnel Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-text: "Funnel Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* rhythmus */
  --nav: 64px;
  --gut: 80px;
  --wrap: 1200px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;

  /* typo */
  --t-label: 13px;
  --t-small: 14px;
  --t-body: 16px;
  --t-lead: 18px;
  --t-card: 18px;
  --t-h3: 20px;
  --t-h2: clamp(28px, 1.53vw + 22px, 44px);
  --t-h1: clamp(38px, 3.24vw + 25.4px, 72px);
  --t-stat: clamp(28px, .95vw + 24.3px, 38px);

  /* radien (Notion: Controls 8, Karten 12, große Flächen 16) */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-btn: 8px; --r-full: 999px;
  --btn-h: 44px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-enter: cubic-bezier(.22, 1, .36, 1);
}

/* Abend-Variante: folgt dem System, außer man hat selbst umgeschaltet */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161615; --surface: #1d1d1c; --card: #1f1f1e;
    --line: #2f2e2c; --line-strong: #4a4844;
    --ink: #f0efec; --ink-2: #dedcd7; --muted: #a8a59e; --soft: #7d7a74; --dot: #2c2b29;
    --action: #4aa3f5; --action-press: #77b9f7; --action-ink: #0a1726; --action-soft: #12263a;
    --danger: #f06a62; --danger-ink: #230705; --danger-soft: #3a1714;
    --pop: 0 1px 2px rgb(0 0 0 / .4), 0 18px 44px -16px rgb(0 0 0 / .7);
    --st-new-bg: #13283d;  --st-new-fg: #93c8f6;  --st-new: #4aa3f5;
    --st-wip-bg: #382313;  --st-wip-fg: #f4b37f;  --st-wip: #f08a3c;
    --st-done-bg: #15301f; --st-done-fg: #8cd6a4; --st-done: #3cc463;
    --k-allgemein-bg: #2a2927; --k-allgemein-fg: #d6d3cd;
    --k-unterricht-bg: #14283b; --k-unterricht-fg: #93c8f6;
    --k-gelaende-bg: #15301f;   --k-gelaende-fg: #8cd6a4;
    --k-events-bg: #382313;     --k-events-fg: #f4b37f;
    --k-pause-bg: #332a10;      --k-pause-fg: #ecd27a;
    --k-sonstiges-bg: #3a1a2b;  --k-sonstiges-fg: #f2a5ca;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161615; --surface: #1d1d1c; --card: #1f1f1e;
  --line: #2f2e2c; --line-strong: #4a4844;
  --ink: #f0efec; --ink-2: #dedcd7; --muted: #a8a59e; --soft: #7d7a74; --dot: #2c2b29;
  --action: #4aa3f5; --action-press: #77b9f7; --action-ink: #0a1726; --action-soft: #12263a;
  --danger: #f06a62; --danger-ink: #230705; --danger-soft: #3a1714;
  --pop: 0 1px 2px rgb(0 0 0 / .4), 0 18px 44px -16px rgb(0 0 0 / .7);
  --st-new-bg: #13283d;  --st-new-fg: #93c8f6;  --st-new: #4aa3f5;
  --st-wip-bg: #382313;  --st-wip-fg: #f4b37f;  --st-wip: #f08a3c;
  --st-done-bg: #15301f; --st-done-fg: #8cd6a4; --st-done: #3cc463;
  --k-allgemein-bg: #2a2927; --k-allgemein-fg: #d6d3cd;
  --k-unterricht-bg: #14283b; --k-unterricht-fg: #93c8f6;
  --k-gelaende-bg: #15301f;   --k-gelaende-fg: #8cd6a4;
  --k-events-bg: #382313;     --k-events-fg: #f4b37f;
  --k-pause-bg: #332a10;      --k-pause-fg: #ecd27a;
  --k-sonstiges-bg: #3a1a2b;  --k-sonstiges-fg: #f2a5ca;
}

@media (max-width: 1023px) { :root { --gut: 48px; --t-lead: 18px; } }
@media (min-width: 1024px) { :root { --t-lead: 20px; --t-card: 18px; --t-h3: 22px; } }
@media (max-width: 639px)  { :root { --nav: 56px; --gut: 16px; } }

/* ------------------------------------------------------------------ basis */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--nav) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--t-body);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.025em; color: var(--ink); margin: 0; text-wrap: balance; hyphens: auto; }
p { margin: 0; text-wrap: pretty; }
img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
::selection { background: color-mix(in oklab, var(--action) 24%, transparent); }

.wrap { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gut)); margin-inline: auto; padding-inline: var(--gut); }
.muted { color: var(--muted); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }
kbd {
  font-family: var(--font-mono); font-size: 12px; line-height: 1; color: var(--muted);
  padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface);
}

.skip-link {
  position: absolute; left: var(--gut); top: 8px; z-index: 60;
  padding: 10px 16px; border-radius: var(--r-btn); background: var(--ink); color: var(--bg);
  font-weight: 500; text-decoration: none; transform: translateY(-160%);
}
.skip-link:focus-visible { transform: none; }

/* ------------------------------------------------------------------ kopfzeile */
.nav {
  position: fixed; inset: 0 0 auto; z-index: 30; height: var(--nav);
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.nav .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.nav__end { display: flex; align-items: center; gap: var(--s-3); }
body { padding-top: var(--nav); }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 44px; }
.brand__mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--ink); color: var(--bg);
  font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: 0;
}
.brand__name { font-family: var(--font-display); font-size: 19px; font-weight: 500; letter-spacing: -0.02em; white-space: nowrap; }
.brand__tag {
  font-size: var(--t-label); font-weight: 500; line-height: 1; padding: 6px 8px; border-radius: 6px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
}
/* Das Schullogo ist eine helle Wortmarke (für den alten dunklen Hintergrund): hier in Tinte eingefärbt */
.school-logo { height: 36px; width: auto; max-width: 132px; object-fit: contain; filter: brightness(0); opacity: .88; }
:root[data-theme="dark"] .school-logo { filter: brightness(0) invert(1); opacity: .9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .school-logo { filter: brightness(0) invert(1); opacity: .9; } }
@media (max-width: 639px) {
  .nav__end { gap: 8px; }
  .brand { gap: 8px; }
  .brand__name { font-size: 17px; }
  .school-logo { height: 28px; max-width: 88px; }
  .nav .btn--header { display: none; }
}
@media (max-width: 400px) { .brand__tag { display: none; } }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--btn-h); padding: 0 20px; border-radius: var(--r-btn);
  font-size: var(--t-body); font-weight: 500; line-height: 1; letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap; border: 1px solid transparent; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn--primary { background: var(--action); color: var(--action-ink); border-color: var(--action); }
.btn--secondary { background: var(--bg); color: var(--ink); border-color: var(--line-strong); }
.btn--danger { background: var(--danger); color: var(--danger-ink); border-color: var(--danger); }
html:not([data-motion="off"]) .btn--danger:hover { background: color-mix(in oklab, var(--danger) 86%, var(--bg)); }
.btn--sm { min-height: 40px; padding: 0 16px; font-size: var(--t-small); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.btn .ico { width: 18px; height: 18px; flex: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: var(--r-btn); border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), transform 90ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn svg { width: 20px; height: 20px; }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: var(--surface); border-color: var(--line-strong); transition-duration: 150ms; }
}
.icon-btn:active { transform: scale(.94); }
.icon-btn--danger { color: var(--danger); }
@media (hover: hover) and (pointer: fine) { .icon-btn--danger:hover { background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 40%, transparent); } }

/* Theme-Schalter: Sonne/Mond tauschen */
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}

.link { color: var(--action); text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--action) 35%, transparent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link:hover { text-decoration-color: currentColor; }

/* ------------------------------------------------------------------ pills, tags, badges */
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 12px 4px 6px;
  border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface);
  font-size: var(--t-label); font-weight: 500; color: var(--ink-2);
}
.pill__dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--line); }
.pill__dot svg { width: 12px; height: 12px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 6px;
  font-size: var(--t-label); font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--k-allgemein-bg); color: var(--k-allgemein-fg);
}
.tag svg { width: 14px; height: 14px; }
.tag[data-k="unterricht"] { background: var(--k-unterricht-bg); color: var(--k-unterricht-fg); }
.tag[data-k="gelaende"]   { background: var(--k-gelaende-bg);   color: var(--k-gelaende-fg); }
.tag[data-k="events"]     { background: var(--k-events-bg);     color: var(--k-events-fg); }
.tag[data-k="pause"]      { background: var(--k-pause-bg);      color: var(--k-pause-fg); }
.tag[data-k="sonstiges"]  { background: var(--k-sonstiges-bg);  color: var(--k-sonstiges-fg); }

.badge {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; border-radius: var(--r-full);
  font-size: var(--t-label); font-weight: 500; line-height: 1; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge--new  { background: var(--st-new-bg);  color: var(--st-new-fg); }
.badge--wip  { background: var(--st-wip-bg);  color: var(--st-wip-fg); }
.badge--done { background: var(--st-done-bg); color: var(--st-done-fg); }

/* ------------------------------------------------------------------ karten */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  --c-r: var(--r-md);
}
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--pop); }

/* ------------------------------------------------------------------ sektionen */
.section { padding-block: var(--s-9) var(--s-9); }
.section--alt { background: var(--surface); border-block: 1px solid var(--line); }
.section__head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s-5); margin-bottom: var(--s-7); }
.section__head h2 { font-size: var(--t-h2); line-height: 1.12; max-width: 22ch; }
.section__head h2 .muted { color: var(--muted); }
@media (max-width: 639px) {
  .section { padding-block: var(--s-8); }
  .section__head { margin-bottom: var(--s-6); }
}

/* ------------------------------------------------------------------ formular-teile */
.field { display: grid; gap: var(--s-2); }
.field__label { font-size: var(--t-small); font-weight: 500; color: var(--ink-2); }
.field__hint { font-size: var(--t-small); color: var(--muted); }
.field__error { font-size: var(--t-small); color: var(--danger); font-weight: 500; display: flex; gap: 6px; align-items: flex-start; }
.field__error:empty { display: none; }
.field__error svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.input, .field textarea, .field input, .field select {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.55; outline: none; -webkit-appearance: none; appearance: none;
}
.field textarea { resize: vertical; min-height: 168px; }
.field :is(input, textarea)::placeholder, .input::placeholder { color: var(--soft); }
.field [aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 1px var(--danger), 0 0 0 4px color-mix(in oklab, var(--danger) 18%, transparent) !important; }

/* ------------------------------------------------------------------ tabs (Filter) */
.tabs {
  display: inline-flex; gap: 2px; padding: 4px; border-radius: calc(var(--r-btn) + 4px);
  background: var(--surface); border: 1px solid var(--line); max-width: 100%;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border: 0; border-radius: var(--r-btn); background: transparent; color: var(--muted);
  font-size: var(--t-small); font-weight: 500; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.tabs.m-has-ind .tab[aria-selected="true"] { color: var(--bg); }
.tab__n { font-variant-numeric: tabular-nums; font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; background: color-mix(in oklab, currentColor 14%, transparent); }
.m-tab-ind { box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

/* ------------------------------------------------------------------ toast */
.toasts {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 80;
  transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 8px 8px 16px;
  border-radius: var(--r-md); background: var(--ink); color: var(--bg); box-shadow: var(--pop);
  font-size: var(--t-small); font-weight: 500; line-height: 1.4;
  animation: toast-in 260ms var(--ease-enter) both;
}
.toast.is-out { animation: toast-out 160ms var(--ease) both; }
.toast__ico { width: 20px; height: 20px; flex: none; }
.toast__msg { flex: 1; padding-block: 6px; }
.toast--error .toast__ico { color: #ff8a80; }
.toast--ok .toast__ico { color: #7ddc98; }
.toast__action {
  min-height: 36px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid color-mix(in oklab, var(--bg) 30%, transparent);
  background: transparent; color: var(--bg); font-size: var(--t-small); font-weight: 500;
}
.toast__action:hover { background: color-mix(in oklab, var(--bg) 12%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ dialog */
dialog.modal {
  width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--card); color: var(--ink); box-shadow: var(--pop);
}
dialog.modal::backdrop { background: rgb(15 15 15 / .45); }
dialog.modal[open] { animation: modal-in 220ms var(--ease-enter) both; }
dialog.modal[open]::backdrop { animation: fade-in 200ms var(--ease) both; }
.modal__body { padding: var(--s-6) var(--s-6) var(--s-5); display: grid; gap: var(--s-4); }
.modal__icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); }
.modal__icon svg { width: 22px; height: 22px; }
.modal h2 { font-size: 22px; line-height: 1.25; }
.modal p { color: var(--muted); }
.modal__quote {
  margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); font-size: var(--t-small); line-height: 1.55; max-height: 9.5em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.modal__actions { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6) var(--s-6); }
@media (max-width: 639px) {
  .modal__actions { flex-direction: column-reverse; }
  .modal__actions .btn { width: 100%; }
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }

/* ------------------------------------------------------------------ ClickSpark (ReactBits-Idee) */
.spark { position: fixed; pointer-events: none; z-index: 90; }

/* ------------------------------------------------------------------ skeleton */
.skeleton { border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card); padding: 20px; display: grid; gap: 12px; }
.skeleton i { display: block; height: 12px; border-radius: 6px; background: var(--surface); }
.skeleton i:nth-child(1) { width: 32%; height: 22px; }
.skeleton i:nth-child(2) { width: 92%; }
.skeleton i:nth-child(3) { width: 70%; }

/* ------------------------------------------------------------------ fußzeile */
.footer { border-top: 1px solid var(--line); padding-block: var(--s-6) calc(var(--s-6) + env(safe-area-inset-bottom)); color: var(--muted); font-size: var(--t-small); }
.footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-5); }
.footer__brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-2); font-weight: 500; }
.footer__brand .brand__mark { width: 24px; height: 24px; font-size: 11px; border-radius: 6px; }

/* ------------------------------------------------------------------ reduzierte bewegung */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .icon-btn:active { transform: none; }
}
