/* Canonical public global header candidate. */
.global-header {
  --global-header-account-slot: 160px;
  --global-header-secondary-slot: 112px;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "brand nav actions";
  align-items: center;
  gap: 18px;
  padding-top: env(safe-area-inset-top);
}

.global-header .brand {
  grid-area: brand;
  min-width: max-content;
  justify-self: start;
}

.global-header-primary {
  grid-area: nav;
  min-width: 0;
  width: max-content;
  max-width: 100%;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.global-header-actions {
  grid-area: actions;
  justify-self: end;
  display: grid;
  grid-template-columns: 44px var(--global-header-secondary-slot) var(--global-header-account-slot);
  align-items: center;
  justify-content: end;
  gap: 8px;
  min-width: calc(60px + var(--global-header-secondary-slot) + var(--global-header-account-slot));
}

.global-header-notification {
  grid-column: 1;
}

.global-header-secondary-action {
  grid-column: 2;
  position: relative;
  width: var(--global-header-secondary-slot);
  min-width: var(--global-header-secondary-slot);
  height: 44px;
  min-height: 44px;
}

.global-header-account {
  grid-column: 3;
  justify-self: end;
}

/* Header chrome owns first-paint geometry. Runtime modules only hydrate behavior/data. */
.global-header-notification {
  position: relative;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
}

.global-header-notification .notification-trigger-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.global-header-notification .notification-bell-mark {
  width: 20px;
  height: 20px;
  display: block;
}


.global-header-notification .notification-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding-inline: 4px;
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: var(--button-text);
  border-color: var(--surface-solid);
  font-size: .68rem;
  line-height: 1;
}

/* Guest HTML is already the correct first paint. The persistent bell and Feedback
   slots exist for every user; only account geometry needs a verified auth hint
   before server hydration. */
html[data-js="true"][data-header-auth-hint="authenticated"] .global-header:not([data-actions-ready="true"]),
.global-header[data-authenticated="true"] {
  --global-header-account-slot: 44px;
}

html[data-js="true"][data-header-auth-hint="authenticated"] .global-header:not([data-actions-ready="true"]) .global-header-account {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 5px;
}

html[data-js="true"][data-header-auth-hint="authenticated"] .global-header:not([data-actions-ready="true"]) .global-header-avatar {
  display: grid;
  background: var(--accent-soft);
}

html[data-js="true"][data-header-auth-hint="authenticated"] .global-header:not([data-actions-ready="true"]) .global-header-account-label,
html[data-js="true"][data-header-auth-hint="authenticated"] .global-header:not([data-actions-ready="true"]) .account-trigger-chevron {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1500px) {
  .global-header {
    --global-header-secondary-slot: 44px;
  }

  .global-header-actions {
    min-width: calc(60px + var(--global-header-secondary-slot) + var(--global-header-account-slot));
  }
}

.global-header-account {
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}

.global-header-avatar {
  display: none;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .02em;
}

.global-header-account:not([data-authenticated="true"]) {
  width: 160px;
  min-width: 160px;
}

.global-header-account[data-authenticated="true"] {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 5px;
}

.global-header-account[data-authenticated="true"] .global-header-avatar {
  display: grid;
}

.global-header-account[data-authenticated="true"] .global-header-account-label,
.global-header-account[data-authenticated="true"] .account-trigger-chevron {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.global-header-account:hover,
.global-header-account:focus-visible {
  border-color: var(--accent);
}

.global-header-feedback,
.global-header-overflow {
  position: absolute;
  inset: 0;
  margin: 0;
}

.global-header-feedback {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  white-space: nowrap;
  visibility: visible;
  pointer-events: auto;
}

.global-header .feedback-trigger {
  min-height: 44px;
  white-space: nowrap;
}

.global-header-overflow {
  width: 100%;
  height: 44px;
  visibility: hidden;
  pointer-events: none;
}

.global-header-overflow > summary {
  list-style: none;
}

.global-header-overflow > summary::-webkit-details-marker {
  display: none;
}

.global-header-overflow-trigger {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  letter-spacing: .08em;
}

.global-header-overflow-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--brand-radius-control);
  background: var(--surface-solid);
  box-shadow: 0 18px 48px color-mix(in srgb, #000 24%, transparent);
}

.global-header-overflow:not([open]) .global-header-overflow-menu {
  display: none;
}

.global-header-overflow-item {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: calc(var(--brand-radius-control) - 4px);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.global-header-overflow-item:hover,
.global-header-overflow-item:focus-visible {
  background: var(--surface-soft);
  outline: none;
}

@media (max-width: 1500px) {
  .global-header-feedback {
    visibility: hidden;
    pointer-events: none;
  }

  .global-header-overflow {
    visibility: visible;
    pointer-events: auto;
  }
}

@media (max-width: 1280px) {
  .global-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "nav nav";
    gap: 10px 12px;
    padding-block: max(10px, env(safe-area-inset-top)) 10px;
  }

  .global-header-primary {
    width: 100%;
    justify-self: stretch;
    justify-content: center;
  }
}

@media (max-width: 820px) {
  .global-header-primary {
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .global-header-primary::-webkit-scrollbar {
    display: none;
  }

  .global-header-primary .ui-nav-link {
    flex: 0 0 auto;
  }
}

@media (max-width: 520px) {
  .global-header {
    width: min(100% - 24px, 1180px);
  }

  .global-header .brand > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .global-header-actions {
    gap: 6px;
  }

  .global-header .feedback-trigger {
    min-height: 40px;
    padding-inline: 11px;
    font-size: .88rem;
  }

  .global-header-account:not([data-authenticated="true"]) {
    min-height: 40px;
    padding-inline: 11px;
    font-size: .88rem;
  }

  .global-header-primary .ui-nav-link {
    padding-inline: 9px;
    font-size: .82rem;
  }
}


/* Progressive enhancement for same-origin full-document navigation.
   Unsupported browsers keep ordinary navigation; supporting browsers preserve
   the canonical header snapshot so it does not blink between public surfaces. */
@view-transition {
  navigation: auto;
}

.global-header {
  view-transition-name: arcana-global-header;
}

::view-transition-group(arcana-global-header) {
  animation-duration: 140ms;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 120ms;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(arcana-global-header),
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0s;
  }
}
