/* ============================================================
   BrowserProbe — Component Library
   Plain CSS, component-based, server-render friendly.
   Depends on tokens.css.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bp-bg); color: var(--bp-fg);
  font-family: var(--bp-font); font-size: var(--bp-t-body); line-height: var(--bp-lh-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; }
a { color: var(--bp-brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(14,116,144,0.22); }
:focus-visible { outline: 3px solid var(--bp-ring); outline-offset: 2px; border-radius: 4px; }

h1,h2,h3,h4 { font-family: var(--bp-font-display); margin: 0; line-height: var(--bp-lh-snug); letter-spacing: -0.01em; color: var(--bp-fg); }
p { margin: 0; }

/* ---------- layout ---------- */
.bp-wrap { max-width: var(--bp-maxw); margin: 0 auto; padding: 0 var(--bp-6); }
.bp-section { padding: var(--bp-20) 0; }
.bp-eyebrow {
  font-family: var(--bp-font-display); font-weight: 600; font-size: var(--bp-t-xs);
  text-transform: uppercase; letter-spacing: var(--bp-track-eyebrow); color: var(--bp-brand-ink);
}
.bp-lead { font-size: var(--bp-t-lg); color: var(--bp-fg-muted); line-height: var(--bp-lh-body); }
.bp-muted { color: var(--bp-fg-muted); }
.bp-subtle { color: var(--bp-fg-subtle); }
.bp-mono { font-family: var(--bp-font-mono); }
.bp-center { text-align: center; }
.bp-tnum { font-variant-numeric: tabular-nums; }

/* ---------- icons (lucide) ---------- */
.bp-i { width: 20px; height: 20px; display: inline-flex; flex: none; }
.bp-i-sm { width: 16px; height: 16px; }
.bp-i-lg { width: 24px; height: 24px; }
[data-lucide] { stroke-width: 1.75; }

