/* ==========================================================================
   Trixi's Spur N — modernes Layout
   Modelleisenbahn-Thema · wählbare Themes (CSS Custom Properties)
   ========================================================================== */

/* ---------- Reset / Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color .3s ease, color .3s ease;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
ul { padding-left: 1.2em; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px);
}

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

/* ---------- Theme-Variablen ---------- */
:root {
  --maxw: 1200px;
  --radius: 16px;
  --radius-sm: 10px;

  /* Standard = "Klassik Grün" */
  --bg: #eef2ee;
  --bg-alt: #e2ebe3;
  --surface: #ffffff;
  --surface-2: #f2f6f2;
  --text: #1e2a20;
  --text-muted: #5a685c;
  --border: #d6e0d7;
  --accent: #2e7d32;
  --accent-strong: #1b5e20;
  --accent-soft: #ddeede;
  --accent-contrast: #ffffff;
  --rail: #2c3138;
  --sleeper: #8a6a44;
  --header-bg: rgba(255, 255, 255, .86);
  --hero-overlay: linear-gradient(180deg, rgba(20,32,22,.88), rgba(20,32,22,.55));
  --shadow: 0 10px 30px rgba(30,42,32,.12);
  --shadow-sm: 0 2px 10px rgba(30,42,32,.08);
  --scrollbar: #b9cbbb;
}

/* Nachtbetrieb */
[data-theme="nacht"] {
  --bg: #12161a;
  --bg-alt: #1a2026;
  --surface: #1e252c;
  --surface-2: #232c34;
  --text: #e8eef0;
  --text-muted: #9fb0b4;
  --border: #2e3941;
  --accent: #7ad56e;
  --accent-strong: #9fea94;
  --accent-soft: #1e3a22;
  --accent-contrast: #0d120e;
  --rail: #0a0c0e;
  --sleeper: #4a4135;
  --header-bg: rgba(18,22,26,.88);
  --hero-overlay: linear-gradient(180deg, rgba(6,10,12,.9), rgba(6,10,12,.6));
  --shadow: 0 10px 30px rgba(0,0,0,.5);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.4);
  --scrollbar: #334049;
}

/* Signal Rot */
[data-theme="signal"] {
  --bg: #faf3f1;
  --bg-alt: #f3e7e3;
  --surface: #ffffff;
  --surface-2: #fbeeea;
  --text: #2b1d1b;
  --text-muted: #6d554f;
  --border: #ecd6cf;
  --accent: #c62828;
  --accent-strong: #8e1b1b;
  --accent-soft: #f8dfdb;
  --accent-contrast: #ffffff;
  --rail: #34282a;
  --sleeper: #7d5b47;
  --header-bg: rgba(255,255,255,.88);
  --hero-overlay: linear-gradient(180deg, rgba(50,20,18,.9), rgba(50,20,18,.55));
  --shadow: 0 10px 30px rgba(90,40,34,.14);
  --shadow-sm: 0 2px 10px rgba(90,40,34,.09);
  --scrollbar: #e4c3bb;
}

/* Stahlblau */
[data-theme="stahlblau"] {
  --bg: #eef3f7;
  --bg-alt: #e1eaf1;
  --surface: #ffffff;
  --surface-2: #f1f6fa;
  --text: #17232e;
  --text-muted: #52636f;
  --border: #d4e0e9;
  --accent: #1565c0;
  --accent-strong: #0d47a1;
  --accent-soft: #dcebfa;
  --accent-contrast: #ffffff;
  --rail: #26313a;
  --sleeper: #6f6a55;
  --header-bg: rgba(255,255,255,.88);
  --hero-overlay: linear-gradient(180deg, rgba(10,25,40,.9), rgba(10,25,40,.55));
  --shadow: 0 10px 30px rgba(20,40,60,.14);
  --shadow-sm: 0 2px 10px rgba(20,40,60,.09);
  --scrollbar: #c0d3e2;
}

