/* Preceptly – Designsystem „Kladde“: Grundlagen (Elemente, Schrift, Formulare, Tabellen)
 * Setzt tokens.css voraus. Komponenten stehen in components.css, das Seitengerüst in shell.css.
 */

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

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem; /* 17 px: Source Sans wirkt bei gleicher Größe kleiner als Systemschriften */
  line-height: 1.55;
  background: var(--paper-page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern", "liga";
}

/* Überschriften: Serif für Titel, Sans (halbfett) für kleine Zwischenüberschriften */
h1, h2 {
  font-family: var(--font-display);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.4rem); margin: 0 0 var(--space-4); }
h2 {
  font-size: clamp(1.3rem, 1.15rem + 0.6vw, 1.6rem);
  margin: var(--space-6) 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}
h3, h4 { font-family: var(--font-body); font-weight: 650; line-height: 1.3; color: var(--ink); text-wrap: balance; }
h3 { font-size: 1.15rem; margin: var(--space-5) 0 var(--space-2); }
h4 { font-size: 1rem; margin: var(--space-4) 0 var(--space-2); }
p { margin: 0 0 var(--space-3); color: var(--ink); }
small { font-size: 0.875em; }
strong, b { font-weight: 650; }
code, kbd, samp { font-family: var(--font-mono); font-size: 0.9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-5) 0; }

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }

img, svg, video { max-width: 100%; height: auto; }
svg.icon { height: 1.15em; width: 1.15em; flex-shrink: 0; vertical-align: -0.2em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Fokus: immer sichtbar, auch auf dunklem und hellem Grund */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
:focus:not(:focus-visible) { outline: none; }

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

/* Sprunglink */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 20px; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 650; z-index: 10000; text-decoration: none;
}
.skip-link:focus {
  position: fixed; left: 50%; top: 0;
  transform: translateX(-50%);
  width: auto; height: auto; overflow: visible;
}

/* Formulare */
label { font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"],
input[type="number"], input[type="tel"], input[type="url"], input[type="search"], input[type="datetime-local"],
textarea, select {
  font: inherit;
  font-size: 1rem; /* mindestens 16 px, sonst zoomt iOS beim Fokus */
  padding: 11px 12px;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-card);
  color: var(--ink);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  touch-action: manipulation;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238c8a80' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
textarea { min-height: 7em; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input::placeholder, textarea::placeholder { color: var(--ink-soft); opacity: 0.85; }
input[type="checkbox"], input[type="radio"] { width: 1.15em; height: 1.15em; accent-color: var(--accent); vertical-align: -0.2em; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; background: var(--paper-sunk); }
.errorlist { list-style: none; margin: var(--space-1) 0; padding: 0; color: var(--danger); font-weight: 600; font-size: 0.95em; }
.helptext, .form-help { color: var(--ink-soft); font-size: 0.9em; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; margin-top: var(--space-4); font-variant-numeric: tabular-nums; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); color: var(--ink); vertical-align: middle; }
th {
  background: var(--paper-sunk);
  font-weight: 650;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-strong);
}
/* Zeilenüberschriften (erste Spalte) sehen aus wie Zellen, nicht wie Kopfzeilen */
tbody th, th[scope="row"] { background: transparent; text-transform: none; letter-spacing: 0; font-size: inherit; font-weight: 650; color: var(--ink); border-bottom: 1px solid var(--line); }
tbody tr:hover { background: var(--paper-sunk); }
caption { text-align: left; color: var(--ink-soft); padding-bottom: var(--space-2); font-size: 0.9em; }