/* ---------- buttons ---------- */
.bp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--bp-2);
  font-family: var(--bp-font); font-weight: 600; font-size: var(--bp-t-sm);
  letter-spacing: var(--bp-track-cta); line-height: 1; cursor: pointer;
  padding: 12px 20px; border-radius: var(--bp-r-pill); border: 1.5px solid transparent;
  transition: transform var(--bp-dur) var(--bp-ease), box-shadow var(--bp-dur), background var(--bp-dur), border-color var(--bp-dur), color var(--bp-dur);
  white-space: nowrap; text-decoration: none;
}
.bp-btn:hover { text-decoration: none; }
.bp-btn .bp-i { width: 18px; height: 18px; }
.bp-btn-primary { background: var(--bp-brand); color: var(--bp-on-brand); box-shadow: var(--bp-shadow-brand); }
.bp-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(14,116,144,0.34); background: var(--bp-brand-hover); }
.bp-btn-primary:active { transform: translateY(0) scale(0.98); background: var(--bp-brand-strong); }
.bp-btn-secondary { background: var(--bp-surface); color: var(--bp-brand-ink); border-color: var(--bp-border-2); box-shadow: var(--bp-shadow-xs); }
.bp-btn-secondary:hover { transform: translateY(-2px); border-color: var(--bp-brand); background: var(--bp-brand-softer); }
.bp-btn-secondary:active { transform: translateY(0) scale(0.98); }
.bp-btn-ghost { background: transparent; color: var(--bp-fg-muted); }
.bp-btn-ghost:hover { background: var(--bp-surface-2); color: var(--bp-fg); }
.bp-btn-onbrand { background: rgba(255,255,255,0.16); color: #fff; border-color: rgba(255,255,255,0.4); }
/* On-brand buttons go white in BOTH themes, so their text uses the theme-stable deep shade —
   dark mode's brand-ink is a bright on-dark cyan that fails contrast on white (BP-045). */
.bp-btn-onbrand:hover { background: #fff; color: var(--bp-brand-strong); transform: translateY(-2px); }
.bp-btn-onbrand-solid { background: #fff; color: var(--bp-brand-strong); }
.bp-btn-onbrand-solid:hover { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(0,0,0,0.18); }
.bp-btn-lg { padding: 15px 28px; font-size: var(--bp-t-body); }
.bp-btn-sm { padding: 9px 14px; font-size: var(--bp-t-xs); }
.bp-btn-block { width: 100%; }

/* ---------- status badge / pill ---------- */
.bp-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--bp-font); font-weight: 600; font-size: var(--bp-t-2xs);
  text-transform: uppercase; letter-spacing: 0.07em; padding: 4px 10px 4px 8px; border-radius: var(--bp-r-pill);
  border: 1px solid transparent;
}
.bp-badge .bp-i { width: 13px; height: 13px; }
.bp-badge[data-state="pass"] { background: var(--bp-pass-soft); color: var(--bp-pass); border-color: var(--bp-pass-border); }
.bp-badge[data-state="warn"] { background: var(--bp-warn-soft); color: var(--bp-warn); border-color: var(--bp-warn-border); }
.bp-badge[data-state="fail"] { background: var(--bp-fail-soft); color: var(--bp-fail); border-color: var(--bp-fail-border); }
.bp-badge[data-state="info"] { background: var(--bp-brand-soft); color: var(--bp-brand-ink); border-color: var(--bp-brand-border); }
.bp-badge[data-state="testing"] { background: var(--bp-surface-2); color: var(--bp-fg-subtle); border-color: var(--bp-border); }

/* ---------- generic card ---------- */
.bp-card {
  background: var(--bp-surface); border: 1px solid var(--bp-border);
  border-radius: var(--bp-r-lg); box-shadow: var(--bp-shadow-sm);
}

/* ============================================================
   RESULT CARD — the core component
   States via data-state="pass|warn|fail|testing"
   ============================================================ */
.bp-result {
  position: relative; display: grid;
  grid-template-columns: auto 1fr auto; align-items: center; gap: var(--bp-4);
  background: var(--bp-surface); border: 1px solid var(--bp-border);
  border-radius: var(--bp-r-md); padding: var(--bp-4) var(--bp-5);
  overflow: hidden; transition: box-shadow var(--bp-dur), border-color var(--bp-dur), transform var(--bp-dur);
}
.bp-result::before { /* status rail — functional scannability aid */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--bp-border-2); transition: background var(--bp-dur);
}
.bp-result:hover { box-shadow: var(--bp-shadow-md); }
.bp-result[data-state="pass"]::before { background: var(--bp-pass-strong); }
.bp-result[data-state="warn"]::before { background: var(--bp-warn-strong); }
.bp-result[data-state="fail"]::before { background: var(--bp-fail-strong); }

.bp-result__icon {
  width: 44px; height: 44px; border-radius: var(--bp-r-sm);
  display: flex; align-items: center; justify-content: center; flex: none;
  background: var(--bp-surface-2); color: var(--bp-fg-muted);
}
.bp-result__icon .bp-i { width: 22px; height: 22px; }
.bp-result[data-state="pass"] .bp-result__icon { background: var(--bp-pass-soft); color: var(--bp-pass); }
.bp-result[data-state="warn"] .bp-result__icon { background: var(--bp-warn-soft); color: var(--bp-warn); }
.bp-result[data-state="fail"] .bp-result__icon { background: var(--bp-fail-soft); color: var(--bp-fail); }