/* Fahrplan Sepia */
[data-theme="sepia"] {
  --bg: #f6efe2;
  --bg-alt: #efe4d1;
  --surface: #fffaf1;
  --surface-2: #f4ecdd;
  --text: #2e2620;
  --text-muted: #6f6353;
  --border: #e3d5bd;
  --accent: #8d6e3f;
  --accent-strong: #6b4f28;
  --accent-soft: #eee0c6;
  --accent-contrast: #ffffff;
  --rail: #3a3228;
  --sleeper: #7c5b33;
  --header-bg: rgba(250,244,233,.9);
  --hero-overlay: linear-gradient(180deg, rgba(46,38,26,.9), rgba(46,38,26,.55));
  --shadow: 0 10px 30px rgba(90,70,40,.14);
  --shadow-sm: 0 2px 10px rgba(90,70,40,.1);
  --scrollbar: #dcc9a6;
}

/* ---------- Scrollbar (dezent) ---------- */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; }

/* ---------- Kopfzeile / Navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 66px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 44px; height: 44px; flex: none; color: var(--accent); }
.brand-text { line-height: 1.1; min-width: 0; }
.brand-name { font-size: 1.12rem; font-weight: 700; color: var(--text); letter-spacing: .2px; white-space: nowrap; }
.brand-tag  { font-size: .72rem; color: var(--text-muted); letter-spacing: .4px; text-transform: uppercase; white-space: nowrap; }

.main-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.main-nav a {
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 500;
  transition: background .2s ease, color .2s ease;
}
.main-nav a:hover { color: var(--accent-strong); background: var(--accent-soft); }
.main-nav a.active { color: var(--accent-strong); background: var(--accent-soft); }

/* Theme-Umschalter */
.theme-toggle { position: relative; margin-left: 8px; }
.theme-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 999px;
  cursor: pointer; font-size: .88rem; font-weight: 500;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.theme-btn:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.theme-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 2px rgba(0,0,0,.08); }
.theme-btn .caret { font-size: .6rem; opacity: .6; }
.theme-panel {
  position: absolute; right: 0; top: calc(100% + 10px);
  width: 230px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 8px;
  display: none; z-index: 60;
}
.theme-panel.open { display: block; animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.theme-panel button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--text); padding: 9px 10px; border-radius: 8px; cursor: pointer;
  font-size: .9rem; font-family: inherit;
}
.theme-panel button:hover { background: var(--surface-2); }
.theme-panel button[aria-checked="true"] { color: var(--accent-strong); font-weight: 600; }
.theme-panel button[aria-checked="true"]::after { content: "✓"; margin-left: auto; }
.swatch { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(0,0,0,.08); }

/* Mobile-Navigation */
.nav-toggle {
  display: none; margin-left: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; width: 42px; height: 42px; cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.nav-toggle span { width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #f4f8f5;
  background: var(--rail);
}
.hero-bg {
  position: absolute; inset: 0;
  background-image: url("../selbstbau/raffinerie/Ende.JPG");
  background-size: cover; background-position: center;
  filter: saturate(.9);
}
.hero-bg::after { content: ""; position: absolute; inset: 0; background: var(--hero-overlay); }
.hero-inner { position: relative; z-index: 2; padding: clamp(56px, 10vw, 120px) 16px clamp(150px, 18vw, 200px); }
.hero-kicker {
  display: inline-block; font-size: .78rem; letter-spacing: 2.5px;
  text-transform: uppercase; color: #dff3e3;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
  padding: 6px 14px; border-radius: 999px; margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); font-weight: 800; margin-bottom: .2em; color: #ffffff; letter-spacing: -.5px; }
.hero h1 span { color: var(--accent); }
.hero-sub { max-width: 620px; font-size: clamp(1.02rem, 2.4vw, 1.28rem); color: #e7efe9; margin-bottom: 28px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 34px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px;
  font-size: .98rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-strong); color: var(--accent-contrast); transform: translateY(-1px); }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.4); }
