/* ============================================================
   Lernlandschaft – style.css
   Farben zentral als CSS-Variablen; Dark-Mode automatisch.
   ============================================================ */

:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.85);
  --text: #1b2233;
  --muted: #5c6678;
  --border: #e2e6ee;
  --accent: #2563eb;
  --radius: 16px;
  --shadow: 0 2px 8px rgba(20, 30, 60, 0.06);
  --shadow-hover: 0 16px 32px rgba(20, 30, 60, 0.16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #182033;
    --surface-glass: rgba(24, 32, 51, 0.85);
    --text: #e8ecf5;
    --muted: #98a3b8;
    --border: #273250;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 16px 32px rgba(0, 0, 0, 0.5);
  }
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-size: 1.1rem;
}

.search-wrap {
  position: relative;
  flex: 0 1 320px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.6;
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 0.55rem 0.9rem 0.55rem 2.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 1.25rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  transition: background 0.2s;
}

.breadcrumbs a:hover { background: rgba(37, 99, 235, 0.1); }

.breadcrumbs .sep { opacity: 0.5; }

.breadcrumbs [aria-current] {
  font-weight: 600;
  color: var(--text);
  padding: 0.15rem 0.4rem;
}

/* ---------- Seitenkopf ---------- */
.page-head { padding: 0.5rem 0 1.5rem; }

.page-head h1 {
  margin: 0.4rem 0 0.25rem;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: -0.01em;
}

.page-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 60ch;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.back-btn:hover {
  transform: translateX(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

/* ---------- Kachel-Raster ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.25rem;
  padding-bottom: 3rem;
}

/* ---------- Kachel (Card) ---------- */
.card {
  --card-accent: var(--accent);                 /* wird per JS gesetzt */
  --card-accent-soft: rgba(37, 99, 235, 0.13);  /* wird per JS gesetzt */

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.5rem 1.4rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  overflow: hidden;

  /* Einblend-Animation, gestaffelt über --i (siehe JS) */
  opacity: 0;
  transform: translateY(14px);
  animation: fadeUp 0.5s ease forwards;
  animation-delay: calc(var(--i, 0) * 60ms);

  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

/* Farbstreifen oben */
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: var(--card-accent);
}

.card:hover,
.card:focus-visible {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: var(--card-accent);
  outline: none;
}

.card:hover .arrow { transform: translateX(4px); }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--card-accent-soft);
  font-size: 1.7rem;
  line-height: 1;
}

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--card-accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card-title {
  margin: 0.2rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}

.card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
  flex: 1;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.tag {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--card-accent-soft);
  color: var(--card-accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.meta { flex: 1; }

.arrow {
  font-size: 1.2rem;
  color: var(--card-accent);
  transition: transform 0.25s ease;
}

/* ---------- Leer-/Fehlerzustand ---------- */
.empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.error-box {
  grid-column: 1 / -1;
  padding: 1.5rem;
  border-radius: var(--radius);
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.error-box h2 { margin-top: 0; color: #dc2626; }
.error-box code { background: rgba(0,0,0,0.08); padding: 0.1rem 0.35rem; border-radius: 4px; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Animation ---------- */
@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; opacity: 1; transform: none; }
  .card, .back-btn, .arrow { transition: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; }
  .search-wrap { flex: 1 1 100%; }
  .grid { grid-template-columns: 1fr; gap: 1rem; }
  .card { padding: 1.25rem 1.1rem 1rem; }
}

/* ============================================================
   Mobile-Feinschliff
   ============================================================ */

/* 1. iOS Safari zoomt automatisch in Eingabefelder mit Schrift < 16 px.
      Auf Touch-Geräten daher exakt 16 px verwenden. */
@media (max-width: 600px) {
  #search { font-size: 16px; }
}

/* 2. Hover-Effekte nur auf Geräten mit echter Maus.
      Auf Touchscreens "klebt" der Hover-Zustand sonst nach dem Antippen. */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: var(--shadow); }
  .back-btn:hover { transform: none; }
}

/* Stattdessen: kurzes Feedback beim Antippen */
.card:active { transform: scale(0.98); transition-duration: 0.1s; }

/* 3. Grauen/blauen Tap-Blitz auf Android/iOS entfernen */
a, button { -webkit-tap-highlight-color: transparent; }

/* 4. Mindestgröße für Fingerbedienung (Apple/Google empfehlen ≥ 44 px) */
.back-btn { min-height: 44px; }
.breadcrumbs a { padding: 0.45rem 0.5rem; }

/* 5. Abstand zu Notch / abgerundeten Displayecken (iPhone & Co.) */
.container {
  padding-left:  max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}
.site-footer { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }

/* 6. Sehr kleine Displays (< 360 px): etwas kompaktere Icons */
@media (max-width: 360px) {
  .card-icon { width: 46px; height: 46px; font-size: 1.4rem; }
  .page-head h1 { font-size: 1.45rem; }
}

/* ============================================================
   Impressum, Datenschutz und Rechtslinks
   ============================================================ */
.legal-links { display: inline-block; margin-left: 0.75rem; }
.legal-links a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.legal-links a:hover { color: var(--accent); }
.legal-links a[aria-current] { font-weight: 600; }
@media (max-width: 600px) { .legal-links { display: block; margin: 0.35rem 0 0; } }

.legal-doc { max-width: 780px; padding-bottom: 3rem; }
.legal-doc h1 { margin: 0.6rem 0 0.4rem; font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -0.01em; }
.legal-doc h2 { margin: 2rem 0 0.5rem; font-size: 1.15rem; }
.legal-doc p, .legal-doc li { color: var(--text); }
.legal-doc ul { padding-left: 1.25rem; margin: 0.5rem 0 1rem; }
.legal-doc li { margin: 0.25rem 0; }
.legal-doc a { color: var(--accent); overflow-wrap: anywhere; }
.legal-doc code { background: var(--border); padding: 0.05rem 0.35rem; border-radius: 4px; font-size: 0.9em; }
.legal-meta { color: var(--muted); font-size: 0.9rem; }
.legal-summary { margin-top: 1.25rem; padding: 0.4rem 1.25rem 0.6rem; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; }
.legal-summary h2 { margin-top: 0.8rem; }
