/**
 * Phase 8B.8 — Canonical public header (Pilot Assessment standard).
 * Single header layout for all public and authority surfaces.
 */

body.ex-institutional-env.ex-canonical-public-header:has(.ex-env-chrome-band) {
  --ex-env-chrome-scroll-padding: 56px;
}

html:has(body.ex-institutional-env.ex-canonical-public-header:has(.ex-env-chrome-band)) {
  scroll-padding-top: var(--ex-env-chrome-scroll-padding, 56px);
}

body.ex-institutional-env.ex-canonical-public-header:has(.ex-env-chrome-band)
  :is(#main-content, main.shell, .shell, .ex-inst-shell)
  :is(section[id], article[id], #app, main[id], .hero) {
  scroll-margin-top: var(--ex-env-chrome-scroll-padding, 56px);
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-header,
body.ex-institutional-env.ex-canonical-public-header .ex-env-header--canonical {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  align-items: center;
  min-height: 40px;
  padding: 6px var(--ex-ds-s24, 24px);
  max-width: 1180px;
  margin: 0 auto;
  border-bottom: none;
  gap: var(--ex-ds-s12, 12px);
  box-sizing: border-box;
  width: 100%;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-brand strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ex-ds-blue, #1c3554);
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-brand span {
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ex-ds-muted, #7a8da3);
  line-height: 1.25;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: var(--ex-ds-s12, 12px);
  padding: 0;
  border: 0;
  background: transparent;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-funnel-flow {
  justify-self: end;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-flow-customer.ex-env-funnel-progression {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 4px 10px;
  border: 1px solid rgba(28, 53, 84, 0.12);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.95);
  flex-wrap: nowrap;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-funnel-separator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  color: rgba(122, 141, 163, 0.72);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-funnel-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-funnel-step.is-active {
  color: var(--ex-ds-blue, #1c3554);
  background: #fff;
  border-color: rgba(28, 53, 84, 0.16);
  box-shadow: 0 1px 0 rgba(28, 53, 84, 0.04);
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-flow-customer,
body.ex-institutional-env.ex-canonical-public-header .ex-env-flow-operator,
body.ex-institutional-env .ex-env-footer-flow-customer,
body.ex-institutional-env .ex-env-footer-flow-operator {
  display: flex;
  align-items: center;
  gap: var(--ex-ds-s16, 16px);
  flex-wrap: wrap;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-flow-separator,
body.ex-institutional-env .ex-env-footer-flow .ex-env-flow-separator {
  color: rgba(122, 141, 163, 0.55);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  padding: 0 2px;
  user-select: none;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-flow-operator {
  margin-left: 2px;
  padding-left: 2px;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow a {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ex-ds-muted, #7a8da3);
  padding: 1px 0;
  white-space: nowrap;
  border-bottom: none;
  background: transparent;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow a.ex-env-funnel-step {
  padding: 2px 8px;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow a:hover {
  color: var(--ex-ds-blue, #1c3554);
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow a.is-active {
  color: var(--ex-ds-blue, #1c3554);
  border-bottom-color: transparent;
  background: transparent;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow a.ex-env-funnel-step.is-active {
  border-bottom: none;
}

/* Operator-only surface — accessible but not customer funnel */
body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow a.ex-env-flow-link--operator {
  opacity: 0.42;
  font-weight: 500;
  letter-spacing: 0.08em;
}

body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow a.ex-env-flow-link--operator:hover,
body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow a.ex-env-flow-link--operator.is-active {
  opacity: 0.62;
  color: var(--ex-ds-muted, #7a8da3);
  border-bottom-color: transparent;
}

body.ex-institutional-env .ex-env-footer-flow a.ex-env-footer-link--operator {
  opacity: 0.45;
}

body.ex-institutional-env.ex-canonical-public-header:has(.ex-env-chrome-band) .shell,
body.ex-institutional-env.ex-canonical-public-header:has(.ex-env-chrome-band) .ex-inst-shell,
body.ex-institutional-env.ex-canonical-public-header:has(.ex-env-chrome-band) main.shell {
  padding-top: var(--ex-ds-s8, 8px);
}

/* Suppress legacy header variants */
body.ex-institutional-env.ex-canonical-public-header .ex-env-header-cta,
body.ex-institutional-env.ex-canonical-public-header .ex-env-context,
body.ex-institutional-env.ex-canonical-public-header .ex-env-governance-status-bar,
body.ex-institutional-env.ex-canonical-public-header .ex-pilot-environment-bar {
  display: none !important;
}

@media (max-width: 900px) {
  body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-header {
    grid-template-columns: 1fr;
    gap: var(--ex-ds-s8, 8px);
  }

  body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-flow {
    justify-self: start;
    flex-wrap: wrap;
    gap: var(--ex-ds-s8, 8px) var(--ex-ds-s12, 12px);
  }

  body.ex-institutional-env.ex-canonical-public-header .ex-env-flow-customer.ex-env-funnel-progression {
    flex-wrap: wrap;
    row-gap: 4px;
    max-width: 100%;
  }

  body.ex-institutional-env.ex-canonical-public-header .ex-env-flow-customer,
  body.ex-institutional-env.ex-canonical-public-header .ex-env-flow-operator {
    gap: var(--ex-ds-s8, 8px) var(--ex-ds-s16, 16px);
  }
}

@media (max-width: 640px) {
  body.ex-institutional-env.ex-canonical-public-header .ex-env-chrome-band .ex-env-header {
    padding-left: var(--ex-ds-s16, 16px);
    padding-right: var(--ex-ds-s16, 16px);
  }
}
