/* ==========================================================================
   Wahl-Radar — Shared App Shell (Header / Sidebar / Back-Button)
   Identisch zum Layout der Haupt-SPA (index.html)
   ========================================================================== */

:root {
  --primary: #9f3d00;
  --primary-container: #c74e00;
  --surface: #fcf9f8;
  --surface-low: #f6f3f2;
  --surface-high: #ede9e8;
  --surface-highest: #e5e2e1;
  --on-surface: #1b1c1c;
  --on-surface-light: #6b6b6b;
  --outline: rgba(27,28,28,0.12);
  --bg: var(--surface);
  --card: #ffffff;
  --border: #e0dbd9;
  --text: var(--on-surface);
  --text-light: var(--on-surface-light);
  --shadow: 0 4px 32px rgba(27,28,28,0.05);
  --shadow-md: 0 8px 40px rgba(27,28,28,0.06);
  --radius: 0;

  /* ---------- Typografie ----------
     Eine Familie (Inter Variable) statt zwei. Gewichte deutlich leichter
     als zuvor; 575 ist eine variable Zwischenstufe zwischen 500 und 600.
     Laufweite ist groessenabhaengig: je groesser, desto enger. */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  --w-body: 400;
  --w-medium: 500;
  --w-heading: 575;
  --w-strong: 600;

  --ls-display: -0.03em;
  --ls-heading: -0.025em;
  --ls-sub: -0.015em;
  --ls-body: -0.01em;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; }
body {
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--on-surface);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 1rem;
  font-weight: var(--w-body);
  line-height: 1.6;
  letter-spacing: var(--ls-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Textskala: Zeilenabstand eng bei grossem Text, weit bei Fliesstext.
   Laufweite wird mit wachsender Groesse negativer. */
h1, h2, h3, h4 { font-family: var(--font-sans); }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.5rem); font-weight: var(--w-heading); line-height: 1.1;  letter-spacing: var(--ls-display); }
h2 { font-size: 1.375rem; font-weight: var(--w-heading); line-height: 1.25; letter-spacing: var(--ls-heading); }
h3 { font-size: 1.125rem; font-weight: var(--w-medium);  line-height: 1.3;  letter-spacing: var(--ls-sub); }
h4 { font-size: 1rem;     font-weight: var(--w-medium);  line-height: 1.4;  letter-spacing: var(--ls-sub); }
p  { line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
strong, b { font-weight: var(--w-heading); }

/* Kleine Schrift braucht etwas mehr Laufweite, nicht weniger */
small, .caption, figcaption { font-size: 0.8125rem; letter-spacing: 0; line-height: 1.5; }

/* ---------- Header ---------- */
header {
  background: linear-gradient(135deg, #e65100 0%, #ff9800 100%);
  color: #fff; padding: 0 24px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
}
/* Logo bewusst ausserhalb der neuen Textskala: eigene Schrift und Gewicht */
header .logo {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 3.2rem;
  font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 6px;
  text-transform: uppercase; letter-spacing: -0.02em; color: #fff; text-decoration: none;
}
header .logo .flag { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; line-height: 1; margin: 0 2px; }
header .logo .flag span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
header .logo .flag span:nth-child(1) { background: #111; }
header .logo .flag span:nth-child(2) { background: #dd0000; }
header .logo .flag span:nth-child(3) { background: #ffce00; }

.header-search-btn {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.15); border: none; cursor: pointer;
  border-radius: 0; padding: 8px; width: 42px; height: 42px;
  display: flex; justify-content: center; align-items: center;
  color: #fff; transition: background 0.2s; text-decoration: none;
}
.header-search-btn:hover { background: rgba(255,255,255,0.25); }

.hamburger-btn {
  display: none;
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.15); border: none; cursor: pointer;
  border-radius: 0; padding: 8px; width: 42px; height: 42px;
  flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  transition: background 0.2s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.25); }
.hamburger-btn span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; transition: transform 0.3s, opacity 0.3s; }
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Layout ----------
   Kein .app-layout-Wrapper: main trägt die Abstände selbst, damit shell.js
   Header und Seitenleiste einfach voranstellen kann, ohne den DOM umzubauen. */
main { max-width: 1100px; padding: 32px 20px; margin-top: 80px; margin-left: 280px; min-height: calc(100vh - 80px); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 280px; flex-shrink: 0; background: var(--surface-low);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 6px;
  position: fixed; top: 80px; left: 0; height: calc(100vh - 80px); overflow-y: auto;
}
a.sidebar-card, a.sidebar-card:visited, a.sidebar-card:hover, a.sidebar-card:active { color: inherit; text-decoration: none; }
.sidebar-card {
  background: transparent; border-radius: 0; padding: 11px 18px;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  border: none; transition: background 0.15s, transform 0.1s;
  text-decoration: none; width: 100%;
}
.sidebar-card:hover { background: var(--surface-high); }
.sidebar-card:active { transform: scale(0.985); }
.sidebar-card svg { flex-shrink: 0; color: var(--on-surface-light); }
.sidebar-card h3 { flex: 1; font-size: 14px; font-weight: 500; color: var(--on-surface); letter-spacing: 0.01em; }
.sidebar-card.active svg { color: var(--primary); }
.sidebar-card.active h3 { color: var(--primary); font-weight: var(--w-heading); }

.sidebar-close-btn { display: none; }

.sidebar-social { display: flex; flex-direction: row; gap: 14px; justify-content: center; margin-top: 16px; width: 100%; flex-wrap: wrap; }
.sidebar-social a {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; min-width: 46px; border-radius: 50%;
  background: #d4a882; text-decoration: none;
}

/* ---------- Menu Overlay ---------- */
.menu-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 150; backdrop-filter: blur(2px); }
.menu-overlay.visible { display: block; }

