/* Basis (AP-D1): Schrift, Grundelemente, Fokusring, Layout der App-Shell.
   Reihenfolge: design-tokens.css → basis.css → bausteine.css → stil.css.
   Farben, Abstände, Radien und Schatten nur über Tokens (Designregeln im Prüfkommando). */

@font-face {
  font-family: Inter;
  src: url("schrift/InterVariable-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background: var(--color-canvas);
  font-feature-settings: "kern";
}

h1,
h2,
h3 {
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

h1 {
  font-size: var(--font-size-3xl);
  margin: 0 0 var(--space-3);
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--font-size-xl);
  margin: 0 0 var(--space-3);
}

h3 {
  font-size: var(--font-size-lg);
  margin: var(--space-4) 0 var(--space-2);
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--color-action);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--color-action-hover);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

img {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* Sichtbarer Fokusring für alle bedienbaren Elemente */
:focus-visible {
  outline: var(--focus-width) solid var(--color-action);
  outline-offset: 2px;
  box-shadow: 0 0 0 calc(var(--focus-width) + 2px) var(--color-focus-ring);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip-Link: erst bei Tastaturfokus sichtbar */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-width) solid var(--color-border-control);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

main:focus {
  outline: none;
}

/* --- App-Shell ------------------------------------------------------------------------ */

.shell {
  min-height: 100vh;
  /* dunkle Spalte hinter der festen Seitenleiste – auch bei langen Seiten durchgehend */
  background: linear-gradient(
    to right,
    var(--color-sidebar) var(--sidebar-width),
    var(--color-canvas) var(--sidebar-width)
  );
}

.seitenleiste {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-sticky);
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  overflow-y: auto;
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
}

.seitenleiste :focus-visible {
  outline-color: var(--color-focus-ring-on-dark);
}

.seitenleiste-marke {
  display: block;
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

.seitenleiste-marke img {
  display: block;
  width: 11.25rem;
  height: auto;
}

.navigation {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}

.navigation a {
  display: flex;
  align-items: center;
  min-height: var(--tap-target-min);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border-left: var(--focus-width) solid transparent;
  color: var(--color-sidebar-text);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-standard);
}

.navigation a:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-text-on-dark);
}

.navigation a[aria-current="page"] {
  background: var(--color-sidebar-active);
  border-left-color: var(--color-action);
  color: var(--color-text-on-dark);
}

.seitenleiste-fuss {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--color-sidebar-line);
}

.abmelden {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0;
}

.abmelden .benutzer {
  color: var(--color-sidebar-text-muted);
  font-size: var(--font-size-sm);
}

.abmelden button {
  min-height: var(--tap-target-min);
  padding: var(--space-2) var(--space-4);
  border: var(--border-width) solid var(--color-sidebar-line);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-on-dark);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}

.abmelden button:hover {
  background: var(--color-sidebar-hover);
}

.shell-kopfleiste {
  display: none;
}

.hauptbereich {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hauptbereich main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  padding: var(--space-8);
}

.meldungen:empty {
  display: none;
}

.meldungen {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.fuss {
  width: 100%;
  max-width: var(--content-max);
  padding: var(--space-6) var(--space-8) var(--space-8);
  border-top: var(--border-width) solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* Seiten ohne Anmeldung (Anmelden, Fehler ohne Sitzung) */
.ohne-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.ohne-shell main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

.ohne-shell .fuss {
  margin: 0 auto;
  text-align: center;
  border-top: 0;
}

/* Tablet und Handy unter 1200 px (PAGE_REFERENCES „Gemeinsame responsive Referenz“:
   768–1199 px off-canvas): Kopfleiste mit Menü-Knopf; die Seitenleiste wird zur
   einblendbaren Ebene, damit Tabellen die volle Breite haben. Ohne JavaScript bleibt die
   Navigation als Liste oben auf der Seite stehen. */
@media (max-width: 74.99rem) {
  .shell-kopfleiste {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface);
    border-bottom: var(--border-width) solid var(--color-border);
  }

  .shell-marke-klein {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--tap-target-min);
    color: var(--color-text);
    font-weight: var(--font-weight-bold);
    text-decoration: none;
  }

  .shell-marke-klein img {
    display: block;
    width: 1.75rem;
    height: auto;
  }

  .menue-knopf {
    min-height: var(--tap-target-min);
    min-width: var(--tap-target-min);
    padding: var(--space-2) var(--space-4);
    border: var(--border-width) solid var(--color-border-control);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
  }

  .shell {
    background: var(--color-canvas);
  }

  .seitenleiste {
    position: static;
    width: auto;
  }

  .hauptbereich {
    margin-left: 0;
    min-height: 0;
  }

  .hauptbereich main {
    padding: var(--space-6);
  }

  .fuss {
    padding: var(--space-6);
  }

  /* mit JavaScript: Ebene von links, Abdunklung dahinter */
  .js-navigation .seitenleiste {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-modal);
    width: min(var(--sidebar-width), 85vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform var(--duration-normal) var(--ease-standard),
      visibility var(--duration-normal);
  }

  .js-navigation .menue-offen .seitenleiste {
    transform: none;
    visibility: visible;
  }

  .js-navigation .menue-offen::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: var(--z-dropdown);
    background: var(--color-overlay);
  }
}

/* Handy unter 768 px: schmaleres Seitenpolster */
@media (max-width: 47.99rem) {
  .hauptbereich main {
    padding: var(--space-4);
  }

  .fuss {
    padding: var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms;
    animation-duration: 0ms;
  }
}
