/* =========================================================
   JH FamilySync — Kopf «Familienfarben» (Entwurf V2, 26.10.2026)
   ---------------------------------------------------------
   Gemeinsamer Baustein der Start- und Unterseiten: kopf.css + kopf.js,
   eingebunden NACH landing.css. Die Idee in einem Satz: die Personenfarben
   der App sind die Signatur — eine Farbleiste aus vier Segmenten am
   unteren Rand, ein Farbpunkt am aktiven Menüpunkt, drei farbige Striche
   als Hamburger, die sich am selben Ort zum X drehen.

   Leistung (Messung 26.10.2026): kein backdrop-filter und kein filter, der
   Grund ist deckend. Bewegt werden nur transform und opacity; ein Schatten
   erscheint über die opacity einer eigenen Schicht. Der Kopf steht fest
   (sticky); beim Runterscrollen fährt er per transform nach oben weg, beim
   Hochscrollen kommt er zurück (Wunsch des Betreibers 27.10.2026, kopf.js
   setzt ist-weg). «Kompakt» setzt kopf.js über einen IntersectionObserver
   auf einem Wachposten oben: dann blendet der Schatten ein und die Leiste
   wird per scaleY dünner.

   Ab 1160 px stehen Navigation, Sprachwahl und Knopf in der Zeile. Darunter
   ein einziger runder Knopf (Hamburger = X) und das Menü als Vollfläche
   unter dem Kopf. 1160 statt 920: die längste Zeile ist die der
   französischen Unterseiten (Fonctionnalités · Tarifs · Thèmes · FAQ, vier
   Sprachknöpfe, «Commencer gratuitement →»); sie braucht 1130 px (gemessen
   26.10.2026, Chrome), darunter drückte sie die Marke zusammen. Eine Grenze
   für alle Seiten: der Kopf wechselt beim Weiterklicken nicht die Form.
   Hell wie die ganze Seite (kein Dunkelmodus, siehe seiten.css).
   ========================================================= */

:root {
  --kopf-hoehe: 72px;
}

/* Anker unter dem festen Kopf: Kopfhöhe + 16 px Luft. landing.js liest
   denselben Wert für die eigene Scroll-Animation.
   Der Rand für den Scrollbalken bleibt immer frei (scrollbar-gutter gilt am
   Wurzelelement für das Fenster, auf body wirkt sie nicht): Das offene Menü
   sperrt die Seite mit overflow: hidden. Ohne freien Rand fiele ein
   klassischer Scrollbalken weg (Windows, macOS «Rollbalken immer
   einblenden»), die Zeile würde breiter und das X rückte um dessen Breite
   vom Ort des Hamburgers weg (gemessen 26.10.2026: 15 px). */
html {
  scroll-padding-top: calc(var(--kopf-hoehe) + 16px);
  scrollbar-gutter: stable;
}

/* Die Zeile steht sticky im Bild (weggefahren holt sie wandernder Fokus
   sofort zurück, siehe «Wegfahren»), liegt aber in der Zone, die das
   scroll-padding oben ausspart. Bekam die Marke, der Knopf oder ein Link der
   Zeile bei gescrollter Seite den Fokus (Tab, Shift+Tab, Esc im offenen
   Menü), scrollte der Browser ihn «ins Bild»: Chrome um eine halbe
   Fensterhöhe, WebKit um rund 80 px, bei jedem Schritt neu (Live-Prüfung
   27.10.2026). Der negative Rand hebt das Polster für genau diese Elemente
   auf; Anker und Fokus im Inhalt behalten es. Nicht auf das Menü ausdehnen:
   dort schnitte er Einträge am oberen Rand ab. */
.kopf-zeile a,
.kopf-zeile button {
  scroll-margin-top: calc(-1 * (var(--kopf-hoehe) + 16px));
}

/* Offenes Menü: die Seite dahinter scrollt nicht mit. */
html.kopf-gesperrt { overflow: hidden; }

/* Wachposten für den kompakten Zustand (kopf.js legt ihn an): die obersten
   16 px der Seite. Ist er aus dem Bild, ist der Kopf kompakt. */
.kopf-wache {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 16px;
  pointer-events: none;
}