/* ---------- Back Button (oben links im Content) ----------
   44x44 = Apple-Mindestgröße für Touch-Ziele. Das Icon bleibt optisch klein. */
.btn-back {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 0;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  margin-bottom: 20px; box-shadow: 0 2px 12px rgba(159,61,0,0.25);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
}
.btn-back:hover { background: var(--primary-container); box-shadow: 0 4px 16px rgba(159,61,0,0.35); }
.btn-back:active { transform: scale(0.95); }

/* ---------- Skip Link ---------- */
.skip-link {
  position: absolute; top: -100px; left: 16px; z-index: 9999;
  background: var(--primary); color: #fff; padding: 10px 20px; border-radius: 0 0 8px 8px;
}
.skip-link:focus { top: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  header { padding: 0 16px; height: 60px; }
  header .logo { font-size: 1.6rem; }
  .hamburger-btn { display: flex; }

  main { width: 100%; padding: 20px 16px; margin-left: 0; margin-top: 60px; min-height: calc(100vh - 60px); }

  /* transform statt left: läuft im Compositor, kein Layout-Reflow pro Frame */
  .sidebar {
    position: fixed; top: 0; left: 0; width: 280px; height: 100vh;
    flex-direction: column; padding: 24px 20px 32px; gap: 12px;
    z-index: 200; overflow-y: auto; overflow-x: visible;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn {
    display: flex;
    background: rgba(0,0,0,0.06); border: none; cursor: pointer;
    border-radius: 10px; padding: 8px; width: 42px; height: 42px;
    flex-direction: column; justify-content: center; align-items: center; gap: 5px;
    transition: background 0.2s; margin-bottom: 16px; flex-shrink: 0;
  }
  .sidebar-close-btn:hover { background: rgba(0,0,0,0.12); }
  .sidebar-close-btn span { display: block; width: 22px; height: 2px; background: var(--primary); border-radius: 2px; }
  .sidebar-close-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .sidebar-close-btn span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  .sidebar-close-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .sidebar .sidebar-card { background: none; box-shadow: none; border-radius: 0; padding: 6px 0; border: none; }
  .sidebar .sidebar-card:hover { box-shadow: none; transform: none; }
  .sidebar .sidebar-card h3 { font-size: 1rem; font-weight: 600; }
}

/* ==========================================================================
   Barrierefreiheit & Feedback
   ========================================================================== */

/* ---------- Sichtbarer Tastatur-Fokus ----------
   :focus-visible zeigt den Ring nur bei Tastaturnavigation, nicht bei Mausklick. */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px;
}
header a:focus-visible,
header button:focus-visible,
.hamburger-btn:focus-visible,
.header-search-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -3px;
}

/* ---------- Druckfeedback: sofort beim Drücken, nicht erst beim Loslassen ---------- */
.sidebar-card:active { background: var(--surface-highest); transform: scale(0.985); }
.hamburger-btn:active,
.header-search-btn:active { background: rgba(255,255,255,0.32); transform: translateY(-50%) scale(0.94); }
.sidebar-social a:active { transform: scale(0.92); }
.sidebar-social a { transition: background 0.2s, transform 0.1s; }

/* ---------- Bewegungsreduktion ----------
   Kein Wegfall der Rückmeldung, sondern eine sanftere Variante ohne
   vestibuläre Reize: keine Verschiebungen, keine Dauerschleifen. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .sidebar {
    transition: opacity 0.2s ease !important;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
}

/* ---------- Reduzierte Transparenz ---------- */
@media (prefers-reduced-transparency: reduce) {
  .menu-overlay { backdrop-filter: none; background: rgba(0,0,0,0.6); }
}

/* ---------- Erhöhter Kontrast ---------- */
@media (prefers-contrast: more) {
  .sidebar { border-right: 2px solid var(--on-surface); }
  .sidebar-card.active h3 { text-decoration: underline; }
  .btn-back { border: 2px solid #fff; }
}
