/* mgf-fed-web — app shell only.
 *
 * The federation dashboard's CHROME layout (dark instrument top-bar + left
 * project rail) and the handful of compositions the brand kit doesn't ship
 * (the sync matrix's commit cell, the roadmap chain, the architecture node
 * list, the task-state chip, the `derived` tag). EVERY component colour is a
 * mgf-brand-web token (tokens.css) so this reads identical to the kit and flips
 * in dark mode; the instrument chrome stays intentionally dark in both themes
 * (it is an instrument, like the wireframe). Additive: no kit class is touched.
 */

/* ------------------------------------------------------------------ shell -- */
.fw-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.fw-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Top bar — always-dark instrument chrome (fixed Ink, not the flipping bg). */
.fw-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 0 0 auto;
  height: 3.4rem;
  padding: 0 var(--space-4);
  background: var(--mgf-ink);
  color: var(--mgf-mist);
  border-bottom: 1px solid color-mix(in srgb, white 10%, var(--mgf-ink));
}
.fw-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--mgf-mist);
  font-family: var(--font-display);
  font-weight: 600;
}
.fw-mark__glyph {
  height: 1.4rem;
  width: auto;
}
.fw-mark__txt {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.fw-mark__sub {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: color-mix(in srgb, var(--mgf-mist) 58%, transparent);
}
.fw-spacer {
  flex: 1;
}
.fw-lastcheck {
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--mgf-mist) 58%, transparent);
}
.fw-gpill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem var(--space-3);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, white 5%, var(--mgf-ink));
  border: 1px solid color-mix(in srgb, white 12%, var(--mgf-ink));
}
.fw-gpill__dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
}
.fw-gpill__label {
  font-weight: 600;
  font-size: 0.82rem;
}
.fw-gpill__counts {
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--mgf-mist) 58%, transparent);
}

/* The kit's secondary button uses --color-text (dark); in the always-dark chrome
 * it must read light. Scope the override to the top-bar so the kit is untouched. */
.fw-topbar .button-secondary {
  color: var(--mgf-mist);
  border-color: color-mix(in srgb, var(--mgf-mist) 26%, transparent);
}
.fw-topbar .button-secondary:hover {
  background: color-mix(in srgb, white 8%, transparent);
  color: var(--mgf-mist);
}

/* Left rail — dark, scrollable; the project list + the pinned legend. */
.fw-rail {
  flex: 0 0 16rem;
  overflow-y: auto;
  padding: var(--space-3);
  background: var(--mgf-ink);
  color: var(--mgf-mist);
  border-right: 1px solid color-mix(in srgb, white 10%, var(--mgf-ink));
}
.fw-rail__h {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--mgf-mist) 55%, transparent);
  margin: var(--space-4) var(--space-2) var(--space-2);
}
.fw-rail__h:first-child {
  margin-top: var(--space-1);
}
.fw-rail__empty {
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--mgf-mist) 50%, transparent);
  padding: var(--space-2);
}
.fw-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--mgf-mist);
}
.fw-nav:hover {
  background: color-mix(in srgb, white 6%, transparent);
  color: var(--mgf-mist);
}
.fw-nav--on {
  background: color-mix(in srgb, white 8%, transparent);
  box-shadow: inset 2px 0 0 var(--color-accent);
}
.fw-nav__main {
  min-width: 0;
}
.fw-nav__name {
  display: block;
  font-size: 0.85rem;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fw-nav__kind {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: color-mix(in srgb, var(--mgf-mist) 55%, transparent);
  margin-top: 0.1rem;
}

/* Per-state dot (rail badges, legend, global pill) — colour + a label is always
 * adjacent, so colour is never the only signal (a11y). Brand hues. */
.fw-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex: none;
  background: var(--mgf-slate);
}
.fw-dot--in-sync { background: var(--mgf-teal); }
.fw-dot--stale { background: var(--mgf-warning); }
.fw-dot--tampered,
.fw-dot--error { background: var(--mgf-error); }
.fw-dot--unknown,
.fw-dot--unreadable { background: var(--mgf-slate); }
.fw-dot--checking,
.fw-dot--syncing { background: var(--mgf-busy); }

/* Legend — pinned state language in the rail. */
.fw-legend {
  margin: var(--space-4) var(--space-1) var(--space-1);
  border: 1px solid color-mix(in srgb, white 12%, var(--mgf-ink));
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: color-mix(in srgb, white 4%, var(--mgf-ink));
}
.fw-legend__h {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--mgf-mist) 55%, transparent);
  margin-bottom: var(--space-2);
}
.fw-legend__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  margin-top: var(--space-2);
}
.fw-legend__desc {
  font-size: 0.66rem;
  color: color-mix(in srgb, var(--mgf-mist) 55%, transparent);
  margin: 0.1rem 0 0 1.05rem;
}
.fw-legend__note {
  margin: var(--space-3) 0 0;
  padding-top: var(--space-2);
  border-top: 1px solid color-mix(in srgb, white 10%, var(--mgf-ink));
  font-size: 0.66rem;
  line-height: 1.5;
  color: color-mix(in srgb, var(--mgf-mist) 60%, transparent);
}

