/* ==========================================================================
   Layout – site frame for Kirby (header, navigation, footer, section rhythm)
   Built on tokens.css + base.css. Roles only, no raw values.
   ========================================================================== */

:root {
  /* Gap between a section head (heading + intro) and its content: 32 → 48 */
  --gap-head-content: clamp(2rem, 1.617rem + 1.7021vw, 3rem);

  /* Header height = button height + vertical padding */
  --header-padding-y: var(--space-16);
}

/* ---------- Skip link (keyboard users jump straight to the content) ---------- */

.skip-link {
  position: absolute;
  top: var(--space-8);
  left: var(--space-8);
  z-index: 10;
  padding: var(--button-padding-y) var(--button-padding-x);
  border-radius: var(--radius-small);
  background-color: var(--surface-action-bg);
  color: var(--surface-action-text);
  transform: translateY(calc(-100% - var(--space-16)));
}

.skip-link:focus {
  transform: none;
}

/* ---------- Header ---------- */

.site-header {
  border-bottom: var(--border-width) solid var(--surface-border);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-16) var(--space-32);
  padding-block: var(--header-padding-y);
}

.site-logo {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  margin-right: auto;
  font-family: var(--font-heading);
  font-size: var(--text-h4);
  font-weight: var(--weight-heading);
  line-height: var(--leading-heading);
  text-decoration: none;
}

.site-logo img {
  height: var(--icon-size-large);
  width: auto;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-24);
  padding: 0;
  list-style: none;
}

.site-nav li {
  max-width: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  text-decoration: none;
}

.site-nav a:not(.button):hover,
.site-nav a:not(.button)[aria-current="page"] {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

/* Menu toggle only exists with JavaScript; without JS the nav stays visible */
.nav-toggle {
  display: none;
}

/* Collapse the menu when the items no longer fit next to logo and button.
   64em fits the starter's few items; adjust per project. */
@media (width <= 74.99em) {
  .js .nav-toggle {
    display: inline-flex;
  }

  .js .site-nav {
    display: none;
    order: 10; /* below logo, toggle and header button */
    flex-basis: 100%;
  }

  .js .site-nav[data-open] {
    display: block;
  }

  .site-nav ul {
    flex-direction: column;
    padding-block: var(--space-8);
  }
}

/* Header button: on narrow screens it moves into the menu, so logo and
   menu toggle stay on one line. The copy in the menu is hidden otherwise. */
.site-nav__cta {
  display: none;
}

@media (width <= 39.99em) {
  .js .site-header__cta {
    display: none;
  }

  .js .site-nav__cta {
    display: block;
    padding-top: var(--space-8);
  }
}

/* ---------- Footer ---------- */

.site-footer {
  padding-block: var(--space-section);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--gap-grid) var(--space-64);
}

.site-footer__name {
  font-family: var(--font-heading);
  font-size: var(--text-h4);
  font-weight: var(--weight-heading);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-24);
  padding: 0;
  list-style: none;
}

.site-footer__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
}

/* ---------- Section rhythm ---------- */

/* Head (eyebrow, heading, intro) above the section content */
.section-head {
  margin-bottom: var(--gap-head-content);
}

/* Section spacing: every section has the same space top and bottom
   (design system v1.7). No rule here may shrink or remove one side. */

/* CTA sits inside its own spacing wrapper (rounded box inset from the page edge).
   The wrapper takes the chosen space, the colored box keeps a fixed inner padding. */
.cta-wrap {
  padding-block: var(--space-section);
}

.cta-wrap > .section--inset {
  padding-block: var(--space-section-m);
}

/* ---------- Hero ---------- */

/* Heading next to the image: shrinks with the screen so text and image stay
   in balance (Regelwerk v1.8). Never smaller than an h2. */
@media (width >= 48em) and (width <= 79.99em) {
  .hero__split h1 {
    font-size: min(var(--text-h1), max(var(--text-h2), 4.2vw));
  }
}

.hero__text .content > * {
  max-width: var(--container-narrow);
}

/* Hero with background effect (canvas drawn by assets/js/hero-effect.js) */
.hero--effect {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  align-items: center;
  min-height: min(70svh, 40rem);
}

@media (width >= 48em) {
  .hero--effect {
    min-height: min(85svh, 56rem);
  }
}

.hero__canvas,
.hero__shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* Hidden until the script has drawn: without WebGL the normal surface shows */
.hero__canvas {
  display: block;
  opacity: 0;
  transition: opacity 600ms ease;
}

.hero--effect-ready .hero__canvas {
  opacity: 1;
}

/* Calms the area behind the text, so contrast stays at AAA level */
.hero__shade {
  background: color-mix(in srgb, var(--surface-bg) 55%, transparent);
}

@media (width >= 48em) {
  .hero__shade {
    background: linear-gradient(90deg,
      color-mix(in srgb, var(--surface-bg) 88%, transparent) 0%,
      color-mix(in srgb, var(--surface-bg) 60%, transparent) 45%,
      transparent 75%);
  }

  /* With an image on the right, keep the effect calm behind both columns */
  .hero--effect:has(.hero__split) .hero__shade {
    background: color-mix(in srgb, var(--surface-bg) 55%, transparent);
  }
}

/* ---------- Running text (writer output) ---------- */

.prose :is(h2, h3, h4) {
  margin-top: var(--gap-text-action);
}

/* Headings inside running text (e.g. legal texts) stay smaller than section headings */
.prose h2 {
  font-size: var(--text-h3);
}

/* ---------- Contact page ----------
   HTML: form first, details second. Side by side from 64em. */

.contact {
  display: grid;
  gap: var(--space-64);
}

@media (width >= 64em) {
  .contact {
    grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
    gap: var(--space-96);
    align-items: start;
  }
}

.contact__details h2 {
  font-size: var(--text-h4);
}

/* ---------- Light/dark switch (optional, Panel: Einstellungen) ----------
   Needs JavaScript; without it the device setting applies. Sits after the
   header button on wide screens and next to the menu toggle on narrow ones. */

.color-mode-toggle {
  display: none;
  order: 1;
  min-width: var(--target-min);
  padding-inline: 0;
  justify-content: center;
}

.js .color-mode-toggle {
  display: inline-flex;
}

.color-mode-toggle svg {
  width: var(--icon-size);
  height: var(--icon-size);
}

.color-mode-toggle[aria-pressed="true"] .color-mode-toggle__moon,
.color-mode-toggle[aria-pressed="false"] .color-mode-toggle__sun {
  display: none;
}

/* ---------- Page title without hero (e.g. Impressum, Datenschutz, Blog) ----------
   Title and the first light section belong together: no double section spacing. */
.page-header {
  padding-bottom: 0;
}

.page-header + .section[data-surface="default"] {
  padding-top: var(--gap-head-content);
}

/* ---------- First section below the header (hero or page title) ----------
   Less space at the top, so the main message is visible right away:
   about 32px on phones, growing to at most 64px on large screens. */
main > .section:first-child {
  padding-top: clamp(2rem, 1rem + 3vw, 4rem);
}
