/* ============================================================
   CLEAR-4  ·  L2 — ELEMENTS
   Atome: Reset, Typografie, Buttons, Cards,
          Badges, Alerts, Forms, Tables.

   Regel: Kein Wert ausser 0, 1, 100%, none, inherit.
          Alles andere kommt aus L1-Tokens.
          Kein Layout hier (Grid, Columns → L3).
   ============================================================ */

/* ── Reset ──────────────────────────────────────────────────*/
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html                   { scroll-behavior: smooth; }
body {
  font-family:  var(--font-body);
  font-size:    var(--fs-base);
  line-height:  var(--lh-normal);
  background:   var(--bg);
  color:        var(--text);
  -webkit-font-smoothing: antialiased;
}
a   { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── Typografie-Hierarchie ──────────────────────────────────*/
h1, .h1 {
  font-family:    var(--font-display);
  font-size:      var(--fs-3xl);
  font-weight:    700;
  line-height:    var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color:          var(--text);
}
h2, .h2 {
  font-family:    var(--font-display);
  font-size:      var(--fs-2xl);
  font-weight:    700;
  line-height:    var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color:          var(--text);
}
h3, .h3 {
  font-size:   var(--fs-xl);
  font-weight: 600;
  line-height: var(--lh-tight);
  color:       var(--text);
}
h4, .h4 {
  font-size:   var(--fs-lg);
  font-weight: 600;
  color:       var(--text);
}
p {
  font-size:   var(--fs-base);
  line-height: var(--lh-relaxed);
  color:       var(--text-soft);
  max-width:   var(--measure);
}
.lead {
  font-size:   var(--fs-lg);
  line-height: var(--lh-relaxed);
  color:       var(--text-soft);
}
.label {
  font-size:      var(--fs-xs);
  font-weight:    600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color:          var(--text-muted);
}
.micro {
  font-size:   var(--fs-xs);
  color:       var(--text-muted);
  line-height: var(--lh-relaxed);
}

/* ── Buttons ────────────────────────────────────────────────*/
.btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             var(--s8);
  padding:         var(--s16) var(--s24);
  min-height:      48px;
  border-radius:   var(--r-pill);
  font-family:     var(--font-body);
  font-size:       var(--fs-base);
  font-weight:     500;
  line-height:     1;
  border:          none;
  cursor:          pointer;
  text-decoration: none;
  transition:      all var(--duration-fast) var(--ease-out);
}
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--sh-soft); }
.btn-primary:hover:not(:disabled) {
  background:  var(--brand-hover);
  transform:   translateY(-1px);
  box-shadow:  var(--sh-medium);
}

.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) {
  background:   var(--brand-soft);
  border-color: var(--brand);
  color:        var(--brand);
}

.btn-ghost {
  background:  transparent;
  color:       var(--text-soft);
  padding:     var(--s8) var(--s16);
  min-height:  44px;
}
.btn-ghost:hover:not(:disabled) { background: var(--border-light); color: var(--text); }

.btn-accent { background: var(--accent); color: var(--text); box-shadow: var(--sh-soft); }
.btn-accent:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--sh-medium); }

.btn-sm { padding: var(--s8) var(--s16); font-size: var(--fs-sm); min-height: 36px; }
.btn-lg { padding: var(--s24) var(--s32); font-size: var(--fs-lg); min-height: 56px; }
.btn-full { width: 100%; }

/* ── Cards ──────────────────────────────────────────────────*/
.card {
  background:    var(--surface);
  border-radius: var(--r-lg);
  border:        1px solid var(--border);
  padding:       var(--s24);
  box-shadow:    var(--sh-soft);
  transition:    all var(--duration-normal) var(--ease-out);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--sh-medium); }

