/* fir-fit.css — Ternara FIR Fit (0-DSP CSD+CSE Polyphase Decimator)
   Ternara Light Editorial Studio layer on top of tech.css, apps.css, lab-brand.css. */

:root {
  --ff-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --ff-f-bg: #e7efe6;
  --ff-f-ink: #1b4b38;
  --ff-f-bd: #bfd4c6;
  --ff-h-bg: #f6efe0;
  --ff-h-ink: #6d4c16;
  --ff-h-bd: #e3d1ab;
  --ff-u-bg: #edf1ef;
  --ff-u-ink: #47564f;
  --ff-u-bd: #cdd7d1;
  --ff-fail-bg: #fdeceb;
  --ff-fail-ink: #8e2820;
  --ff-fail-bd: #ebc4bf;
}

.ff-num,
.as-table,
.sl-kpi,
.ff-kmax-card,
.ff-bar-meta,
.ff-profile-metrics {
  font-variant-numeric: lining-nums tabular-nums;
}

.ff-mono {
  font-family: var(--ff-mono);
  font-size: 12.5px;
}

/* Hero action pills (structural geometry paired with lab-brand.css colors) */
.sl-dl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.sl-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: var(--green);
  color: #ffffff;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.sl-dl-btn:hover {
  background: var(--green-hover);
  border-color: var(--green-hover);
  color: #ffffff;
  transform: translateY(-1px);
}

.sl-dl-btn--ghost {
  background: rgba(255, 255, 255, .07);
  border-color: rgba(255, 255, 255, .24);
  color: #eef3ea;
}

.sl-dl-btn--ghost:hover {
  background: rgba(255, 255, 255, .15);
  border-color: rgba(255, 255, 255, .42);
  color: #ffffff;
}

/* Badges: F / H / U & PASS / REVISE / FAIL */
.ff-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid transparent;
}

.ff-badge--f,
.ff-status--pass {
  background: var(--ff-f-bg);
  color: var(--ff-f-ink);
  border-color: var(--ff-f-bd);
}

.ff-badge--h,
.ff-status--revise {
  background: var(--ff-h-bg);
  color: var(--ff-h-ink);
  border-color: var(--ff-h-bd);
}

.ff-badge--u {
  background: var(--ff-u-bg);
  color: var(--ff-u-ink);
  border-color: var(--ff-u-bd);
}

.ff-status--fail {
  background: var(--ff-fail-bg);
  color: var(--ff-fail-ink);
  border-color: var(--ff-fail-bd);
}

/* Truth legend strip */
.ff-truth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ff-truth-box {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
}

.ff-truth-box--h {
  border-left-color: #b07921;
}

.ff-truth-box--u {
  border-left-color: #6a7c73;
}

.ff-truth-box strong {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--ink);
  margin-bottom: 6px;
}

.ff-truth-box p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

/* Controls / Switchers */
.ff-ctrl-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  margin: 0 0 22px;
}

.ff-ctrl-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ff-ctrl-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}

.ff-pill-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #c9d4cc;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.ff-pill-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.ff-pill-btn[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

/* Profile Applicability Panel (Section 01) */
.ff-profile-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.ff-profile-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ff-profile-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(24px, 2.3vw, 31px);
  font-weight: 500;
  color: var(--ink);
}

.ff-profile-desc {
  margin: 6px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 76ch;
}

.ff-profile-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.ff-metric-box {
  background: var(--studio);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}

.ff-metric-box dt {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.ff-metric-box dd {
  margin: 5px 0 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.ff-metric-box small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.ff-honest-note {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #f5f7f2;
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
}

.ff-gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.ff-gate-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  min-width: 0;
}

.ff-gate-card h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.ff-gate-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

/* Comparison Bars (Section 02) */
.ff-bench-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 20px;
  margin-top: 22px;
  align-items: start;
}

.ff-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  min-width: 0;
}

.ff-card h3 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
}

.ff-card-sub {
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.ff-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ff-bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ff-bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--ink);
}

.ff-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e6ece6;
  overflow: hidden;
}

.ff-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #7c9387;
  transition: width .25s ease;
}

.ff-bar-fill--ternara {
  background: var(--green);
}

.ff-bar-fill--dsp {
  background: #b07921;
}

.ff-kmax-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ff-kmax-card {
  background: var(--studio);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}

.ff-kmax-card--win {
  background: #eaf2ec;
  border-color: #9ec0ae;
}

.ff-kmax-card strong {
  display: block;
  font-size: 13px;
  color: var(--ink);
}

