/* ==========================================================================
   Basis: Reset, Typografie, Layout, Flächen, Fokus.
   Grundlage: cg-smartsolutions-claude-code-paket/DESIGN.md Abschnitt 3, 4, 7, 8.
   Farben und Schriftfamilien nur aus tokens.css. Komponenten folgen in
   components.css.
   ========================================================================== */

/* ---------- Fließende Größen ----------------------------------------------
   Linear von 360px (Mobil-Zielwert, DESIGN.md §7) bis 1440px (Entwurf).
   Formel: clamp(min, min - k*360px + k*100vw, max), k = (max - min) / 1080 */
:root {
  --fs-h1-home:  clamp(40px, 32.00px + 2.222vw, 64px);  /* 64 -> 40 */
  --fs-h1:       clamp(40px, 29.33px + 2.963vw, 72px);  /* 72 -> 40 */
  --fs-h2-lg:    clamp(34px, 28.00px + 1.667vw, 52px);  /* 52 -> 34 */
  --fs-h2:       clamp(32px, 27.33px + 1.296vw, 46px);  /* 46 -> 32 */
  --fs-h3-lg:    clamp(30px, 26.67px + 0.926vw, 40px);  /* 40 -> 30 */
  --fs-h3:       clamp(28px, 26.00px + 0.556vw, 34px);  /* 34 -> 28 */
  --fs-h4:       clamp(24px, 22.67px + 0.370vw, 28px);  /* 28 -> 24, Serif nie unter 24 */
  --fs-num-lg:   clamp(44px, 37.33px + 1.852vw, 64px);  /* 64 -> 44 */
  --fs-num:      clamp(28px, 26.67px + 0.370vw, 32px);  /* Ziffer in Karten */
  --fs-num-sm:   24px;                                  /* Ziffer im Mega-Menü */
  --fs-lead:     clamp(18px, 17.00px + 0.278vw, 21px);  /* 21 -> 18 */
  --fs-body:     17px;                                  /* bleibt auf allen Breiten */
  --fs-step:     18px;
  --fs-card:     16px;
  --fs-nav:      16px;
  --fs-footer:   15px;
  --fs-small:    14px;
  --fs-note:     13px;

  --section-y-compact: 72px;
  --section-y-hero:    88px;
  --measure:     760px;   /* Textseiten, Kontaktband-Titel */
  --measure-lead: 820px;  /* Einleitungen */

  --serif-weight: 400;    /* auf Mobil 500, DESIGN.md §9 Nr. 7 */
  --ease: 180ms ease;
}

