/*
 * Base Layer
 * Reset, typography, layout primitives, shared components.
 * Loaded after tokens.css, before viewer.css.
 */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg, video { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; background: none; border: none; padding: 0; color: inherit; }
input, textarea, select { font: inherit; }

/* ---- Document ---- */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--h-font-body);
  font-size: var(--h-base);
  line-height: var(--h-line);
  color: var(--h-text);
  background: var(--h-bg);
  min-height: 100vh;
}

/* ---- Headings ---- */
h1, h2, h3, h4 {
  font-family: var(--h-font-heading);
  font-weight: 500;
  line-height: var(--h-line-tight);
  margin: 0;
  color: var(--h-text);
}
h1 { font-size: var(--h-2xl); }
h2 { font-size: var(--h-xl); }
h3 { font-size: var(--h-lg); }
h4 { font-size: var(--h-base); }

/* ---- Links ---- */
a {
  color: var(--h-ziegelrot);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--h-transition);
}
a:hover { color: var(--h-ziegelrot-light); }
a:focus-visible { outline: 2px solid var(--h-ziegelrot); outline-offset: 2px; }

/* ---- Code ---- */
code, pre, kbd {
  font-family: var(--h-font-mono);
  font-size: 0.93em;
}

/* ---- Hidden ---- */
.hidden { display: none !important; }
.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: carries .sr-only until it takes focus, then it becomes visible chrome. */
.skip-link:focus {
  position: fixed;
  top: var(--h-space-sm);
  left: var(--h-space-sm);
  z-index: 1000;
  width: auto;
  height: auto;
  margin: 0;
  padding: var(--h-space-xs) var(--h-space-sm);
  overflow: visible;
  clip: auto;
  background: var(--h-surface);
  color: var(--h-text);
  border: 1px solid var(--h-border-emphasis);
  border-radius: var(--h-radius);
  font-family: var(--h-font-heading);
  font-size: var(--h-sm);
  text-decoration: none;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--h-space-sm);
  padding: 0.4em 0.9em;
  border: 1px solid var(--h-border-emphasis);
  border-radius: var(--h-radius);
  background: var(--h-surface);
  color: var(--h-text);
  font-family: var(--h-font-heading);
  font-size: var(--h-sm);
  cursor: pointer;
  transition: all var(--h-transition-fast);
}
.btn:hover {
  background: var(--h-bg-alt);
  border-color: var(--h-text-muted);
}
.btn:focus-visible {
  outline: 2px solid var(--h-ziegelrot);
  outline-offset: 1px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn--primary {
  background: var(--h-ziegelrot);
  border-color: var(--h-ziegelrot);
  color: var(--h-text-inverse);
}
.btn--primary:hover {
  background: var(--h-ziegelrot-light);
  border-color: var(--h-ziegelrot-light);
}
.btn--ghost {
  border-color: transparent;
  background: transparent;
}
.btn--ghost:hover {
  background: var(--h-bg-alt);
}
.btn--sm {
  padding: 0.25em 0.6em;
  font-size: var(--h-xs);
}
.btn--icon {
  padding: 0.35em 0.5em;
}
.btn[aria-pressed="true"] {
  background: var(--h-ziegelrot-subtle);
  border-color: var(--h-ziegelrot);
  color: var(--h-ziegelrot);
}

/* ---- Inputs ---- */
.input {
  padding: 0.4em 0.7em;
  border: 1px solid var(--h-border-emphasis);
  border-radius: var(--h-radius);
  background: var(--h-surface);
  color: var(--h-text);
  font-size: var(--h-sm);
  width: 100%;
}
.input:focus-visible {
  outline: 2px solid var(--h-ziegelrot);
  outline-offset: 1px;
  border-color: var(--h-ziegelrot);
}
select.input {
  cursor: pointer;
  padding-right: 1.8em;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: var(--h-radius-sm);
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.4;
  background: var(--h-bg-alt);
  color: var(--h-text-secondary);
  border: 1px solid var(--h-border);
}
.badge--ok      { background: var(--h-olivgruen-subtle); color: var(--h-olivgruen); border-color: var(--h-olivgruen); }
.badge--warn    { background: var(--h-ocker-subtle); color: var(--h-ocker); border-color: var(--h-ocker); }
.badge--info    { background: var(--h-preussischblau-subtle); color: var(--h-preussischblau); border-color: var(--h-preussischblau); }

/* ---- Cards ---- */
.card {
  background: var(--h-surface);
  border: 1px solid var(--h-border);
  border-radius: var(--h-radius);
  padding: var(--h-space-md);
}

/* ---- Toast (used by core.js) ---- */
#zbz-toast-container { position: fixed; top: 70px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--h-anthrazit);
  color: var(--h-text-inverse);
  padding: 0.6em 1em;
  border-radius: var(--h-radius);
  box-shadow: var(--h-shadow-md);
  font-size: var(--h-sm);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--h-transition), transform var(--h-transition);
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast--ok    { background: var(--h-olivgruen); }
.toast--warn  { background: var(--h-ocker); color: var(--h-anthrazit); }
.toast--error { background: var(--h-ziegelrot); }

