/* ==========================================================================
   E4 Cards — Site Header
   Global top bar with tool switcher. Requires colors_and_type.css first.
   ========================================================================== */

.e4-header {
  background: var(--ink);
  /* Atrium Edged: faintly luminous hairline at the bottom of the header,
     reads as a glass edge against the lit page background. */
  border-bottom: 1px solid var(--sky-tint);
  position: sticky;
  top: 0;
  z-index: 40;
}

.e4-header__inner {
  display: flex;
  align-items: center;
  gap: 1em;
  padding: 0.75em 1.25em;
  max-width: var(--max-w-tool, 1280px);
  margin: 0 auto;
}

/* ---------- BRAND -------------------------------------------------------- */
.e4-header__brand {
  display: flex;
  align-items: center;
  gap: 0.7em;
  flex-shrink: 0;
  color: #fff;
  text-decoration: none;
}
.e4-header__logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}
.e4-header__wordmark {
  font-size: 0.95em;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ---------- TOOL RAIL (breadcrumb-style switcher) ----------------------- */
.e4-toolrail {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.e4-toolrail__tools {
  font-family: var(--font);
  height: 28px;
  padding: 0 0.85em;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  border-radius: var(--r-pill);
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.e4-toolrail__tools:hover,
.e4-toolrail__tools[aria-expanded="true"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.e4-toolrail__tools:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.e4-toolrail__sep {
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.7em;
  padding: 0 0.2em;
  user-select: none;
}

.e4-toolrail__current {
  height: 28px;
  padding: 0 0.95em;
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-pill);
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--cyan);
  color: #fff;
  border: 1px solid var(--cyan);
  white-space: nowrap;
}

.e4-toolrail__caret {
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.6;
}

/* ---------- DROPDOWN MENU ----------------------------------------------- */
.e4-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 320px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0.5em;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.e4-toolrail[data-open="true"] .e4-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.e4-menu__label {
  font-size: 0.62em;
  font-weight: 600;
  color: var(--text-mute);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.7em 0.9em 0.3em;
}

/* Collapsible section header — same visual weight as the static label,
   just made into a button so users can collapse a category. */
.e4-menu__label--toggle {
  display: flex;
  align-items: center;
  gap: 0.45em;
  width: 100%;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 0.62em;
  font-weight: 600;
  color: var(--text-mute);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.7em 0.9em 0.3em;
}
.e4-menu__label--toggle:hover,
.e4-menu__label--toggle:focus-visible {
  color: var(--heading);
  outline: none;
}
.e4-menu__chevron {
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 1em;
  line-height: 1;
}
.e4-menu__label--toggle[aria-expanded="false"] .e4-menu__chevron {
  transform: rotate(-90deg);
}
.e4-menu__section[data-collapsed="true"] .e4-menu__items { display: none; }

.e4-menu__divider {
  border: 0;
  border-top: 1px solid var(--divider);
  margin: 0.4em 0.3em;
}

.e4-menu__item {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.55em 0.8em;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 0.88em;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.3;
}
.e4-menu__item:hover,
.e4-menu__item:focus-visible {
  background: var(--panel-hover);
  border-color: var(--border);
  color: var(--heading);
  outline: none;
}
.e4-menu__item[aria-current="page"] {
  background: var(--cyan-tint);
  border-color: var(--cyan);
  color: var(--cyan);
}

.e4-menu__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
}
.e4-menu__icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.e4-menu__item:hover .e4-menu__icon,
.e4-menu__item:focus-visible .e4-menu__icon { color: var(--heading); }
.e4-menu__item[aria-current="page"] .e4-menu__icon { color: var(--cyan); }

.e4-menu__body { flex: 1; }
.e4-menu__sub {
  display: block;
  color: var(--text-mute);
  font-size: 0.78em;
  font-weight: 400;
  margin-top: 0.1em;
  letter-spacing: 0;
  text-transform: none;
}
.e4-menu__item[aria-current="page"] .e4-menu__sub {
  color: rgba(34, 200, 224, 0.7);
}

/* ---------- USER + SIGN OUT (right side) -------------------------------- */
.e4-header__right {
  display: flex;
  align-items: center;
  gap: 0.55em;
  flex-shrink: 0;
  margin-left: auto;
}

.e4-userchip {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0 0.85em;
  height: 34px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.e4-userchip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 200, 224, 0.18);
}
.e4-userchip__name {
  color: inherit;
  text-decoration: none;
  letter-spacing: inherit;
  text-transform: inherit;
}
.e4-userchip__name:hover,
.e4-userchip__name:focus-visible {
  color: #fff;
  outline: none;
  text-decoration: underline;
}
.e4-userchip__name[aria-current="page"] {
  color: var(--cyan);
}
.e4-userchip__role {
  background: var(--cyan-tint);
  color: var(--cyan);
  border: 1px solid var(--cyan);
  font-size: 0.85em;
  padding: 0.1em 0.5em;
  border-radius: var(--r-pill);
  letter-spacing: 0.1em;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
a.e4-userchip__role:hover,
a.e4-userchip__role:focus-visible {
  background: var(--cyan);
  color: #fff;
  outline: none;
}
a.e4-userchip__role[aria-current="page"] {
  background: var(--cyan);
  color: #fff;
}

.e4-signout {
  height: 34px;
  line-height: 32px;
  padding: 0 1em;
  border-radius: var(--r-pill);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.e4-signout:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

/* ---------- RESPONSIVE -------------------------------------------------- */
@media (max-width: 720px) {
  .e4-header__wordmark { display: none; }
  .e4-toolrail__tools span:not(.e4-toolrail__caret) { display: none; }
  .e4-userchip { padding: 0 0.5em; }

  /* Two-column dropdown so all tools fit on one mobile screen. The section
     wrappers span the full width; the items inside each section grid into
     two columns themselves. */
  .e4-menu {
    min-width: min(92vw, 360px);
    max-width: 92vw;
  }
  .e4-menu__section,
  .e4-menu__divider,
  .e4-menu__item--admin {
    grid-column: 1 / -1;
  }
  .e4-menu__items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 0.25em;
    row-gap: 0.1em;
  }
  .e4-menu__sub { display: none; }
  .e4-menu__item { padding: 0.5em 0.55em; font-size: 0.9em; }
}

/* ---------- TICKETS BUTTON --------------------------------------------- */
/* Top-bar Tickets button (rendered globally in _site_header.html). Style
   lives here, not in tools/tickets/static/tickets.css, because the
   button is visible on every page — not just /tickets.

   Two visual states:
   - Default (no open tickets) — muted slate so it fades into the dark bar.
   - .e4-tickets-btn--active (open tickets > 0) — saturated yellow, draws
     the eye on login. */
.e4-tickets-btn {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.25em 0.7em; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none; font-weight: 600; font-size: 0.88em;
  margin-right: 0.6em;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.e4-tickets-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.35);
}
.e4-tickets-btn--active {
  background: #fff7d6;
  border-color: #e0c75e;
  color: #5b4400;
}
.e4-tickets-btn--active:hover {
  background: #ffefae;
  color: #5b4400;
  border-color: #e0c75e;
}
.e4-tickets-btn__icon { width: 16px; height: 16px; flex: 0 0 auto; }
/* Default-state icon: dim the warning dot so it matches the muted text. */
.e4-tickets-btn:not(.e4-tickets-btn--active) .e4-tickets-btn__icon { opacity: 0.55; }
.e4-tickets-btn__count {
  display: inline-block; padding: 0 0.45em; border-radius: 999px;
  background: #b85a00; color: #fff; font-size: 0.78em; line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* ---------- PRINT ------------------------------------------------------- */
@media print {
  .e4-header { display: none !important; }
}
