/*
 * ntlddata.com
 *
 * Palette roles come from the validated reference instance. Sequential blue is
 * the workhorse because almost every figure on this site is a magnitude or a
 * trend; categorical slots are only used where series identity is the subject.
 * Diverging blue/red is reserved for adds-vs-drops, which is genuinely polar.
 *
 * Validator results for the sets used here (surface #fcfcfb / #1a1a19):
 *   ordinal blue 250-650, light + dark ......... ALL PASS
 *   categorical slots 1-4, light + dark ........ ALL PASS
 *     (light aqua 2.74:1 and yellow 2.11:1 are sub-3:1, so every chart using
 *      them ships direct labels and a table view — the relief rule.)
 *
 * The four categorical slots are the rule; --slice-1..10 below is the documented
 * exception. Registrar share within one TLD is a part-to-whole over ten named
 * competitors, which needs ten identities and cannot be told with four. It is a fixed,
 * hand-picked, declared set — not cycled, not generated — and it is used by the share
 * donut only. Adjacent hues are separated in lightness as well as hue so the ordering
 * survives monochrome and the common forms of colour blindness, and the donut always
 * ships a legend carrying the name, count and percentage, so colour is never the only
 * channel.
 */

:root {
  color-scheme: light;

  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  /* Sequential blue, ordinal-safe steps (250, 350, 450, 550, 650). */
  --seq-1: #86b6ef;
  --seq-2: #5598e7;
  --seq-3: #2a78d6;
  --seq-4: #1c5cab;
  --seq-5: #104281;
  --seq-wash: #cde2fb;

  /* Categorical, fixed order — never cycled, never generated. */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;

  /* Registrar-share donut. Fixed order, assigned by rank. See the note at the top. */
  --slice-1: #2a78d6;
  --slice-2: #eb6834;
  --slice-3: #1baf7a;
  --slice-4: #eda100;
  --slice-5: #8a5cd6;
  --slice-6: #1d97b4;
  --slice-7: #d1477d;
  --slice-8: #6d8f2c;
  --slice-9: #a9652b;
  --slice-10: #566a8d;
  --slice-other: #a8a6a0;

  /* Diverging: adds vs drops. Neutral midpoint is the gray below. */
  --pos: #2a78d6;
  --neg: #e34948;
  --mid: #f0efec;

  /* Status — reserved, always shipped with an icon and a label. */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --delta-up: #006300;

  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    /* Dark steps run the other way so the pale end still clears the surface. */
    --seq-1: #184f95;
    --seq-2: #256abf;
    --seq-3: #3987e5;
    --seq-4: #6da7ec;
    --seq-5: #9ec5f4;
    --seq-wash: #14335c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;

    /* Registrar-share donut, lifted for the dark surface. */
    --slice-1: #4b93e8;
    --slice-2: #f07b4b;
    --slice-3: #2ec48c;
    --slice-4: #f0b32c;
    --slice-5: #a077e0;
    --slice-6: #35abc6;
    --slice-7: #e26694;
    --slice-8: #86a641;
    --slice-9: #c07f42;
    --slice-10: #7286a6;
    --slice-other: #7d7b75;

    --pos: #3987e5;
    --neg: #e66767;
    --mid: #383835;
    --delta-up: #0ca30c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --seq-1: #184f95;
  --seq-2: #256abf;
  --seq-3: #3987e5;
  --seq-4: #6da7ec;
  --seq-5: #9ec5f4;
  --seq-wash: #14335c;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  /* Registrar-share donut, lifted for the dark surface. */
  --slice-1: #4b93e8;
  --slice-2: #f07b4b;
  --slice-3: #2ec48c;
  --slice-4: #f0b32c;
  --slice-5: #a077e0;
  --slice-6: #35abc6;
  --slice-7: #e26694;
  --slice-8: #86a641;
  --slice-9: #c07f42;
  --slice-10: #7286a6;
  --slice-other: #7d7b75;
  --pos: #3987e5;
  --neg: #e66767;
  --mid: #383835;
  --delta-up: #0ca30c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--seq-3); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ------------------------------------------------------------------ header */

.site-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 58px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; color: var(--text-primary); letter-spacing: -0.01em; }
.brand span { color: var(--seq-3); }
.site-nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.site-nav a {
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
}
.site-nav a:hover { background: var(--page); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text-primary); font-weight: 600; background: var(--page); }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: 5px 9px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

