/* /complexity-formula: how facility levels are set. One reading column on the
   site tokens in style.css (--card-bg, --card-border, --text-color), so it
   follows the light/dark theme; facility types keep the site's map colours. */

.fl-page {
  --fl-accent: #1d4e89;
  --fl-accent-soft: rgba(29, 78, 137, 0.08);
  --fl-up: #198754;
  --fl-down: #c2410c;
  --fl-muted: var(--secondary);
  max-width: 820px;
}
[data-bs-theme="dark"] .fl-page {
  --fl-accent: #8ab4f8;
  --fl-accent-soft: rgba(138, 180, 248, 0.1);
  --fl-up: #6edba0;
  --fl-down: #fb923c;
}
.fl-narrow { max-width: 820px; }

.hero-section.bg-complexity-formula {
  background: radial-gradient(circle at 85% 20%, rgba(138, 180, 248, 0.25), transparent 55%),
              linear-gradient(135deg, #0f2238 0%, #1d3f66 100%);
  color: #fff;
}
.bg-complexity-formula .lead { opacity: 0.85; line-height: 1.5; }

/* Facility type colours: the site's map colours. */
.fl-tone-tower    { --fl-tone: var(--color-tower); }
.fl-tone-tracon   { --fl-tone: var(--color-tracon); }
.fl-tone-updown   { --fl-tone: var(--color-updown); }
.fl-tone-combined { --fl-tone: #5f6b7a; }
.fl-tone-center   { --fl-tone: var(--color-center); }
[data-bs-theme="dark"] .fl-tone-updown   { --fl-tone: #c99a76; }
[data-bs-theme="dark"] .fl-tone-combined { --fl-tone: #9aa7b5; }

/* ── The questions this page answers ── */
.fl-questions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}
@media (min-width: 640px) { .fl-questions { grid-template-columns: 1fr 1fr; } }
.fl-questions a {
  display: block;
  padding: 0.7rem 0.9rem 0.7rem 2.1rem;
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.6rem;
  color: var(--text-color);
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
}
.fl-questions a::before {
  content: "?";
  position: absolute;
  left: 0.8rem;
  top: 0.68rem;
  color: var(--fl-accent);
  font-weight: 800;
}
.fl-questions a:hover, .fl-questions a:focus-visible { border-color: var(--fl-accent); background: var(--fl-accent-soft); }

/* ── Sections ── */
.fl-section { margin-top: 3rem; scroll-margin-top: 5.5rem; }
.fl-section > h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.9rem; }
.fl-section h3 { font-size: 1.1rem; font-weight: 700; }
.fl-section p, .fl-section li { line-height: 1.65; }
.fl-page [id] { scroll-margin-top: 5.5rem; }
.fl-cite { font-size: 0.85rem; color: var(--fl-muted); margin-top: 0.75rem; }
.fl-sources {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--card-border);
  font-size: 0.85rem;
  color: var(--fl-muted);
}

/* ── The four steps ── */
.fl-steps {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  counter-reset: none;
}
@media (min-width: 640px) { .fl-steps { grid-template-columns: 1fr 1fr; } }
.fl-steps li {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  padding: 1rem 1rem 0.9rem 3.4rem;
}
.fl-steps h3 { font-size: 1rem; margin: 0.1rem 0 0.35rem; }
.fl-steps p { margin: 0; font-size: 0.93rem; line-height: 1.55; }
.fl-step-n {
  position: absolute;
  left: 1rem;
  top: 1rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--fl-accent);
  color: var(--card-bg);
  font-weight: 800;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
}
.fl-result {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--fl-accent);
  background: var(--fl-accent-soft);
  border-radius: 0 0.6rem 0.6rem 0;
}

/* ── Worked example ── */
.fl-example {
  margin: 1.75rem 0 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 4px solid var(--fl-accent);
  border-radius: 0.9rem;
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}
@media (min-width: 768px) { .fl-example { padding: 1.5rem 1.75rem; } }
.fl-example figcaption h3 { margin: 0 0 0.25rem; }
.fl-example figcaption p { margin: 0 0 1rem; color: var(--fl-muted); font-size: 0.93rem; }
.fl-sum { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fl-sum th { font-weight: 400; padding: 0.4rem 0.75rem 0.4rem 0; font-size: 0.93rem; }
.fl-sum td { text-align: right; padding: 0.4rem 0; white-space: nowrap; font-weight: 600; }
.fl-sum tr + tr > * { border-top: 1px solid var(--card-border); }
.fl-sum-total > * { border-top: 2px solid var(--text-color) !important; font-weight: 800 !important; }
.fl-dial { margin: 1.25rem 0 0.5rem; }
.fl-dial label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.fl-dial output { font-variant-numeric: tabular-nums; color: var(--fl-accent); font-weight: 800; }
.fl-dial input[type="range"] { width: 100%; accent-color: var(--fl-accent); }
.fl-dial-scale { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--fl-muted); }
.fl-verdict {
  margin: 0.75rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--fl-accent-soft);
  border-radius: 0.6rem;
  font-variant-numeric: tabular-nums;
}

