/* ==========================================================================
   Base – reset, typography, layout primitives
   Uses tokens.css roles only. No raw values except 0 / 100% / 1px.
   ========================================================================== */

/* ---------- Reset ---------- */

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

* {
  margin: 0;
}

html {
  /* stylelint-disable-next-line property-no-vendor-prefix -- Safari still needs the prefix */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Short pages: the footer sits at the bottom of the screen (main grows) */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: var(--weight-body);
  line-height: var(--leading-body);
  color: var(--surface-text);
  background-color: var(--surface-bg);
  -webkit-font-smoothing: antialiased;
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* Long words (e.g. German compounds) must not break the layout on mobile.
   Hyphenation only for long words (≥ 10 letters, ≥ 4 on each side), so short
   words like "ei-nen" are never split. Headings never hyphenate. (Regelwerk v1.8) */
p,
li,
dd,
dt,
td,
th {
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphenate-limit-before: 4;
  -webkit-hyphenate-limit-after: 4;
  hyphenate-limit-chars: 10 4 4;
}

/* ---------- Color worlds ---------- */

[data-surface] {
  color: var(--surface-text);
  background-color: var(--surface-bg);
}

/* ---------- Typography ---------- */

h1,
h2,
h3,
h4 {
  overflow-wrap: break-word;
  hyphens: manual; /* headings never hyphenate (Regelwerk v1.8) */
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  line-height: var(--leading-heading);
  text-wrap: balance;
}

h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }
h4 { font-size: var(--text-h4); }

p,
li {
  max-width: var(--measure);
  text-wrap: pretty;
}

.text-lead {
  font-size: var(--text-lead);
}

.text-small {
  font-size: var(--text-small);
}

.text-muted {
  color: var(--surface-text-muted);
}

.text-highlight {
  font-family: var(--font-highlight);
}

strong,
b {
  font-weight: var(--weight-strong);
}

a {
  color: var(--surface-link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-thickness var(--transition);
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Eyebrow – small label above a heading, set in the body font.
   Test: read eyebrow + heading aloud as one sentence. Makes sense and adds
   context? → inside the heading. Decoration, numbers, repetition? → separate.

   A) Inside the heading (default) – read as part of the heading:
        <h2><span class="eyebrow">Leistungen</span> Was ich für Sie tue</h2>
      Keep a space or line break between eyebrow and heading text in the HTML,
      otherwise both words run together when read aloud.

   B) Separate – in the code AFTER the heading, shown above it via CSS, so
      people jumping from heading to heading still hear it:
        <hgroup>
          <h2>Was ich für Sie tue</h2>
          <p class="eyebrow">Unser Versprechen</p>
        </hgroup> */
.eyebrow {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
  line-height: var(--leading-body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-wrap: wrap;
}

:is(h1, h2, h3, h4) > .eyebrow {
  margin-bottom: var(--gap-eyebrow-heading);
}

/* ---------- Focus (WCAG AAA: always visible, never removed) ---------- */

:focus-visible {
  outline: var(--focus-width) solid var(--surface-focus);
  outline-offset: var(--focus-offset);
}

/* ---------- Layout: sections and containers ---------- */

/* Every section has the same space at top and bottom – never only one side.
   Size per section: data-space="s" | "m" (default) | "l" */
.section {
  padding-block: var(--space-section);
}

[data-space="s"] { --space-section: var(--space-section-s); }
[data-space="m"] { --space-section: var(--space-section-m); }
[data-space="l"] { --space-section: var(--space-section-l); }

/* ---------- Jump links (#anchor) ----------
   Smooth scrolling (off with "reduce motion", see the end of this file).
   The target lands with a small gap to the top edge: about 24px on phones, 40px on large screens.
   A section counts from its heading, not from its padding. */
:root {
  --space-anchor-gap: clamp(1.5rem, 1rem + 1.5vw, 2.5rem);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

[id] {
  scroll-margin-top: var(--space-anchor-gap);
}

.section[id] {
  scroll-margin-top: calc(var(--space-anchor-gap) - var(--space-section));
}

.container {
  width: min(100% - 2 * var(--page-gutter), var(--container-default));
  margin-inline: auto;
}

.container--wide {
  width: min(100% - 2 * var(--page-gutter), var(--container-wide));
}

.container--narrow {
  width: min(100% - 2 * var(--page-gutter), var(--container-narrow));
}

/* Colored section with rounded corners, inset from the page edge */
.section--inset {
  width: min(100% - 2 * var(--page-gutter), var(--container-wide));
  margin-inline: auto;
  border-radius: var(--radius-large);
}

/* ---------- Layout: grid ---------- */

/* 12-column grid. On small screens every item spans the full width;
   column spans apply from 48em (768px) upwards. */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  gap: var(--gap-grid);
}

.grid > * {
  grid-column: span var(--grid-columns);
}

@media (width >= 48em) {
  .grid > [data-span="3"] { grid-column: span 3; }
  .grid > [data-span="4"] { grid-column: span 4; }
  .grid > [data-span="5"] { grid-column: span 5; }
  .grid > [data-span="6"] { grid-column: span 6; }
  .grid > [data-span="7"] { grid-column: span 7; }
  .grid > [data-span="8"] { grid-column: span 8; }
}

/* Content-driven grid for repeated items (cards, icon boxes).
   Items wrap when they get narrower than --grid-min, independent of device. */
.grid-auto {
  --grid-min: 16rem;

  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--grid-min)), 1fr));
  gap: var(--gap-grid);
}