/* ------------------------------------------------------------------ layout */

main { padding: 28px 0 60px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--text-secondary); max-width: 70ch; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}
.card > h2 { margin: 0 0 4px; font-size: 16px; }
.card > h2 + .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

/* Card heading with a control on the far right (the share view toggle). */
.card-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 4px; }
.card-head > h2 { margin: 0; font-size: 16px; }
.card-head > :last-child { margin-left: auto; }

/*
 * Registrar-share donut and its legend.
 *
 * Side by side when there is room, stacked below ~640px. The legend is a real table, not
 * a styled list: it is the precise reading of the chart, so it should be selectable,
 * copyable and navigable by a screen reader as tabular data.
 */
.donut-wrap { display: flex; flex-wrap: wrap; gap: 24px 32px; align-items: flex-start; }
.donut { position: relative; flex: 0 0 auto; }
.donut svg { display: block; }
.donut-arc { transition: opacity 0.12s ease; }
.donut-wrap:hover .donut-arc { opacity: 0.55; }
.donut-wrap .donut-arc:hover { opacity: 1; }
.donut-centre {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; pointer-events: none; text-align: center;
}
.donut-centre strong { font-size: 22px; font-variant-numeric: tabular-nums; }

.donut-legend { flex: 1 1 220px; border-collapse: collapse; font-size: 13px; }
.donut-legend th, .donut-legend td { padding: 5px 8px; border-bottom: 1px solid var(--grid); text-align: left; font-weight: 400; }
.donut-legend th { color: var(--text-primary); }
.donut-legend td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.donut-legend tr:last-child th, .donut-legend tr:last-child td { border-bottom: 0; }
.swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 8px; vertical-align: baseline; flex: 0 0 auto;
}
/* Name and its note stack, and the note aligns under the name rather than under the
   swatch — which is what a bare block element in the cell would have done. */
.donut-legend .legend-text { display: inline-block; vertical-align: top; }
.donut-legend .legend-note { display: block; line-height: 1.35; }

@media (max-width: 640px) {
  .donut-wrap { gap: 16px; }
  .donut { margin: 0 auto; }
}

/* Colour is never the only channel: forced-colors keeps the arcs distinguishable by
   outline, and the legend text carries the values regardless. */
@media (forced-colors: active) {
  .donut-arc { forced-color-adjust: none; }
  .swatch { border: 1px solid CanvasText; }
}

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
/* Cards of unequal height sit at the top of their row rather than stretching: the share
   legend is taller than the registry facts, and stretching left a large blank. */
.grid.align-start { align-items: start; }

/* -------------------------------------------------------------- stat tiles */

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile .label { color: var(--text-secondary); font-size: 13px; margin-bottom: 4px; }
.stat-tile .value { font-size: 25px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.stat-tile .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }

.hero-figure { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.hero-label { color: var(--text-secondary); font-size: 14px; margin-top: 6px; }

/* Deltas pair an arrow glyph with the number: never color alone. */
.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--delta-up); }
.delta.down { color: var(--critical); }
.delta.flat { color: var(--muted); }

/* ------------------------------------------------------------------ tables */

.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--grid); }
table.data th { color: var(--text-secondary); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
table.data th a { color: inherit; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Client-sorted tables. The paginated listings render their own arrows server-side, so
   these rules are scoped to headers this script actually took over. */
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover, table.data th.sortable:focus-visible { color: var(--text-primary); }
table.data th.sortable::after {
  content: " \2195";
  opacity: 0.25;
  font-size: 11px;
}
table.data th.sortable[aria-sort="ascending"]::after { content: " \2191"; opacity: 1; }
table.data th.sortable[aria-sort="descending"]::after { content: " \2193"; opacity: 1; }
table.data tbody tr:hover { background: var(--page); }
table.data td.name { font-weight: 550; }

/* Inline magnitude bar inside a table cell: sequential, one hue. */
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell .track { width: 90px; height: 8px; background: var(--mid); border-radius: 4px; overflow: hidden; flex: none; }
.bar-cell .fill { height: 100%; background: var(--seq-3); border-radius: 4px; }

/* One-line family composition under a registrar-group name. Sits tight to the name so
   the pair reads as a unit, and stays on one line: the point is a glance, not a list. */
.composition {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
  max-width: 46ch;
}
.composition .muted { color: var(--muted); }

/* Native disclosure for long dormant-accreditation lists — no JavaScript needed. */
details > summary {
  cursor: pointer;
  color: var(--seq-3);
  font-size: 14px;
  padding: 4px 0;
}
details > summary:hover { text-decoration: underline; }
details[open] > summary { margin-bottom: 4px; }

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--page);
  white-space: nowrap;
}
.pill.inferred { border-style: dashed; }