.bp-result__main { min-width: 0; }
.bp-result__name { font-weight: 600; font-size: var(--bp-t-body); color: var(--bp-fg); margin-bottom: 2px; }
.bp-result__detail { font-size: var(--bp-t-sm); color: var(--bp-fg-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bp-result__value { font-weight: 600; color: var(--bp-fg); font-variant-numeric: tabular-nums; }
.bp-result__sep { width: 3px; height: 3px; border-radius: 50%; background: var(--bp-border-2); }
.bp-result__aside { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

/* testing / skeleton state */
.bp-result[data-state="testing"] .bp-result__icon { animation: bp-pulse 1.4s var(--bp-ease) infinite; }
.bp-skel { display: inline-block; height: 0.7em; border-radius: 4px;
  background: linear-gradient(90deg, var(--bp-skel-a) 25%, var(--bp-skel-b) 37%, var(--bp-skel-a) 63%);
  background-size: 320% 100%; animation: bp-shimmer 1.3s ease-in-out infinite; }
@keyframes bp-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes bp-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* reveal animation when a result lands */
.bp-result.bp-reveal { animation: bp-rise 0.42s var(--bp-ease) both; }
@keyframes bp-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- category group ---------- */
.bp-cat { margin-bottom: var(--bp-8); }
.bp-cat__head { display: flex; align-items: center; gap: var(--bp-3); margin-bottom: var(--bp-4); }
.bp-cat__icon { width: 30px; height: 30px; border-radius: var(--bp-r-sm); background: var(--bp-brand-soft);
  color: var(--bp-brand-ink); display: flex; align-items: center; justify-content: center; }
.bp-cat__icon .bp-i { width: 17px; height: 17px; }
.bp-cat__title { font-family: var(--bp-font-display); font-weight: 600; font-size: var(--bp-t-h4); }
.bp-cat__meta { margin-left: auto; font-size: var(--bp-t-sm); color: var(--bp-fg-subtle); }
.bp-result-list { display: flex; flex-direction: column; gap: var(--bp-3); }

/* ============================================================
   SCORE GAUGE / SUMMARY
   ============================================================ */
.bp-score {
  display: grid; grid-template-columns: auto 1fr; gap: var(--bp-8); align-items: center;
  background: var(--bp-surface); border: 1px solid var(--bp-border);
  border-radius: var(--bp-r-xl); padding: var(--bp-8); box-shadow: var(--bp-shadow-md);
}
.bp-gauge { --p: 0; --gc: var(--bp-brand); position: relative; width: 168px; height: 168px; flex: none; }
.bp-gauge__ring {
  width: 100%; height: 100%; border-radius: 50%;
  background: conic-gradient(var(--gc) calc(var(--p) * 1%), var(--bp-surface-2) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 16px), #000 calc(100% - 15px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 16px), #000 calc(100% - 15px));
  transition: background 0.1s linear;
}
.bp-gauge__center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.bp-gauge__num { font-family: var(--bp-font-display); font-weight: 700; font-size: 3rem; line-height: 1; color: var(--bp-fg); font-variant-numeric: tabular-nums; }
.bp-gauge__den { font-size: var(--bp-t-xs); color: var(--bp-fg-subtle); margin-top: 2px; letter-spacing: 0.04em; }
.bp-score__body { min-width: 0; }
.bp-score__grade { display: inline-flex; align-items: center; gap: 8px; font-family: var(--bp-font-display);
  font-weight: 600; font-size: var(--bp-t-h3); margin-bottom: 6px; }
.bp-score__summary { color: var(--bp-fg-muted); margin-bottom: var(--bp-5); max-width: 46ch; }
.bp-score__bars { display: flex; flex-direction: column; gap: var(--bp-2); }
.bp-cbar { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: var(--bp-3); font-size: var(--bp-t-sm); }
.bp-cbar__label { color: var(--bp-fg-muted); display: flex; align-items: center; gap: 7px; }
.bp-cbar__track { height: 7px; border-radius: var(--bp-r-pill); background: var(--bp-surface-2); overflow: hidden; }
.bp-cbar__fill { display: block; height: 100%; border-radius: inherit; }
.bp-cbar__fill[data-state="pass"] { background: var(--bp-pass-strong); }
.bp-cbar__fill[data-state="warn"] { background: var(--bp-warn-strong); }
.bp-cbar__fill[data-state="fail"] { background: var(--bp-fail-strong); }
.bp-cbar__val { font-weight: 600; color: var(--bp-fg); font-variant-numeric: tabular-nums; }

/* ---------- share bar ---------- */
.bp-share { display: flex; align-items: center; gap: var(--bp-3); flex-wrap: wrap; }
.bp-linkfield { display: flex; align-items: center; gap: var(--bp-2); flex: 1 1 280px; min-width: 0;
  background: var(--bp-surface-2); border: 1px solid var(--bp-border-2); border-radius: var(--bp-r-pill);
  padding: 6px 6px 6px 16px; }
.bp-linkfield input { flex: 1; min-width: 0; border: 0; background: transparent; font-family: var(--bp-font-mono);
  font-size: var(--bp-t-sm); color: var(--bp-fg-muted); padding: 6px 0; }
.bp-linkfield input:focus { outline: none; }

/* ---------- progress (auto-run) ---------- */
.bp-progress { height: 6px; border-radius: var(--bp-r-pill); background: var(--bp-surface-2); overflow: hidden; }
.bp-progress__fill { height: 100%; width: 0; border-radius: inherit; background: var(--bp-grad); transition: width 0.4s var(--bp-ease); }

/* ---------- theme toggle ---------- */
.bp-iconbtn { width: 40px; height: 40px; border-radius: var(--bp-r-pill); display: inline-flex; align-items: center;
  justify-content: center; color: var(--bp-fg-muted); background: transparent; border: 1px solid transparent; cursor: pointer;
  transition: background var(--bp-dur), color var(--bp-dur), border-color var(--bp-dur); flex: none; }
.bp-iconbtn:hover { background: var(--bp-surface-2); color: var(--bp-fg); }
.bp-iconbtn .bp-i { width: 19px; height: 19px; }

/* ---------- toggle switch (accessible checkbox) ---------- */
.bp-switch { position: relative; display: inline-flex; align-items: center; flex: none; }
.bp-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.bp-switch__track { width: 42px; height: 24px; border-radius: var(--bp-r-pill); background: var(--bp-border-2);
  transition: background var(--bp-dur) var(--bp-ease); display: block; flex: none; }
.bp-switch__thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--bp-shadow-sm); transition: transform var(--bp-dur) var(--bp-ease); }
.bp-switch input:checked ~ .bp-switch__track { background: var(--bp-brand); }
.bp-switch input:checked ~ .bp-switch__thumb { transform: translateX(18px); }
.bp-switch input:focus-visible ~ .bp-switch__track { outline: 3px solid var(--bp-ring); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .bp-gauge__ring, .bp-cbar__fill, .bp-progress__fill { transition: none !important; }
}

/* ============================================================
   MOBILE  — testing pages must work well on phones
   ============================================================ */
@media (max-width: 600px) {
  .bp-wrap { padding: 0 var(--bp-4); }
  .bp-section { padding: var(--bp-12) 0; }

  /* result card: tighten, let value/badge breathe */
  .bp-result { gap: var(--bp-3); padding: var(--bp-3) var(--bp-4); border-radius: var(--bp-r-sm); }
  .bp-result__icon { width: 38px; height: 38px; }
  .bp-result__icon .bp-i { width: 19px; height: 19px; }
  .bp-result__name { font-size: var(--bp-t-sm); }
  .bp-result__detail { font-size: var(--bp-t-xs); }
  /* badge → compact (icon + short label still present, never color-only) */
  .bp-badge { padding: 4px 8px; font-size: 0.6rem; }

  /* score summary stacks, gauge centered */
  .bp-score { grid-template-columns: 1fr; gap: var(--bp-5); padding: var(--bp-5); justify-items: center; text-align: center; }
  .bp-score__body { width: 100%; }
  .bp-score__grade { justify-content: center; }
  .bp-score__summary { margin-left: auto; margin-right: auto; }
  .bp-gauge { width: 150px; height: 150px; }
  .bp-cbar { grid-template-columns: 1fr auto; gap: var(--bp-2) var(--bp-3); text-align: left; }
  .bp-cbar__track { grid-column: 1 / -1; order: 3; }

  .bp-cat__head { gap: var(--bp-2); }
  .bp-cat__title { font-size: var(--bp-t-body); }

  .bp-share { flex-direction: column; align-items: stretch; }
  .bp-share .bp-btn { width: 100%; }
}