.card-flat  { box-shadow: none; }
.card-soft  { background: var(--surface-soft); }
.card-brand { background: var(--brand); border-color: transparent; color: #fff; }
.card-brand p, .card-brand .card-body { color: rgba(255,255,255,.85); }

.card-icon  {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  width:           48px;
  height:          48px;
  border-radius:   var(--r-md);
  background:      var(--brand-soft);
  color:           var(--brand);
  font-size:       var(--fs-lg);
  margin-bottom:   var(--s16);
  flex-shrink:     0;
}
.card-title    { font-size: var(--fs-base); font-weight: 600; margin-bottom: var(--s8); color: var(--text); }
.card-subtitle { font-size: var(--fs-sm);  color: var(--text-muted); margin-bottom: var(--s8); }
.card-body     { font-size: var(--fs-base); color: var(--text-soft); line-height: var(--lh-relaxed); }

/* ── Badges ─────────────────────────────────────────────────*/
.badge {
  display:        inline-flex;
  align-items:    center;
  gap:            var(--s4);
  padding:        var(--s4) var(--s8);
  border-radius:  var(--r-pill);
  font-size:      var(--fs-xs);
  font-weight:    600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border:         1px solid var(--border);
  background:     var(--bg-alt);
  color:          var(--text-soft);
}
.badge-ok    { background: rgba(5,150,105,.10);  border-color: rgba(5,150,105,.25);  color: var(--ok); }
.badge-warn  { background: rgba(217,119,6,.10);  border-color: rgba(217,119,6,.25);  color: var(--warn); }
.badge-error { background: rgba(220,38,38,.10);  border-color: rgba(220,38,38,.25);  color: var(--error); }
.badge-info  { background: rgba(2,132,199,.10);  border-color: rgba(2,132,199,.25);  color: var(--info); }
.badge-brand { background: var(--brand-soft);    border-color: var(--brand);          color: var(--brand); }

/* ── Alerts ─────────────────────────────────────────────────*/
.alert {
  border:        1px solid var(--border);
  border-radius: var(--r-lg);
  padding:       var(--s16);
  background:    var(--surface);
}
.alert-title { font-weight: 600; margin-bottom: var(--s8); }
.alert-text  { font-size: var(--fs-sm); color: var(--text-soft); line-height: var(--lh-relaxed); }

.alert-ok    { border-color: rgba(5,150,105,.30);  background: rgba(5,150,105,.06); }
.alert-warn  { border-color: rgba(217,119,6,.30);  background: rgba(217,119,6,.06); }
.alert-error { border-color: rgba(220,38,38,.30);  background: rgba(220,38,38,.06); }
.alert-info  { border-color: rgba(2,132,199,.30);  background: rgba(2,132,199,.06); }

/* ── Forms ──────────────────────────────────────────────────*/
.form-group   { display: flex; flex-direction: column; gap: var(--s8); }
.form-label   { font-size: var(--fs-sm); font-weight: 500; color: var(--text-soft); }
.form-hint    { font-size: var(--fs-xs); color: var(--text-muted); }

.form-input,
.form-textarea,
.form-select {
  width:       100%;
  padding:     var(--s16);
  min-height:  48px;
  border:      1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size:   var(--fs-base);
  background:  var(--surface);
  color:       var(--text);
  transition:  all var(--duration-fast) var(--ease-out);
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline:    none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-input.error,
.form-textarea.error { border-color: var(--error); box-shadow: 0 0 0 3px rgba(220,38,38,.10); }
.form-textarea { min-height: 120px; resize: vertical; }

/* ── Tables ─────────────────────────────────────────────────*/
.table {
  width:           100%;
  border-collapse: collapse;
  background:      var(--surface);
  border:          1px solid var(--border);
  border-radius:   var(--r-lg);
  overflow:        hidden;
}
.table th,
.table td { padding: var(--s16); text-align: left; border-bottom: 1px solid var(--border); }
.table th {
  font-size:      var(--fs-xs);
  font-weight:    600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color:          var(--text-muted);
  background:     var(--bg-alt);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover         { background: var(--surface-soft); }
.table td                     { font-size: var(--fs-sm); color: var(--text-soft); }
.table td strong              { color: var(--text); }

/* ── Divider ────────────────────────────────────────────────*/
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--s32) 0;
}

/* ── Skip Link (A11y) ───────────────────────────────────────*/
.skip-link {
  position:  absolute;
  top:       -100%;
  left:      var(--s16);
  padding:   var(--s8) var(--s16);
  background: var(--brand);
  color:     #fff;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  z-index:   1000;
  transition: top var(--duration-fast) var(--ease-out);
}
.skip-link:focus { top: var(--s16); }

/* ── Focus Visible ──────────────────────────────────────────*/
.btn:focus-visible,
a:focus-visible {
  outline:        2px solid var(--brand);
  outline-offset: 2px;
  border-radius:  var(--r-sm);
}
.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible {
  outline:        2px solid var(--brand);
  outline-offset: 1px;
}

/* ── Reduced Motion ─────────────────────────────────────────*/
@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;
  }
}