/* ── Breakpoint ladders ── */
.fl-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1.25rem 0 0.75rem; }
.fl-tabs[hidden] { display: none; }
.fl-tab {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-color);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.fl-tab::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--fl-tone);
  margin-right: 0.4rem;
}
.fl-tab[aria-pressed="true"] { background: var(--fl-tone); border-color: var(--fl-tone); color: #fff; }
.fl-tab[aria-pressed="true"]::before { background: #fff; }

.fl-ladder { margin-top: 1rem; }
.fl-ladder-title { font-size: 1rem; margin: 1.25rem 0 0.5rem; }
.fl-ladder.is-tabbed .fl-ladder-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fl-ladder[hidden] { display: none; }
.fl-rung { border-bottom: 1px solid var(--card-border); }
.fl-rung:first-of-type { border-top: 2px solid var(--fl-tone); }
.fl-rung summary {
  list-style: none;
  display: grid;
  grid-template-columns: 4.6rem 8.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.25rem;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.fl-rung summary::-webkit-details-marker { display: none; }
.fl-rung summary:hover, .fl-rung[open] summary { background: var(--fl-accent-soft); }
.fl-rung[data-empty] summary { color: var(--fl-muted); }
.fl-rung-level { font-weight: 800; }
.fl-rung-need { font-weight: 700; line-height: 1.2; }
.fl-rung-need small { display: block; font-weight: 400; font-size: 0.78rem; color: var(--fl-muted); }
.fl-rung-bar { height: 0.7rem; background: rgba(127, 127, 127, 0.12); border-radius: 999px; overflow: hidden; }
.fl-rung-bar > span { display: block; height: 100%; background: var(--fl-tone); border-radius: 999px; }
.fl-rung-count { text-align: right; font-weight: 700; }
.fl-rung-ids { margin: 0; padding: 0.25rem 0.25rem 0.8rem 5.2rem; font-size: 0.9rem; line-height: 1.9; }
.fl-rung-ids a { display: inline-block; margin-right: 0.55rem; font-weight: 600; }
@media (max-width: 480px) {
  .fl-rung summary { grid-template-columns: 3.9rem 6.6rem 1fr 2rem; gap: 0.45rem; font-size: 0.92rem; }
  .fl-rung-ids { padding-left: 0.25rem; }
}

/* ── Moving up and down ── */
.fl-moves { display: grid; grid-template-columns: 1fr; gap: 0.9rem; margin: 1.25rem 0; }
@media (min-width: 768px) { .fl-moves { grid-template-columns: 1fr 1fr; } }
.fl-move {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 4px solid var(--fl-move);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem 0.4rem;
}
.fl-move-up { --fl-move: var(--fl-up); }
.fl-move-down { --fl-move: var(--fl-down); }
.fl-move h3 { color: var(--fl-move); margin-bottom: 0.75rem; }
.fl-timeline { list-style: none; padding: 0; margin: 0 0 0.6rem; position: relative; }
.fl-timeline li {
  position: relative;
  padding: 0 0 0.85rem 1.6rem;
  font-size: 0.95rem;
  line-height: 1.55;
}
.fl-timeline li::before {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: 0.45rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--fl-move, var(--fl-accent));
}
.fl-timeline li::after {
  content: "";
  position: absolute;
  left: 0.47rem;
  top: 1.15rem;
  bottom: 0;
  width: 2px;
  background: var(--card-border);
}
.fl-timeline li.fl-timeline-end::before { background: var(--fl-move, var(--fl-accent)); }
.fl-timeline li:last-child::after { display: none; }
.fl-timeline-plain { margin-top: 1rem; }

/* ── Pay ── */
.fl-section h3.mt-4 { margin-top: 1.75rem; }
.fl-pay-table { font-variant-numeric: tabular-nums; font-size: 0.93rem; }
.fl-pay-table td, .fl-pay-table th { white-space: nowrap; }
.fl-gain { color: var(--fl-up); font-weight: 700; margin-left: 0.25rem; }
/* Phones: each upgrade is a small card, its two ends labelled, instead of a table that scrolls sideways. */
@media (max-width: 575.98px) {
  .fl-pay-table thead { display: none; }
  .fl-pay-table tr { display: block; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--card-border); }
  .fl-pay-table tbody tr:last-child { border-bottom: 0; }
  .fl-pay-table tbody th, .fl-pay-table tbody td { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.15rem 0; border: 0; white-space: normal; }
  .fl-pay-table tbody th { font-size: 1rem; }
  .fl-pay-table tbody td::before { content: attr(data-label); color: var(--fl-muted); width: 3.6rem; flex: none; }
  .fl-pay-table .fl-gain { margin-left: auto; }
}
.fl-callout {
  margin: 1.25rem 0 0.5rem;
  padding: 1rem 1.1rem;
  border-radius: 0.75rem;
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(255, 193, 7, 0.45);
}
.fl-callout h4 { font-size: 1rem; font-weight: 800; margin: 0 0 0.35rem; }
.fl-callout p { margin: 0; }

@media print {
  .fl-tabs, .fl-dial { display: none !important; }
  .fl-ladder[hidden] { display: block !important; }
}
