/* kar.re 2 – Grundlagen: Reset, Typografie, Fokus, Barrierefreiheit, Bewegung (7.3, 7.5). */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 56px);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-1);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--s-3);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: normal;
}

h1 { font-size: var(--fs-3); }
h2 { font-size: var(--fs-2); }
h3 { font-size: var(--fs-1); font-weight: 600; }
h4 { font-size: var(--fs-0); color: var(--text-2); font-weight: 600; }

p {
  margin: 0 0 var(--s-4);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

small {
  font-size: var(--fs-0);
  color: var(--text-2);
}

strong {
  font-weight: 600;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--s-5) 0;
}

code, kbd, .mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

code {
  font-size: .92em;
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: var(--radius-s);
}

img, svg, video {
  max-width: 100%;
  display: block;
}

img {
  height: auto;
}

ul, ol {
  margin: 0 0 var(--s-4);
  padding-left: 1.25em;
}

dl {
  margin: 0;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

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

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  color: var(--text);
  transition: border-color var(--dauer) var(--ease), background-color var(--dauer) var(--ease);
}

input::placeholder, textarea::placeholder {
  color: var(--text-3);
}

input:hover, select:hover, textarea:hover {
  border-color: var(--border-strong);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
}

input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

input[type="checkbox"], input[type="radio"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

input[type="file"] {
  padding: 8px;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.45;
}

select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a7adb5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: var(--s-4);
  margin: 0 0 var(--s-5);
  min-width: 0;
}

legend {
  padding: 0 var(--s-2);
  color: var(--text-2);
  font-size: var(--fs-0);
  font-weight: 600;
}

label {
  display: block;
  font-size: var(--fs-0);
  font-weight: 500;
  color: var(--text-2);
}

summary {
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

mark {
  background: var(--brand-soft);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

dialog {
  color: var(--text);
}

/* Das hidden-Attribut gewinnt gegen display-Regeln der Komponenten (z. B. .job-status { display: flex }),
   ohne !important: :root + doppeltes Attribut = Spezifität 0,3,0. Bewusste Ausnahmen stehen später mit
   gleicher oder höherer Spezifität im Modul-CSS (z. B. ki.css .ki-panel-vollseite > .ki-verlauf[hidden]). */
:root [hidden][hidden] {
  display: none;
}

/* Geschlossene <dialog>-Elemente bleiben unsichtbar, auch wenn eine Komponente display setzt (.ki-sheet) */
:root dialog:not([open]) {
  display: none;
}

::selection {
  background: var(--brand-soft);
}

/* Fokus: überall sichtbar, 2 px Fokusfarbe mit 2 px Abstand (ungleich Akzent) */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-s);
}

summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Skip-Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--s-4);
  z-index: 200;
  padding: 10px 14px;
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
}

.skip-link:focus {
  top: var(--s-2);
}

/* Nur für Screenreader */
.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;
}

/* Hilfstexte, Kleinigkeiten */
.hilfe {
  color: var(--text-2);
  font-size: var(--fs-0);
}

.hilfe .icon {
  vertical-align: -3px;
  margin-right: 4px;
}

.optional {
  color: var(--text-3);
  font-weight: 400;
}

.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-ki { color: var(--ki); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-brand { color: var(--brand); }
.rechts { text-align: right; }
.mittig { text-align: center; }
.nowrap { white-space: nowrap; }
.versteckt { display: none; }

/* Icons aus dem Sprite */
.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.icon-s { width: 16px; height: 16px; }
.icon-l { width: 28px; height: 28px; }

/* Bewegung: nur transform/opacity, 150 ms; reduced-motion → praktisch aus */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms;
    animation-iteration-count: 1;
    transition-duration: .01ms;
    scroll-behavior: auto;
  }
}
