/* Courtavo Nutzerhandbuch — Stylesheet
   Farbschema orientiert sich an den Courtavo-Markenfarben (Grün),
   siehe src/app/globals.css im Hauptprojekt. */

:root {
  --primary: #0d461c;
  --primary-foreground: #ffffff;
  --primary-soft: #e6f4e0;

  --background: #f7f8f7;
  --surface: #ffffff;
  --foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #6b7280;
  --border: #e4e4e7;

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 280px;
  --header-height: 64px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
}

/* Dark-Mode-Werte liegen bewusst zweimal vor: einmal fuer die
   Systemeinstellung (@media, greift nur ohne manuelle Wahl -- siehe
   :not([data-theme="light"])) und einmal als expliziter Override, wenn
   data-theme="dark" gesetzt ist (per Inline-Script aus dem localStorage-
   Key "theme" uebernommen, sobald diese Seite in der App eingebettet ist --
   siehe <script> in index.html sowie ThemeToggle.tsx im Hauptprojekt).
   Standalone (Doppelklick/eigener Webhoster, kein Inline-Script-Kontext)
   greift automatisch nur der @media-Block. Beide Bloecke synchron halten. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #6fcf42;
    --primary-foreground: #0b2b10;
    --primary-soft: #16321e;

    --background: #09090b;
    --surface: #18181b;
    --foreground: #fafafa;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --border: #27272a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --primary: #6fcf42;
  --primary-foreground: #0b2b10;
  --primary-soft: #16321e;

  --background: #09090b;
  --surface: #18181b;
  --foreground: #fafafa;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --border: #27272a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  color: var(--foreground);
  background: var(--background);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--primary);
}

/* ---------- Kopfbereich ---------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 40;
  gap: 16px;
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.site-header .brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.site-header .brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.site-header .doc-label {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.site-header .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

/* Eingebettete Version (iframe in der App, siehe src/app/docs/page.tsx --
   "embedded" wird per Inline-Script in index.html gesetzt, sobald
   window.self !== window.top): die App zeigt bereits ihren eigenen
   Kopfbereich (PublicHeader) mit Branding/Navigation, der doku-eigene
   Kopfbereich waere doppelt -- Marke/Label/Datum ausblenden. Der mobile
   Kapitel-Umschalter (Hamburger) bleibt jedoch bestehen, da er auf
   schmalen Bildschirmen die einzige Moeglichkeit ist, die Sidebar zu
   oeffnen -- nur auf Breitbildschirmen (Umschalter ohnehin unsichtbar,
   siehe @media weiter unten) wird der gesamte Kopfbereich entfernt. */
html.embedded .site-header .brand,
html.embedded .site-header .doc-label,
html.embedded .site-header .meta {
  display: none;
}

@media (min-width: 721px) {
  html.embedded .site-header {
    display: none;
  }

  html.embedded .app-shell {
    padding-top: 0;
  }

  html.embedded .sidebar {
    top: 0;
  }
}

/* ---------- Layout ---------- */

.app-shell {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 12px 40px;
  z-index: 30;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  padding: 8px 12px 6px;
}

.nav-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--foreground);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition:
    background-color 0.12s ease,
    color 0.12s ease;
}

.nav-link .nav-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--muted);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-link.active .nav-index {
  background: var(--primary);
  color: var(--primary-foreground);
}

.nav-link.overview-link {
  font-weight: 600;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px clamp(20px, 4vw, 56px) 80px;
  min-width: 0;
}

.content-wrap {
  max-width: 880px;
  margin: 0 auto;
}

/* ---------- Übersicht / Inhaltsverzeichnis ---------- */

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overview-hero h1 {
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.overview-hero p {
  color: var(--muted-foreground);
  font-size: 1.05rem;
  max-width: 640px;
  margin: 0 0 32px;
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.toc-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.toc-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.toc-card .toc-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.toc-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.toc-card p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.88rem;
}

/* ---------- Kapitel ---------- */

.chapter-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
  margin-bottom: 28px;
}

