/* Розміри в px: Material рахує rem від 20-24px, а графіки розраховані на 16px. */
/* Figures for "Why Business Ratings Should Be Open".
   US Directory palette "Zatoka" (light only) + validated data colors:
   series #2a78d6 and negative #e34948 pass all checks on #ffffff;
   accent #ff6a3d is 2.85:1 on white, so every accent mark has a visible label
   or a table view next to it. De-emphasis gray #898781 is used only for
   "the rest" in emphasis charts. */

.ud-fig {
  --surface: #ffffff;
  --ink: #0b2545;
  --muted: #4f6479;
  --line: #d3e0ea;
  --series: #2a78d6;
  --emph: #ff6a3d;
  --neg: #e34948;
  --deemph: #898781;
  color-scheme: light;
  position: relative;
  margin: 32px 0;
  padding: 20px 20px 16px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
.ud-fig *, .ud-fig *::before, .ud-fig *::after { box-sizing: border-box; }
.ud-fig__title { margin: 0 0 4px; font-size: 16.8px; font-weight: 650; line-height: 1.35; }
.ud-fig__sub { margin: 0 0 16px; color: var(--muted); font-size: 14.72px; }
.ud-fig__note { margin: 14px 0 0; color: var(--muted); font-size: 12.8px; }
.ud-fig__note a, .ud-fig td a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* legend: the key mirrors the mark */
.ud-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 14px; padding: 0; list-style: none; color: var(--muted); font-size: 13.6px; }
.ud-legend li { display: flex; align-items: center; gap: 6px; }
.ud-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.ud-key--dot { border-radius: 50%; }
.ud-key--ring { border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px var(--emph); }

/* table view toggle */
.ud-toggle {
  margin-top: 12px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13.12px; cursor: pointer;
}
.ud-toggle:hover { border-color: var(--muted); }
.ud-toggle:focus-visible, .ud-fig [tabindex]:focus-visible, .ud-fig input:focus-visible, .ud-chip:focus-visible {
  outline: 2px solid var(--series); outline-offset: 2px;
}
.ud-tablewrap { overflow-x: auto; margin-top: 10px; }
.ud-table { width: 100%; border-collapse: collapse; font-size: 13.6px; }
.ud-table caption { text-align: left; color: var(--muted); font-size: 12.8px; padding-bottom: 6px; }
.ud-table th, .ud-table td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ud-table th { color: var(--muted); font-weight: 600; font-size: 12.8px; }
.ud-table td.ud-num, .ud-table th.ud-num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }

