/* Gemeinsame Grundlage aller Seiten (React-Startseite UND Flask-Templates):
   Schriften, Farbwerte, Hintergrundkulisse, Glasrezept, Knoepfe.
   Kopf- und Fusszeile: glas-rahmen.css. EINE Quelle — nicht in Seiten kopieren. */

@font-face { font-family: 'Playfair Display'; src: url('/static/fonts/PlayfairDisplay.woff2') format('woff2'); font-weight: 400 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Playfair Display'; src: url('/static/fonts/PlayfairDisplay-Italic.woff2') format('woff2'); font-weight: 400 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'Manrope'; src: url('/static/fonts/Manrope-Variable.woff2') format('woff2'); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/static/fonts/JetBrainsMono-Variable.woff2') format('woff2'); font-weight: 400 800; font-style: normal; font-display: swap; }

:root {
  /* Blau */
  --bg-primary: #050e17;
  --dark-blue: #01325e;
  --primary-blue: #0a4b94;
  --secondary-blue: #1976d2;
  --accent-blue: #64b5f6;
  --hellblau: #a8d4ff;
  --cyan: #00d4ff;

  /* Text auf Glas */
  --text-primary: #ffffff;
  --text-secondary: rgba(235, 244, 255, 0.84);
  --text-muted: rgba(228, 239, 252, 0.8);

  /* Glas: weiss getoent, stark verwischt, Lichtkante oben links */
  --glas-flaeche: linear-gradient(140deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.06) 42%, rgba(255, 255, 255, 0.035) 100%);
  --glas-flaeche-hover: linear-gradient(140deg, rgba(255, 255, 255, 0.19) 0%, rgba(255, 255, 255, 0.09) 42%, rgba(255, 255, 255, 0.05) 100%);
  --glas-blur: 22px;
  --glas-rand: rgba(255, 255, 255, 0.1);
  --glas-kante: linear-gradient(150deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.1) 30%, rgba(255, 255, 255, 0) 58%, rgba(168, 212, 255, 0.28) 100%);
  --glas-schatten: 0 1px 1px rgba(0, 6, 20, 0.25), 0 28px 56px -28px rgba(0, 6, 20, 0.85);
  --glas-radius: 24px;
  --linie: rgba(255, 255, 255, 0.1);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease-glas: cubic-bezier(0.32, 0.72, 0, 1);
}

html { background-color: var(--bg-primary); color-scheme: dark; }

/* Kulisse: Bibliothek in Blau, darueber ein Schleier fuer Lesbarkeit.
   Fest am Viewport (kein background-attachment:fixed — bricht auf iOS). */
html::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(70% 60% at 22% 48%, rgba(5, 14, 23, 0.5) 0%, rgba(5, 14, 23, 0) 72%),
    linear-gradient(90deg, rgba(5, 14, 23, 0) 62%, rgba(5, 14, 23, 0.55) 100%),
    linear-gradient(180deg, rgba(5, 14, 23, 0.5) 0%, rgba(5, 14, 23, 0.64) 48%, rgba(5, 14, 23, 0.86) 100%),
    url('/static/img/bibliothek-blau-2400.webp') 22% center / cover no-repeat,
    var(--bg-primary);
}

/* Licht: zwei weiche Quellen, die langsam wandern — geben dem Glas Farbe zum Verwischen */
body::before {
  content: '';
  position: fixed;
  inset: -15%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38% 32% at 22% 28%, rgba(25, 118, 210, 0.42) 0%, rgba(25, 118, 210, 0) 70%),
    radial-gradient(32% 30% at 80% 72%, rgba(100, 181, 246, 0.2) 0%, rgba(100, 181, 246, 0) 70%),
    radial-gradient(26% 22% at 62% 12%, rgba(0, 212, 255, 0.1) 0%, rgba(0, 212, 255, 0) 70%);
  animation: kulisse-licht 38s ease-in-out infinite alternate;
}

/* Feines Korn gegen Streifen in den Verlaeufen */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='k'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23k)'/%3E%3C/svg%3E");
}

@keyframes kulisse-licht {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(3%, 2%, 0) scale(1.06); }
}

