/* ============================================================
   Frey³ Hausverwaltung — Design System
   Tokens → themeable, scalable. Manrope. Light & dark built in.
   ============================================================ */

/* --- 1. Primitives (raw palette, from Lukas' draft) ---------- */
:root {
  /* brand */
  --c-navy-900: #0b2240;
  --c-navy-800: #14355c;
  --c-navy-700: #1e2a38;
  --c-navy-600: #33414f;
  --c-slate-500: #4a5868;
  --c-slate-400: #64748b;
  --c-slate-300: #8a99ab;
  --c-slate-200: #b8c2ce;
  --c-slate-100: #d6dee8;
  --c-slate-050: #eef2f6;
  --c-copper-600: #9e5524;
  --c-copper-500: #b0693a;
  --c-copper-100: #f3e4d7;
  --c-cream: #faf9f5;

  /* type */
  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* spatial rhythm */
  --space-1: 4px;  --space-2: 8px;  --space-3: 16px;  --space-4: 24px;
  --space-5: 32px; --space-6: 48px; --space-7: 72px;  --space-8: 104px;
  --container: 1120px;
  --container-narrow: 720px;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --ease: cubic-bezier(.22,.61,.36,1);
  --dur: .25s;
}

/* --- 2. Semantic tokens (what components consume) ------------- */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--c-cream);
  --bg-raise: #ffffff;
  --bg-inset: var(--c-slate-050);
  --ink: #1b1f24;
  --ink-strong: var(--c-navy-800);
  --ink-muted: var(--c-slate-500);
  --ink-faint: #5d6b7a; /* was slate-400, 2.76:1 → now 5.18:1 AA */
  --line: var(--c-slate-100);
  --line-strong: var(--c-slate-200);
  --accent: var(--c-navy-800);
  --accent-ink: #ffffff;
  --accent-soft: var(--c-slate-050);
  --highlight: var(--c-copper-600);
  --highlight-soft: var(--c-copper-100);
  --shadow-1: 0 1px 2px rgba(11,34,64,.06), 0 4px 16px rgba(11,34,64,.06);
  --shadow-2: 0 2px 6px rgba(11,34,64,.08), 0 16px 40px rgba(11,34,64,.10);
  --hero-ink: var(--accent-ink);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141a21;
  --bg-raise: #1c242d;
  --bg-inset: #10161c;
  --ink: #e4e9ef;
  --ink-strong: #ffffff;
  --ink-muted: var(--c-slate-300);
  --ink-faint: #98a6b4; /* 7.04:1 AA on dark bg */
  --line: #2a343f;
  --line-strong: #38455285;
  --accent: var(--c-slate-100);
  --accent-ink: var(--c-navy-900);
  --accent-soft: #232e39;
  --highlight: #e0a374;
  --highlight-soft: rgba(224,163,116,.12);
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --shadow-2: 0 2px 6px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.45);
  --hero-ink: var(--accent-ink);
}

/* auto-follow system preference unless user chose */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #141a21; --bg-raise: #1c242d; --bg-inset: #10161c;
    --ink: #e4e9ef; --ink-strong: #fff; --ink-muted: var(--c-slate-300);
    --ink-faint: #98a6b4; /* 7.04:1 AA on dark */ --line: #2a343f; --line-strong: #38455285;
    --accent: var(--c-slate-100); --accent-ink: var(--c-navy-900);
    --accent-soft: #232e39; --highlight: #e0a374;
    --highlight-soft: rgba(224,163,116,.12);
    --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    --shadow-2: 0 2px 6px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.45);
    --hero-ink: var(--accent-ink);
  }
}

/* --- 3. Base ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[id] { scroll-margin-top: 96px; /* below sticky header */ }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
h1, h2, h3, h4 {
  color: var(--ink-strong);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-3);
  font-weight: 800;
  text-wrap: balance; /* no manual breaks needed; balanced lines */
}
h1 { font-size: clamp(2.2rem, 5.4vw, 3.6rem); }
h2 { font-size: clamp(1.7rem, 3.6vw, 2.4rem); }
h3 { font-size: 1.15rem; letter-spacing: -0.01em; }
p  { margin: 0 0 var(--space-3); }
a  { color: inherit; text-decoration: none; }
img{ max-width: 100%; display: block; }
sup:where(h1 *, h2 *, h3 *) { color: var(--highlight); }