/* Readout — the light (brand-bg) printable content area. */
.fw-main {
  flex: 1;
  overflow-y: auto;
  background: var(--color-bg);
  color: var(--color-text);
  padding: var(--space-6) var(--space-8) var(--space-16);
}

/* ----------------------------------------------------------- view header -- */
.fw-view-h {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.fw-view-h__t {
  font-size: 1.4rem;
  margin: 0;
}
.fw-view-h__s {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.fw-lede {
  max-width: 80ch;
  margin-top: var(--space-2);
}
.fw-lensbar {
  margin: var(--space-3) 0 var(--space-6);
}

/* Panels reuse .card; give the head a quiet divider and a note slot. */
.fw-panel {
  padding: 0;
  margin-bottom: var(--space-6);
  overflow: hidden;
}
.fw-panel__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.fw-panel__title {
  margin: 0;
  font-size: 1rem;
}
.fw-panel__note {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}
.fw-panel .table-wrap {
  border: 0;
  border-radius: 0;
}
.fw-panel > .lead,
.fw-panel > .fw-arch-layer,
.fw-panel > .detail-block {
  margin: var(--space-4);
}

/* --------------------------------------------------------- sync matrix --- */
.fw-matrix__name {
  text-decoration: none;
  color: var(--color-text);
}
.fw-matrix__name b {
  font-weight: 600;
}
.fw-matrix__name span {
  display: block;
  font-size: 0.68rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}
.fw-commits {
  font-size: 0.75rem;
}
.fw-arrow {
  color: var(--color-text-muted);
  margin: 0 0.35rem;
}
.fw-behind {
  color: var(--color-warning-text);
}
.fw-resultline {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  margin-top: 0.3rem;
}

/* --------------------------------------------------- project header strip - */
.fw-phead {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-2);
}
.fw-phead__name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}
.fw-phead__kind {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}
.fw-phead__meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}
.fw-phead__sp {
  flex: 1;
}
.fw-phead-gap {
  margin-top: var(--space-6);
}
.fw-ribbon {
  margin: var(--space-4) 0 var(--space-2);
}
.fw-tabs {
  margin: var(--space-4) 0 var(--space-6);
}

/* ---------------------------------------------------------- roadmap chain - */
.fw-chain {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: wrap;
  padding: var(--space-4);
  overflow-x: auto;
}
.fw-chain__node {
  flex: 1 1 9rem;
  min-width: 9rem;
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--color-bg);
}
.fw-chain__node--here {
  border-color: color-mix(in srgb, var(--state-busy) 55%, var(--color-border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--state-busy) 40%, transparent);
}
.fw-chain__here {
  position: absolute;
  top: -0.7rem;
  left: var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--state-busy);
  border-radius: var(--radius-pill);
  padding: 0.1rem var(--space-2);
}
.fw-chain__label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: var(--space-2);
}
.fw-chain__bar {
  margin: var(--space-2) 0 0.35rem;
}
.fw-chain__pct {
  font-size: 0.66rem;
  color: var(--color-text-muted);
}
.fw-chain__link {
  display: flex;
  align-items: center;
  padding: 0 0.35rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.fw-cell-title {
  font-weight: 540;
}

/* --------------------------------------------------- architecture graph -- */
.fw-arch-layer {
  margin-bottom: var(--space-4);
}
.fw-arch-layer__h {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
}
.fw-arch-nodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-2);
}
.fw-node {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-bg-soft);
}
.fw-node__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text);
}
.fw-node__deps {
  font-size: 0.66rem;
  color: var(--color-text-muted);
}

/* ----------------------------------------------------------- work cards -- */
.fw-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.fw-task {
  padding: var(--space-4);
}
.fw-task__h {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.fw-task__t {
  flex: 1;
  min-width: 12rem;
  font-weight: 600;
  font-size: 0.95rem;
}
.fw-task__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.fw-task .detail-block,
.fw-task .evidence {
  margin-top: var(--space-3);
}

/* --------------------------------------------- task / stage workflow chip - */
/* The kit's .status-chip covers SYNC/TEST states; task-WORKFLOW states get this
 * sibling, on the same tokens (done=teal, in_progress=blue, next=violet,
 * postponed=amber, blocked=red, todo/skipped/planned=slate). */
.tstate {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.22rem var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  background: var(--color-bg-soft);
  white-space: nowrap;
}
.tstate__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.tstate--done { color: var(--color-success-text); background: var(--color-success-tint); }
.tstate--in_progress { color: var(--state-busy-text); background: var(--state-busy-tint); }
.tstate--next { color: var(--state-derived-text); background: var(--state-derived-tint); }
.tstate--postponed { color: var(--color-warning-text); background: var(--color-warning-tint); }
.tstate--blocked { color: var(--color-error-text); background: var(--color-error-tint); }

/* ------------------------------------------------------------ derived tag - */
.derived-tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--state-derived-text);
  background: var(--state-derived-tint);
  border: 1px dashed var(--state-derived);
  border-radius: var(--radius-sm);
  padding: 0.08rem var(--space-2);
  white-space: nowrap;
}