/* Eigene Hintergruende der Seiten (auch !important aus styles.min.css) wuerden die Kulisse verdecken */
body {
  background: transparent !important;
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: rgba(100, 181, 246, 0.35); color: #fff; }
:focus-visible { outline: 2px solid var(--hellblau); outline-offset: 3px; }

/* ---------- Glas ----------
   Die Scheibe (Unschaerfe + Toenung) liegt auf ::before, die Lichtkante auf
   ::after — NICHT auf dem Element. Ein Element mit eigenem backdrop-filter wird
   zum Backdrop-Root: Knoepfe, Menueblatt oder Karten darin verwischen dann
   nicht mehr die Seite, sondern nur noch die Scheibe (verschachteltes Glas).
   Eigene Toenung einer Flaeche: --glas-scheibe setzen, nicht background. */
@property --hebung { syntax: '<number>'; inherits: true; initial-value: 0; }

.glas {
  position: relative;
  isolation: isolate;
  border: 1px solid transparent;
  border-radius: var(--glas-radius);
  box-shadow: var(--glas-schatten);
}
.glas::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -2;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(320px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, calc(0.1 * var(--hebung))), transparent 62%),
    var(--glas-scheibe, linear-gradient(140deg,
      rgba(255, 255, 255, calc(0.14 + 0.05 * var(--hebung))) 0%,
      rgba(255, 255, 255, calc(0.06 + 0.03 * var(--hebung))) 42%,
      rgba(255, 255, 255, calc(0.035 + 0.015 * var(--hebung))) 100%));
  -webkit-backdrop-filter: blur(var(--glas-blur)) saturate(165%);
  backdrop-filter: blur(var(--glas-blur)) saturate(165%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
/* Lichtkante: Verlaufsrand, die Maske laesst nur den 1-px-Rand stehen */
.glas::after {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: var(--glas-kante), linear-gradient(var(--glas-rand), var(--glas-rand));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

/* Schale: Fassung um eine Glasplatte (Doppelrand) — selbst ebenfalls Glas */
.glas-schale {
  position: relative;
  isolation: isolate;
  padding: 6px;
  border-radius: calc(var(--glas-radius) + 6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.glas-schale::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.04);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
}

/* Einblenden von Glas — und von allem, was Glas enthaelt — NUR ueber Bewegung.
   opacity < 1 macht ein Element zum Backdrop-Root: waehrend des Einblendens
   waere das Glas darin unverwischt und spraenge am Ende sichtbar um. */
@keyframes glas-auf { from { transform: translateY(18px); } }

/* Bedienbares Glas: hebt sich, Licht folgt dem Zeiger (--mx/--my per Skript) */
.glas-interaktiv {
  transition: transform 0.6s var(--ease-glas), box-shadow 0.6s var(--ease-glas), --hebung 0.4s ease;
}
.glas-interaktiv:hover,
a:focus-visible > .glas-interaktiv,
a.glas-interaktiv:focus-visible {
  --hebung: 1;
  transform: translateY(-3px);
  box-shadow: 0 1px 1px rgba(0, 6, 20, 0.25), 0 36px 64px -28px rgba(0, 6, 20, 0.9);
}

/* ---------- Knoepfe (Pille, Pfeil im eigenen Kreis) ---------- */
.knopf {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.35rem 0.4rem 0.35rem 1.35rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: background 0.3s ease, transform 0.4s var(--ease-glas), border-color 0.3s ease, color 0.3s ease;
}
.knopf:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.knopf:active { transform: scale(0.98); }
.knopf-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: transform 0.4s var(--ease-glas);
}
.knopf:hover .knopf-icon { transform: translate(2px, -1px) scale(1.05); }
.knopf-primaer { background: rgba(236, 245, 255, 0.84); color: #04203d; border-color: rgba(255, 255, 255, 0.5); }
.knopf-primaer:hover { background: rgba(244, 249, 255, 0.88); color: #04203d; }
.knopf-primaer .knopf-icon { background: rgba(4, 32, 61, 0.86); color: #eef6ff; }
.knopf:disabled { opacity: 0.6; cursor: progress; transform: none; }

@media (max-width: 720px) {
  :root { --glas-blur: 18px; --glas-radius: 20px; }
  html::before {
    background:
      linear-gradient(180deg, rgba(5, 14, 23, 0.62) 0%, rgba(5, 14, 23, 0.74) 48%, rgba(5, 14, 23, 0.88) 100%),
      url('/static/img/bibliothek-blau-1280.webp') 28% center / cover no-repeat,
      var(--bg-primary);
  }
}

/* Ohne backdrop-filter: deckender, damit Text lesbar bleibt */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glas::before, .glas-schale::before { background: rgba(12, 36, 66, 0.94); }
}

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