/* =========================================================
   Navigation — Klar
   - .app-header   : 60 px bar, brand or back, avatar on the right
   - .bottom-nav   : the four main areas, flush at the bottom edge
   - .icon-button  : icon-only action with a 44 px touch target
   ----------------------------------------------------------
   The reference draws both bars inside a phone frame. Here they
   belong to the window: the header sticks to the top, the
   navigation to the bottom, and both keep clear of the safe areas.
   ========================================================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
}

.app-header__inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  min-height: var(--app-header-row-h);
  /* Die Referenz gibt dem Kopf 20 px, dem Inhalt 18 px. Das ist kein
     Versehen: der Kopf trägt runde Touchziele, die optisch weiter
     innen stehen als ein Textblock mit derselben Kante. */
  padding-left: max(20px, var(--safe-left));
  padding-right: max(20px, var(--safe-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ---------------- "Anmelden als" band ----------------
   While a superuser sees the app as somebody else (django-hijack), a band
   stands above the header row on every page. It belongs to the sticky header,
   so it never scrolls away; the header grows by its height through
   ``--app-header-h``, and the toasts and scroll margins that read that token
   stay below it. The colours are the danger-soft set: a state to notice,
   not an error. */

body.is-hijacked {
  --app-header-h: calc(var(--app-header-row-h) + var(--hijack-band-h));
}

.app-header__hijack {
  min-height: var(--hijack-band-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-left: max(20px, var(--safe-left));
  padding-right: max(12px, var(--safe-right));
  background: var(--danger-soft-bg);
  color: var(--danger-soft-ink);
  border-bottom: 1px solid var(--danger-soft-line);
  font-size: var(--text-md);
  line-height: 1.3;
}

.app-header__hijack-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header__hijack-text strong {
  font-weight: 650;
}

.app-header__hijack form {
  flex: none;
  margin: 0;
}

.app-header__hijack-end {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.app-header__hijack-end:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -4px;
  border-radius: 8px;
}

.app-header__lead {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.app-header__trail {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.app-header__back {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  line-height: 1;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast);
}

.app-header__back:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--tint);
}

.app-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.6px;
}
.app-header__brand:hover {
  color: var(--ink);
}

/* Die Größe der Marke steht bei den Symbolen (klar-icons.css,
   ``.app-header__brand svg`` = 24 px), nicht hier. */
.app-header__logo {
  color: var(--accent);
  line-height: 1;
  display: inline-flex;
  flex: none;
}

.app-header__title {
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header__actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Avatar: initials, centred, on the accent tint. */
.app-header__avatar,
.avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  line-height: 1;
  flex: none;
  background: var(--tint);
  color: var(--accent);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  padding: 0;
  overflow: hidden;
}

/* Der Kreis im Kopf ist ein Link und damit ein Touchziel — 44 px, nicht 40
   wie der rein anzeigende Avatar in Listen. */
.app-header__avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

.app-header__avatar:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Icon action */
.icon-button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast);
}
.icon-button:hover {
  background: var(--tint);
  color: var(--accent);
}

.icon-button--ghost,
.icon-button--plain {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.icon-button--ghost:hover,
.icon-button--plain:hover {
  background: var(--tint);
  color: var(--accent);
}

.icon-button--accent {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.icon-button--accent:hover {
  background: var(--accent);
  color: #fff;
  filter: brightness(1.07);
}

/* ---------------- Bottom navigation ----------------
   Home, Tagebuch, Körperdaten, Rezepte, Mehr (Körperdaten since
   25.10.2026). A sub-view keeps the area it belongs to marked
   (UIUX.md) — the view sets ``nav_active``.

   Five items: each takes the width of its label, and the space left
   over is shared equally. Equal columns would cut "Körperdaten" below
   390 px while "Home" and "Mehr" kept room to spare (measured in
   Chromium: the label needs 65 px at 10 px, a fifth of a 320 px bar
   is 56 px). */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 9px max(12px, var(--safe-left)) max(12px, var(--safe-bottom)) max(12px, var(--safe-right));
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-height: var(--bottom-nav-h);
}

.bottom-nav__inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  gap: 4px;
}

.bottom-nav__item {
  flex: 1 1 auto;
  padding-inline: 4px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 54px;
  border-radius: 13px;
  text-decoration: none;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  border: 0;
  background: transparent;
  /* Never narrower than a touch target; below that the label shortens. */
  min-width: 44px;
  transition:
    color var(--t-fast),
    background var(--t-fast);
}
.bottom-nav__item span {
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.bottom-nav__item:hover {
  color: var(--ink);
}

/* Aktiver Punkt (25.10.2026): keine Fläche, sondern Akzentfarbe, kräftigere
   Schrift und ein kurzer Unterstrich unter der Beschriftung. */
.bottom-nav__item.is-active {
  color: var(--accent);
  font-weight: 800;
}
.bottom-nav__item.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 18px;
  height: 2px;
  margin-left: -9px;
  border-radius: 2px;
  background: var(--accent);
}

/* Short viewports and an open keyboard: the bar must not eat the
   form. ``svh`` cannot see the keyboard, so this is height-based. */
@media (max-height: 420px) {
  .bottom-nav {
    min-height: 58px;
    padding-top: 4px;
  }
  .bottom-nav__item {
    min-height: 44px;
    flex-direction: row;
    gap: 7px;
  }
  .bottom-nav__item svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 360px) {
  .bottom-nav__item span {
    font-size: var(--text-2xs);
  }
  .app-header__brand {
    font-size: max(1rem, 16px);
  }
}
