/* The one app header (shared/nav.ts): the editor's top bar, used on every signed in page.
   Shared by both sides: the server pages link this file (server/pages/layout.ts) and the React
   AppHeader of the editor and the calendar imports it (src/components/AppHeader.tsx), so the
   markup and these classes are the same everywhere. It reads the editor tokens (--editor-*, RGB
   triplets; src/index.css and server/static/app.css define them, light and `.dark`), never a fixed
   light-only or dark-only color.
   The page switch: cross document View Transitions keep the header in place (its own transition
   name) and fade the rest of the page; browsers without them get the fallback classes that
   theme-init.js and transitions.js (and AppHeader on the React pages) set on <html>:
   `ah-leaving` fades the content out on a same-origin link click, `ah-fade-in` fades it in on load.
   Nothing moves with prefers-reduced-motion: reduce. */

.app-header {
  view-transition-name: app-header;
  position: relative;
  /* view-transition-name makes the header its own stacking context; without a z-index the page
     content after it paints on top and covers the header's menus (Meer, Nieuwe post). Page
     dialogs and toasts sit far above this (z-index 9999 and up). */
  z-index: 40;
  flex-shrink: 0;
  background-color: rgb(255 255 255 / 0.65);
  border: 1px solid rgb(255 255 255 / 0.8);
  border-radius: 1.25rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  color: rgb(var(--editor-text));
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-style: normal;
  letter-spacing: normal;
}
.dark .app-header {
  background-color: rgb(23 31 54 / 0.55);
  border-color: rgb(255 255 255 / 0.08);
}
/* Server pages and the calendar: the same 12px inset the editor gets from its own padding. */
.app-header.ah-inset {
  margin: 0.75rem 0.75rem 0;
}

.ah-row {
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.75rem;
}
.ah-start,
.ah-end {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
}
.ah-start {
  gap: 0.5rem;
}
.ah-end {
  gap: 0.25rem;
}
@media (min-width: 1280px) {
  .ah-row {
    padding: 0 1rem;
  }
  .ah-start {
    gap: 0.75rem;
  }
}

.ah-logo {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  min-height: 2rem;
  border-radius: 0.625rem;
  background: #ffffff; /* the logo is drawn for a white tile, in both themes */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ah-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ah-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}
.ah-form {
  display: contents;
  margin: 0;
}

/* A nav pill: the main nav, Wachtwoord and Uitloggen. */
.ah-pill {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.375rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: rgb(var(--editor-muted));
  font: inherit;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1), background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.ah-pill:hover {
  color: rgb(var(--editor-text));
  background-color: rgb(var(--editor-border));
}
.ah-pill.is-active {
  color: rgb(var(--editor-accent));
  background-color: rgb(var(--editor-accent) / 0.1);
}
/* Bigger touch targets on a phone. */
@media (max-width: 639px) {
  .ah-pill {
    padding: 0.5rem;
  }
}

/* The pill label: always read out, shown from sm (640px), or from xl (1280px) in the editor,
   whose row is full of its own buttons. */
.ah-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
@media (min-width: 640px) {
  .app-header:not(.ah-labels-xl) .ah-label {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
  }
}
@media (min-width: 1280px) {
  .app-header .ah-label {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
  }
}

.ah-svg {
  display: block;
  flex-shrink: 0;
}

.ah-sep {
  display: block;
  height: 1.5rem;
  width: 1px;
  margin: 0 0.25rem;
  background-color: rgb(var(--editor-border));
  flex-shrink: 0;
}

/* A round icon button: the theme switch (and the editor's own buttons next to it). */
.ah-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: rgb(var(--editor-muted));
  cursor: pointer;
  transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1), background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.ah-icon-btn:hover {
  color: rgb(var(--editor-text));
  background-color: rgb(var(--editor-border));
}
.ah-only-dark {
  display: none;
}
.dark .ah-only-dark {
  display: block;
}
.dark .ah-only-light {
  display: none;
}

.app-header a:focus-visible,
.app-header button:focus-visible {
  outline: 2px solid rgb(var(--editor-accent));
  outline-offset: 2px;
}

/* ── The page switch ─────────────────────────────────────────────────── */

@view-transition {
  navigation: auto;
}

@keyframes ah-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes ah-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
/* The content: a short fade out, then the new page fades in. */
::view-transition-old(root) {
  animation: 120ms cubic-bezier(0.4, 0, 1, 1) both ah-fade-out;
}
::view-transition-new(root) {
  animation: 180ms cubic-bezier(0, 0, 0.2, 1) 60ms both ah-fade-in;
}
/* The header keeps its place; it only morphs where the two pages show other buttons. */
::view-transition-group(app-header) {
  animation-duration: 200ms;
}
::view-transition-old(app-header),
::view-transition-new(app-header) {
  animation-duration: 200ms;
}
/* The editor and the calendar draw their header with React a moment after the first frame, inside
   the new page's live image: the old header stays a moment, then crossfades into it instead of
   blinking out. */
::view-transition-old(app-header):only-child {
  animation: 200ms cubic-bezier(0.4, 0, 1, 1) 120ms both ah-fade-out;
}
/* From a page without the header (the login) the header fades in with the content. */
::view-transition-new(app-header):only-child {
  animation: 180ms cubic-bezier(0, 0, 0.2, 1) 60ms both ah-fade-in;
}

/* The fallback without View Transitions: everything after the header is the content. */
@media (prefers-reduced-motion: no-preference) {
  .ah-leaving .app-header ~ * {
    opacity: 0;
    transition: opacity 140ms cubic-bezier(0.4, 0, 1, 1);
  }
  .ah-fade-in .app-header ~ * {
    animation: ah-fade-in 200ms cubic-bezier(0, 0, 0.2, 1) both;
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
  .app-header,
  .ah-pill,
  .ah-icon-btn {
    transition: none;
  }
}
