/* ============================================================
   Black Ink Intranet — Unified Site Navigation
   Professional minimalism. Black-on-white, generous spacing,
   subtle dropdown panels, full-width sticky header.
   ============================================================ */

.bibs-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow 200ms ease;
}

.bibs-header--scrolled {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03), 0 4px 16px rgba(0, 0, 0, 0.04);
}

.bibs-header__inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px;
  min-height: 72px;
}

/* --- Logo --- */
.bibs-header__logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  margin-right: 8px;
}

.bibs-header__logo img {
  height: 46px;
  width: auto;
  display: block;
}

/* --- Nav --- */
.bibs-header__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  margin-left: 16px;
}

.bibs-header__link,
.bibs-header__trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--color-gray-dark);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  line-height: 1.2;
  white-space: nowrap;
}

.bibs-header__link:hover,
.bibs-header__trigger:hover {
  background: var(--color-bg-light);
  color: var(--color-black);
}

.bibs-header__link--active,
.bibs-header__trigger[aria-expanded="true"] {
  color: var(--color-black);
  background: var(--color-bg-light);
}

.bibs-header__link:focus-visible,
.bibs-header__trigger:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: 2px;
}

.bibs-header__chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 200ms ease;
  opacity: 0.6;
}

.bibs-header__trigger[aria-expanded="true"] .bibs-header__chevron {
  transform: rotate(180deg);
}

/* --- Dropdown groups --- */
.bibs-header__group {
  position: relative;
}

.bibs-header__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  padding: 6px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  display: none;
  flex-direction: column;
  z-index: 110;
  animation: bibs-panel-in 160ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes bibs-panel-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bibs-header__group--open .bibs-header__panel { display: flex; }

.bibs-header__panel a {
  display: block;
  padding: 9px 12px;
  color: var(--color-gray-dark);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  transition: background 120ms ease, color 120ms ease;
  line-height: 1.3;
}

.bibs-header__panel a:hover {
  background: var(--color-bg-light);
  color: var(--color-black);
}

.bibs-header__panel a:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: -2px;
}

.bibs-header__panel-divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 4px;
}

.bibs-header__panel-caption {
  display: block;
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-gray-light);
}

/* --- User bar slot (auth.js fills this) --- */
.bibs-header__user {
  flex-shrink: 0;
  position: relative;
  margin-left: 8px;
}

/* User trigger pill (rendered by auth.js) */
.bibs-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-gray-dark);
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.bibs-user-trigger:hover {
  background: var(--color-bg-light);
  border-color: var(--color-border);
  color: var(--color-black);
}

.bibs-user-trigger[aria-expanded="true"] {
  background: var(--color-bg-light);
  border-color: var(--color-border);
  color: var(--color-black);
}

.bibs-user-trigger:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: 2px;
}

.bibs-user-trigger__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--color-bg-light);
}

.bibs-user-trigger__avatar--initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-black);
  color: var(--color-white);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.bibs-user-trigger__name {
  white-space: nowrap;
}

.bibs-user-trigger__chevron {
  width: 12px;
  height: 12px;
  opacity: 0.5;
  margin-right: 2px;
  transition: transform 200ms ease;
}

.bibs-user-trigger[aria-expanded="true"] .bibs-user-trigger__chevron {
  transform: rotate(180deg);
}

/* User dropdown menu */
.bibs-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  padding: 6px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  display: none;
  flex-direction: column;
  z-index: 110;
  animation: bibs-panel-in 160ms cubic-bezier(0.32, 0.72, 0, 1);
}

.bibs-user-menu--open { display: flex; }

.bibs-user-menu a,
.bibs-user-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--color-gray-dark);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 120ms ease, color 120ms ease;
}

.bibs-user-menu a:hover,
.bibs-user-menu button:hover {
  background: var(--color-bg-light);
  color: var(--color-black);
}

.bibs-user-menu a:focus-visible,
.bibs-user-menu button:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: -2px;
}

.bibs-user-menu__role-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.bibs-user-menu__divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 4px;
}

.bibs-user-menu__identity {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}

.bibs-user-menu__identity-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-black);
  line-height: 1.3;
}

.bibs-user-menu__identity-email {
  font-size: 12px;
  color: var(--color-gray-light);
  line-height: 1.3;
  word-break: break-all;
}

.bibs-user-menu__signout {
  color: var(--color-gray-dark) !important;
}

/* --- Mobile hamburger --- */
.bibs-header__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 150ms ease;
}

.bibs-header__hamburger:hover { background: var(--color-bg-light); }

.bibs-header__hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-black);
  border-radius: 2px;
  transition: transform 200ms ease, opacity 200ms ease;
}

body.bibs-nav-open .bibs-header__hamburger span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
body.bibs-nav-open .bibs-header__hamburger span:nth-child(2) { opacity: 0; }
body.bibs-nav-open .bibs-header__hamburger span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* --- Mobile drawer --- */
.bibs-header__drawer {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-white);
  padding: 16px 20px 32px;
  overflow-y: auto;
  z-index: 99;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
}

body.bibs-nav-open .bibs-header__drawer { transform: translateX(0); }

.bibs-header__drawer-group {
  border-bottom: 1px solid var(--color-border);
  padding: 4px 0;
}

.bibs-header__drawer-group:last-child { border-bottom: none; }

.bibs-header__drawer-section-title {
  display: block;
  padding: 14px 4px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-gray-light);
}

.bibs-header__drawer a,
.bibs-header__drawer button {
  display: block;
  padding: 12px 4px;
  color: var(--color-gray-dark);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
  border-radius: 6px;
}

.bibs-header__drawer a:hover,
.bibs-header__drawer button:hover {
  background: var(--color-bg-light);
  color: var(--color-black);
}

.bibs-header__drawer a.bibs-header__drawer-link--child {
  font-size: 15px;
  padding-left: 14px;
  color: var(--color-gray-medium);
}

/* --- Responsive --- */
@media (max-width: 880px) {
  .bibs-header__nav { display: none; }
  .bibs-header__hamburger { display: inline-flex; }
  .bibs-header__inner { padding: 0 16px; }
}

@media (min-width: 881px) {
  .bibs-header__drawer { display: none !important; }
}

/* --- Hide the original site-header during the JS-driven swap --- */
.site-header[data-bibs-replaced] { display: none !important; }