/* ------------------------------------------------------------------ charts */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--baseline); stroke-width: 1; }
.chart .tick-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke: var(--seq-3); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { fill: var(--seq-wash); }
.chart .point { fill: var(--seq-3); stroke: var(--surface-1); stroke-width: 2; }
.chart .bar-pos { fill: var(--pos); }
.chart .bar-neg { fill: var(--neg); }
.chart .mark-label { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 3 3; }

/* Horizontal ranking bars. Sequential single hue; every bar directly labelled,
   which is also the relief for the sub-3:1 light steps. */
.hbars { display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr max-content; gap: 12px; align-items: center; font-size: 14px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--mid); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--seq-3); border-radius: 5px; min-width: 2px; }
.hbar-value { color: var(--text-secondary); white-space: nowrap; }
@media (max-width: 560px) {
  .hbar { grid-template-columns: 1fr max-content; }
  .hbar-track { grid-column: 1 / -1; }
}

.sparkline { display: block; margin-top: 6px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 10px; padding: 0; list-style: none; font-size: 13px; color: var(--text-secondary); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 12.5px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.13);
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
  white-space: nowrap;
}
.chart-tooltip.on { opacity: 1; }
.chart-tooltip .tt-date { color: var(--muted); font-size: 11.5px; }
.chart-tooltip .tt-value { font-weight: 650; font-variant-numeric: tabular-nums; }

.empty-state { color: var(--text-secondary); padding: 28px 0; text-align: center; }
.empty-state strong { display: block; color: var(--text-primary); margin-bottom: 4px; }

/* ----------------------------------------------------------------- notices */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}
.notice .ico { flex: none; font-weight: 700; }
.notice.warn { border-left-color: var(--warning); }
.notice.info { border-left-color: var(--seq-3); }
.notice.bad { border-left-color: var(--critical); }
.notice strong { color: var(--text-primary); }

/* Status states always pair the color with a glyph and a word. */
.state { font-weight: 600; white-space: nowrap; }
.state-ok { color: var(--good); }
.state-stale, .state-skipped { color: var(--serious); }
.state-failing, .state-never_run, .state-never_succeeded { color: var(--critical); }

/* --------------------------------------------------------------- utilities */

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="search"], .toolbar select {
  font: inherit;
  font-size: 14px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
}
.toolbar .spacer { margin-left: auto; }
.toolbar button {
  font: inherit; font-size: 14px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--seq-3); color: #fff;
}

.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; font-size: 14px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 5px 10px; border-radius: var(--radius); border: 1px solid var(--border); color: var(--text-secondary);
}
.pagination .current { background: var(--seq-3); color: #fff; border-color: transparent; font-weight: 600; }
.pagination .gap { border: 0; }

.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.secondary { color: var(--text-secondary); }
.nowrap { white-space: nowrap; }
.small { font-size: 13px; }
.right { text-align: right; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--text-secondary); }
dl.facts dd { margin: 0; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 40px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-1);
}
.site-footer a { color: var(--text-secondary); }
.site-footer .cols { display: flex; gap: 30px; flex-wrap: wrap; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

@media (max-width: 640px) {
  .hero-figure { font-size: 40px; }
  .site-nav { order: 3; width: 100%; margin-left: 0; }
}

/* Texture is the accessibility channel: opt-in, never decorative. */
@media (forced-colors: active) {
  .chart .series-area { fill: none; }
  .chart .series-line, .chart .bar-pos, .chart .bar-neg { forced-color-adjust: none; }
  .bar-cell .fill { border: 1px solid currentColor; }
}