/* contact band: full-bleed navy, big headline, CTA right (hierarchie per original) */
.contact-band { background: var(--c-navy-900); }
.contact-inner {
  display: grid; gap: var(--space-4); align-items: center;
  grid-template-columns: 2fr 1fr;   /* text 2/3, CTA 1/3 */
  padding-block: var(--space-7);
}
.contact-copy { display: flex; flex-direction: column; gap: var(--space-4); }
@media (max-width: 700px) { .contact-inner { grid-template-columns: 1fr; } }
.contact-inner h2 { margin: 0; }
.contact-line { margin: 0; }
.contact-inner > .btn { margin: 0; }
.contact-band h2 { color: #ffffff; font-size: clamp(2rem, 4.2vw, 3rem); }
.contact-band h2 sup { color: #e0a374; }
.contact-band .muted { color: #b8c9d8; }
.contact-line { font-weight: 800; color: #ffffff; }
.contact-line a { color: inherit; text-decoration: underline; text-underline-offset: 4px; }

.contact-inner { text-align: left; }

/* split section head: content left, vertically-centered link right */
.split-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-5); max-width: none;
}
.split-head > div:first-child { min-width: 0; }
.split-head .head-link { margin: 0; flex-shrink: 0; }
.split-head h2 { margin: 8px 0; font-size: clamp(1.5rem, 3.6vw, 2.4rem); }
.head-link {
  font-weight: 700; color: var(--ink-strong); white-space: nowrap;
  text-decoration: underline; text-underline-offset: 6px;
  text-decoration-color: var(--line-strong);
  transition: text-decoration-color var(--dur);
}
.head-link:hover { text-decoration-color: var(--ink-strong); }
@media (max-width: 560px) { .split-head { flex-wrap: wrap; } .split-head > div:first-child { flex-basis: 100%; } }

/* keyboard focus — always visible */
:focus-visible { outline: 3px solid var(--highlight); outline-offset: 2px; border-radius: 4px; }

.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--space-4); }
.narrow { max-width: var(--container-narrow); }

/* --- 4. Components ------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 14px 26px;
  border-radius: 999px;
  font-weight: 700; font-size: .95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-1); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { border-color: var(--line-strong); color: var(--ink-strong); background: transparent; }
.btn .arrow { transition: transform var(--dur) var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

.eyebrow {
  display: inline-block;
  font-size: .78rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--highlight);
  margin-bottom: var(--space-2);
}

/* cards are informational, not interactive → no hover affordance
   (hover replies only on genuinely clickable elements: links, buttons) */
.card {
  background: var(--bg-raise);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card a, .btn { position: relative; z-index: 1; }
a:hover, a:focus-visible { text-decoration-thickness: 2px; }
.card ul { list-style: none; padding: 0; margin: 0; }
.card li { position: relative; padding-left: 26px; margin-bottom: 10px; color: var(--ink-muted); }
.card li::before { content: "→"; position: absolute; left: 0; top: -1px; color: var(--highlight); font-weight: 800; line-height: 1.6; }

.grid { display: grid; gap: var(--space-4); }
.grid > * { min-width: 0; overflow-wrap: break-word; hyphens: auto; }
.card h3 { hyphens: auto; }
@media (min-width: 760px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* --- Header ---------------------------------------------------- */
.header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; color: var(--ink-strong); letter-spacing: -0.02em; }
.brand img { width: 34px; height: auto; }
.nav { display: none; gap: clamp(12px, 1.6vw, 24px); font-weight: 600; font-size: .95rem; color: var(--ink-muted); }
.nav a { white-space: nowrap; }
.nav a:hover { color: var(--ink-strong); }
.nav a[aria-current="page"] { color: var(--ink-strong); text-decoration: underline; text-underline-offset: 7px; text-decoration-thickness: 2px; text-decoration-color: var(--highlight); }
@media (min-width: 900px) { .nav { display: flex; } }

/* mobile navigation — native <details>, keyboard-accessible */
.mobile-nav { display: grid; border-top: 1px solid var(--line); padding: 4px 0 12px; }
.mobile-nav summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink-strong); padding: 12px 4px; }
.mobile-nav summary::-webkit-details-marker { display: none; }
.mobile-links { display: grid; }
.mobile-links a { padding: 12px 4px; border-top: 1px solid var(--line); color: var(--ink-muted); font-weight: 600; }
.mobile-links a[aria-current="page"] { color: var(--ink-strong); }
@media (min-width: 900px) { .mobile-nav { display: none; } }

