/* MR-GUFi – base and global components. Values from the approved mockup (design/mockup, docs/04-design.md).
   Colours, type and spacing only through the custom properties in tokens.css. */

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--c-ink);
  background: var(--c-bg);
}

main {
  flex: 1 0 auto;
}

/* Components set their own display; the hidden attribute must still win (filters, panels, empty states) */
[hidden] {
  display: none !important;
}

/* Controls that only work with JavaScript (filters): visible from the first paint – no layout shift when the script
   starts – and absent when scripting is off. Browsers without the media feature show them; their script runs. */
@media (scripting: none) {
  .needs-js {
    display: none !important;
  }
}

main:focus {
  outline: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

h1,
h2,
h3 {
  line-height: 1.15;
  font-weight: 600;
  /* Long German compounds ("Forschungsschwerpunkte") must not widen the page at 320 px */
  overflow-wrap: break-word;
  hyphens: auto;
}

a {
  color: var(--c-teal);
}

/* Visible focus on every interactive element (WCAG 2.4.7, 1.4.11 – at least 3:1 against the surface): teal on light
   (5.9:1), cyan on dark (8.8:1; teal would be 2.9:1 on ink). Dark surfaces set --focus-color once here, so every
   component on them is covered, also new ones; light cards inside a dark band set it back. */
:focus-visible {
  outline: 3px solid var(--focus-color);
  outline-offset: 2px;
}

:where(.on-dark, .band-dark, .breadcrumb-strip:has(+ .band-dark), .site-footer, .members-bar, .news-article__head, .dash-card--dark, .aside-card--dark, .lightbox, .skip-link) {
  --focus-color: var(--c-accent);
}

:where(.band-dark .page-intro__card) {
  --focus-color: var(--c-teal);
}

/* --container is the content width (as in the mockup); the gutters come on top */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border-radius: var(--radius-m);
  background: var(--c-ink);
  color: var(--c-surface);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

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

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.button--ink {
  background: var(--c-ink);
  color: var(--c-surface);
}

.button--outline {
  background: transparent;
  border-color: var(--c-line-strong);
  color: var(--c-ink);
}

/* Hover: one rule per kind – fill gets one step lighter, outline gets a firmer border and a light fill */
.button {
  transition: background-color 0.15s, border-color 0.15s;
}

.button--ink:hover {
  background: var(--c-ink-2);
}

.button--accent:hover {
  background: color-mix(in srgb, var(--c-accent) 82%, white);
}

.button--outline:hover {
  border-color: var(--c-ink);
  background: var(--c-surface-2);
}

:where(.on-dark, .band-dark) .button--outline:hover,
.button--outline-dark:hover {
  border-color: var(--c-on-dark-muted);
  background: var(--c-ink-2);
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-6) 0 0;
}

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

.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  padding-top: 10px;
}

.site-header__logo {
  display: flex;
  align-items: center;
  min-height: 48px;
}

.site-header__logo img {
  width: auto;
  height: 52px;
}

.site-header__tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.lang-switch__list {
  display: inline-flex;
  margin: 0;
  padding: 2px;
  list-style: none;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-m);
}

.lang-switch__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  border-radius: var(--radius-s);
  color: var(--c-muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.lang-switch__link.is-active {
  background: var(--c-teal-tint);
  color: var(--c-teal-dark);
}

.main-nav {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
  margin-top: var(--space-1);
  overflow-x: auto;
  scrollbar-width: thin;
}

.main-nav__list {
  display: flex;
  flex: 1 1 auto;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.main-nav__link,
.main-nav__search {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  border-bottom: 3px solid transparent;
  color: var(--c-ink);
  text-decoration: none;
}

.main-nav__link {
  padding: 0 var(--space-4);
  white-space: nowrap;
  font-size: var(--fs-small);
  font-weight: 500;
}

.main-nav__link:hover,
.main-nav__link.is-active {
  border-bottom-color: var(--c-teal);
}

.main-nav__link.is-active {
  font-weight: 600;
}

.main-nav__search {
  justify-content: center;
  min-width: 48px;
}

/* Focus rings inside the scrolling navigation would be clipped by overflow – draw them inside */
.main-nav :focus-visible {
  outline-offset: -3px;
}

/* Scroll shadows (main and members navigation): a soft shadow at an edge where more items are hidden, so a cut-off
   "Aktuelle…" reads as "scroll for more". Pure CSS: the covers move with the content (local), the shadows stay (scroll). */
.main-nav {
  background:
    linear-gradient(to right, var(--nav-bg, var(--c-surface)) 40%, transparent) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--nav-bg, var(--c-surface)) 40%, transparent) right / 32px 100% no-repeat local,
    linear-gradient(to right, var(--nav-shadow, rgb(15 27 42 / 0.16)), transparent) left / 16px 100% no-repeat scroll,
    linear-gradient(to left, var(--nav-shadow, rgb(15 27 42 / 0.16)), transparent) right / 16px 100% no-repeat scroll;
}

