/* ============================================================================
   ecoPi base
   Element-level defaults built on the tokens. No component classes here.
   ========================================================================= */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--ep-nav-h) + var(--ep-space-4));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ep-bg-page);
  color: var(--ep-text);
  font-family: var(--ep-font-body);
  font-size: var(--ep-text-base);
  line-height: var(--ep-leading-body);
  /* German compounds ("Verbraucherstreitbeilegung") overflow narrow viewports */
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* ---- Headings --------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--ep-space-4);
  color: var(--ep-text);
  font-family: var(--ep-font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  /* Long German compounds ("Anwendungsbereiche") must never overflow. */
  overflow-wrap: break-word;
  hyphens: auto;
}

/* At display sizes a mid-word hyphen is very visible, and the browser will
   insert one whenever it improves line filling — the English h1 broke as
   "envi-ronmental" on the home page. Wrapping between words is enough here;
   overflow-wrap above still prevents overflow. Hyphenation comes back below
   480px, where a long compound genuinely cannot fit on one line and an
   explicit hyphen reads better than a bare break. */
h1, h2 {
  hyphens: manual;
}

@media (max-width: 479.98px) {
  h1, h2 {
    hyphens: auto;
  }
}

h1 { font-size: var(--ep-h1); line-height: var(--ep-leading-tight); }
h2 { font-size: var(--ep-h2); line-height: var(--ep-leading-tight); }
h3 { font-size: var(--ep-h3); line-height: var(--ep-leading-snug); }
h4 { font-size: var(--ep-h4); line-height: var(--ep-leading-snug); }

/* ---- Text ------------------------------------------------------------- */

p, ul, ol, dl, figure, blockquote, table {
  margin: 0 0 var(--ep-space-4);
}

p:last-child,
ul:last-child,
ol:last-child {
  margin-bottom: 0;
}

a {
  color: var(--ep-primary);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--ep-primary-hover);
}

strong, b {
  font-weight: 700;
}

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

code, kbd, samp, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* ---- Media ------------------------------------------------------------ */

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

/* ---- Forms ------------------------------------------------------------ */

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

/* ---- Focus -------------------------------------------------------------
   Bootstrap strips the outline on .btn/.nav-link and substitutes a
   box-shadow that disappears against the dark navbar. Those classes are
   listed explicitly so this rule wins on specificity. */

a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
.navbar-toggler:focus-visible,
.btn-close:focus-visible {
  outline: 3px solid var(--ep-primary-light);
  outline-offset: 3px;
  border-radius: var(--ep-radius-sm);
  box-shadow: none;
}

/* <model-viewer> is a tab stop and is operable with the arrow keys, so it
   needs a visible focus indicator — but it also takes focus on mouse-down
   when you drag to rotate, which drew a box around the model on every drag.
   `:focus-visible` cannot make that distinction here: the element delegates
   focus into its shadow root, so the host only ever matches `:focus`.
   kb-focus.js sets data-kb-nav while the user is navigating by keyboard,
   which restores the intended behaviour. !important beats the custom
   element's own `outline: none`. */
[data-kb-nav] model-viewer:focus {
  outline: 3px solid var(--ep-primary) !important;
  outline-offset: 3px;
}

/* ---- Skip link -------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: 0;
  left: var(--ep-space-4);
  z-index: 9999;
  padding: var(--ep-space-3) var(--ep-space-4);
  border-radius: 0 0 var(--ep-radius-md) var(--ep-radius-md);
  background: var(--ep-bg-card);
  color: var(--ep-text);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-120%);
  transition: transform var(--ep-duration-base) var(--ep-ease);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

/* ---- Layout helpers --------------------------------------------------- */

.ep-container {
  width: 100%;
  max-width: var(--ep-container);
  margin-inline: auto;
  padding-inline: var(--ep-gutter);
}

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

/* ---- Motion ----------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Content offset for the fixed header. Replaces the inline
   `style="margin-top:110px"` that was repeated on every page. */
.page {
  padding-top: var(--ep-nav-h);
  padding-bottom: var(--ep-space-8);
}

/* Sections own their own vertical rhythm, so the page's bottom padding would
   add a stray band of page background between a full-bleed final section and
   the footer. */
.page:has(> .ep-section:last-child),
.page:has(> section:last-child),
.page:has(> .ep-project-modals:last-child),
.page:has(> .modal:last-child) {
  padding-bottom: 0;
}