/* data tables */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { color: var(--ink-strong); font-weight: 800; border-bottom: 2px solid var(--line-strong); }
.table tbody tr:hover td { background: var(--bg-inset); }
.table caption { text-align: left; font-weight: 700; color: var(--ink-strong); padding-bottom: 10px; }

/* form fields */
.input { width: 100%; padding: 12px 14px; margin-top: 6px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg-raise); color: var(--ink); font: inherit; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.form-row > label { flex: 1; min-width: 150px; }
.form-label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 4px; color: var(--ink-strong); }
.form-note { font-size: .8rem; color: var(--ink-muted); margin-top: 10px; }
.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.btn { white-space: nowrap; }
/* brand collapses to logo when the fixed-width nav needs the room */
@media (min-width: 900px) and (max-width: 1159px) {
  .brand-text { display: none; }
}

/* keep header on one line: compress between 900–1280px */
@media (min-width: 900px) and (max-width: 1280px) {
  .header-inner { gap: var(--space-3); }
  .brand { font-size: .85rem; }
  .brand img { width: 28px; }
  .nav { font-size: .9rem; }
  .btn { padding: 11px 20px; font-size: .88rem; }
}
.theme-toggle {
  background: none; border: 1px solid var(--line-strong); color: var(--ink-strong);
  width: 44px; height: 44px; border-radius: 999px; cursor: pointer; /* ≥44px touch target */
  display: grid; place-items: center; font-size: 1.05rem;
  transition: transform var(--dur) var(--ease);
}
.theme-toggle:hover { transform: rotate(15deg) scale(1.06); }

/* --- Hero ------------------------------------------------------ */
/* inverse artwork on dark backgrounds (ink -> white, copper preserved via hue-rotate) */
.hero-grid img { filter: invert(1) hue-rotate(180deg); }
:root[data-theme="dark"] .story img,
:root:not([data-theme]) .story img { filter: invert(1) hue-rotate(180deg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .story img { filter: invert(1) hue-rotate(180deg); } }

/* hero: text left, drawing right (stacked on mobile) */
.hero-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); }
.hero-grid > div:last-child { display: grid; place-items: center; }
.hero-grid img { width: 100%; max-width: 460px; height: auto; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }

/* story scribbles: three equal spots in a 3x1 row, no card frames */
.story-grid > * { display: flex; flex-direction: column; }
.story-grid img { width: 100%; max-width: 200px; height: auto; margin-bottom: 12px; }
/* navy hero band — identical in light & dark, white text by design */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(158,85,36,.35), transparent 60%),
    linear-gradient(160deg, #0b2240, #14355c 65%, #1d3d63);
}
.hero-inner { position: relative; z-index: 1; padding-block: var(--space-8) 0; max-width: 760px; }
.hero::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(closest-side at 70% 30%, black, transparent);
  pointer-events: none;
}
.hero h1 { color: #ffffff; }
.hero h1 sup { color: #e0a374; }
.hero p  { color: #c9d5e2; font-size: 1.08rem; max-width: 58ch; }
.hero .eyebrow { color: #e0a374; }
.hero .btn-primary { background: #ffffff; color: #14355c; }
.hero .btn-ghost { border-color: rgba(255,255,255,.35); color: #fff; }
.hero .stat { border-left: 1px solid rgba(255,255,255,.15); }
.hero .stat b { color: #ffffff; }
.hero .stat span { color: #9fb2c4; }

.hero-stats {
  position: relative; z-index: 1;
  display: grid; gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  border-top: 1px solid rgba(255,255,255,.15);
  margin-top: var(--space-6);
}
/* stats — theme-color by default, hero (navy) overrides */
.stat { padding: var(--space-4) var(--space-3); border-left: 1px solid var(--line-strong); }
.stat b { display: block; font-size: 1.5rem; color: var(--ink-strong); letter-spacing: -0.02em; }
.stat span { font-size: .85rem; color: var(--ink-muted); }
.hero .stat { border-left: 1px solid rgba(255,255,255,.15); }
.hero .stat b { color: #fff; }
.hero .stat span { color: #9fb2c4; }

/* --- Sections --------------------------------------------------- */
section { padding-block: var(--space-7); }
.section-head { max-width: 640px; margin-bottom: var(--space-5); }
@media (max-width: 640px) { .split-head h2, .section-head h2[style*="nowrap"] { white-space: normal; } }
.muted { color: var(--ink-muted); }

.steps { counter-reset: step; }
.step {
  position: relative;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-raise);
}
.step::before {
  counter-increment: step;
  content: "SCHRITT " counter(step);
  display: inline-block;
  font-size: .72rem; font-weight: 800; letter-spacing: .12em;
  color: var(--highlight);
  margin-bottom: 8px;
}

/* standalone stats strip (outside hero): navy band per original design */
.stats-band { background: var(--c-navy-900); }
.stats-band .stat b { color: #ffffff; }
.stats-band .stat span { color: #9fb2c4; }
.stats-band .stat { border-left: 1px solid rgba(255,255,255,.18); }

.banner {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
}
.banner h2 { color: var(--accent-ink); }
.banner .muted { color: color-mix(in srgb, var(--accent-ink) 70%, transparent); }

/* name story */
.story { background: var(--bg-inset); }
.story-word { font-size: .8rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }
.story-eq { font-size: 2.4rem; font-weight: 800; color: var(--ink-strong); letter-spacing: -0.02em; margin-bottom: var(--space-4); }
.story-eq sup { color: var(--highlight); }

.bio-grid { display: grid; gap: var(--space-5); align-items: center; }
@media (min-width: 760px) { .bio-grid { grid-template-columns: 300px 1fr; } }

.quote {
  border-left: 3px solid var(--highlight);
  padding-left: var(--space-4);
  font-size: 1.5rem; /* one scale level up from body/lead */
  font-weight: 600; color: var(--ink-strong);
  line-height: 1.45;
}
.person { display: flex; align-items: center; gap: 14px; margin-top: var(--space-4); }
.person .avatar {
  width: 52px; height: 52px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800;
}
.person b { display: block; color: var(--ink-strong); }
.person span { font-size: .9rem; color: var(--ink-muted); }

.cred { display: flex; gap: var(--space-3); align-items: flex-start; }
.cred .tag {
  flex-shrink: 0;
  font-weight: 900; font-size: .85rem;
  color: var(--highlight);
  background: var(--highlight-soft);
  padding: 6px 12px; border-radius: 999px;
}

/* map */
.map-legend b { color: var(--highlight); }

/* contact / footer */
.contact-box { display: grid; gap: var(--space-5); }
@media (min-width: 860px) { .contact-box { grid-template-columns: 1.1fr .9fr; align-items: start; } }
/* Einzugsgebiet: vertical line, Lahr highlighted with a copper segment */
.area-timeline {
  list-style: none; margin: 24px 0 0 8px; padding: 0;
  position: relative;
}
.area-timeline::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--line);
  border-radius: 2px;
}
.area-timeline li { position: relative; padding: 14px 0 14px 36px; }

/* copper segment on the line marking Lahr (3rd item) */
.area-timeline li:nth-child(3)::before {
  content: ""; position: absolute; left: 0; top: -10px; bottom: -10px;
  width: 4px; background: var(--c-copper-600); border-radius: 2px;
}

.footer {
  /* one step darker than the navy contact band (#0b2240) above it */
  background: #081c33; color: #b8c9d8;
  padding-block: var(--space-6); font-size: .9rem;
}
.footer a, .footer b { color: #eef2f6; }
.footer a:hover { color: #ffffff; }
.footer-inner { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: center; }
.footer nav { display: flex; gap: var(--space-4); }
.footer a:hover { color: var(--ink-strong); }

/* reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 12px; top: 12px; background: var(--bg-raise); padding: 8px 14px; border-radius: 8px; z-index: 100; }
