/* Ad blocker test, shared by the landing and check.tems.band: a summary band
   across the full width, then one column of category cards that open in
   place. The component adapts to its own width. */

.check {
  container: check / inline-size;
}

.check-layout {
  display: grid;
  gap: 14px;
}

/* Summary band: ring, title, numbers and the button in one row. Before the
   test the numbers describe the base, then they count the results. */

.check-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "ring info stats action";
  align-items: center;
  gap: 24px 40px;
  padding: 28px 32px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(120deg, rgba(120, 196, 107, 0.06), transparent 55%), var(--surface);
}

.check-ring {
  grid-area: ring;
  position: relative;
  width: 176px;
  height: 176px;
}

.check-ring svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

/* Butt caps: round ones overlap into a notch when the ring is nearly full. */
.check-track,
.check-fill {
  fill: none;
  stroke-width: 10;
}

.check-track {
  stroke: rgba(120, 196, 107, 0.12);
}

/* Circumference of r=50 is 314.16. */
.check-fill {
  stroke: var(--state-up);
  stroke-dasharray: 314.16;
  stroke-dashoffset: 314.16;
  transition: stroke-dashoffset 0.4s ease, stroke 0.3s;
}

.check[data-level="partial"] .check-fill { stroke: var(--state-degraded); }
.check[data-level="bad"] .check-fill { stroke: var(--state-down); }

.check-score {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 2px;
  text-align: center;
}

.check-score strong {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.check-score span {
  max-width: 108px;
  color: var(--faint);
  font-size: 0.75rem;
  line-height: 1.3;
}

.check-info {
  grid-area: info;
  min-width: 0;
}

.check-title {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
}

.check[data-level="good"][data-state="done"] .check-title { color: var(--state-up); }
.check[data-level="partial"][data-state="done"] .check-title { color: var(--state-degraded); }
.check[data-level="bad"][data-state="done"] .check-title { color: var(--state-down); }

.check-stats {
  grid-area: stats;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  list-style: none;
}

.check-stats li {
  display: grid;
}

.check-stats b {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.check-stats span {
  color: var(--faint);
  font-size: 0.8125rem;
}

.check-stats [data-kind="blocked"] b { color: var(--state-up); }
.check-stats [data-kind="reachable"][data-some] b { color: var(--state-down); }

.check-progress {
  height: 4px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
}

.check:not([data-state="running"]) .check-progress {
  display: none;
}

.check-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s;
}

.check-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.check-note:empty {
  display: none;
}

.check-start {
  grid-area: action;
  min-width: 220px;
}

/* While the test runs the button is a quiet status with a spinner: it looks
   as unavailable as it is. */
.check-start:disabled,
.check-start:disabled:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: progress;
  transform: none;
}

.check-start:disabled::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: check-spin 0.8s linear infinite;
}

@keyframes check-spin {
  to { transform: rotate(360deg); }
}

/* Categories: one column of cards. On wide screens the bars line up in a
   column between the names and the numbers. */

.check-list {
  --name-w: 16.5rem;
  --meta-w: 7.5rem;
  display: grid;
  gap: 10px;
}

.check-cat {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  transition: border-color 0.2s;
}

.check-cat:hover {
  border-color: var(--line-strong);
}

.check-cat.is-open {
  border-color: var(--accent-brd);
}

.check-cat-heading {
  font-size: inherit;
}