/* ---- Scrollbar (Webkit) ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--h-bg); }
::-webkit-scrollbar-thumb { background: var(--h-border-emphasis); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--h-text-muted); }

/* ============================================================
   Site-Header (gemeinsame Top-Nav fuer alle Seiten)
   ============================================================ */
.site-header {
  background: var(--h-surface);
  border-bottom: 1px solid var(--h-border);
}
.site-header__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--h-space-md) var(--h-space-xl);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--h-space-md);
  align-items: baseline;
}
.site-header__brand {
  font-family: var(--h-font-heading);
  font-size: var(--h-lg);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
  color: var(--h-text);
  text-decoration: none;
  display: inline-flex;
  gap: var(--h-space-xs);
  align-items: baseline;
  transition: opacity var(--h-transition-fast);
}
.site-header__brand:hover { opacity: 0.75; color: var(--h-text); }
.site-header__brand strong { color: var(--h-ziegelrot); font-weight: 500; }
.site-header__brand span { color: var(--h-text); font-weight: 400; }
.site-header__sub {
  font-style: italic;
  font-size: var(--h-sm);
  color: var(--h-text-muted);
  margin: 0;
}
.site-header__nav {
  display: flex;
  gap: var(--h-space-md);
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
}
.site-header__nav a {
  color: var(--h-text-secondary);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color var(--h-transition-fast), border-color var(--h-transition-fast);
}
.site-header__nav a:hover { color: var(--h-text); }
.site-header__nav a[aria-current="page"] {
  color: var(--h-ziegelrot);
  border-bottom-color: var(--h-ziegelrot);
}
.site-header__nav .site-header__icon {
  display: inline-flex;
  align-items: center;
  align-self: center;
  color: var(--h-text-muted);
  padding-bottom: 0;
  border-bottom: none;
}
.site-header__nav .site-header__icon:hover { color: var(--h-text); }

@media (max-width: 700px) {
  .site-header__inner { grid-template-columns: 1fr; }
  .site-header__sub { display: none; }
}

/* ---- Header centre: subtitle + experimental badge inline ---- */
.site-header__center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--h-space-md);
  min-width: 0;
}
.site-header__exp-badge {
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--h-radius-sm);
  color: var(--h-ziegelrot);
  border: 1px solid var(--h-ziegelrot-light);
  background: var(--h-ziegelrot-subtle);
  cursor: help;
  flex: 0 0 auto;
  user-select: none;
}
.site-header__exp-badge:hover { background: var(--h-ziegelrot-light); color: var(--h-bg); border-color: var(--h-ziegelrot); }

