/* Veil Docs Portal — header/footer/nav chrome. Uses tokens.css custom properties only. */

/* A same-specificity author rule (e.g. .btn/.account-menu { display: flex }) otherwise beats
   the browser's own [hidden] { display: none } default, since author styles always win over
   the UA stylesheet regardless of declaration order — found live via Playwright: auth.js's
   [data-auth-logged-out]/[data-auth-logged-in] toggle set the `hidden` attribute correctly,
   but the element stayed visually visible because .btn/.account-menu's own display rule
   overrode it. One global override here covers every current and future hidden-toggled
   element instead of patching each class individually. */
[hidden] {
  display: none !important;
}

.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header__inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.site-header__logo {
  display: block;
  height: 28px;
  width: auto;
}

.site-header__brand {
  display: flex;
  align-items: center;
}

.site-header__panel {
  display: none;
}

/* Mobile dropdown state (nav-toggle.js toggles .is-open on click). .site-header keeps its
   pre-existing `position: sticky`, which is a valid containing block for this panel's
   `position: absolute` — so it drops full-bleed below the whole header, ignoring
   .site-header__inner's own max-width/padding, rather than being squeezed into the inner
   content column. */
.site-header__panel.is-open {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4);
  box-shadow: 0 8px 24px var(--color-shadow);
  max-height: calc(100vh - 100%);
  overflow-y: auto;
}

.site-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.site-nav__link {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.site-nav__link:hover {
  color: var(--color-accent);
}

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

.site-nav__shortcut {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
  line-height: 1.4;
}

.site-header__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
}

.locale-switch {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.account-menu {
  position: relative;
}

.account-menu__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.account-menu__trigger:hover,
.account-menu__trigger[aria-expanded="true"] {
  border-color: var(--color-border);
  background: var(--color-bg-subtle);
}

.account-menu__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
  overflow: hidden;
}

.account-menu__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-menu__email {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu__chevron {
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.account-menu__trigger[aria-expanded="true"] .account-menu__chevron {
  transform: rotate(180deg);
}

.account-menu__panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 15rem;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px var(--color-shadow);
  padding: var(--space-2);
  z-index: 50;
}

.account-menu__panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-3);
  margin-bottom: var(--space-1);
  border-bottom: 1px solid var(--color-border);
}

.account-menu__panel-email {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu__admin-badge {
  flex-shrink: 0;
}

.account-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  background: none;
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-family: inherit;
  cursor: pointer;
}

.account-menu__item:hover {
  background: var(--color-bg-subtle);
}

.account-menu__item--danger:hover {
  color: var(--color-danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn--primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.btn--primary:hover {
  background: var(--color-accent-hover);
  color: var(--color-on-accent);
}

.btn--ghost {
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.btn--ghost:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.site-header__menu-toggle {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.site-header__menu-toggle span {
  display: block;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

/* Animate the three bars into an X while the mobile panel is open. */
.site-header__menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.site-header__menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

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

@media (min-width: 1024px) {
  .site-header__panel,
  .site-header__panel.is-open {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-5);
    flex: 1;
    position: static;
    background: none;
    border-bottom: none;
    box-shadow: none;
    padding: 0;
    max-height: none;
    overflow: visible;
  }

  .site-nav {
    flex-direction: row;
    gap: var(--space-5);
    flex: 1;
  }

  .site-header__actions {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
  }

  .site-header__menu-toggle {
    display: none;
  }
}

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  margin-top: var(--space-9);
}

.site-footer__inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-7) var(--space-4) var(--space-6);
  display: grid;
  gap: var(--space-6);
}

.site-footer__brand img {
  height: 24px;
  width: auto;
}

.site-footer__tagline {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-top: var(--space-3);
  max-width: 24ch;
}

.site-footer__columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5);
}

.site-footer__column h3 {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 var(--space-3);
}

.site-footer__column a {
  display: block;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-2);
}

.site-footer__column a:hover {
  color: var(--color-accent);
}

.site-footer__bottom {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4);
  text-align: center;
}

.site-footer__bottom p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

@media (min-width: 640px) {
  .site-footer__inner {
    grid-template-columns: 1fr 2fr;
  }

  .site-footer__columns {
    grid-template-columns: repeat(3, 1fr);
  }
}
