/* Grundlayout: Reset, Typografie, Kopfleiste, Navigation, Fußzeile. */

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01";
  /* Leuchtfeuer: schwaches Glutlicht von oben auf warmem Fast-Schwarz */
  background:
    radial-gradient(ellipse 70rem 28rem at 50% -8rem, var(--ember-faint), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
}

/* Feine Asche-Körnung über allem (inline SVG, keine externen Requests) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.9 0 0 0 0 0.8 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

img, svg, video, iframe { max-width: 100%; }
.icon { width: 18px; height: 18px; flex: none; }
img { height: auto; }

::selection { background: var(--ember-soft); color: var(--text); }

/* ---------- Typografie ---------- */

h1, h2, h3, h4 { margin: 0 0 var(--s-3); line-height: 1.2; text-wrap: balance; }

h1, h2, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: var(--track-display);
}

h1 { font-size: var(--fs-2xl); line-height: 1.1; }
h2 { font-size: var(--fs-lg); margin-top: var(--s-8); }
h2:first-child { margin-top: 0; }
h3 { font-size: var(--fs-md); font-weight: 600; }
h4 { font-size: var(--fs-base); font-weight: 600; }

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

ul, ol { padding-left: var(--s-6); }

a {
  color: var(--ember);
  text-decoration: underline;
  text-decoration-color: var(--ember-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease), text-decoration-color var(--dur-fast) var(--ease);
}
a:hover { color: var(--ember-bright); text-decoration-color: currentColor; }

code, pre { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.9em; }
code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

hr { border: 0; height: 1px; background: var(--line); margin: var(--s-8) 0; }

strong { font-weight: 650; }

/* Sichtbarer Fokus auf allen interaktiven Elementen */
:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

/* ---------- Hilfsklassen ---------- */

.wrap {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--s-4);
}
@media (min-width: 760px) { .wrap { padding-inline: var(--s-6); } }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute; left: var(--s-4); top: -100px; z-index: 50;
  padding: var(--s-2) var(--s-4);
  background: var(--ember); color: var(--ember-ink);
  border-radius: var(--radius-control);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--s-2); color: var(--ember-ink); }

.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.error { color: var(--danger); }
.success { color: var(--ok); }
.warning { color: var(--gold); }
.grow { flex: 1; min-width: 0; }
.narrow { max-width: 32rem; }
.row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.stack > * + * { margin-top: var(--s-4); }
form.inline { display: inline; margin: 0; }

/* Glutlinie: das wiederkehrende Motiv – eine Linie, die von einer Glutquelle aus verglimmt */
.ember-line {
  height: 1px;
  border: 0;
  margin: 0;
  background: linear-gradient(90deg, transparent, var(--line) 15%, var(--ember) 50%, var(--line) 85%, transparent);
}

/* ---------- Kopfleiste ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-header .ember-line { opacity: 0.7; }

.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-6);
  min-height: 64px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--tap);
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-md);
  letter-spacing: var(--track-display);
  white-space: nowrap;
}
.wordmark:hover { color: var(--text); }
.wordmark .flame { width: 18px; height: 24px; flex: none; filter: drop-shadow(0 0 6px var(--ember-soft)); }
.flame .f-outer { fill: var(--ember); }
.flame .f-inner { fill: var(--gold); }
.wordmark:hover .flame { filter: drop-shadow(0 0 10px var(--ember)); }

.mainnav { display: flex; gap: var(--s-1); }

.navlink {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--s-3);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  border-radius: var(--radius-control);
}
.navlink:hover { color: var(--text); }
.navlink[aria-current="page"] { color: var(--text); }
.navlink[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: var(--s-3); right: var(--s-3); bottom: 6px;
  height: 2px;
  border-radius: 2px;
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* Nutzermenü */
.usermenu { position: relative; }
.usermenu > summary,
.mobilenav > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-2) 0 var(--s-1);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--text);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.usermenu > summary::-webkit-details-marker,
.mobilenav > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover,
.usermenu[open] > summary { background: var(--bg-raised); border-color: var(--line); }
.usermenu-name { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.usermenu .chevron { width: 16px; height: 16px; color: var(--text-muted); transition: transform var(--dur) var(--ease); }
.usermenu[open] .chevron { transform: rotate(180deg); }

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--s-2));
  z-index: 40;
  min-width: 15rem;
  padding: var(--s-2);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-overlay);
}
.menu-head { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--line); margin-bottom: var(--s-2); }
.menu-head strong { display: block; }
.menu-head span { font-size: var(--fs-sm); color: var(--text-muted); }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover { background: var(--bg-hover); color: var(--text); }
.menu-item svg { width: 18px; height: 18px; color: var(--text-muted); flex: none; }
.menu-sep { height: 1px; background: var(--line); margin: var(--s-2) 0; }
.menu-panel form { margin: 0; }

/* Mobile Navigation über <details> */
.mobilenav { display: none; margin-left: auto; }
.mobilenav > summary {
  padding: 0 var(--s-4);
  border-color: var(--line);
  border-radius: var(--radius-control);
  font-weight: 600;
}
.mobilenav > summary svg { width: 20px; height: 20px; }
.mobilenav[open] > summary { background: var(--bg-raised); }
.mobilenav .icon-close { display: none; }
.mobilenav[open] .icon-close { display: block; }
.mobilenav[open] .icon-menu { display: none; }

.mobilenav-panel {
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  z-index: 40;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  padding: var(--s-3) var(--s-4) var(--s-6);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-overlay);
}
.mobilenav-panel .menu-item { font-size: var(--fs-md); }
.mobilenav-panel .mobilenav-primary .menu-item {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: var(--track-display);
  font-size: var(--fs-lg);
  min-height: 52px;
}
.mobilenav-panel .menu-item[aria-current="page"] { color: var(--ember); }
.mobilenav-actions { display: grid; gap: var(--s-2); margin-top: var(--s-3); }

@media (max-width: 759.98px) {
  .mainnav, .header-actions { display: none; }
  .mobilenav { display: block; }
  .header-inner { min-height: 60px; }
  h1 { font-size: var(--fs-xl); }
}

/* ---------- Inhalt ---------- */

.hero-slot { width: 100%; }

main {
  flex: 1;
  width: 100%;
  padding-block: var(--s-8) var(--s-16);
}

/* ---------- Fußzeile ---------- */

.site-footer {
  margin-top: auto;
  background: var(--bg-sunken);
}
.site-footer .ember-line { opacity: 0.45; }

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4) var(--s-8);
  padding-block: var(--s-8);
}
.footer-brand { display: grid; gap: var(--s-1); }
.footer-brand .wordmark { font-size: var(--fs-base); min-height: 0; }
.footer-motto {
  font-family: var(--font-display);
  letter-spacing: var(--track-wide);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.footer-nav { display: flex; flex-wrap: wrap; gap: 0 var(--s-2); margin-inline: calc(-1 * var(--s-2)); }
.footer-nav a { font-size: var(--fs-sm); }

/* ---------- Bewegung reduzieren ---------- */

@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;
  }
}
