/* ==========================================================================
   base.css — Reset, Typografie, Layout-Grundlagen, Accessibility
   Prüfungsapp Amelie · Mobile-first
   Tokens kommen aus theme.css (Single source of truth).
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Minimaler Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-hover) transparent;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* WebKit-Scrollbar-Styling */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-border-hover);
  background-clip: content-box;
  border: 2px solid transparent;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

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

button {
  background: none;
  border: none;
  cursor: pointer;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
}


/* --------------------------------------------------------------------------
   2. Globale Layout-Variablen (nicht-themed)
   -------------------------------------------------------------------------- */
:root {
  --font-family-base: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --container-max-width: 1200px;
  --content-max-width: 800px;
}


/* --------------------------------------------------------------------------
   3. Typografie
   -------------------------------------------------------------------------- */
body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base, 1rem);
  line-height: var(--line-height-base, 1.5);
  color: var(--color-fg);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  color: var(--color-fg);
  font-weight: var(--font-weight-semibold, 600);
  line-height: var(--line-height-tight, 1.25);
  margin-bottom: var(--space-md);
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2rem;        /* 32px */
  font-weight: var(--font-weight-bold, 700);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 1.5rem;      /* 24px */
  font-weight: var(--font-weight-semibold, 600);
  line-height: 1.25;
}
h3 {
  font-size: 1.25rem;     /* 20px */
  font-weight: var(--font-weight-semibold, 600);
  line-height: 1.3;
}
h4 {
  font-size: 1.125rem;    /* 18px */
  font-weight: var(--font-weight-semibold, 600);
  line-height: 1.35;
}
h5 {
  font-size: 1rem;
  font-weight: var(--font-weight-semibold, 600);
  line-height: 1.4;
}
h6 {
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold, 600);
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-fg-muted);
}

p {
  margin-bottom: var(--space-md);
  line-height: var(--line-height-base, 1.5);
}
p:last-child {
  margin-bottom: 0;
}

small,
.text-sm {
  font-size: var(--font-size-sm, 0.875rem);
}

strong,
b {
  font-weight: var(--font-weight-semibold, 600);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  text-underline-offset: 2px;
  transition: color var(--transition-fast, 150ms) ease;
}
a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}
a:focus-visible {
  text-decoration: underline;
}

/* Reset Underline auf Button-/Card-Wrappers, die als Link rendern */
a.btn,
a.card,
a.icon-button,
a.tag {
  text-decoration: none;
}
a.btn:hover,
a.card:hover,
a.icon-button:hover,
a.tag:hover {
  text-decoration: none;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-family-mono);
  font-size: 0.9375em;
}
code {
  padding: 0.125em 0.375em;
  background-color: var(--color-surface-muted);
  color: var(--color-fg);
  border-radius: var(--radius-sm, 0.375rem);
}
pre {
  padding: var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 0.5rem);
  overflow-x: auto;
  line-height: var(--line-height-snug, 1.35);
}
pre code {
  padding: 0;
  background: transparent;
}


/* --------------------------------------------------------------------------
   4. Body / Page-Layout
   -------------------------------------------------------------------------- */
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
}

header {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

header > .brand,
header > h1 {
  font-size: 1.25rem;
  font-weight: var(--font-weight-bold, 700);
  color: var(--color-primary);
  margin: 0;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

nav button,
nav a {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
  color: var(--color-fg);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 0.5rem);
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color var(--transition-fast, 150ms) ease,
    border-color var(--transition-fast, 150ms) ease,
    color var(--transition-fast, 150ms) ease;
  min-height: 40px;
}

nav button:hover,
nav a:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-border-hover);
  text-decoration: none;
}

nav button[aria-current="page"],
nav a[aria-current="page"],
nav .active {
  background-color: var(--color-primary);
  color: var(--color-on-accent);
  border-color: var(--color-primary);
}

main,
#app {
  flex: 1;
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

footer {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-fg-muted);
  text-align: center;
}


/* --------------------------------------------------------------------------
   5. Container / Grid Utilities
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.col            { flex: 1 1 100%; }
.col-auto       { flex: 0 0 auto; width: auto; }
.col-1-2        { flex: 0 0 100%; }
.col-1-3        { flex: 0 0 100%; }
.col-2-3        { flex: 0 0 100%; }
.col-1-4        { flex: 0 0 100%; }


/* --------------------------------------------------------------------------
   6. Accessibility — Fokus & Skip-Link
   -------------------------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm, 0.375rem);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Skip-Link — sichtbar bei Tastatur-Fokus */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-md);
  z-index: var(--z-tooltip, 1300);
  padding: var(--space-sm) var(--space-md);
  background-color: var(--color-primary);
  color: var(--color-on-accent);
  font-weight: var(--font-weight-semibold, 600);
  text-decoration: none;
  border-radius: var(--radius-md, 0.5rem);
  box-shadow: var(--shadow-md);
  transition: top var(--transition-base, 200ms) ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: var(--space-md);
  text-decoration: none;
  outline: 2px solid var(--color-on-accent);
  outline-offset: 2px;
}

/* Visually hidden — nur für Screenreader */
.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* --------------------------------------------------------------------------
   7. Selektion
   -------------------------------------------------------------------------- */
::selection {
  background-color: var(--color-primary);
  color: var(--color-on-accent);
}
::-moz-selection {
  background-color: var(--color-primary);
  color: var(--color-on-accent);
}


/* --------------------------------------------------------------------------
   8. Responsive — Desktop ab 768px
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  body {
    padding: var(--space-lg);
  }

  header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  nav {
    flex-wrap: nowrap;
  }

  h1 { font-size: 2.25rem; }   /* 36px */
  h2 { font-size: 1.75rem; }   /* 28px */
  h3 { font-size: 1.375rem; }  /* 22px */
  h4 { font-size: 1.125rem; }

  .col-1-2 { flex: 0 0 calc(50% - var(--space-md)); }
  .col-1-3 { flex: 0 0 calc(33.3333% - var(--space-md)); }
  .col-2-3 { flex: 0 0 calc(66.6666% - var(--space-md)); }
  .col-1-4 { flex: 0 0 calc(25% - var(--space-md)); }
}

@media (min-width: 1024px) {
  body {
    padding: var(--space-xl) var(--space-lg);
  }
}
