/* ==========================================================================
   bitschule — Startseite (Variante A „Bit-Grid")
   Frische, positive Farbwelt · helles Theme mit optionalem Dunkelmodus
   ========================================================================== */

:root {
  /* Farben */
  --bg:        #f4f7ff;
  --surface:   #ffffff;
  --ink:       #1b2144;
  --muted:     #5a6183;
  --line:      #e8ecfa;
  --accent:    #3d6fff;
  --accent-2:  #12b3a6;
  --accent-3:  #ff6b6b;
  --footer-bg: #161b3a;
  --footer-fg: #aab2d6;

  /* Typografie */
  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Maße */
  --shell-max: 1120px;
  --radius:    14px;
  --radius-sm: 9px;
  --header-h:  66px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0c0f1c;
    --surface:   #141a2e;
    --ink:       #eef1fb;
    --muted:     #9aa2c4;
    --line:      #242b45;
    --accent:    #7f9bff;
    --accent-2:  #35d0c2;
    --accent-3:  #ff8a8a;
    --footer-bg: #090b16;
    --footer-fg: #9aa2c4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:        #0c0f1c;
  --surface:   #141a2e;
  --ink:       #eef1fb;
  --muted:     #9aa2c4;
  --line:      #242b45;
  --accent:    #7f9bff;
  --accent-2:  #35d0c2;
  --accent-3:  #ff8a8a;
  --footer-bg: #090b16;
  --footer-fg: #9aa2c4;
  color-scheme: dark;
}

/* ---------- Reset / Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; background: var(--bg); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ganzseitiger 0/1-Hintergrund. Inhalt wird per JavaScript zufällig erzeugt
   (siehe assets/js/main.js) und bei Größenänderung neu aufgebaut. Liegt hinter
   dem Inhalt und scheint nur durch transparente Bereiche durch. */
#bit-rain {
  position: fixed; inset: 0; z-index: -1;
  overflow: hidden; pointer-events: none; user-select: none;
  padding: 8px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.5;
  color: var(--accent); opacity: .06;
  white-space: pre-wrap; word-break: break-all;
}
img { max-width: 100%; height: auto; }
a { color: inherit; }

:where(a, button, .tile):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  background: var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 0 0 10px 10px;
  z-index: 100; transition: top .15s;
}
.skip-link:focus { top: 0; }