@media (max-width: 1199px) {
  :root {
    --gutter: 40px;
    --section-y: 72px;
    --section-y-compact: 56px;
    --section-y-hero: 72px;
  }
}
@media (max-width: 767px) {
  :root {
    --gutter: 20px;
    --section-y: 56px;
    --section-y-compact: 48px;
    --section-y-hero: 56px;
    --serif-weight: 500;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Sprungmarken landen unterhalb des fixierten Headers */
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img, svg, video, picture { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
p, ul, ol, dl, figure, blockquote { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }
table { border-collapse: collapse; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
[hidden] { display: none !important; }

a { color: var(--navy); text-decoration: none; transition: color var(--ease); }
a:hover { color: var(--gold-700); }

/* Fließtext-Links in Absätzen sichtbar unterstreichen */
.prose a { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* ---------- Überschriften ------------------------------------------------- */
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: var(--serif-weight);
  color: var(--navy);
  line-height: 1.1;
  /* lange Komposita ("Energiemanagement") auf schmalen Geräten trennen,
     aber nur lange Wörter (min. 12 Zeichen, je Teil min. 5) */
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 12 5 5;
  /* Zeilen gleichmäßig verteilen statt einzelnes Wort in der letzten Zeile */
  text-wrap: balance;
}
h5, h6 { margin: 0; font-size: inherit; }

/* Fließtext: keine einzelnen Wörter in der letzten Zeile (wo unterstützt) */
p, li, dd, blockquote, figcaption, summary { text-wrap: pretty; }

/* Rollen aus DESIGN.md §3 – unabhängig vom HTML-Element einsetzbar */
.h1-home { font-size: var(--fs-h1-home); line-height: 1.05; }
.h1      { font-size: var(--fs-h1);      line-height: 1.05; }
.h2-lg   { font-size: var(--fs-h2-lg);   line-height: 1.08; }
.h2      { font-size: var(--fs-h2);      line-height: 1.05; }
.h3-lg   { font-size: var(--fs-h3-lg);   line-height: 1.1; }
.h3      { font-size: var(--fs-h3);      line-height: 1.1; }
.h4      { font-size: var(--fs-h4);      line-height: 1.15; }

.h1-home, .h1, .h2-lg, .h2, .h3-lg, .h3, .h4 {
  font-family: var(--font-serif);
  font-weight: var(--serif-weight);
  text-wrap: balance;
}

/* Ziffern in Serif: auf Hell --gold-600 (nur ab 24px), auf Navy --gold */
.num-lg, .num, .num-sm {
  font-family: var(--font-serif);
  font-weight: var(--serif-weight);
  line-height: 1;
  color: var(--gold-600);
  font-variant-numeric: lining-nums;
}
.num-lg { font-size: var(--fs-num-lg); }
.num    { font-size: var(--fs-num); }
.num-sm { font-size: var(--fs-num-sm); }

/* ---------- Text ---------------------------------------------------------- */
.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  max-width: var(--measure-lead);
}
.text-step  { font-size: var(--fs-step); line-height: 1.5; }
.text-card  { font-size: var(--fs-card); line-height: 1.45; }
.text-small { font-size: var(--fs-small); }
.muted      { color: var(--ink-muted); }

.footnote {
  font-size: var(--fs-note);
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Eyebrow: Versalien nur per CSS, im HTML normale Schreibweise (DESIGN.md §8) */
.eyebrow {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--navy);
}
.eyebrow--card { font-size: 12px; letter-spacing: 2.5px; }
.eyebrow--gold { color: var(--gold-700); }

/* Textlink mit Pfeil – der Pfeil kommt per CSS, im HTML nur der Text */
/* inline-block statt inline-flex: bei zweizeiligem Text folgt der Pfeil dem
   letzten Wort, statt als eigene Spalte rechts neben dem Textblock zu stehen. */
.textlink {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--navy);
}
.textlink::after { content: "→"; display: inline-block; margin-left: .5em; letter-spacing: 0; transition: transform var(--ease); }
.textlink:hover::after { transform: translateX(3px); }

/* ---------- Layout -------------------------------------------------------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: calc(var(--measure) + 2 * var(--gutter)); }

.section          { padding-block: var(--section-y); }
.section--compact { padding-block: var(--section-y-compact); }
.section--hero    { padding-block: var(--section-y-hero); }
.section--ruled   { border-bottom: 1px solid var(--line); }

/* Raster (DESIGN.md §4), Umbrüche nach §7 */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); }
.grid--4      { gap: 20px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--2      { gap: 24px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3      { gap: 40px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--footer { gap: 32px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > * { min-width: 0; }   /* lange Wörter sprengen die Spalte nicht */

@media (max-width: 1199px) {
  .grid--4, .grid--footer { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Drei Karten mit Serif-Titeln (28–34px) sind unter 1024px zu schmal: eine Spalte */
@media (max-width: 1023px) {
  .grid--3 { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 767px) {
  .grid--4, .grid--2, .grid--3, .grid--footer { grid-template-columns: minmax(0, 1fr); }
}

/* Abstände im Fluss: Kinder bekommen einen Abstand nach oben */
/* :not(:first-child) statt * + *: höhere Spezifität, damit Komponenten mit
   margin: 0 (Checkliste, Listen) den Abstand nicht aufheben */
.stack > :not(:first-child) { margin-top: var(--stack, 16px); }
.stack--sm        { --stack: 8px; }
.stack--lg        { --stack: 24px; }
.stack--xl        { --stack: 40px; }

/* ---------- Flächen (Abfolge: Navy, Creme, Weiß/Mist, Navy) -------------- */
.surface-cream { background: var(--cream); }
.surface-white { background: var(--white); }
.surface-mist  { background: var(--mist); }
.surface-navy  { background: var(--navy); color: var(--slate-200); }

.surface-navy :is(h1, h2, h3, h4, .h1-home, .h1, .h2-lg, .h2, .h3-lg, .h3, .h4) { color: var(--white); }
.surface-navy :is(.num-lg, .num, .num-sm) { color: var(--gold); }
.surface-navy .eyebrow.eyebrow--gold { color: var(--gold); }  /* vor .surface-navy .eyebrow schützen */
.surface-navy .eyebrow { color: var(--slate-300); }
.surface-navy .muted { color: var(--slate-300); }
.surface-navy a:not([class]), .surface-navy .textlink { color: var(--gold); }
.surface-navy a:not([class]):hover, .surface-navy .textlink:hover { color: var(--white); }

/* ---------- Barrierefreiheit ---------------------------------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--gold-700);
  outline-offset: 2px;
}
.surface-navy :focus-visible { outline-color: var(--gold); }

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 1000;
  padding: 12px 20px;
  background: var(--navy);
  color: var(--white);
  font-weight: 600;
}
.skip-link:focus { top: 16px; color: var(--white); outline-color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