/* Phones: logo, language switch and the members button on one row (two header rows instead of three) */
@media (max-width: 599px) {
  .site-header__inner {
    column-gap: var(--space-3);
  }

  .site-header__logo img {
    height: 44px;
  }
}

/* ---------- Breadcrumb ---------- */

.breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--c-muted);
}

.breadcrumb__item {
  display: inline-flex;
  align-items: center;
}

.breadcrumb__item + .breadcrumb__item::before {
  content: "/";
  margin-inline: var(--space-2);
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

/* Phones: only the way up – "← parent page" – instead of a trail that wraps (the page title says where you are) */
@media (max-width: 599px) {
  .breadcrumb__item:not(:nth-last-child(2)) {
    display: none;
  }

  .breadcrumb__item:nth-last-child(2)::before {
    content: "←";
    margin-inline: 0 6px;
  }
}

/* ---------- Inner pages ---------- */

.page {
  padding-top: var(--space-6);
  padding-bottom: var(--space-9);
}

.page__eyebrow {
  margin: var(--space-5) 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-teal);
}

.page__title {
  max-width: 760px;
  margin: var(--space-5) 0 var(--space-5);
  font-size: var(--fs-h1);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page__eyebrow + .page__title {
  margin-top: 0;
}

.page__lead {
  font-size: 18px;
  color: var(--c-muted);
}

/* Text blocks keep a readable line length; tables and the forum may use the full container width */
.prose :where(p, ul, ol, h2, h3, h4, dl, blockquote) {
  max-width: 72ch;
}

.prose > :first-child {
  margin-top: 0;
}

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

.site-footer {
  background: var(--c-ink);
  color: var(--c-on-dark-muted);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
  padding-top: var(--space-8);
  padding-bottom: var(--space-6);
}

.site-footer__columns {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-7) var(--space-8);
}

.site-footer__about {
  flex: 2 1 300px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.site-footer__logo {
  align-self: flex-start;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-m);
  background: var(--c-surface);
}

.site-footer__logo img {
  width: auto;
  height: 56px;
}

.site-footer__description {
  max-width: 42ch;
  margin: 0;
  font-size: var(--fs-small);
}

.site-footer__funding {
  margin: 0;
  font-size: 14px;
  color: var(--c-on-dark-faint);
}

/* DFG logo: protection zone = height of the "DFG" capitals all around (styleguide); 30 px high */
.site-footer__dfg {
  display: inline-block;
  align-self: flex-start;
  padding: 10px 0;
  line-height: 0;
}

.site-footer__dfg img {
  width: auto;
  height: 30px;
}

.site-footer__nav {
  flex: 1 1 160px;
}

.site-footer__heading {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-surface);
}

.site-footer__nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__nav a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  font-size: var(--fs-small);
  color: var(--c-on-dark-muted);
  text-decoration: none;
}

.site-footer__nav a:hover {
  color: var(--c-surface);
  text-decoration: underline;
}

.site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-5);
  border-top: 1px solid var(--c-line-dark);
  font-size: var(--fs-xs);
  color: var(--c-on-dark-faint);
}

.site-footer__privacy-note {
  font-family: var(--font-mono);
}