/* ---------- Layout-Hülle ---------- */
.shell {
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-left:  max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

/* Startseite nutzt die volle Bildschirmbreite.
   Spätere Unterseiten ohne .page-home behalten die zentrierte .shell-Begrenzung. */
.page-home .shell {
  max-width: none;
  padding-left:  max(28px, env(safe-area-inset-left, 0px));
  padding-right: max(28px, env(safe-area-inset-right, 0px));
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-size: .9rem; font-weight: 500;
  padding: 10px 18px; border-radius: var(--radius-sm);
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -10px var(--accent); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Logo ---------- */
.logo {
  display: inline-flex; align-items: center; gap: 1px;
  font-family: var(--font-head); font-weight: 600; font-size: 1.3rem;
  letter-spacing: -.02em; text-decoration: none; color: var(--ink);
}
.logo__bit {
  font-family: var(--font-mono); color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  padding: 1px 8px; border-radius: 8px; margin-right: 4px;
}
.logo__cursor {
  width: 9px; height: 1.05em; margin-left: 4px; border-radius: 1px;
  background: var(--accent); display: inline-block;
  animation: blink 1.1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .logo__cursor { animation: none; } }

/* ---------- Kopf / Navigation ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: var(--header-h);
}
/* Tagline rechts in der oberen Leiste (ersetzt die frühere Navigation). */
.site-header__tagline {
  margin: 0;
  font-family: var(--font-mono); font-size: .82rem; letter-spacing: .02em;
  color: var(--accent-2);
}
@media (max-width: 460px) {
  .site-header__tagline { font-size: .72rem; }
}

/* ---------- Themen-Sektion ---------- */
.topics { padding-block: 40px 60px; }
.section-head {
  display: flex; align-items: baseline; justify-content: flex-end;
  gap: 12px; margin-bottom: 16px;
}
.section-head h2 {
  font-family: var(--font-head); font-size: 1.35rem; font-weight: 600; margin: 0;
  letter-spacing: -.01em;
}
.section-head__link { font-family: var(--font-mono); font-size: .85rem; color: var(--accent); text-decoration: none; }
.section-head__link:hover { text-decoration: underline; }

/* Auto-fill: füllt die verfügbare Breite mit so vielen Spalten wie passen.
   Auf breiten Schirmen entstehen mehr Kacheln pro Reihe statt weniger, sehr breiter. */
.tile-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
}

/* ---------- Kachel ---------- */
.tile {
  --tc: var(--accent);
  position: relative; display: block; min-width: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  text-decoration: none; color: var(--ink);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.tile:hover, .tile:focus-visible {
  transform: translateY(-3px);
  border-color: var(--tc);
  box-shadow: 0 16px 36px -20px color-mix(in srgb, var(--tc) 65%, transparent);
}
.tile__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tile__icon {
  display: grid; place-items: center; width: 46px; height: 46px;
  border-radius: 12px; flex: none;
  background: color-mix(in srgb, var(--tc) 14%, var(--surface));
  color: var(--tc);
}
.tile__icon svg { width: 23px; height: 23px; }
.tile__title { font-family: var(--font-head); font-size: 1.05rem; font-weight: 600; margin: 0 0 5px; }
.tile__desc { font-size: .88rem; color: var(--muted); margin: 0 0 16px; }
.tile__level {
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--tc); background: color-mix(in srgb, var(--tc) 12%, var(--surface));
  padding: 3px 9px; border-radius: 6px;
}
.tile__arrow {
  position: absolute; top: 20px; right: 20px;
  color: var(--tc); opacity: 0; transform: translateX(-4px);
  transition: opacity .16s, transform .16s; font-size: 1.1rem; line-height: 1;
}
.tile:hover .tile__arrow, .tile:focus-visible .tile__arrow { opacity: 1; transform: translateX(0); }

/* Laufende Nummer neben dem Icon — in der Icon-Farbe der jeweiligen Kachel. */
.tile__num {
  font-family: var(--font-mono); font-size: 1.2rem; font-weight: 600;
  color: var(--tc); font-variant-numeric: tabular-nums; line-height: 1;
}

.tile-empty {
  padding: 28px; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); text-align: center;
}
.tile-empty code { font-family: var(--font-mono); color: var(--accent); }

/* ---------- Kachel-Unterseite (/thema/…) ---------- */
.topic-page { --tc: var(--accent); padding-block: 28px 60px; }

.crumbs {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: .8rem; color: var(--muted);
  margin-bottom: 22px;
}
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.topic-head {
  display: flex; align-items: flex-start; gap: 18px;
  padding-bottom: 24px; margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.topic-head__icon {
  display: grid; place-items: center; width: 60px; height: 60px; flex: none;
  border-radius: 16px;
  background: color-mix(in srgb, var(--tc) 14%, var(--surface));
  color: var(--tc);
}
.topic-head__icon svg { width: 30px; height: 30px; }
.topic-head__title {
  font-family: var(--font-head); font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 600; letter-spacing: -.01em; margin: 0 0 6px;
}
.topic-head__lead { margin: 0 0 10px; color: var(--muted); font-size: 1rem; max-width: 60ch; }

/* ---------- Fuß ---------- */
.site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--footer-bg); color: var(--footer-fg);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.site-footer__inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 14px; padding-block: 28px;
}
.logo--footer { color: #fff; font-size: 1.15rem; }
.site-footer__meta { margin: 0; font-size: .85rem; }
.site-footer__meta a { color: var(--footer-fg); text-decoration: none; }
.site-footer__meta a:hover { color: #fff; text-decoration: underline; }