.check-cat-head {
  display: grid;
  grid-template-columns: 22px var(--name-w) minmax(48px, 1fr) var(--meta-w) 48px 12px;
  grid-template-areas: "icon name bar meta pct chev";
  align-items: center;
  column-gap: 16px;
  row-gap: 12px;
  width: 100%;
  padding: 16px 18px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.check-cat-head::after {
  content: '';
  grid-area: chev;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.25s;
}

.check-cat.is-open .check-cat-head::after {
  margin-top: 2px;
  transform: rotate(-135deg);
}

.check-cat-icon {
  grid-area: icon;
  display: block;
  width: 22px;
  height: 22px;
}

.check-cat-name {
  grid-area: name;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Blocked share in green, reachable in red, side by side; the rest is unchecked. */
.check-cat-bar {
  grid-area: bar;
  display: flex;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
}

.check-cat-bar i {
  flex: none;
  width: 0;
  height: 100%;
  background: var(--state-up);
  transition: width 0.3s;
}

.check-cat-bar i.check-cat-bar-miss {
  background: var(--state-down);
}

/* Before the test the place of the bar lists the vendors of the category. */
.check-cat-peek {
  grid-area: bar;
  overflow: hidden;
  color: var(--faint);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check[data-state="idle"] .check-cat-bar,
.check:not([data-state="idle"]) .check-cat-peek {
  display: none;
}

.check-cat-meta {
  grid-area: meta;
  display: inline-flex;
  justify-content: flex-end;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 400;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.check-cat-count {
  color: var(--faint);
}

.check-cat-ok {
  color: var(--state-up);
  font-weight: 600;
}

.check-cat-miss {
  color: var(--faint);
  font-weight: 600;
}

.check-cat-miss[data-some] {
  color: var(--state-down);
}

.check-cat-pct {
  grid-area: pct;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.check-cat[data-level="good"] .check-cat-pct { color: var(--state-up); }
.check-cat[data-level="partial"] .check-cat-pct { color: var(--state-degraded); }
.check-cat[data-level="bad"] .check-cat-pct { color: var(--state-down); }

/* The body grows its only row from 0fr to 1fr, so the card opens smoothly to
   the exact height of its content. Padding sits on the inner content. */
.check-cat-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.check-cat.is-open .check-cat-body {
  grid-template-rows: 1fr;
}

.check-cat-clip {
  min-height: 0;
  overflow: hidden;
}

/* Masonry from adcheck.js: columns share one height, boxes stretch to fill. */
.check-cat-content {
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  gap: 10px;
  padding: 2px 18px 18px;
}

.check-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.check-sub {
  flex: 1 1 auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-inner);
}

.check-sub-name {
  margin-bottom: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* A wide box, like a category with one subcategory, flows its domains into
   columns. minmax(0, 1fr) keeps long names from pushing the badge out. */
.check-sub ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 4px 20px;
  list-style: none;
}

.check-sub li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 26px;
  font-size: 0.8125rem;
}

/* A long domain wraps after a dot instead of losing its end: phones have no
   hover to show the full name. */
.check-domain {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.check-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 99px;
  font-size: 0.6875rem;
  font-weight: 700;
  white-space: nowrap;
}

.check-badge:empty {
  display: none;
}

.check-badge[data-state="blocked"] {
  border-color: rgba(120, 196, 107, 0.3);
  background: rgba(120, 196, 107, 0.14);
  color: var(--state-up);
}

.check-badge[data-state="reachable"] {
  border-color: rgba(235, 100, 90, 0.3);
  background: rgba(235, 100, 90, 0.12);
  color: var(--state-down);
}

.check-badge[data-state="scanning"] {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--faint);
}

/* Medium: numbers under the title, the button under the band. */
@container check (max-width: 859px) {
  .check-summary {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "ring info"
      "ring stats"
      "action action";
    gap: 14px 28px;
    padding: 24px;
  }

  .check-info {
    align-self: end;
  }

  .check-stats {
    align-self: start;
  }

  .check-start {
    width: 100%;
    margin-top: 6px;
  }
}

/* Bars go under the category names, the vendor list lines up with the name. */
@container check (max-width: 859px) {
  .check-cat-head {
    grid-template-columns: 22px minmax(0, 1fr) auto 48px 12px;
    grid-template-areas:
      "icon name meta pct chev"
      "bar bar bar bar bar";
    padding: 16px 18px 14px;
  }

  .check-cat-peek {
    grid-area: 2 / 2 / 3 / -1;
  }

  .check[data-state="idle"] .check-cat-head {
    row-gap: 4px;
  }
}

/* Narrow: everything centred in the band, counts give way to the names. */
@container check (max-width: 479px) {
  .check-summary {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "ring"
      "info"
      "stats"
      "action";
    justify-items: center;
    gap: 18px;
    padding: 26px 18px 20px;
    border-radius: 20px;
    text-align: center;
  }

  .check-ring {
    width: 184px;
    height: 184px;
  }

  .check-stats {
    justify-content: center;
    gap: 8px 24px;
  }

  .check-start {
    margin-top: 0;
  }

  .check-cat-head {
    grid-template-columns: 22px minmax(0, 1fr) 44px 12px;
    grid-template-areas:
      "icon name pct chev"
      "bar bar bar bar";
    column-gap: 10px;
    padding: 14px 14px 12px;
  }

  /* Before the test the empty percent gives its place to the name. */
  .check[data-state="idle"] .check-cat-head {
    grid-template-columns: 22px minmax(0, 1fr) 12px;
    grid-template-areas:
      "icon name chev"
      "bar bar bar";
  }

  .check[data-state="idle"] .check-cat-pct,
  .check-cat-meta {
    display: none;
  }

  .check-cat-name {
    white-space: normal;
    text-wrap: balance;
  }

  .check-cat-content {
    padding: 2px 12px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .check-start:disabled::before {
    animation: none;
  }

  .check-fill,
  .check-progress i,
  .check-cat-bar i,
  .check-cat-body,
  .check-cat-head::after {
    transition: none;
  }
}
