/* Moat Map directory pages — the hub (/moat/) and the industry leaderboards
   (/moat/industry/<slug>/).

   Everything here is written against the custom-property tokens defined in
   static/css/bootstrap-overrides.css, so both pages follow the viewer's
   light/dark preference without a [data-bs-theme] patch. The older

   The score-band tokens (--moat-strong and friends), the .moat-band-* classes
   that set --moat-band from a score, and the .moat-rating-* colour classes all
   come from companies/css/moat_map.css, which both pages also load. Anything on
   these pages that carries a score paints itself from --moat-band, so the three
   surfaces -- leaderboard row, distribution strip and per-ticker hero -- cannot
   disagree about what a given number looks like. */

.moat-dir-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.moat-dir-header {
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.moat-dir-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.moat-dir-header-lede {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 72ch;
  margin-bottom: 0.75rem;
}

.moat-dir-freshness {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.moat-dir-crumb {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.moat-dir-crumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.moat-dir-crumb a:hover {
  text-decoration: underline;
}

.moat-dir-crumb span {
  margin: 0 0.4rem;
}

/* ── Sections ─────────────────────────────────────────────────────────────── */

.moat-dir-section {
  margin-bottom: 3rem;
}

.moat-dir-section-heading {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.moat-dir-lede {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-muted);
  max-width: 72ch;
  margin-bottom: 1.5rem;
}

/* ── Leaderboard ──────────────────────────────────────────────────────────── */

.moat-dir-board {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
}

.moat-dir-board-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--bg-light);
  transition: background 0.15s ease;
}

.moat-dir-board-row:hover {
  background: color-mix(in oklch, var(--moat-band, var(--primary)) 6%, var(--bg-light));
}

/* The top three carry a little more weight than the rest, which is what a reader
   scanning a leaderboard is looking for first. */
.moat-dir-board-row--top .moat-dir-board-rank {
  color: var(--text);
}

.moat-dir-board-row--top .moat-dir-board-ticker {
  font-size: 1.0625rem;
}

/* Score meter along the bottom edge of the row. Absolutely positioned so it adds
   no height and no column, and hidden from assistive tech -- the score it
   duplicates is already read out as text beside it. */
.moat-dir-board-meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: transparent;
}

.moat-dir-board-meter > span {
  display: block;
  height: 100%;
  background: var(--moat-band, var(--primary));
  opacity: 0.55;
}

.moat-dir-board-row + .moat-dir-board-row {
  border-top: 1px solid var(--border);
}

.moat-dir-board-rank {
  flex: 0 0 1.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
}

.moat-dir-board-link {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  text-decoration: none;
}

.moat-dir-board-link:hover .moat-dir-board-name {
  text-decoration: underline;
}

.moat-dir-board-ticker {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.moat-dir-board-name {
  font-size: 0.875rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moat-dir-board-industry {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.125rem 0.625rem;
}

.moat-dir-board-industry:hover {
  color: var(--text);
}

.moat-dir-board-score {
  flex: 0 0 auto;
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 5.5rem;
  color: var(--moat-band, var(--text));
}

.moat-dir-board-score small {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Hide the per-row industry pill on narrow screens before the name truncates —
   the score and the ticker are what the row is for. */
@media (max-width: 575.98px) {
  .moat-dir-board-industry {
    display: none;
  }

  .moat-dir-board-name {
    display: none;
  }
}

/* ── Distribution ─────────────────────────────────────────────────────────── */

.moat-dir-dist {
  margin: 0 0 1.5rem;
}

/* The full 0-100 range, with the group's middle half drawn on it. Same track,
   same scale and same band colours as the score strip in the per-ticker hero. */
.moat-dir-dist-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(
      to right,
      color-mix(in oklch, var(--moat-weak) 22%, transparent) 0 25%,
      color-mix(in oklch, var(--moat-developing) 22%, transparent) 25% 50%,
      color-mix(in oklch, var(--moat-moderate) 22%, transparent) 50% 75%,
      color-mix(in oklch, var(--moat-strong) 22%, transparent) 75% 100%
    );
}

/* Interquartile range: where the middle half of the group sits. */
.moat-dir-dist-range {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: color-mix(in oklch, var(--text-muted) 55%, transparent);
}

.moat-dir-dist-median {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 999px;
  background: var(--text);
}

.moat-dir-dist-legend {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.55rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.moat-dir-dist-legend b {
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-right: 0.2rem;
}

.moat-dir-dist-legend--primary b {
  font-size: 1.125rem;
}

/* ── Industry cards (hub) ─────────────────────────────────────────────────── */

.moat-dir-industry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.moat-dir-industry {
  display: flex;
  flex-direction: column;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.moat-dir-industry-name {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.moat-dir-industry-name a {
  color: var(--text);
  text-decoration: none;
}

.moat-dir-industry-name a:hover {
  text-decoration: underline;
}

.moat-dir-industry-meta {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.moat-dir-industry-leaders {
  margin-bottom: 1rem;
}

.moat-dir-industry-leaders-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.moat-dir-industry-leaders ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.moat-dir-industry-leaders li {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  padding: 0.1875rem 0;
}

.moat-dir-industry-leaders a {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.moat-dir-industry-leaders a:hover {
  text-decoration: underline;
}

.moat-dir-industry-leaders span {
  color: var(--moat-band, var(--text-muted));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .moat-dir-board-row {
    transition: none;
  }
}

.moat-dir-industry-cta {
  margin-top: auto;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.moat-dir-industry-cta:hover {
  text-decoration: underline;
}

/* ── Defense explainers ───────────────────────────────────────────────────── */

.moat-dir-defenses {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  margin-bottom: 3rem;
}

.moat-dir-defense-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.moat-dir-defense {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.moat-dir-defense-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.moat-dir-defense-weight {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.moat-dir-defense-text {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* ── FAQ ──────────────────────────────────────────────────────────────────── */

.moat-dir-faq {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  margin-bottom: 3rem;
}

.moat-dir-faq-item + .moat-dir-faq-item {
  margin-top: 1.5rem;
}

.moat-dir-faq-question {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.moat-dir-faq-answer {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-muted);
  max-width: 72ch;
  margin-bottom: 0;
}

/* ── Sibling links ────────────────────────────────────────────────────────── */

.moat-dir-siblings {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.moat-dir-siblings a {
  display: inline-block;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3125rem 0.875rem;
}

.moat-dir-siblings a:hover {
  border-color: var(--text-muted);
}
