﻿/* Compact single-row engine header + hover/focus dropdown menus.
   Restores the layout expected by index.html header-menus markup.
   Without this file, Action/Status panels render inline and stack ~5 rows. */

.engine-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand nav menus";
  align-items: center;
  gap: 0.55rem 0.85rem;
  padding: 0.35rem 0.85rem;
  min-height: 3rem;
  max-height: none;
  overflow: visible;
  z-index: 500;
}

.engine-header .sub {
  display: none;
}

.engine-header .logo-ring {
  width: 34px;
  height: 34px;
}

.engine-header h1 {
  font-size: 1.15rem;
  line-height: 1.1;
}

.header-brand {
  grid-area: brand;
}

.page-dot-nav {
  grid-area: nav;
}

.product-navigation {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  z-index: 40;
  grid-area: nav;
}

.header-menus {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 0.35rem;
  min-width: 0;
  flex-wrap: nowrap;
  z-index: 520;
  grid-area: menus;
  overflow: visible;
}

.product-navigation-list {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.product-nav-item {
  flex: 0 0 auto;
  min-height: 2.15rem;
  padding: 0.35rem 0.55rem;
  white-space: nowrap;
}

.product-nav-item[aria-current="page"],
.product-nav-item.is-active {
  color: var(--cyan, #22d3ee);
  border-color: rgba(34, 211, 238, 0.55);
}

.product-navigation-status {
  flex: 0 0 auto;
}

.header-menu {
  position: relative;
  flex: 0 0 auto;
  overflow: visible;
  z-index: 520;
}

.header-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.15rem;
  padding: 0.35rem 0.7rem;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 521;
  visibility: visible;
}

.header-menu-caret {
  font-size: 0.7em;
  opacity: 0.75;
  line-height: 1;
}

/* Beat tokens.css `.header-actions { display:flex }` (same specificity) so
   Action/Status content never spills into the compact header row. */
.header-menus > .header-menu > .header-menu-panel {
  display: none;
  position: fixed;
  top: calc(var(--chrome-h, 56px) + 0.25rem);
  right: 0.75rem;
  left: auto;
  min-width: 16rem;
  max-width: min(28rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 32rem);
  overflow: auto;
  padding: 0.65rem;
  background: rgba(10, 14, 24, 0.98);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 640;
}

.header-menus > .header-menu:hover > .header-menu-panel,
.header-menus > .header-menu:focus-within > .header-menu-panel,
.header-menus > .header-menu.is-open > .header-menu-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: stretch;
}

/* Hover bridge: a transparent strip spanning the 0.25rem gap between the trigger
   and the panel so the pointer can travel across without dropping :hover and
   collapsing the menu (Fix 1, Wave 4.3). */
.header-menus > .header-menu > .header-menu-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 0.5rem;
  background: transparent;
}

/* Actions panel: chips stack vertically inside the dropdown, never the header row */
.header-menus > .header-menu > .header-menu-panel.header-actions {
  min-width: 16rem;
  flex-wrap: nowrap;
  margin-left: 0;
  justify-self: auto;
  /* neutralize legacy .header-actions flex-row chrome */
  align-items: stretch;
  gap: 0.45rem;
}

.header-menu-panel.header-actions > .chip,
.header-menu-panel.header-actions > .session-badge,
.header-menu-panel.header-actions > button {
  width: 100%;
  justify-content: flex-start;
  border-radius: 8px;
  text-align: left;
}

/* View preset chips share Actions chip chrome; accent marks the active lens. */
#header-menu-view > .chip[aria-pressed="true"],
#header-menu-view > .chip.accent {
  border-color: rgba(34, 211, 238, 0.45);
}

.header-menu-panel .moa-truth-label {
  flex: 0 0 auto;
  max-width: none;
  margin: 0;
  padding-top: 0.15rem;
}

.header-menu-panel .health,
.header-menu-panel .single-wheel-health {
  margin: 0;
}

.header-menu-panel .single-wheel-health {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: stretch;
}

.header-menu-panel #persistent-health-strip {
  flex: 0 0 auto;
  width: 100%;
  max-width: none;
}

.header-menu-panel .ollama-work-lineage {
  margin: 0;
  max-width: 32rem;
  white-space: normal;
}

.header-menu-panel .ollama-work-lineage[data-work-attribution="flywheel_attributed"],
.header-menu-panel .ollama-work-lineage[data-work-attribution="no_active_flywheel_work_observed"] {
  color: var(--lime);
}

.header-menu-panel .ollama-work-lineage[data-work-attribution="unattributed_local_provider_activity"],
.header-menu-panel .ollama-work-lineage[data-work-attribution="unknown_or_external"] {
  color: #fbbf24;
}

#btn-single-wheel-health-live[data-provider-state="live"] {
  color: var(--lime);
  border-color: rgba(132, 204, 22, 0.78);
  box-shadow: 0 0 0.35rem rgba(132, 204, 22, 0.55), 0 0 1rem rgba(132, 204, 22, 0.28);
}

#btn-single-wheel-health-live[data-provider-state="offline"] {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.48);
  box-shadow: none;
}

#btn-single-wheel-health-live[data-provider-state="starting"],
#btn-single-wheel-health-live[data-provider-state="stopping"],
#btn-single-wheel-health-live[data-provider-state="degraded"] {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.58);
  box-shadow: 0 0 0.6rem rgba(251, 191, 36, 0.22);
}

/* Status trigger tints from live #health state (see header-menus.js) */
.header-menu-trigger[data-health="ok"] {
  border-color: rgba(132, 204, 22, 0.45);
  color: var(--lime);
}

.header-menu-trigger[data-health="bad"] {
  border-color: rgba(248, 113, 113, 0.45);
  color: #f87171;
}

.header-menus > .session-badge {
  flex: 0 0 auto;
  max-width: 11rem;
}

.page-dot-nav {
  margin: 0;
  padding: 0.1rem 0.25rem;
  white-space: nowrap;
  gap: 0.85rem;
}

/* Compact readable page names — dots alone were too cryptic in the slim header */
.engine-header .page-dot-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.engine-header .page-dot-item-control {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18rem;
}

.engine-header .page-dot-label {
  display: inline !important;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: rgba(226, 232, 240, 0.78);
  line-height: 1.1;
}

.engine-header .page-dot-label small {
  display: none;
}

.engine-header .page-dot-item:has(.page-dot.is-active) .page-dot-label {
  color: var(--cyan, #22d3ee);
}

body.presenter-mode .header-menus,
body[data-presenter="on"] .header-menus {
  display: none;
}

@media (max-width: 1180px) {
  .engine-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "brand nav menus";
    align-items: center;
  }

  .header-menus {
    max-width: min(100%, 28rem);
    overflow: visible;
    scrollbar-width: thin;
  }
}

@media (max-width: 760px) {
  .engine-header {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "brand menus"
      "product product"
      "dots dots";
    gap: 0.35rem 0.55rem;
    padding: 0.35rem 0.65rem;
  }

  .header-brand { grid-area: brand; }
  .page-dot-nav {
    grid-area: dots;
    justify-self: start;
  }
  .product-navigation {
    grid-area: product;
  }
  .header-menus {
    grid-area: menus;
    max-width: none;
  }

  .header-menu-trigger,
  .header-menus > .session-badge {
    min-height: 2.4rem;
  }

  .header-menus > .header-menu > .header-menu-panel {
    position: fixed;
    left: 0.5rem;
    right: 0.5rem;
    top: auto;
    width: auto;
    max-width: none;
  }
}