.kopf {
  --kopf-grund: #FAF7F2;
  --kopf-flaeche: #FFFFFF;
  --kopf-tinte: #1A1B2E;
  --kopf-tinte-weich: #2A2C44;
  --kopf-sub: #5B5C7A;
  --kopf-linie: rgba(26, 27, 46, 0.10);
  --kopf-linie-stark: rgba(26, 27, 46, 0.22);
  --kopf-fokus: #3A5BBE;
  --kopf-weich: cubic-bezier(0.2, 0.8, 0.2, 1);
  --kopf-feder: cubic-bezier(0.3, 1.6, 0.5, 1);
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--kopf-hoehe);
  background: var(--kopf-grund);
  color: var(--kopf-tinte);
  font-family: 'Onest', 'Inter', system-ui, -apple-system, sans-serif;
  transition: transform 0.3s var(--kopf-weich);
}
/* Offen liegt das Menü über allem, auch über dem Cookie-Hinweis (9999), der
   sonst Sprachwahl und Knopf unten im Menü verdeckt; er ist wieder da, sobald
   das Menü zu ist. Zu bleibt der Kopf unter Hinweis und Einstellungen. */
.kopf.ist-offen { z-index: 10001; }

/* ---------- Wegfahren (kopf.js setzt ist-weg) ----------
   Runter fährt der Kopf nach oben aus dem Bild, hoch kommt er zurück; der
   Schatten blendet mit aus (siehe «Schatten»), sonst bliebe ein grauer Rand
   oben im Bild. Sichtbar steht KEIN transform am Kopf: mit einem transform
   würde er zum Bezugsrahmen des Menüs (position: fixed), und das Menü
   schrumpfte auf die Kopfhöhe. Darum öffnet das Menü ohne Übergang (ein
   laufendes Einfahren bricht ab).
   Fokus, der in den Kopf wandert (Tastatur, Screenreader; die Maus kommt
   nicht hin), zeigt ihn sofort und ohne Übergang, BEVOR der Browser den
   Fokus «ins Bild» scrollt; sonst stünde er dabei noch oben oder halb
   eingefahren, und die Seite sprang um 400 bis 550 px (Messung 27.10.2026).
   Chrome scrollt vor dem focusin, darum die beiden :has-Regeln; WebKit
   schickt focusin vorher (kopf.js setzt dann auch ist-sofort). Fokus, der
   beim Wegfahren schon im Kopf lag, trägt kopf-fokus-alt (kopf.js) und
   hält ihn nicht. :has() steht allein: in einer Liste fiele in einem
   Browser ohne :has() die ganze Regel weg. */
.kopf.ist-weg:not(.ist-offen) { transform: translateY(-100%); }
.kopf.ist-offen,
.kopf.ist-sofort { transition: none; }
.kopf:has(:focus:not(.kopf-fokus-alt)) { transition: none; }
.kopf.ist-weg:has(:focus:not(.kopf-fokus-alt)) { transform: none; }
/* Gedruckt steht er oben auf der ersten Seite, auch wenn er gerade weg ist.
   Sticky druckt Chrome an der Scrolllage, mitten im Inhalt (Messung
   27.10.2026), darum static. */
@media print {
  .kopf,
  .kopf.ist-weg:not(.ist-offen) { position: static; transform: none; }
}

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