.btn-ghost:hover { background: rgba(255,255,255,.22); color: #fff; }

.hero-stats { display: flex; flex-wrap: wrap; gap: 26px; }
.hero-stat b { display: block; font-size: 1.5rem; font-weight: 800; color: #fff; }
.hero-stat span { font-size: .82rem; color: #cddcd2; }

/* Gleis + fahrender Zug */
.hero-track { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; }
.hero-track-rail {
  height: 20px;
  background:
    linear-gradient(var(--rail) 0 0) 0 4px / 100% 3px no-repeat,
    linear-gradient(var(--rail) 0 0) 0 15px / 100% 3px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 22px, var(--sleeper) 22px 34px) 0 6px / 100% 9px no-repeat;
  opacity: .85;
}
.hero-train {
  position: absolute; bottom: 15px; left: 0;
  height: 60px; width: auto; max-width: none;
  animation: train-run 20s linear infinite;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.35));
}
@keyframes train-run {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100vw); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-train { animation: none; display: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Abschnitte ---------- */
section { padding: clamp(44px, 7vw, 84px) 0; }
.section-alt { background: var(--bg-alt); }
.section-head { max-width: 720px; margin-bottom: 34px; }
.kicker {
  display: inline-block; font-size: .72rem; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase; color: var(--accent);
  margin-bottom: 10px;
}
.section-head h2 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); font-weight: 800; letter-spacing: -.3px; }
.section-head p { color: var(--text-muted); margin: 0; }

/* Schienen-Trenner */
.rail-divider { height: 8px; opacity: .45; margin: 0; position: relative; }
.rail-divider::before {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(var(--rail) 0 0) 0 1px / 100% 2px no-repeat,
    linear-gradient(var(--rail) 0 0) 0 6px / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 16px, var(--sleeper) 16px 24px) 0 2px / 100% 5px no-repeat;
}

.feature-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
  margin-bottom: 12px;
}
.feature-icon svg { width: 24px; height: 24px; }

/* ---------- Karten ---------- */
.grid { display: grid; gap: 22px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--accent); }
.card-media {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  background: linear-gradient(135deg, var(--bg-alt), var(--surface-2));
}
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card:hover .card-media img { transform: scale(1.05); }
.card-media .badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--accent); color: var(--accent-contrast);
  font-size: .7rem; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; padding: 4px 10px; border-radius: 999px;
}
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-body h3 { font-size: 1.04rem; margin: 0; }
.card-body h3 a { color: var(--text); }
.card-body h3 a:hover { color: var(--accent-strong); }
.card-body p { margin: 0; color: var(--text-muted); font-size: .92rem; flex: 1; }
.card-link { font-size: .86rem; font-weight: 600; color: var(--accent); }
.card-link::after { content: " →"; }

/* App-Karten (Logo zentriert) */
.card-media.logo-media { display: grid; place-items: center; padding: 24px; }
.card-media.logo-media img { width: auto; max-width: 120px; max-height: 160px; height: auto; object-fit: contain; }

/* ---------- Software-Detail (sw-Ordner) ---------- */
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.sw-card .card-media { aspect-ratio: 16 / 10; }
.card-media.no-img {
  display: grid; place-items: center;
  font-size: 3.4rem; font-weight: 800; letter-spacing: 1px;
  color: var(--accent); background: var(--accent-soft);
}
.sw-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.btn-sm { padding: 9px 16px; font-size: .88rem; }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent-soft); color: var(--accent-strong); }
.cta-bar { margin-top: 26px; text-align: center; }

/* ---------- Filter ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  padding: 7px 15px; border-radius: 999px; font-size: .86rem; font-weight: 500; cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.chip.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.search-input {
  width: 100%; max-width: 360px; padding: 11px 16px; margin-bottom: 18px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: .94rem; font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Software ---------- */
.soft-card { flex-direction: row; align-items: center; }
.soft-card .card-body { padding: 16px 18px; }
.soft-icon {
  width: 52px; height: 52px; flex: none; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.4rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-strong);
  margin: 16px 0 16px 16px;
}
.tag { font-size: .7rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--accent-strong); background: var(--accent-soft); padding: 3px 9px; border-radius: 6px; display: inline-block; }