/* ============================================================
   Site-Footer (gemeinsam)
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--h-border);
  margin-top: var(--h-space-2xl);
  background: var(--h-surface);
}
.site-footer__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--h-space-md) var(--h-space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--h-space-lg);
  font-size: var(--h-xs);
  color: var(--h-text-muted);
  flex-wrap: wrap;
}
.site-footer__col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.site-footer__col--right {
  flex-direction: row;
  align-items: center;
  gap: var(--h-space-md);
}
.site-footer a {
  color: var(--h-text-secondary);
  text-decoration: none;
}
.site-footer a:hover { color: var(--h-ziegelrot); }
.site-footer__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--h-text-muted);
  transition: color var(--h-transition-fast);
}
.site-footer__icon:hover { color: var(--h-text); }
.site-footer__generated {
  font-family: var(--h-font-mono);
  color: var(--h-text-muted);
}

/* ============================================================
   Prose-Layout (About-Seite und aehnliche Textseiten)
   ============================================================ */
.prose {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--h-space-2xl) var(--h-space-xl);
}
.prose h1 {
  font-size: var(--h-2xl);
  margin-bottom: var(--h-space-md);
  line-height: 1.2;
}
.prose .lede {
  font-size: var(--h-lg);
  line-height: 1.5;
  color: var(--h-text-secondary);
  margin: 0 0 var(--h-space-2xl);
}
.prose section {
  margin: var(--h-space-2xl) 0;
  padding-top: var(--h-space-lg);
  border-top: 1px solid var(--h-border);
}
.prose section h2 {
  font-size: var(--h-lg);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
  color: var(--h-text-muted);
  margin-bottom: var(--h-space-md);
  font-weight: 500;
}
.prose p { margin: 0 0 var(--h-space-md); line-height: 1.65; }

.prose ul.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.prose ul.feature-list li {
  padding: var(--h-space-sm) 0;
  border-bottom: 1px dotted var(--h-border);
  line-height: 1.5;
}
.prose ul.feature-list li:last-child { border-bottom: none; }
.prose ul.feature-list strong { color: var(--h-ziegelrot); font-weight: 500; }

.prose dl.meta-list {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--h-space-sm) var(--h-space-md);
  margin: 0;
}
.prose dl.meta-list dt {
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
  color: var(--h-text-muted);
  font-weight: 500;
}
.prose dl.meta-list dd { margin: 0; color: var(--h-text); }
.prose dl.meta-list dd a { color: var(--h-ziegelrot); }
@media (max-width: 700px) {
  .prose dl.meta-list { grid-template-columns: 1fr; gap: 2px var(--h-space-md); }
  .prose dl.meta-list dd { margin-bottom: var(--h-space-sm); }
}

.prose ol.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
}
.prose ol.steps li {
  position: relative;
  padding: var(--h-space-sm) 0 var(--h-space-sm) 36px;
  border-bottom: 1px dotted var(--h-border);
  counter-increment: step;
  line-height: 1.5;
}
.prose ol.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: var(--h-space-sm);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--h-bg-alt);
  color: var(--h-text-secondary);
  font-family: var(--h-font-mono);
  font-size: var(--h-xs);
  display: flex;
  align-items: center;
  justify-content: center;
}
.prose ol.steps li:last-child { border-bottom: none; }
.prose ol.steps strong { color: var(--h-text); font-weight: 500; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--h-space-md) 0;
  font-size: var(--h-sm);
}
.prose table caption {
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
  color: var(--h-text-muted);
  text-align: left;
  margin-bottom: var(--h-space-sm);
  font-weight: 500;
}
.prose table th,
.prose table td {
  padding: var(--h-space-sm) var(--h-space-md) var(--h-space-sm) 0;
  border-bottom: 1px dotted var(--h-border);
  text-align: left;
  vertical-align: top;
}
.prose table th {
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
  color: var(--h-text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.prose table td.num,
.prose table th.num {
  font-family: var(--h-font-mono);
  text-align: right;
  white-space: nowrap;
  padding-right: var(--h-space-lg);
}
.prose table tr:last-child td { border-bottom: none; }
.prose table strong { color: var(--h-ziegelrot); font-weight: 500; }
.prose .note {
  font-size: var(--h-xs);
  color: var(--h-text-muted);
  font-style: italic;
  margin-top: var(--h-space-sm);
}

/* ============================================================
   Reduced motion
   ============================================================ */
/* A viewer who asks the system for less motion gets no transitions and no
   animations; the states themselves stay, they arrive without movement. */
@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;
  }
}