/* tooltip: value leads, label follows */
.ud-tip {
  position: absolute; z-index: 5; max-width: 260px; padding: 8px 10px; pointer-events: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(11, 37, 69, .12); font-size: 13.12px; line-height: 1.35;
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.ud-tip.is-on { opacity: 1; transform: none; }
.ud-tip strong { display: block; font-size: 15.2px; }
.ud-tip span { color: var(--muted); }
.ud-tip .ud-tip-row { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.ud-tip .ud-tip-row i { display: inline-block; width: 10px; height: 2px; background: var(--series); }

/* ---------- platform table ---------- */
.ud-platforms th:first-child, .ud-platforms td:first-child { font-weight: 600; color: var(--ink); white-space: nowrap; }
.ud-platforms td:nth-child(3) { white-space: nowrap; }
.ud-yes { color: var(--ink); font-weight: 600; }
@media (max-width: 560px) {
  /* one card per platform; ARIA roles in the markup keep the table semantics */
  .ud-platforms thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ud-platforms, .ud-platforms tbody { display: block; width: 100%; }
  .ud-platforms tr { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .ud-platforms tbody tr:last-child { border-bottom: 0; }
  .ud-platforms th, .ud-platforms td, .ud-platforms td:nth-child(3) { display: block; padding: 0; border: 0; white-space: normal; }
  .ud-platforms td:nth-child(3), .ud-platforms td:nth-child(4) { font-size: 12.8px; }
  .ud-platforms td:nth-child(3)::before { content: "Numbers on each factor: "; color: var(--muted); font-weight: 400; }
}
.ud-no { color: var(--muted); }

/* ---------- horizontal bars (BBB) ---------- */
.ud-group { margin: 0 0 18px; }
.ud-group:last-of-type { margin-bottom: 0; }
.ud-group__head { margin: 0 0 8px; font-size: 13.6px; font-weight: 600; color: var(--muted); }
.ud-bars { margin: 0; padding: 0; list-style: none; }
.ud-bar-row { display: grid; grid-template-columns: minmax(0, 44%) 1fr; align-items: center; gap: 12px; padding: 5px 0; }
.ud-bar-label { font-size: 13.76px; color: var(--ink); }
.ud-bar-track { position: relative; display: flex; align-items: center; height: 24px; border-left: 1px solid var(--line); }
.ud-bar {
  height: 16px; border-radius: 0 4px 4px 0; background: var(--series); flex: none;
  transition: filter .12s;
}
.ud-bar--neg { background: var(--neg); }
.ud-bar:hover, .ud-bar:focus-visible { filter: brightness(1.08); }
.ud-bar-val { margin-left: 8px; font-size: 13.12px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 560px) {
  .ud-bar-row { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- FICO strip ---------- */
.ud-strip { display: flex; gap: 2px; height: 24px; }
.ud-strip__seg { background: var(--series); transition: filter .12s; }
.ud-strip__seg:first-child { border-radius: 4px 0 0 4px; }
.ud-strip__seg:last-child { border-radius: 0 4px 4px 0; }
.ud-strip__seg:hover, .ud-strip__seg:focus-visible { filter: brightness(1.12); }
.ud-strip-nums { display: flex; gap: 2px; margin-top: 6px; }
.ud-strip-nums span { text-align: center; font-size: 12.8px; font-weight: 600; color: var(--ink); }
.ud-fico-table { margin-top: 14px; }
.ud-fico-table td:first-child { width: 28px; color: var(--muted); font-weight: 600; }

/* ---------- dot grid (two "best of" lists) ---------- */
.ud-dots { display: grid; grid-template-columns: repeat(15, 16px); gap: 8px; padding: 4px 0; }
@media (max-width: 560px) { .ud-dots { grid-template-columns: repeat(9, 16px); } }
.ud-dot { width: 16px; height: 16px; border-radius: 50%; flex: none; background: var(--deemph); }
.ud-dot--both { background: var(--emph); }
.ud-dot--maybe { background: var(--surface); box-shadow: inset 0 0 0 2px var(--emph); }

/* ---------- interactive weights ---------- */
.ud-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.ud-chip {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13.6px; cursor: pointer;
}
.ud-chip:hover { border-color: var(--muted); }
.ud-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #ffffff; }
.ud-sliders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; margin: 0 0 18px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ud-slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; font-size: 13.76px; }
.ud-slider label { color: var(--ink); }
.ud-slider output { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13.12px; }
.ud-slider input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--series); margin: 0; }
@media (max-width: 560px) { .ud-sliders { grid-template-columns: 1fr; } }

.ud-rank { margin: 0; padding: 0; list-style: none; position: relative; }
.ud-rank__row {
  display: grid; grid-template-columns: 28px minmax(0, 42%) 1fr; gap: 4px 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); background: var(--surface);
}
.ud-rank__row:last-child { border-bottom: 0; }
.ud-rank__pos { font-weight: 650; font-size: 15.2px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ud-rank__row.is-lead .ud-rank__pos { color: var(--ink); }
.ud-rank__name { font-weight: 600; font-size: 14.72px; }
.ud-rank__desc { display: block; color: var(--muted); font-size: 12.8px; font-weight: 400; line-height: 1.35; }
.ud-rank__plot { display: flex; align-items: center; min-width: 0; height: 24px; border-left: 1px solid var(--line); }
.ud-rank__bar { height: 16px; border-radius: 0 4px 4px 0; background: var(--series); flex: none; transition: width .35s ease, background-color .2s; }
.ud-rank__row.is-lead .ud-rank__bar { background: var(--emph); }
.ud-rank__score { margin-left: 8px; font-size: 13.76px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ud-rank__lead { margin-left: 6px; font-size: 11.52px; font-weight: 600; color: var(--ink); white-space: nowrap; }
@media (max-width: 560px) {
  .ud-rank__row { grid-template-columns: 24px 1fr; }
  .ud-rank__plot { grid-column: 2; }
}
.ud-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .ud-rank__bar, .ud-tip, .ud-bar, .ud-strip__seg { transition: none; }
}