/* Wider minimum for text-heavy items (e.g. testimonials) */
.grid-auto--wide {
  --grid-min: 20rem;
}

/* ---------- Text spacing (spacing roles) ----------
   Wrap headings, paragraphs and actions in .content.
   The gaps follow the roles, never ad-hoc margins. */

.content > * + * {
  margin-top: var(--gap-paragraph);
}

hgroup {
  display: flex;
  flex-direction: column;
}

hgroup > .eyebrow {
  order: -1; /* visually above the heading, in the code after it */
  margin-bottom: var(--gap-eyebrow-heading);
}

.content > :is(h1, h2, h3, h4, hgroup) + * {
  margin-top: var(--gap-heading-text);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center; /* buttons and text links share one center line */
  gap: var(--space-16) var(--space-24);
}

.content > * + .actions {
  margin-top: var(--gap-text-action);
}


/* ---------- Layout: text + image ----------
   HTML order is ALWAYS text first, image second.
   Visual order is set here (Regelwerk v1.8):
   - mobile: heading → flat image → rest of the text
     data-mobile="text-first" (hero): all text first, then the image
   - from 48em: image right (default) or left (data-image="start") */

.split {
  display: grid;
  gap: var(--gap-grid);
  align-items: center;
}

@media (width <= 47.99em) {
  /* The text column dissolves, so the image can sit between heading and text.
     Spacing inside .content still works (it is a selector, not a layout box). */
  .split:not([data-mobile="text-first"]) {
    row-gap: 0;
  }

  .split:not([data-mobile="text-first"]) > .content {
    display: contents;
  }

  .split:not([data-mobile="text-first"]) > .content > :first-child {
    order: -2;
  }

  .split:not([data-mobile="text-first"]) > .split__media {
    order: -1;
    margin-block: var(--gap-heading-text);
  }

  .split:not([data-mobile="text-first"]) > .content > :nth-child(2) {
    margin-top: 0;
  }

  /* Flat formats on small screens, never taller than 60 % of the screen */
  .split__media img {
    aspect-ratio: 3 / 2;
    object-fit: cover;
    max-height: 60svh;
  }

  .split[data-mobile="text-first"] .split__media img {
    aspect-ratio: 16 / 10;
  }
}

@media (width >= 48em) {
  .split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-64);
  }

  .split > .split__media {
    order: 0;
  }

  .split[data-image="start"] > .split__media {
    order: -1;
  }
}

.split__media img {
  width: 100%;
  border-radius: var(--radius-large);
}

/* ---------- Box elements: shared foundation ----------
   Card, icon box, image box, testimonial, comparison column all start here.
   Each component only adds what makes it different. */

.box {
  display: flex;
  flex-direction: column;
  gap: var(--gap-box-inner);
  padding: var(--padding-box);
  border: var(--border-width) solid var(--surface-border);
  border-radius: var(--radius-medium);
  background-color: var(--surface-box-bg);
}

/* Media flush with the box edge takes the box radius.
   The bottom margin tops the box gap up to --gap-box-media. */
.box__media--flush {
  margin: calc(-1 * var(--padding-box)) calc(-1 * var(--padding-box)) calc(var(--gap-box-media) - var(--gap-box-inner));
  border-radius: var(--radius-medium) var(--radius-medium) 0 0;
  overflow: hidden;
}

/* Media inside the padding: inner = outer − gap */
.box__media {
  border-radius: var(--radius-box-inner);
  overflow: hidden;
}

/* ---------- Accessibility helpers ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Decorative elements (logo patterns etc.) – hidden from screen readers via
   aria-hidden="true" in HTML; never carry content. */
.decor {
  pointer-events: none;
  user-select: none;
}

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

main {
  flex: 1 0 auto;
}
