/* ======================================
   HEADER ROOT
====================================== */

.app-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: var(--z-fixed);
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0;
  transition:
    padding var(--animation-duration) var(--animation-timing),
    transform var(--animation-duration) var(--animation-timing);
}

.header-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  min-height: var(--header-height);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--spacing-3);
  padding: 0.95rem 1.25rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-xl);
  transition:
    padding 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    border-radius 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.35s ease,
    box-shadow 0.35s ease;
}

.app-header.scrolled {
  padding-top: 0.5rem;
}

.app-header.scrolled .header-shell {
  background: rgb(255 255 255 / 90%);
  box-shadow: var(--shadow-lg);
}

.app-header-compact .header-shell {
  grid-template-columns: 1fr;
  border-radius: 22px;
}

.header-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
  color: inherit;
}

.header-brand:hover {
  color: inherit;
}

.logo-circle {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    rgb(255 255 255 / 90%),
    rgb(220 232 247 / 50%)
  );
  box-shadow: var(--shadow-glow);
  object-fit: cover;
}

.brand-copy {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.brand-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.brand-copy strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.1;
  color: var(--text-strong);
}

.brand-copy small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.header-nav {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.header-link:hover,
.header-link.is-active {
  color: var(--text-strong);
  background: rgb(15 36 63 / 6%);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
}

.header-mobile-panel {
  display: contents;
}

.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  background: var(--gradient-primary);
  color: #fff;
  font-size: var(--font-size-sm);
  font-weight: 700;
  box-shadow: var(--shadow-glow);
}

.header-cta:hover {
  color: #fff;
  transform: translateY(-1px);
}

.header-menu-toggle {
  display: none;
  width: 46px;
  height: 46px;
  border: 1px solid var(--color-border-strong);
  border-radius: 16px;
  background: rgb(255 255 255 / 72%);
  color: var(--text-strong);
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  padding: 0.7rem;
  transition:
    background-color 0.35s ease,
    border-color 0.35s ease,
    transform 0.35s ease;
}

.header-menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentcolor;
  transform-origin: center;
  transition:
    transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.25s ease;
}

.header-menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.header-menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0.55);
}

.header-menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

[data-theme="dark"] .header-shell {
  background: rgb(14 23 38 / 82%);
}

[data-theme="dark"] .header-menu-toggle {
  background: rgb(18 31 52 / 78%);
}

[data-theme="contrast"] .header-shell {
  background: #fff;
  border: 2px solid #000;
  box-shadow: none;
}

[data-theme="contrast"] .header-link:hover,
[data-theme="contrast"] .header-link.is-active {
  background: #000;
  color: #fff;
}

[data-theme="contrast"] .header-cta {
  background: #000;
  box-shadow: none;
}

@media (width <= 960px) {
  body.nav-open {
    overflow: hidden;
  }

  .header-shell {
    grid-template-columns: 1fr auto;
    border-radius: 26px;
    align-items: center;
  }

  .header-menu-toggle {
    display: inline-flex;
  }

  .header-mobile-panel {
    display: grid;
    grid-column: 1 / -1;
    width: 100%;
    gap: 0.75rem;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-0.5rem);
    transform-origin: top center;
    transition:
      max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.35s ease,
      transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
      visibility 0s linear 0.4s;
  }

  .header-nav,
  .header-actions {
    display: flex;
    grid-column: 1 / -1;
    width: 100%;
  }

  .app-header.nav-open .header-shell {
    grid-template-columns: 1fr auto;
    align-items: start;
    row-gap: 0.9rem;
    border-radius: 28px;
    padding-bottom: 1rem;
    max-height: calc(100dvh - max(1rem, env(safe-area-inset-top)));
    overflow-y: auto;
    background: rgb(255 255 255 / 96%);
  }

  .app-header.nav-open .header-mobile-panel {
    max-height: 16rem;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0s;
  }

  .header-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .header-link,
  .header-cta {
    width: 100%;
    justify-content: center;
  }
}

@media (width <= 640px) {
  .app-header {
    padding-inline: 0.55rem;
  }

  .header-shell {
    padding: 0.8rem 0.9rem;
  }

  .logo-circle {
    width: 42px;
    height: 42px;
  }

  .brand-copy strong {
    font-size: 0.95rem;
  }

  .brand-copy small {
    font-size: 0.76rem;
  }
}

@media (width <= 480px) {
  .brand-kicker {
    display: none;
  }

  .app-header.nav-open .brand-copy small {
    display: none;
  }

  .header-shell {
    border-radius: 22px;
  }

  .brand-copy strong {
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-header,
  .header-shell,
  .header-link,
  .header-cta,
  .header-menu-toggle,
  .header-menu-toggle span {
    transition-duration: 0.01ms;
  }

  .header-mobile-panel {
    transition-duration: 0.15s;
  }
}
