/* ==========================================================================
   routing-table.css — responsive scam-type → agency routing table
   ART3 /article/fbi-vs-ic3-vs-ftc-where-to-report/
   --------------------------------------------------------------------------
   Desktop (>=768px): real <table>, sticky header, zebra, hover.
   Mobile  (<768px) : each <tr> becomes a card, CSS-only (no JS needed).
   Print            : always the table, never the card view.
   --------------------------------------------------------------------------
   Tokens fall back to the host site's own variables when present, so the
   component inherits truemoneytalk.com's dark palette automatically.
   ========================================================================== */

.rt {
  /* --- light defaults (standalone use) --- */
  --rt-bg: var(--surface, #ffffff);
  --rt-bg-alt: var(--surface-2, #f7f9fc);
  --rt-head-bg: var(--surface-3, #eef2f8);
  --rt-text: var(--text, #101828);
  --rt-text-2: var(--text-2, #475467);
  --rt-muted: var(--muted, #5b6b82);
  --rt-line: var(--line, #e3e8ef);
  --rt-line-strong: var(--line-2, #cfd8e3);
  --rt-accent: var(--gold-dp, #8a5a00);
  --rt-accent-soft: rgba(184, 116, 0, 0.08);
  --rt-focus: var(--teal-dp, #0f766e);
  --rt-radius: var(--r-md, 14px);
  --rt-radius-sm: var(--r-sm, 10px);
  --rt-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px -12px rgba(16, 24, 40, 0.18);

  margin: 0;
  color: var(--rt-text);
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* Dark mode for standalone use. On a site that already ships its own dark
   tokens, add class `rt--inherit` to skip this block and use the site's. */
@media (prefers-color-scheme: dark) {
  .rt:not(.rt--inherit) {
    --rt-bg: #0d1321;
    --rt-bg-alt: #121b2d;
    --rt-head-bg: #17223a;
    --rt-text: #eef2f8;
    --rt-text-2: #a9b6cb;
    --rt-muted: #8b9ab1;
    --rt-line: rgba(148, 163, 184, 0.16);
    --rt-line-strong: rgba(148, 163, 184, 0.3);
    --rt-accent: #ffd166;
    --rt-accent-soft: rgba(240, 180, 41, 0.1);
    --rt-focus: #5eead4;
    --rt-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -12px rgba(0, 0, 0, 0.7);
  }
}

/* ---------------------------------------------------------------- caption */

.rt__caption {
  caption-side: top;
  text-align: left;
  padding: 0 0 14px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--rt-muted);
  font-weight: 500;
}

.rt__caption strong {
  color: var(--rt-text);
  font-weight: 700;
}

/* ------------------------------------------------------------ scroll box */

.rt__scroll {
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-radius);
  background: var(--rt-bg);
  box-shadow: var(--rt-shadow);
  overflow-x: auto;
  overflow-y: auto;
  max-height: 78vh;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* A scrollable region must be reachable by keyboard (WCAG 2.1.1). */
.rt__scroll:focus-visible {
  outline: 2px solid var(--rt-focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------- scroll affordance
   Between 768px and ~1000px the six columns are wider than the viewport, so
   the table scrolls. Without a cue that reads as "cut off", so JS adds
   .is-scrollable and we show a right-edge fade plus a one-line hint. Both
   are decoration only — with JS off the table still scrolls normally, and
   in card mode (below 768px) nothing scrolls so neither ever appears. */

.rt {
  position: relative;
}

.rt::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 46px;
  border-radius: 0 var(--rt-radius) var(--rt-radius) 0;
  background: linear-gradient(to right, transparent, var(--rt-bg) 76%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.rt.is-scrollable::after { opacity: 1; }
.rt.is-scroll-end::after { opacity: 0; }

.rt__hint {
  display: none;
  margin: 8px 0 0;
  color: var(--rt-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.rt.is-scrollable .rt__hint { display: block; }

.rt__hint::after {
  content: " \2192";
}

/* JS adds this once the box is scrolled — a hairline under the sticky head. */
.rt__scroll.is-scrolled thead th {
  box-shadow: 0 1px 0 var(--rt-line-strong), 0 6px 14px -10px rgba(0, 0, 0, 0.45);
}

/* ---------------------------------------------------------------- table */

.rt__table {
  width: 100%;
  /* Six columns of real prose need room. Below this the table scrolls
     horizontally instead of squeezing every cell into a 3-line wrap — the
     scroll box is keyboard-focusable, so nothing is lost. */
  min-width: 700px;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 0.875rem;
  text-align: left;
}

/* Tablet band: tighten the table so all six columns fit at 768px without
   horizontal scrolling. */
@media (min-width: 768px) and (max-width: 1023px) {
  .rt__table {
    min-width: 0;
    font-size: 0.8125rem;
  }

  .rt__table thead th {
    padding: 10px 9px;
    font-size: 0.625rem;
    letter-spacing: 0.06em;
    white-space: normal;
  }

  .rt__table tbody th,
  .rt__table tbody td {
    padding: 10px 9px;
  }

  .rt__table tbody th {
    min-width: 0;
  }

  .rt__link {
    padding: 4px 7px;
    font-size: 0.75rem;
  }
}

/* The fade and hint are meaningless once the table fits. */
@media (min-width: 1024px) {
  .rt::after { display: none; }
  .rt__hint { display: none !important; }
}

/* ...and in card mode nothing scrolls, so neither may ever appear — enforced
   in CSS rather than relying on the JS removing .is-scrollable. */
@media (max-width: 767px) {
  .rt::after { display: none; }
  .rt__hint { display: none !important; }
}

.rt__table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 14px;
  background: var(--rt-head-bg);
  color: var(--rt-accent);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: bottom;
  border-bottom: 1px solid var(--rt-line-strong);
}

.rt__table tbody th,
.rt__table tbody td {
  padding: 13px 14px;
  vertical-align: top;
  border-bottom: 1px solid var(--rt-line);
  color: var(--rt-text-2);
  font-weight: 400;
}

/* Row header = the scam type. */
.rt__table tbody th {
  color: var(--rt-text);
  font-weight: 600;
  min-width: 12rem;
}

/* Zebra striping. */
.rt__table tbody tr:nth-child(even) {
  background: var(--rt-bg-alt);
}

.rt__table tbody tr:hover {
  background: var(--rt-accent-soft);
}

.rt__table tbody tr:last-child th,
.rt__table tbody tr:last-child td {
  border-bottom: 0;
}

/* Column widths — keeps the URL column from eating the row. */
.rt__table col.rt-col-type { width: 20%; }
.rt__table col.rt-col-agency { width: 15%; }
.rt__table col.rt-col-url { width: 13%; }
.rt__table col.rt-col-secondary { width: 20%; }
.rt__table col.rt-col-limit { width: 16%; }
.rt__table col.rt-col-response { width: 16%; }

/* ------------------------------------------------------------ report link */

.rt__link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--rt-line-strong);
  border-radius: var(--rt-radius-sm);
  background: var(--rt-bg);
  color: var(--rt-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.rt__link:hover {
  background: var(--rt-accent-soft);
  border-color: var(--rt-accent);
}

.rt__link:focus-visible {
  outline: 2px solid var(--rt-focus);
  outline-offset: 2px;
}

/* The little "opens in a new tab" arrow, drawn in CSS (no icon font). */
.rt__link::after {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: translateY(-1px) rotate(45deg);
  flex: none;
}

/* ------------------------------------------------------- sort (JS-added) */

.rt__sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  border-radius: 4px;
}

.rt__sort:hover { color: var(--rt-text); }

.rt__sort:focus-visible {
  outline: 2px solid var(--rt-focus);
  outline-offset: 3px;
}

.rt__sort::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-bottom: 5px solid currentColor;
  opacity: 0.28;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.rt__sort[data-dir="asc"]::after { opacity: 1; }
.rt__sort[data-dir="desc"]::after { opacity: 1; transform: rotate(180deg); }

/* ==========================================================================
   MOBILE — < 768px : every row becomes a card. Pure CSS, works with JS off.
   ========================================================================== */

@media (max-width: 767px) {
  .rt__scroll {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }

  .rt__table,
  .rt__table tbody,
  .rt__table tr,
  .rt__table th,
  .rt__table td {
    display: block;
    width: auto;
  }

  /* The desktop min-width must not survive into card mode. */
  .rt__table { min-width: 0; }

  /* Column widths are meaningless in card mode. */
  .rt__table colgroup { display: none; }

  /* The header row is replaced by per-cell labels. */
  .rt__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .rt__table tbody tr {
    margin: 0 0 14px;
    padding: 0 0 6px;
    border: 1px solid var(--rt-line);
    border-radius: var(--rt-radius);
    background: var(--rt-bg);
    box-shadow: var(--rt-shadow);
    overflow: hidden;
  }

  .rt__table tbody tr:nth-child(even) { background: var(--rt-bg); }

  .rt__table tbody tr:hover { background: var(--rt-bg); }

  /* Card title = the scam type. */
  .rt__table tbody th {
    display: block;
    padding: 14px 16px 12px;
    margin: 0 0 4px;
    border-bottom: 1px solid var(--rt-line);
    background: var(--rt-head-bg);
    color: var(--rt-text);
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.35;
    min-width: 0;
  }

  .rt__table tbody td {
    display: grid;
    grid-template-columns: 8.5rem 1fr;
    gap: 10px;
    align-items: start;
    padding: 9px 16px;
    border-bottom: 0;
    font-size: 0.875rem;
  }

  /* The label, from data-label — this is what replaces the <thead>. */
  .rt__table tbody td::before {
    content: attr(data-label);
    color: var(--rt-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    line-height: 1.7;
  }

  /* Report URL becomes a full-width button. */
  .rt__table tbody td.rt-cell-url {
    display: block;
    padding: 10px 16px 14px;
  }

  .rt__table tbody td.rt-cell-url::before {
    display: block;
    margin-bottom: 7px;
  }

  .rt__link {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 11px 14px;
    font-size: 0.875rem;
    box-sizing: border-box;
  }
}

/* Very narrow phones — stack label above value. */
@media (max-width: 359px) {
  .rt__table tbody td {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ==========================================================================
   PRINT — always the table, never the cards.
   ========================================================================== */

@media print {
  .rt {
    --rt-bg: #ffffff;
    --rt-bg-alt: #f4f6f9;
    --rt-head-bg: #e9edf3;
    --rt-text: #000000;
    --rt-text-2: #1f2937;
    --rt-muted: #374151;
    --rt-line: #b8c0cc;
    --rt-line-strong: #8b95a5;
    --rt-accent: #000000;
    --rt-accent-soft: transparent;
    --rt-shadow: none;
    font-size: 8.5pt;
    color: #000;
  }

  .rt__scroll {
    max-height: none !important;
    overflow: visible !important;
    border: 1px solid #8b95a5;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }

  /* Undo every mobile card rule. */
  .rt__table { display: table !important; width: 100%; min-width: 0 !important; }
  .rt__table colgroup { display: table-column-group !important; }
  .rt__table thead { display: table-header-group !important; position: static !important; clip: auto !important; clip-path: none !important; width: auto !important; height: auto !important; overflow: visible !important; }
  .rt__table tbody { display: table-row-group !important; }
  .rt__table tr { display: table-row !important; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; page-break-inside: avoid; }
  .rt__table th,
  .rt__table td {
    display: table-cell !important;
    padding: 4pt 5pt !important;
    border-bottom: 0.5pt solid #b8c0cc !important;
    background: transparent !important;
    font-size: 8pt !important;
    line-height: 1.3 !important;
  }

  .rt__table thead th {
    position: static !important;
    background: #e9edf3 !important;
    color: #000 !important;
    box-shadow: none !important;
    font-size: 7pt !important;
  }

  .rt__table tbody th {
    background: transparent !important;
    border-bottom: 0.5pt solid #b8c0cc !important;
    font-weight: 700 !important;
    min-width: 0 !important;
  }

  /* No data-label prefixes on paper. */
  .rt__table tbody td::before { content: none !important; display: none !important; }

  .rt__table tbody tr:nth-child(even) { background: #f4f6f9 !important; }

  .rt__link {
    display: inline !important;
    width: auto !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    color: #000 !important;
    font-size: 7.5pt !important;
    text-decoration: underline !important;
    white-space: normal !important;
  }

  .rt__link::after { content: none !important; }

  .rt__sort::after { content: none !important; }
  .rt__sort { cursor: auto; }

  .rt__caption { color: #000; font-size: 8pt; padding-bottom: 6pt; }
}

/* ------------------------------------------------- reduced motion / a11y */

@media (prefers-reduced-motion: reduce) {
  .rt *,
  .rt *::before,
  .rt *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Windows High Contrast / forced colors. */
@media (forced-colors: active) {
  .rt__scroll { border: 1px solid CanvasText; }
  .rt__table thead th { border-bottom: 1px solid CanvasText; }
  .rt__link { border: 1px solid LinkText; color: LinkText; }
  .rt__link:focus-visible { outline: 2px solid Highlight; }
}

/* ==========================================================================
   SEARCH + FILTER  (v2)
   --------------------------------------------------------------------------
   Everything here is inert without JS: the toolbar and the filter panel carry
   the `hidden` attribute in the markup, and the JS removes it on init. A
   no-JS reader therefore sees the full 23-row table and no dead controls.
   ========================================================================== */

/* `hidden` must win over the display values set below. */
.rt [hidden] { display: none !important; }

/* Visually hidden, still announced. */
.rt__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------- toolbar */

.rt__toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

.rt__search-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.rt__search {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 44px 11px 14px;
  border: 1px solid var(--rt-line-strong);
  border-radius: var(--rt-radius-sm);
  background: var(--rt-bg);
  color: var(--rt-text);
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
}

.rt__search::placeholder {
  color: var(--rt-muted);
  opacity: 1;
}

.rt__search:focus-visible {
  outline: 2px solid var(--rt-focus);
  outline-offset: 2px;
  border-color: var(--rt-focus);
}

/* Kill the native clear button — we handle Escape ourselves. */
.rt__search::-webkit-search-cancel-button { -webkit-appearance: none; }

.rt__kbd {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--rt-line-strong);
  border-radius: 5px;
  background: var(--rt-bg-alt);
  color: var(--rt-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

/* The hint is only useful while the box is empty. */
.rt__search:not(:placeholder-shown) ~ .rt__kbd { display: none; }

/* ------------------------------------------------------------- filters */

.rt__filters {
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-radius-sm);
  background: var(--rt-bg-alt);
}

.rt__fs {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.rt__legend {
  padding: 0;
  margin: 0 0 8px;
  color: var(--rt-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.rt__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.rt__chip,
.rt__toggle,
.rt__clear,
.rt__filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--rt-line-strong);
  border-radius: 999px;
  background: var(--rt-bg);
  color: var(--rt-text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.rt__chip:hover,
.rt__toggle:hover,
.rt__clear:hover,
.rt__filter-toggle:hover {
  border-color: var(--rt-accent);
  color: var(--rt-text);
}

.rt__chip:focus-visible,
.rt__toggle:focus-visible,
.rt__clear:focus-visible,
.rt__filter-toggle:focus-visible {
  outline: 2px solid var(--rt-focus);
  outline-offset: 2px;
}

/* Selected chip / pressed toggle. */
.rt__chip[aria-pressed="true"],
.rt__toggle[aria-pressed="true"] {
  border-color: var(--rt-accent);
  background: var(--rt-accent-soft);
  color: var(--rt-accent);
}

/* A tick, drawn in CSS, so selection is not colour-only (WCAG 1.4.1). */
.rt__chip[aria-pressed="true"]::before,
.rt__toggle[aria-pressed="true"]::before {
  content: "";
  width: 0.5em;
  height: 0.28em;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
  flex: none;
}

.rt__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rt__clear {
  border-style: dashed;
  color: var(--rt-muted);
}

/* --------------------------------------------------------- result count */

.rt__count {
  margin: 0 0 10px;
  color: var(--rt-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* ---------------------------------------------------------- empty state */

.rt__empty {
  margin: 0;
  padding: 28px 20px;
  border: 1px dashed var(--rt-line-strong);
  border-radius: var(--rt-radius);
  background: var(--rt-bg-alt);
  text-align: center;
}

.rt__empty-msg {
  margin: 0 0 14px;
  color: var(--rt-text-2);
  font-size: 0.9375rem;
}

.rt__empty-msg strong {
  color: var(--rt-text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------- filtered-out rows */

.rt__table tbody tr[hidden] { display: none !important; }

/* --------------------------------------------------- row keyboard focus */

/* Rows are programmatically focusable (tabindex="-1") so arrow-key
   navigation can land on them; the report link inside stays the tab stop. */
.rt__table tbody tr:focus { outline: none; }

.rt__table tbody tr:focus-visible {
  outline: 2px solid var(--rt-focus);
  outline-offset: -2px;
}

/* ------------------------------------------------------------- mobile */

@media (max-width: 767px) {
  .rt__toolbar { gap: 8px; }

  .rt__filter-toggle { flex: none; }

  /* The panel is collapsed behind the Filter button on phones. */
  .rt__filters {
    margin-top: 0;
  }

  .rt__chips { gap: 6px; }

  .rt__chip,
  .rt__toggle,
  .rt__clear,
  .rt__filter-toggle {
    padding: 8px 12px;
    font-size: 0.8125rem;
  }

  .rt__search { font-size: 1rem; } /* >=16px stops iOS zoom-on-focus */
}

/* On desktop the Filter button is redundant — the panel is always open. */
@media (min-width: 768px) {
  .rt__filter-toggle { display: none !important; }
}

/* ------------------------------------------------------------- print */

@media print {
  .rt__toolbar,
  .rt__filters,
  .rt__count,
  .rt__empty,
  .rt__kbd { display: none !important; }

  /* Print the whole table, never a filtered subset. */
  .rt__table tbody tr[hidden] { display: table-row !important; }
}
