/* =========================================================
   CFOA Masthead — framework-agnostic tool chrome
   Vanilla CSS. Consumes the CFOA design tokens (colors_and_type.css)
   with hard fallbacks so it still renders if loaded standalone.
   Drop into ANY tool (static HTML or React) + cfoa-masthead.js.
   ========================================================= */

.cfoa-mast, .cfoa-mast * { box-sizing: border-box; }
.cfoa-mast {
  font-family: var(--font-sans, 'Source Sans 3', system-ui, -apple-system, sans-serif);
  -webkit-font-smoothing: antialiased;
  position: relative; z-index: 50;
}

/* signature gradient edge — the one branded gradient moment */
.cfoa-mast__edge {
  height: 3px;
  background: var(--brand-gradient, linear-gradient(100deg, #EF4B24 0%, #F5871F 55%, #FDB713 100%));
}

.cfoa-mast__bar {
  height: 64px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 26px;
  background: var(--surface-0, #FFFFFF);
  border-bottom: 1px solid var(--border-1, rgba(26,27,28,0.08));
  box-shadow: var(--shadow-xs, 0 1px 2px rgba(80,50,20,0.06));
}

/* ---- left brand + identity zone ---- */
.cfoa-mast__brandzone { display: flex; align-items: center; gap: 16px; min-width: 0; flex-shrink: 0; }
.cfoa-mast__brand { display: flex; align-items: center; gap: 11px; text-decoration: none; flex-shrink: 0; }
.cfoa-mast__logo { height: 27px; width: auto; display: block; }
.cfoa-mast__wordmark { font-size: 19px; line-height: 1; letter-spacing: -0.012em; white-space: nowrap; }
.cfoa-mast__wordmark b   { font-weight: 800; color: #4d4f51; }
.cfoa-mast__wordmark i   { font-style: normal; font-weight: 400; color: var(--fg-3, #5B5D5F); }
.cfoa-mast__div { width: 1px; height: 30px; background: var(--border-2, rgba(26,27,28,0.12)); flex-shrink: 0; }
.cfoa-mast__id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cfoa-mast__id b    { font-size: 16px; font-weight: 700; color: var(--fg-1, #1A1B1C); line-height: 1.15; letter-spacing: -0.01em; white-space: nowrap; }
.cfoa-mast__id span { font-size: 12.5px; color: var(--fg-3, #5B5D5F); line-height: 1.2; white-space: nowrap; }

.cfoa-mast__spacer { flex: 1; }
.cfoa-mast__center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.cfoa-mast__right  { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cfoa-mast__vdiv   { width: 1px; height: 26px; background: var(--border-2, rgba(26,27,28,0.12)); flex-shrink: 0; }

/* ---- center command/search ---- */
.cfoa-search {
  display: flex; align-items: center; gap: 9px;
  height: 38px; width: 460px; max-width: 44vw;
  padding: 0 12px; border-radius: 10px;
  background: var(--surface-1, #FAF7F2);
  border: 1px solid var(--border-2, rgba(26,27,28,0.12));
  cursor: text; transition: border-color 140ms var(--ease-out, cubic-bezier(.22,.61,.36,1));
}
.cfoa-search:hover { border-color: var(--border-3, rgba(26,27,28,0.22)); }
.cfoa-search:focus-within { border-color: var(--accent, #EF4B24); }
.cfoa-search__ph  { flex: 1; font-size: 14px; color: var(--fg-4, #8A8B8D); text-align: left; }
.cfoa-search--input { cursor: text; }
.cfoa-search__input {
  flex: 1; min-width: 0; padding: 0; margin: 0; border: none; background: transparent;
  outline: none; font-family: inherit; font-size: 14px; color: var(--fg-1, #1A1B1C);
}
.cfoa-search__input::placeholder { color: var(--fg-4, #8A8B8D); }
.cfoa-mast[data-theme="dark"] .cfoa-search__input { color: #FAF7F2; }
.cfoa-search__kbd {
  display: inline-flex; align-items: center; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border-2, rgba(26,27,28,0.12));
  font-size: 11.5px; font-weight: 600; color: var(--fg-3, #5B5D5F);
}

/* ---- controls ---- */
.cfoa-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 9px; border: none;
  cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 700;
  white-space: nowrap; line-height: 1;
  transition: all 140ms var(--ease-out, cubic-bezier(.22,.61,.36,1));
}
.cfoa-btn--primary { background: var(--accent, #EF4B24); color: #fff; box-shadow: 0 1px 2px rgba(80,50,20,0.18); }
.cfoa-btn--primary:hover  { background: var(--accent-hover, #D63E18); box-shadow: 0 4px 14px rgba(239,75,36,0.30); }
.cfoa-btn--primary:active { background: var(--accent-press, #B8340F); box-shadow: inset 0 1px 2px rgba(0,0,0,0.18); }
.cfoa-btn--ghost { background: transparent; color: var(--fg-3, #5B5D5F); font-weight: 600; padding: 0 13px; }
.cfoa-btn--ghost:hover { background: rgba(26,27,28,0.05); color: var(--fg-1, #1A1B1C); }

.cfoa-icon {
  width: 36px; height: 36px; padding: 0; border: none; border-radius: 9px;
  background: transparent; color: var(--fg-3, #5B5D5F); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 140ms var(--ease-out, cubic-bezier(.22,.61,.36,1));
}
.cfoa-icon:hover { background: rgba(26,27,28,0.05); color: var(--fg-1, #1A1B1C); }

.cfoa-chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 11px; border-radius: 9px;
  border: 1px solid var(--border-1, rgba(26,27,28,0.08));
  background: var(--surface-1, #FAF7F2); color: var(--fg-1, #1A1B1C);
  font-family: inherit; font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: border-color 140ms var(--ease-out, cubic-bezier(.22,.61,.36,1));
}
.cfoa-chip:hover { border-color: var(--border-2, rgba(26,27,28,0.12)); }
.cfoa-chip > svg { color: var(--fg-3, #5B5D5F); }

/* ---- status + identity chips ---- */
.cfoa-live {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 9px;
  background: var(--success-soft, #E6EFE4); border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--success, #3F7D4E);
}
.cfoa-live__dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; animation: cfoaPulse 2s infinite; }
@keyframes cfoaPulse { 0% { box-shadow: 0 0 0 0 rgba(63,125,78,0.45); } 70% { box-shadow: 0 0 0 5px rgba(63,125,78,0); } 100% { box-shadow: 0 0 0 0 rgba(63,125,78,0); } }
@media (prefers-reduced-motion: reduce) { .cfoa-live__dot { animation: none; } }

.cfoa-synced { font-size: 13px; color: var(--fg-3, #5B5D5F); white-space: nowrap; }
.cfoa-synced b { color: var(--fg-1, #1A1B1C); font-weight: 600; font-variant-numeric: tabular-nums; }

.cfoa-role {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px 0 9px;
  border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent, #EF4B24); background: var(--accent-soft, #FDEDE7); border: 1px solid rgba(239,75,36,0.25);
}
.cfoa-user { display: inline-flex; align-items: center; gap: 9px; }
.cfoa-user__name { font-size: 14px; font-weight: 600; color: var(--fg-1, #1A1B1C); white-space: nowrap; }
.cfoa-avatar {
  width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0;
  background: var(--brand-gradient, linear-gradient(100deg, #EF4B24 0%, #F5871F 55%, #FDB713 100%));
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--surface-0, #fff), 0 1px 2px rgba(80,50,20,0.18);
}

/* ---- focus (kept, per system) ---- */
.cfoa-btn:focus-visible, .cfoa-icon:focus-visible, .cfoa-chip:focus-visible, .cfoa-search:focus-visible {
  outline: 2px solid var(--accent, #EF4B24); outline-offset: 2px;
}

/* ---- dark variant (optional; for tools with a dark theme toggle) ---- */
.cfoa-mast[data-theme="dark"] .cfoa-mast__bar { background: #1b1917; border-bottom-color: rgba(250,247,242,0.10); }
.cfoa-mast[data-theme="dark"] .cfoa-mast__wordmark b,
.cfoa-mast[data-theme="dark"] .cfoa-mast__id b { color: #FAF7F2; }
.cfoa-mast[data-theme="dark"] .cfoa-mast__wordmark i,
.cfoa-mast[data-theme="dark"] .cfoa-mast__id span,
.cfoa-mast[data-theme="dark"] .cfoa-synced,
.cfoa-mast[data-theme="dark"] .cfoa-user__name { color: rgba(250,247,242,0.82); }
.cfoa-mast[data-theme="dark"] .cfoa-icon,
.cfoa-mast[data-theme="dark"] .cfoa-btn--ghost { color: rgba(250,247,242,0.60); }
.cfoa-mast[data-theme="dark"] .cfoa-icon:hover,
.cfoa-mast[data-theme="dark"] .cfoa-btn--ghost:hover { background: rgba(250,247,242,0.10); color: #FAF7F2; }
.cfoa-mast[data-theme="dark"] .cfoa-chip,
.cfoa-mast[data-theme="dark"] .cfoa-search { background: rgba(250,247,242,0.06); border-color: rgba(250,247,242,0.13); color: #FAF7F2; }
.cfoa-mast[data-theme="dark"] .cfoa-mast__div,
.cfoa-mast[data-theme="dark"] .cfoa-mast__vdiv { background: rgba(250,247,242,0.13); }

/* ---- responsive: compact bar, drop secondary text/search ---- */
@media (max-width: 820px) {
  .cfoa-mast__bar { height: 56px; padding: 0 16px; gap: 12px; }
  .cfoa-mast__center, .cfoa-synced, .cfoa-user__name, .cfoa-mast__id span { display: none; }
  .cfoa-btn--ghost span.cfoa-label { display: none; }
}