/* Die Familienfarben (Personenfarben der App) */
.kopf-blau    { --farbe: #5277E3; --hauch: rgba(82, 119, 227, 0.12); }
.kopf-violett { --farbe: #A855C9; --hauch: rgba(168, 85, 201, 0.12); }
.kopf-pink    { --farbe: #DB2777; --hauch: rgba(219, 39, 119, 0.11); }
.kopf-orange  { --farbe: #EA580C; --hauch: rgba(234, 88, 12, 0.11); }
.kopf-tuerkis { --farbe: #0D9488; --hauch: rgba(13, 148, 136, 0.12); }
.kopf-gruen   { --farbe: #16A34A; --hauch: rgba(22, 163, 74, 0.12); }

/* Links im Kopf: keine Unterstreichung und kein Farbübergang aus landing.css
   (animiert wird nur transform und opacity). */
.kopf a { text-decoration: none; transition: none; }
.kopf a:hover { text-decoration: none; }
.kopf a:focus-visible,
.kopf button:focus-visible {
  outline: 3px solid var(--kopf-fokus);
  outline-offset: 3px;
}

/* ---------- Schatten (kompakt, nicht weggefahren) ---------- */
.kopf-schatten {
  position: absolute;
  inset: 0;
  box-shadow: 0 10px 26px rgba(26, 27, 46, 0.10);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.kopf.ist-kompakt:not(.ist-offen):not(.ist-weg) .kopf-schatten { opacity: 1; }

/* ---------- Zeile ---------- */
.kopf-zeile {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 72px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 14px 0 20px;
  background: var(--kopf-grund);
}

.kopf-marke {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding-right: 6px;
  border-radius: 12px;
  color: var(--kopf-tinte);
}
.kopf-marke:hover { color: var(--kopf-tinte); }
.kopf-marke picture { display: block; flex: none; }
.kopf-marke img { display: block; width: 36px; height: 36px; border-radius: 9px; }
.kopf-name {
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ---------- Navigation in der Zeile (ab 1160 px) ---------- */
.kopf-nav,
.kopf-rechts { display: none; }

.kopf-link {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 17px 0 33px;
  border-radius: 999px;
  color: var(--kopf-sub);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
/* Hauch in der Farbe des Punkts hinter dem aktiven Link */
.kopf-link::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  background: var(--hauch);
  opacity: 0;
  transition: opacity 0.25s ease;
}
/* Farbpunkt */
.kopf-link::after {
  content: '';
  position: absolute;
  top: 17px;
  left: 15px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--farbe);
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 0.2s ease, transform 0.35s var(--kopf-feder);
}
.kopf-link:hover,
.kopf-link[aria-current="true"] { color: var(--kopf-tinte); }
.kopf-link[aria-current="true"]::before { opacity: 1; }
.kopf-link:hover::after,
.kopf-link[aria-current="true"]::after { opacity: 1; transform: scale(1); }

/* ---------- Sprachwahl: vier runde Knöpfe ---------- */
.kopf-sprachen { display: flex; align-items: center; }
.kopf-sprache {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.kopf-sprache span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--kopf-linie-stark);
  color: var(--kopf-tinte-weich);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.06em;
  transition: transform 0.2s ease;
}
.kopf-sprache[aria-current="page"] span {
  background: var(--kopf-tinte);
  box-shadow: none;
  color: #FFFFFF;
}
.kopf-sprache:hover span { transform: scale(1.08); }

.kopf-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px 0 22px;
  border-radius: 999px;
  background: var(--kopf-tinte);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.kopf-cta:hover { color: #FFFFFF; }
.kopf-pfeil { display: inline-block; transition: transform 0.2s ease; }
.kopf-cta:hover .kopf-pfeil { transform: translateX(3px); }

/* ---------- Knopf: drei Striche in drei Familienfarben = X ---------- */
.kopf-knopf {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kopf-flaeche);
  box-shadow: inset 0 0 0 1px var(--kopf-linie), 0 1px 3px rgba(26, 27, 46, 0.06);
  color: var(--kopf-tinte);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.kopf-striche {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 20px;
  height: 20px;
}
.kopf-striche span {
  position: absolute;
  left: 0;
  width: 20px;
  height: 3px;
  border-radius: 2px;
  transition: transform 0.38s cubic-bezier(0.65, 0, 0.35, 1);
}
.kopf-striche span:nth-child(1) { top: 3px;  background: #5277E3; }
.kopf-striche span:nth-child(2) { top: 9px;  background: #DB2777; transition: opacity 0.2s ease, transform 0.3s ease; }
.kopf-striche span:nth-child(3) { top: 15px; background: #EA580C; }
.kopf-knopf[aria-expanded="true"] .kopf-striche span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.kopf-knopf[aria-expanded="true"] .kopf-striche span:nth-child(2) { opacity: 0; transform: scaleX(0.2); }
.kopf-knopf[aria-expanded="true"] .kopf-striche span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Menü: Vollfläche unter dem Kopf ---------- */
.kopf-menue {
  position: fixed;
  inset: 0;
  z-index: 1;
  padding-top: var(--kopf-hoehe);
  background: var(--kopf-grund);
  opacity: 0;
  transform: translateY(-16px);
  visibility: hidden;
  pointer-events: none;
  /* versteckt heisst versteckt (auch für Tab und Screenreader), aber erst
     NACH dem Ausblenden; beim Öffnen sofort sichtbar */
  transition: opacity 0.26s ease, transform 0.34s var(--kopf-weich), visibility 0s linear 0.36s;
}
.kopf.ist-offen .kopf-menue {
  opacity: 1;
  transform: none;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.26s ease, transform 0.34s var(--kopf-weich), visibility 0s;
}
.kopf-menue-innen {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px max(16px, calc(50% - 264px)) 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.kopf-menue nav { margin-bottom: 24px; }

.kopf-eintraege {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.kopf-eintrag {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
  padding: 0 16px;
  border-radius: 18px;
  color: var(--kopf-tinte);
  /* Instrument Serif gibt es nur in 400: nie fett setzen */
  font-family: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  font-size: 36px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.005em;
}
.kopf-eintrag:hover { color: var(--kopf-tinte); }
.kopf-eintrag::before {
  content: '';
  flex: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--farbe);
  transform: scale(0);
  transition: transform 0.45s var(--kopf-feder);
}
/* Aktiver Eintrag: Hauch und ein Ring in der Familienfarbe, also ein
   Merkmal neben der Farbe (den Punkt trägt im Menü jeder Eintrag). Ein
   schmaler Spalt in der Menüfarbe trennt Ring und Hauch: Der Ring grenzt
   beidseitig an den Menügrund, alle sechs Farben mit mindestens 3:1. */
.kopf-eintrag[aria-current="true"] {
  background: var(--hauch);
  box-shadow: inset 0 0 0 2px var(--farbe), inset 0 0 0 4px var(--kopf-grund);
}

.kopf-menue-sprache {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 0 8px;
}
.kopf-globus { flex: none; width: 20px; height: 20px; color: var(--kopf-sub); }
.kopf-menue .kopf-sprachen { gap: 10px; }
.kopf-menue .kopf-sprache,
.kopf-menue .kopf-sprache span { width: 48px; height: 48px; }
.kopf-menue .kopf-sprache span { font-size: 13px; }
.kopf-menue .kopf-sprache:hover span { transform: none; }

.kopf-menue-cta {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 56px;
  margin-top: 22px;
  border-radius: 999px;
  background: var(--kopf-tinte);
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 700;
}
.kopf-menue-cta:hover { color: #FFFFFF; }

.kopf-menue-fuss {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: 8px;
  margin-top: 10px;
  padding: 0 6px 0 2px;
  color: var(--kopf-sub);
}
.kopf-menue-fuss > span:first-child { display: flex; align-items: center; }
.kopf-menue-fuss a {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 8px;
  color: var(--kopf-sub);
  font-size: 14px;
  font-weight: 500;
}
.kopf-menue-fuss a:hover { color: var(--kopf-tinte); }
.kopf-von { font-size: 13px; }

/* Gestaffeltes Erscheinen beim Öffnen; beim Schliessen ohne Verzögerung */
.kopf-eintraege li,
.kopf-menue-sprache,
.kopf-menue-cta,
.kopf-menue-fuss {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.3s ease, transform 0.5s var(--kopf-weich);
}
.kopf-eintraege li:nth-child(1) { --verz: 70ms; }
.kopf-eintraege li:nth-child(2) { --verz: 100ms; }
.kopf-eintraege li:nth-child(3) { --verz: 130ms; }
.kopf-eintraege li:nth-child(4) { --verz: 160ms; }
.kopf-eintraege li:nth-child(5) { --verz: 190ms; }
.kopf-eintraege li:nth-child(6) { --verz: 220ms; }
.kopf-menue-sprache { --verz: 260ms; }
.kopf-menue-cta     { --verz: 290ms; }
.kopf-menue-fuss    { --verz: 320ms; }
.kopf.ist-offen .kopf-eintraege li,
.kopf.ist-offen .kopf-menue-sprache,
.kopf.ist-offen .kopf-menue-cta,
.kopf.ist-offen .kopf-menue-fuss {
  opacity: 1;
  transform: none;
  transition-delay: var(--verz, 0ms);
}
.kopf.ist-offen .kopf-eintrag::before {
  transform: scale(1);
  transition-delay: calc(var(--verz, 0ms) + 100ms);
}

/* Ziel eines Menülinks: bekommt den Fokus (Startpunkt für die nächste
   Tab-Taste), aber keinen Rahmen um den ganzen Abschnitt. */
.kopf-ziel:focus { outline: none; }

/* ---------- Farbleiste: vier Segmente am unteren Rand ---------- */
.kopf-leiste {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: flex;
  gap: 3px;
  height: 5px;
  pointer-events: none;
}
.kopf-leiste span {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: var(--farbe);
  transform: scaleY(0.6);
  transform-origin: 50% 100%;
  transition: transform 0.45s var(--kopf-weich);
}
.kopf-leiste span:nth-child(2) { transition-delay: 45ms; }
.kopf-leiste span:nth-child(3) { transition-delay: 90ms; }
.kopf-leiste span:nth-child(4) { transition-delay: 135ms; }
/* Hervorgehoben: das Segment des aktiven (oder überfahrenen) Menüpunkts */
.kopf[data-hervor="blau"] .kopf-leiste .kopf-blau,
.kopf[data-hervor="violett"] .kopf-leiste .kopf-violett,
.kopf[data-hervor="pink"] .kopf-leiste .kopf-pink,
.kopf[data-hervor="orange"] .kopf-leiste .kopf-orange { transform: scaleY(1); }
/* Kompakt: alles dünner, das hervorgehobene Segment bleibt etwas höher */
.kopf.ist-kompakt:not(.ist-offen) .kopf-leiste span { transform: scaleY(0.3); }
.kopf.ist-kompakt:not(.ist-offen)[data-hervor="blau"] .kopf-leiste .kopf-blau,
.kopf.ist-kompakt:not(.ist-offen)[data-hervor="violett"] .kopf-leiste .kopf-violett,
.kopf.ist-kompakt:not(.ist-offen)[data-hervor="pink"] .kopf-leiste .kopf-pink,
.kopf.ist-kompakt:not(.ist-offen)[data-hervor="orange"] .kopf-leiste .kopf-orange { transform: scaleY(0.6); }

/* ---------- Ab 1160 px: alles in der Zeile (Grenze wie in kopf.js) ---------- */
@media (min-width: 1160px) {
  :root { --kopf-hoehe: 80px; }
  .kopf-zeile {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    height: 76px;
    padding: 0 24px;
  }
  .kopf-marke { justify-self: start; gap: 11px; padding-right: 8px; }
  .kopf-nav { display: flex; align-items: center; gap: 2px; }
  .kopf-rechts { display: flex; align-items: center; gap: 14px; justify-self: end; }
  .kopf-knopf,
  .kopf-menue { display: none; }
  .kopf-schatten { box-shadow: 0 10px 30px rgba(26, 27, 46, 0.10); }
}

/* ---------- Weniger Bewegung ---------- */
@media (prefers-reduced-motion: reduce) {
  .kopf,
  .kopf *,
  .kopf *::before,
  .kopf *::after { transition: none !important; }
  .kopf-menue { transform: none; }
}

/* ---------- Hoher Kontrast (Windows): Farben werden ersetzt ---------- */
@media (forced-colors: active) {
  .kopf-knopf { border: 1px solid ButtonText; }
  .kopf-striche span { background: ButtonText !important; }
  .kopf-link[aria-current="true"],
  .kopf-eintrag[aria-current="true"] { text-decoration: underline; }
  /* Flächen und box-shadow fallen hier weg: Die Sprachknöpfe bekommen einen
     Rand, die eigene Sprache bleibt gefüllt (in Systemfarben), die
     Hauptknöpfe einen Rahmen. */
  .kopf-sprache span { outline: 1px solid CanvasText; outline-offset: -1px; }
  .kopf-sprache[aria-current="page"] span {
    forced-color-adjust: none;
    background: CanvasText;
    color: Canvas;
  }
  .kopf-cta,
  .kopf-menue-cta { border: 2px solid ButtonText; }
}