.ff-kmax-val {
  margin: 6px 0 3px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.ff-kmax-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* Figures & Lightbox */
.ff-fig-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.ff-fig-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  min-width: 0;
}

.ff-fig-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
}

.ff-fig-btn img {
  display: block;
  width: 100%;
  height: auto;
}

.ff-fig-zoom {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
}

.ff-fig-cap {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.ff-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(12, 20, 17, .88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ff-lightbox[hidden] {
  display: none !important;
}

.ff-lightbox-dialog {
  max-width: min(1160px, 96vw);
  max-height: 92vh;
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 28px 60px rgba(0, 0, 0, .45);
}

.ff-lightbox-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.ff-lightbox-top p {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.ff-lightbox-close {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.ff-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 90px);
  object-fit: contain;
  border-radius: 8px;
}

/* Mask Configurator (Section 03) */
.ff-builder-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  gap: 24px;
  align-items: start;
}

.ff-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.ff-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.ff-field--full {
  grid-column: 1 / -1;
}

.ff-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.ff-field input,
.ff-field select,
.ff-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #c7d2ca;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  box-sizing: border-box;
}

.ff-field input:focus,
.ff-field select:focus,
.ff-field textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(40, 91, 72, .14);
}

.ff-field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 22px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.ff-field-check input {
  width: 16px;
  height: 16px;
}

.ff-precheck {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  border: 1px solid var(--line);
  background: var(--studio);
}

.ff-precheck--win {
  background: #eaf2ec;
  border-color: #a9cab8;
}

.ff-precheck--cascade {
  background: #f7f0df;
  border-color: #e0cc9d;
}

.ff-precheck--err {
  background: var(--ff-fail-bg);
  border-color: var(--ff-fail-bd);
  color: var(--ff-fail-ink);
}

.ff-yaml-box {
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  background: #101815;
  color: #dcebe3;
  font-family: var(--ff-mono);
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  max-height: 410px;
}

.ff-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.ff-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.ff-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.ff-btn--primary {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.ff-btn--primary:hover {
  background: var(--green-hover);
  border-color: var(--green-hover);
  color: #ffffff;
}

.ff-inline-msg {
  margin: 8px 0 0;
  font-size: 12.5px;
  min-height: 18px;
  color: var(--green);
  font-weight: 600;
}

/* Commercial Track & OEM Verticals (Section 04) */
.ff-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 22px 0 28px;
}

.ff-step {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  min-width: 0;
}

.ff-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--studio);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 10px;
}

.ff-step h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
}

.ff-step p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.ff-oem-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.ff-oem-card {
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}

.ff-oem-card:hover,
.ff-oem-card.is-selected {
  border-color: var(--green);
  background: #f2f7f3;
  transform: translateY(-2px);
}

.ff-oem-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--green);
}

.ff-oem-card strong {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
}

.ff-oem-card span {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

/* Downloads & Pilot Form (Section 05) */
.ff-pilot-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 24px;
  align-items: start;
}

.ff-pilot-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ff-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ff-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.ff-check input {
  margin-top: 3px;
  flex: none;
}

.ff-submit {
  padding: 13px 22px;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: var(--green);
  color: #ffffff;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
}

.ff-submit:hover {
  background: var(--green-hover);
  border-color: var(--green-hover);
}

.ff-submit:disabled {
  opacity: .65;
  cursor: wait;
}

.ff-form-msg {
  margin: 4px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  min-height: 20px;
}

.ff-form-msg--ok {
  color: var(--ff-f-ink);
}

.ff-form-msg--err {
  color: var(--ff-fail-ink);
}

.ff-fallback-box {
  margin-top: 8px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--studio);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
}

.ff-fallback-box[hidden] {
  display: none;
}

.ff-dl-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ff-dl-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s ease, background .15s ease;
}

.ff-dl-item:hover {
  border-color: var(--green);
  background: #edf3ee;
}

.ff-dl-item strong {
  display: block;
  font-family: var(--ff-mono);
  font-size: 12.5px;
  color: var(--ink);
}

.ff-dl-item small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.ff-dl-item span {
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 1024px) {
  .ff-truth-grid,
  .ff-steps {
    grid-template-columns: minmax(0, 1fr);
  }
  .ff-profile-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ff-bench-split,
  .ff-builder-grid,
  .ff-pilot-grid,
  .ff-fig-grid,
  .ff-gate-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .ff-oem-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .ff-profile-metrics,
  .ff-kmax-list,
  .ff-form-grid,
  .ff-oem-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .ff-pill-btn {
    font-size: 12.5px;
    padding: 7px 12px;
  }
  .ff-submit {
    width: 100%;
  }
}