.chapter-header h1 {
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

.chapter-intro {
  color: var(--muted-foreground);
  max-width: 620px;
  margin: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  text-decoration: none;
  margin-bottom: 16px;
}

.back-link:hover {
  color: var(--primary);
}

/* Desktop/Mobile-Umschalter */

.view-toggle {
  display: inline-flex;
  background: var(--muted);
  border-radius: 999px;
  padding: 3px;
  flex-shrink: 0;
}

.view-toggle button {
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.view-toggle button svg {
  width: 14px;
  height: 14px;
}

.view-toggle button.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Schritte */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.step {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.step:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.step:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.step-figure {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--muted);
}

.expand-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(15, 15, 17, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.expand-hint svg {
  width: 15px;
  height: 15px;
}

.step-figure img {
  width: 100%;
  height: auto;
}

.step-figure[data-shot="mobile"] {
  max-width: 220px;
}

.step-body {
  min-width: 0;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-body p {
  margin: 0;
  color: var(--foreground);
}

.step-body p + p {
  margin-top: 8px;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

/* Bilder je nach aktivem Umschalter ein-/ausblenden */

.chapter[data-view="desktop"] .step-figure[data-shot="mobile"] {
  display: none;
}

.chapter[data-view="mobile"] .step-figure[data-shot="desktop"] {
  display: none;
}

.chapter[data-view="mobile"] .step {
  grid-template-columns: 220px 1fr;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  text-decoration: none;
  color: var(--foreground);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s ease;
}

.chapter-nav a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chapter-nav .spacer {
  flex: 1;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .toc-grid {
    grid-template-columns: 1fr;
  }

  .step {
    grid-template-columns: 1fr;
  }

  .chapter[data-view="mobile"] .step {
    grid-template-columns: 1fr;
  }

  .step-figure[data-shot="mobile"] {
    max-width: 260px;
  }

  .site-header .meta {
    display: none;
  }
}

@media (max-width: 720px) {
  .menu-toggle {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  body.nav-open .nav-scrim {
    display: block;
  }

  .nav-scrim {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0, 0, 0, 0.3);
    z-index: 25;
  }

  .main {
    margin-left: 0;
  }

  .site-header .doc-label {
    display: none;
  }
}

@media (max-width: 480px) {
  .main {
    padding: 28px 16px 64px;
  }

  .chapter-header {
    flex-direction: column;
  }
}

/* ---------- Lightbox (Schritt in Vollbild) ---------- */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 17, 0.88);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.lightbox.open {
  display: flex;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox-panel {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  /* calc() reserviert Platz fuer die fest positionierten Pfeil-Buttons
     links/rechts (siehe .lightbox-nav) -- ohne diese Reservierung
     ueberlappt das Panel auf schmalen Viewports die Buttons (der
     "Zurueck"-Pfeil landete dadurch optisch HINTER dem Panel, da er vor
     dem Panel im Quelltext steht und spaeter gezeichnete Geschwister-
     Elemente ohne z-index sonst obenauf liegen). */
  max-width: min(900px, calc(100vw - 152px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px 28px 28px;
  box-shadow: var(--shadow-md);
}

.lightbox-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
}

.lightbox-header .step-number {
  margin: 0;
}

.lightbox-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.lightbox-image-wrap {
  display: flex;
  justify-content: center;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
}

.lightbox-image-wrap img {
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  border-radius: 4px;
}

.lightbox-caption p {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.lightbox-caption p:first-child {
  color: var(--foreground);
}

.lightbox-caption p:not(:first-child) {
  color: var(--muted-foreground);
}

.lightbox-hint {
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.lightbox-close,
.lightbox-nav {
  position: fixed;
  z-index: 2;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.lightbox-close:hover,
.lightbox-nav:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-close {
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
}

.lightbox-close svg {
  width: 18px;
  height: 18px;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
}

.lightbox-nav svg {
  width: 22px;
  height: 22px;
}

.lightbox-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

.lightbox-prev {
  left: 20px;
}

.lightbox-next {
  right: 20px;
}

@media (max-width: 640px) {
  .lightbox {
    padding: 12px;
  }

  .lightbox-nav {
    width: 40px;
    height: 40px;
  }

  .lightbox-prev {
    left: 8px;
  }

  .lightbox-next {
    right: 8px;
  }

  .lightbox-panel {
    max-width: calc(100vw - 112px);
    padding: 18px 16px 20px;
  }
}