/* ---------- Downloads ---------- */
.dl-list { display: grid; gap: 12px; }
.dl-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.dl-item:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.dl-icon {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-weight: 800; font-size: .8rem;
  background: var(--accent-soft); color: var(--accent-strong);
}
.dl-meta { flex: 1; min-width: 0; }
.dl-meta b { display: block; color: var(--text); }
.dl-meta span { font-size: .8rem; color: var(--text-muted); }
.dl-size { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }

/* ---------- Video ---------- */
.video-card .card-media { color: #fff; background: linear-gradient(160deg, #26313a, #11161b); }
.play-badge {
  position: absolute; top: 50%; left: 50%;
  width: 64px; height: 45px; margin: -22px 0 0 -32px;
  background: #f00; border-radius: 10px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  transition: transform .2s ease;
}
.play-badge::before {
  content: ""; width: 0; height: 0;
  border-style: solid; border-width: 9px 0 9px 16px;
  border-color: transparent transparent transparent #fff;
  margin-left: 4px;
}
.video-card:hover .play-badge { transform: scale(1.1); }

/* ---------- Projekt-Detailseiten ---------- */
.project-head { padding: clamp(28px, 5vw, 48px) 0 8px; }
.back-link { display: inline-block; margin-bottom: 14px; font-size: .88rem; font-weight: 600; color: var(--accent); }
.back-link:hover { color: var(--accent-strong); }
.project-title { font-size: clamp(1.5rem, 3.6vw, 2.2rem); font-weight: 800; letter-spacing: -.3px; margin: 0 0 18px; }
.project-article { max-width: 860px; margin: 0 auto; padding-bottom: clamp(40px, 6vw, 72px); }
.project-article p { margin: 0 0 1em; }
.project-article h1, .project-article h2, .project-article h3, .project-article h4 { color: var(--text); }
.project-article img { max-width: 100%; height: auto; border: 0; border-radius: var(--radius-sm); }
.project-article iframe { max-width: 100%; border: 0; border-radius: var(--radius-sm); }
.project-article hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.project-article a { color: var(--accent); }
.project-article font { font-family: inherit !important; font-size: inherit !important; color: inherit !important; }
.project-article table { max-width: 100%; border-collapse: collapse; }

/* ---------- Kontakt / Footer ---------- */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; }
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.contact-card h3 { font-size: 1.05rem; }
.contact-card p { color: var(--text-muted); margin: 0 0 10px; font-size: .94rem; }
.mail { font-weight: 600; }

.site-footer { background: var(--rail); color: #cbd6cd; padding: 44px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 30px; margin-bottom: 30px; }
.footer-grid h4 { color: #fff; font-size: .95rem; margin-bottom: 12px; }
.footer-grid a { color: #b9c8bc; display: block; padding: 3px 0; }
.footer-grid a:hover { color: #fff; }
.footer-brand { color: #aebdb0; }
.footer-note { border-top: 1px solid rgba(255,255,255,.14); padding-top: 20px; font-size: .82rem; color: #93a498; }
.footer-note a { color: #c6d5c9; }
.legal { margin-top: 12px; font-size: .78rem; color: #7f8f82; }

/* Back to top */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent); color: var(--accent-contrast);
  border: 0; cursor: pointer; font-size: 1.1rem;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { transform: translateY(-3px); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .main-nav { display: none; }
  .nav-toggle { display: flex; }
  .main-nav.mobile-open {
    display: flex; flex-direction: column; align-items: stretch;
    position: absolute; top: 66px; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 10px 16px 16px; gap: 2px;
  }
  .main-nav.mobile-open a { padding: 11px 12px; border-radius: 10px; }
  .footer-grid { grid-template-columns: 1fr; }
  .soft-card { flex-direction: column; align-items: stretch; }
  .soft-icon { margin: 16px 16px 0; }
}

@media (max-width: 560px) {
  .brand-tag { display: none; }
  .grid-cards { grid-template-columns: 1fr 1fr; }
  .hero-stats { gap: 16px; }
  .hero-train { height: 42px; }
}