/* ----------------------------------------------------------- absence ----- */
.fw-absence {
  padding: var(--space-12) var(--space-6);
}
.fw-absence__state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: var(--space-3) 0 0;
}
.fw-absence__errs {
  list-style: none;
  margin: var(--space-3) auto 0;
  padding: 0;
  max-width: 60ch;
  font-size: 0.66rem;
  color: var(--color-error-text);
  text-align: left;
}

/* ------------------------------------------------- M3 · sync actions ----- */
/* Action forms collapse to inline so the buttons sit in a row (topbar, header,
 * matrix cell) instead of stacking as block-level <form>s. */
.fw-actform,
.fw-phead__act form,
.fw-matrix__act form {
  display: inline-flex;
  margin: 0;
}
.fw-topbar > .fw-actform,
.fw-topbar > .fw-confirm {
  flex: 0 0 auto;
}

/* The affirmative-action accent (Force-sync): a gold OUTLINE so the single gold
 * FILL CTA budget (brand book Part VIII) is spent only on the confirmed action
 * revealed inside the disclosure pop. Reads gold on the dark chrome and on the
 * light readout (accent-strong flips with the theme). */
.fw-act--gold {
  background: transparent;
  color: var(--color-accent-strong);
  border-color: color-mix(in srgb, var(--mgf-gold) 55%, transparent);
}
.fw-act--gold:hover {
  background: color-mix(in srgb, var(--mgf-gold) 16%, transparent);
  color: var(--color-accent-strong);
  border-color: var(--mgf-gold);
}

/* Confirm disclosure — a brief, no-JS affordance before a force-sync mutation: the
 * <summary> is the trigger; opening it reveals the warning + the real submit. */
.fw-confirm {
  position: relative;
  display: inline-flex;
}
.fw-confirm > summary {
  list-style: none;
  cursor: pointer;
}
.fw-confirm > summary::-webkit-details-marker {
  display: none;
}
.fw-confirm__pop {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 30;
  width: 19rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-surface-raised);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.fw-confirm__warn {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--color-text-muted);
}

/* In-flight button — CHECKING/SYNCING: keep the (renamed) label, add a spinner.
 * Reduced-motion freezes the ring (the disabled state still reads). */
.button.is-busy {
  opacity: 0.9;
  cursor: progress;
}
.button.is-busy::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: fw-spin 0.7s linear infinite;
}
@keyframes fw-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .button.is-busy::before {
    animation: none;
  }
}

/* Per-project header actions + the honest "can't check" for unwired/unreadable. */
.fw-phead__act {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.fw-phead__noact {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* The action result line (under the header) — a quiet readout that prints. */
.fw-resultbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-soft);
  color: var(--color-text-muted);
  font-size: 0.76rem;
}
.fw-resultbar__icon {
  font-weight: 700;
}
.fw-resultbar--ok {
  color: var(--color-success-text);
  background: var(--color-success-tint);
  border-color: color-mix(in srgb, var(--mgf-teal) 35%, transparent);
}
.fw-resultbar--warn {
  color: var(--color-warning-text);
  background: var(--color-warning-tint);
  border-color: color-mix(in srgb, var(--mgf-warning) 35%, transparent);
}

/* Matrix per-row actions + the in-sync result-line tint. */
.fw-matrix__acth,
.fw-matrix__act {
  text-align: right;
  white-space: nowrap;
}
.fw-matrix__act form + form {
  margin-left: var(--space-2);
}
.fw-resultline--ok {
  color: var(--color-success-text);
}

/* ------------------------------------------------------- responsive ------ */
@media (max-width: 50rem) {
  .fw-rail {
    flex-basis: 13rem;
  }
  .fw-main {
    padding: var(--space-4);
  }
}

/* ------------------------------------------------------------ print ------- */
/* The brand component layer is print-friendly; this strips the app CHROME so the
 * readout prints clean and light (spec §5.8 — every view prints). */
@media print {
  .fw-topbar,
  .fw-rail,
  .fw-tabs,
  .fw-lensbar,
  .fw-phead__act,
  .fw-confirm,
  .fw-matrix__acth,
  .fw-matrix__act,
  .button {
    display: none !important;
  }
  .fw-app,
  .fw-body {
    display: block;
    height: auto;
  }
  .fw-main {
    overflow: visible;
    padding: 0;
    background: #fff;
  }
  .fw-panel,
  .fw-phead,
  .fw-task,
  .card {
    break-inside: avoid;
    box-shadow: none;
  }
}

/* --- M6 Follow-live: shell glue only (the brand kit owns .live-pane / .progress) --- */
.fw-livemark {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: 0.78rem;
}
.fw-livemark__link {
  font-family: var(--font-mono);
  font-weight: 600;
  text-decoration: none;
}
.fw-livemark__link:hover {
  text-decoration: underline;
}
.fw-live__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}
.fw-live__hint,
.fw-live__telemetry {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}
.fw-live__telemetry {
  margin-top: var(--space-3);
}
