/* ==========================================================================
   THEME & A11Y — Light-Kontraste, Fokus-Indikatoren, Reduced Motion, Schrift
   Laedt als letzte CSS-Datei und gewinnt darum bei gleicher Spezifitaet.
   ========================================================================== */

/* 1. LIGHT-THEME: Überschriften und Kennzahlen dunkel, Rot bleibt Akzent */
[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3:not(#screen-rdhub *),
[data-theme="light"] h4:not(#screen-rdhub *),
[data-theme="light"] strong,
[data-theme="light"] .brand h1,
[data-theme="light"] .brand-title,
[data-theme="light"] .screen-title,
[data-theme="light"] .section-title,
[data-theme="light"] .kpi-card span.kpi-val,
[data-theme="light"] td strong,
[data-theme="light"] #dashboardAdvisorQuote,
[data-theme="light"] .tech-node h4,
[data-theme="light"] .kpi-val,
[data-theme="light"] #resultModalTitle,
[data-theme="light"] #dashboardAdvisorQuote + strong {
  color: var(--color-pure-white) !important;
}

/* 2. VISUELLES SYMMETRIE- & ÄSTHETIK-TUNING IM LIGHT-THEME */

/* Dunkle Titel: roter statt schwarzer Versatzschatten, sonst verschwimmt die Schrift */
[data-theme="light"] .brand-title,
[data-theme="light"] .screen-title {
  text-shadow: 2px 2px 0 color-mix(in srgb, var(--color-accent-fill) 35%, transparent);
}

/* Inputs im Light-Theme reinweiß statt schmutzig-grau gestalten für erstklassige Ästhetik */
[data-theme="light"] .glass-input {
  background-color: #ffffff !important;
  color: var(--color-ink-black) !important;
}

[data-theme="light"] .glass-input:focus {
  border-color: var(--color-accent-text) !important;
}

/* Tabellenzeilen-Hover im Light-Theme harmonisieren */
[data-theme="light"] .glass-table tbody tr:hover {
  background-color: color-mix(in srgb, var(--color-accent-fill) 6%, transparent) !important;
}

/* Navigation-Tabs im Light-Theme markanter und symmetrischer hervorheben */
/* Ohne !important: die Seitenleiste (main.css) setzt Schrift und Fläche des
   aktiven Tabs mit höherer Spezifität und gilt in beiden Themes. */
[data-theme="light"] .tab-button.active {
  color: var(--color-accent-text);
  font-weight: 800;
}

/* Unterkante und Schatten nur in der oberen Leiste; mobil sitzt sie unten. */
@media (min-width: 768px) {
  [data-theme="light"] .tab-button.active {
    border-bottom-color: var(--color-accent-text);
    box-shadow:
      0 4px 14px -4px color-mix(in srgb, var(--color-accent-fill) 35%, transparent),
      inset 0 -1px 0 color-mix(in srgb, var(--color-accent-fill) 15%, transparent);
  }
}

@media (max-width: 767px) {
  [data-theme="light"] .tab-button.active {
    border-top-color: var(--color-accent-text);
  }
}




/* 3. PREMIUM NOIR SIGNATUR-EFFEKT: CARD NOISE-OVERLAY */
/* Wir binden die feine Körnung auf alle Cards ein, um dem Premium-Designsystem zu entsprechen */
.noir-card {
  position: relative;
  overflow: hidden; /* Sichert ab, dass das Noise-Overlay nicht über die Ecken ragt */
}

.noir-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  opacity: 0.02; /* Extrem subtile Körnung */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Sicherstellen, dass Card-Inhalt über dem Noise-Overlay liegt */
.noir-card > * {
  position: relative;
  z-index: 2;
}

/* 4. FLIESSTEXT-SCHRIFT LOKAL (public/fonts/), Überschriften nutzen Systemschriften */
@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/dm-sans-v14-latin-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/dm-sans-v14-latin-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Globale Font-Anwendung */
html {
  font-family: var(--font-body);
}

body {
  font-family: var(--font-body);
}

/* Typografie-Skala: Headlines */
h1 {
  font-family: var(--font-headline);
  font-weight: var(--type-weight-headline);
  font-size: var(--type-h1);
  line-height: var(--type-line-height-headline);
  letter-spacing: var(--type-letter-spacing-headline);
}

h2 {
  font-family: var(--font-headline);
  font-weight: var(--type-weight-headline);
  font-size: var(--type-h2);
  line-height: var(--type-line-height-headline);
  letter-spacing: var(--type-letter-spacing-headline);
}

h3 {
  font-family: var(--font-headline);
  font-weight: var(--type-weight-headline);
  font-size: var(--type-h3);
  line-height: var(--type-line-height-headline);
  letter-spacing: var(--type-letter-spacing-headline);
}

.screen-title {
  font-family: var(--font-headline);
  font-weight: var(--type-weight-headline);
  font-size: var(--type-screen-title);
  line-height: var(--type-line-height-headline);
  letter-spacing: var(--type-letter-spacing-headline);
  color: var(--color-pure-white);
}

.section-title {
  font-family: var(--font-headline);
  font-weight: var(--type-weight-headline);
  font-size: var(--type-section-title);
  line-height: var(--type-line-height-headline);
  letter-spacing: var(--type-letter-spacing-caps);
}

/* Skip-to-Content Link (visuell versteckt bis Fokus) */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 100000;
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-on-accent);
  background-color: var(--color-accent-fill);
  border: 2px solid var(--color-ink-black, #020203);
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: var(--space-4);
  outline: 3px solid var(--color-pure-white, #fff);
  outline-offset: 3px;
}

/* Erweiterte Fokus-Indikatoren (WCAG 2.4.7 / 2.4.11). Scrollbare
   Tabellen-Wrapper erreicht Chrome per Tab auch ohne tabindex (#135). */
:focus {
  outline: none;
}

button:focus-visible,
summary:focus-visible,
.tab-button:focus-visible,
.glass-button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible,
.table-scroll-wrapper:focus-visible {
  outline: var(--focus-ring) !important;
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow);
}

.glass-input:focus-visible {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-fill) 45%, transparent),
              5px 5px 0 var(--color-ink-black, #020203) !important;
  transform: translate(-2px, -2px);
}

/* prefers-reduced-motion: zentraler Guard (konsolidiert) */
@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;
  }

  .kpi-card,
  .glass-table tbody tr,
  .screen,
  .modal-content,
  .noir-card,
  .premium-glow {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  /* Der Wipe ist reine Bewegung ohne Endzustand: ausblenden statt deckend
     stehen lassen (#172). */
  .comic-wipe-overlay {
    display: none;
  }

  .noir-card:hover {
    transform: none;
  }

  .glass-button:hover,
  .glass-button:active,
  .tab-button:hover,
  .tab-button.active {
    transform: none;
  }
}
