/* ── Perfping — Redesign additions ───────────────────────────────────────
   New components for the beginner-friendly homepage.
   Reuses ALL existing tokens from app.css (--bg, --net, --dns, --r, --mono …).
   Nothing here overrides app.css — it only adds. Safe to drop onto live.
   ───────────────────────────────────────────────────────────────────────── */

/* Map now sits at the very top (banner), so the header line would double up
   with the map's top hairline — drop the header line and let the map separate. */
.hdr { border-bottom: none; }
/* The intro text is now BELOW the map and grouped with the search, so pull it
   in tighter. */
.hero { padding: 26px 0 22px; }

/* ── Sticky search dock ────────────────────────────────────────────────── */
/* The search bar stays pinned to the top once you scroll into the report, so a
   second check is always one tap away. A soft elevation keeps it readable as
   content scrolls underneath. */
.sbar {
  position: sticky;
  top: 12px;
  z-index: 40;
  box-shadow: var(--sh);
}

/* ── Top page-progress bar (fixed, full-width, no radius) ──────────────── */
.chk-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  margin: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  z-index: 200;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.chk-progress.active { opacity: 1; }
.chk-progress i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 0;
  background: linear-gradient(90deg, var(--cat-color, var(--chk)), var(--cat-mid, var(--chk-mid)));
  transition: width .35s ease;
}

/* ── Mode dropdown (inside the search bar) ─────────────────────────────── */
.mode-dd { position: relative; flex-shrink: 0; }
.mode-dd-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: var(--t2); background: var(--bg-sub);
  border: 0.5px solid var(--bd2); border-radius: 7px;
  padding: 6px 9px; cursor: pointer; white-space: nowrap; transition: all .15s;
}
.mode-dd-btn:hover { color: var(--text); border-color: var(--bd3); }
.mode-dd-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cat-color, var(--chk)); flex-shrink: 0; }
.mode-chev { width: 12px; height: 12px; opacity: .55; transition: transform .18s; }
.mode-dd.open .mode-chev { transform: rotate(180deg); }
.mode-dd-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 156px; padding: 4px;
  background: var(--bg-card); border: 0.5px solid var(--bd2);
  border-radius: var(--rl); box-shadow: var(--sh);
  z-index: 210; display: none;
}
.mode-dd.open .mode-dd-menu { display: block; }
.mode-dd-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  font-family: var(--sans); font-size: 13px; color: var(--text);
  background: none; border: none; border-radius: 7px; padding: 8px 10px; cursor: pointer;
}
.mode-dd-menu button::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; flex-shrink: 0; }
.mode-dd-menu button:hover { background: var(--bg-sub); }
.mode-dd-menu button.on { color: var(--cat-color, var(--chk)); font-weight: 600; }
.mode-dd-menu button.on::before { opacity: 1; }

/* ── Section heading (shared) ──────────────────────────────────────────── */
.sec {
  margin: 46px 0 0;
}
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.sec-head h2 {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.sec-head .sec-sub {
  font-size: 13px;
  color: var(--t2);
}
.sec-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 6px;
}

/* ── Hero world map (full-width banner at top) ─────────────────────────── */
/* Lives OUTSIDE .wrap, so it's naturally viewport-wide — no 100vw / overflow
   hacks (which would break the sticky search below). */
.hero-map-wrap {
  position: relative;
  width: 100%;
  margin: 0 0 4px;
  border-bottom: 0.5px solid var(--bd);
  background:
    radial-gradient(90% 120% at 50% 0%, var(--cat-glow, var(--chk-glow)) 0%, transparent 60%),
    var(--bg-card);
  overflow: hidden;
}
.pp-map {
  display: block;
  width: 100%;
  height: auto;
}
.pp-map-land path {
  fill: var(--bd2);
  stroke: var(--bd3);
  stroke-width: 0.4;
  opacity: .55;
  transition: fill .3s;
}
[data-theme="dark"] .pp-map-land path { opacity: .4; }

.pp-target-marker {
  fill: var(--cat-color, var(--chk));
  stroke: var(--bg-card);
  stroke-width: 1.2;
}

.pp-node-dot { fill: var(--net); transition: fill .35s; }
.pp-node-dot.warn { fill: var(--warn); }
.pp-node-dot.fail { fill: var(--fail); }
.pp-node-dot.idle { fill: var(--t3); }
.pp-node-ring.fail { stroke: var(--fail); }
.pp-arc.fail { stroke: var(--fail); }
.pp-node-ring {
  fill: none;
  stroke: var(--net);
  transform-origin: center;
  transform-box: fill-box;
  animation: ppPulse 2.6s ease-out infinite;
}
.pp-node-ring.warn { stroke: var(--warn); }
@keyframes ppPulse {
  0%   { r: 4; opacity: .55; }
  70%  { r: 13; opacity: 0; }
  100% { r: 13; opacity: 0; }
}
.pp-node-label {
  font-family: var(--mono);
  font-size: 9.5px;
  fill: var(--t3);
  text-anchor: middle;
}
.pp-arc {
  fill: none;
  stroke: var(--net);
  stroke-width: 1.4;
  opacity: .55;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.pp-arc.warn { stroke: var(--warn); }
.pp-arc.run { transition: stroke-dashoffset 1s ease; stroke-dashoffset: 0; }

.pp-target-chip {
  fill: var(--bg-sub);
  stroke: var(--cat-color, var(--chk));
  stroke-width: 1;
}
.pp-target-text {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  fill: var(--text);
  text-anchor: middle;
}

/* Legend under the map — kept aligned with the content column */
.pp-map-legend {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 20px;
  border-top: 0.5px solid var(--bd);
  font-size: 11.5px;
  color: var(--t2);
}
.pp-lg { display: inline-flex; align-items: center; gap: 6px; }
.pp-lg i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pp-lg .lg-ok { background: var(--ok); }
.pp-lg .lg-warn { background: var(--warn); }
.pp-lg .lg-fail { background: var(--fail); }
.pp-map-legend .lg-spacer { margin-left: auto; font-family: var(--mono); color: var(--t3); }

/* ── Goal cards (intent-based entry) ───────────────────────────────────── */
.goals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.goal {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 16px;
  background: var(--bg-card);
  border: 0.5px solid var(--bd2);
  border-left: 3px solid var(--goal, var(--net));
  border-radius: var(--r);
  box-shadow: var(--sh-sm);
  cursor: pointer;
  transition: border-color .18s, transform .12s, box-shadow .18s;
  font-family: var(--sans);
  color: var(--text);
  text-decoration: none;
}
.goal:hover {
  border-color: var(--goal, var(--net));
  transform: translateY(-2px);
  box-shadow: var(--sh);
}
.goal-ic {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--goal-light, var(--net-light));
  color: var(--goal, var(--net));
  flex-shrink: 0;
}
.goal-ic svg { width: 18px; height: 18px; }
.goal-q { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.goal-d { font-size: 12px; color: var(--t2); line-height: 1.5; }
.goal-run {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--goal, var(--net));
  display: inline-flex; align-items: center; gap: 5px;
  opacity: .9;
}
.goal-run svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ── How it works ──────────────────────────────────────────────────────── */
.howit {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.howit-step {
  position: relative;
  padding: 16px 18px;
  background: var(--bg-sub);
  border: 0.5px solid var(--bd);
  border-radius: var(--r);
}
.howit-n {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--cat-color, var(--chk));
  background: var(--cat-light, var(--chk-light));
  border: 0.5px solid var(--cat-mid, var(--chk-mid));
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  margin-bottom: 10px;
}
.howit-t { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.howit-d { font-size: 12px; color: var(--t2); line-height: 1.55; }

/* ── Plain-language verdict banner (results) ───────────────────────────── */
.verdict-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--rl);
  border: 1px solid var(--bd2);
  background: var(--bg-card);
  box-shadow: var(--sh-sm);
  margin-bottom: 12px;
  border-left: 4px solid var(--ok);
}
.verdict-banner.v-warn { border-left-color: var(--warn); }
.verdict-banner.v-fail { border-left-color: var(--fail); }
.vb-ic {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ok-bg); color: var(--ok);
}
.verdict-banner.v-warn .vb-ic { background: var(--warn-bg); color: var(--warn); }
.verdict-banner.v-fail .vb-ic { background: var(--fail-bg); color: var(--fail); }
.vb-ic svg { width: 18px; height: 18px; }
.vb-body { flex: 1; min-width: 0; }
.vb-title { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.vb-text { font-size: 13px; color: var(--t2); line-height: 1.55; }
.vb-text b { color: var(--text); font-weight: 600; }

/* Simple / Advanced view toggle */
.view-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: var(--bg-sub);
  border: 0.5px solid var(--bd);
  border-radius: var(--rx);
  margin: 2px 0 16px;
}
.view-toggle button {
  padding: 6px 15px;
  border: none;
  background: none;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--t2);
  cursor: pointer;
  border-radius: var(--rx);
  transition: all .15s;
  display: flex; align-items: center; gap: 6px;
}
.view-toggle button.on {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--sh-sm);
  border: 0.5px solid var(--bd2);
}
.view-toggle button svg { width: 13px; height: 13px; }

/* Human sentence on each result card (Simple view) */
.chk-plain {
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  color: var(--t2);
}
.chk-plain b { color: var(--text); font-weight: 600; }
/* Advanced view: hide plain sentence, show raw mono line */
body[data-view="advanced"] .chk-plain { display: none; }
body[data-view="simple"]   .chk-card-d { display: none; }
/* "What it means" — always visible after a check (no hover, no height jump). */
.chk-why-note {
  display: block;
  margin-top: 6px;
  padding-left: 9px;
  border-left: 2px solid var(--bd2);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--t3);
}

/* ── Tool catalog ──────────────────────────────────────────────────────── */
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.cat-card {
  display: flex;
  gap: 11px;
  padding: 13px 14px;
  background: var(--bg-card);
  border: 0.5px solid var(--bd2);
  border-radius: var(--r);
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, transform .12s;
  box-shadow: var(--sh-sm);
}
.cat-card:hover { border-color: var(--cc, var(--net)); transform: translateY(-1px); }
.cat-card-ic {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--cc-light, var(--net-light));
  color: var(--cc, var(--net));
}
.cat-card-ic svg { width: 16px; height: 16px; }
.cat-card-b { min-width: 0; }
.cat-card-t {
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.cat-card-t .cc-tag {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--cc, var(--net));
  background: var(--cc-light, var(--net-light));
  padding: 1px 6px;
  border-radius: 4px;
}
.cat-card-d { font-size: 11.5px; color: var(--t2); line-height: 1.45; margin-top: 3px; }

.catalog-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

/* ── Trust strip ───────────────────────────────────────────────────────── */
.trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--t2);
}
.trust span { display: inline-flex; align-items: center; gap: 6px; }
.trust svg { width: 14px; height: 14px; color: var(--ok); }

/* ── How to fix (per card) ─────────────────────────────────────────────── */
.chk-fix { margin-top: 2px; border-top: 0.5px dashed var(--bd2); padding-top: 8px; }
.chk-fix summary {
  cursor: pointer; list-style: none;
  font-size: 12px; font-weight: 600; color: var(--cat-color, var(--chk));
  display: inline-flex; align-items: center; gap: 6px; user-select: none;
}
.chk-fix summary::-webkit-details-marker { display: none; }
.chk-fix .chk-fix-ic { font-style: normal; font-size: 11px; }
.chk-fix[open] summary { margin-bottom: 7px; }
.chk-fix-body { font-size: 12px; color: var(--t2); line-height: 1.55; }
.chk-fix-body p { margin: 0 0 8px; }
.chk-fix-body code { font-family: var(--mono); color: var(--text); background: var(--bg-sub); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.chk-snip {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--bg-sub); border: 0.5px solid var(--bd2); border-radius: var(--r); padding: 8px 10px;
}
.chk-snip code { flex: 1; background: none; padding: 0; white-space: pre-wrap; word-break: break-word; font-size: 11.5px; line-height: 1.5; color: var(--text); }
.chk-copy {
  flex-shrink: 0; font-family: var(--sans); font-size: 11px; font-weight: 600;
  color: var(--cat-color, var(--chk)); background: var(--bg-card);
  border: 0.5px solid var(--bd2); border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
.chk-copy:hover { border-color: var(--cat-color, var(--chk)); }
.chk-card.flash { animation: cardFlash 1.2s ease; }
@keyframes cardFlash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 2px var(--cat-color, var(--chk)); } }

/* ── Fix these first ───────────────────────────────────────────────────── */
#fix-priorities:empty { display: none; }
.prio-head { font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--t2); margin: 4px 0 8px; }
.prio-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.prio-item {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 0.5px solid var(--bd2); border-left: 3px solid var(--warn);
  border-radius: var(--r); padding: 7px 12px; cursor: pointer;
  font-family: var(--sans); color: var(--text); font-size: 12.5px; transition: border-color .15s, transform .12s;
}
.prio-item.v-fail { border-left-color: var(--fail); }
.prio-item:hover { border-color: var(--bd3); transform: translateY(-1px); }
.prio-item .prio-t { font-weight: 600; }
.prio-item .prio-arrow { color: var(--t3); }

/* ── Report action bar (view toggle + share) ───────────────────────────── */
.report-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 2px 0 16px; }
.report-actions { display: flex; gap: 8px; }
.report-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--t2);
  background: var(--bg-card); border: 0.5px solid var(--bd2); border-radius: var(--rx);
  padding: 6px 13px; cursor: pointer; transition: all .15s;
}
.report-btn:hover { color: var(--text); border-color: var(--bd3); }
.report-btn svg { width: 14px; height: 14px; }

/* Validation error */
#chk-err { color: var(--fail); font-size: 12.5px; margin: -6px 0 10px; display: none; }

/* ── Focus-visible (keyboard nav) ──────────────────────────────────────── */
.ctab:focus-visible, .pill:focus-visible, .goal:focus-visible, .cat-card:focus-visible,
.go-btn:focus-visible, .view-toggle button:focus-visible, .report-btn:focus-visible,
.prio-item:focus-visible, .chk-copy:focus-visible, .chk-fix summary:focus-visible {
  outline: 2px solid var(--cat-color, var(--chk));
  outline-offset: 2px;
}

/* ── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .pp-node-ring { animation: none; }
  .pp-arc.run { transition: none; }
  .nd, .node-badge .nb-dot, .logo-icon::after, .rdot.spin, .chk-spin { animation: none; }
  .goal:hover, .cat-card:hover, .prio-item:hover { transform: none; }
  .chk-card.flash { animation: none; }
  html { scroll-behavior: auto !important; }
}

/* ── Print / Save as PDF (report only) ─────────────────────────────────── */
@media print {
  .hero-map-wrap, .hero, .cat-tabs, .sbar, .chk-mode, .trust, #goals-sec,
  .report-bar, .footer, .hdr-right { display: none !important; }
  body { background: #fff; color: #000; }
  #report-sec { display: block !important; margin: 0; }
  .chk-card, .verdict-banner, .chk-summary, .prio-item { break-inside: avoid; box-shadow: none; }
  .chk-plain { display: block !important; }
  .chk-card-d { display: none !important; }
  .chk-fix summary { display: none; }
  .chk-fix-body { display: block !important; }
}

/* ── Category tabs: inner wrapper scrolls, outer shows edge fades ──────── */
.cat-tabs { position: relative; }
.cat-tabs-inner { display: flex; gap: 4px; min-width: 0; }
/* Edge fades fade the tabs into the strip's OWN background (--bg-sub),
   not the page background. JS toggles .fade-l / .fade-r on .cat-tabs. */
.cat-tabs::before, .cat-tabs::after {
  content: '';
  position: absolute;
  top: 3px; bottom: 3px; width: 30px;
  z-index: 2; pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
.cat-tabs::before { left: 3px; background: linear-gradient(to right, var(--bg-sub), transparent); }
.cat-tabs::after  { right: 3px; background: linear-gradient(to left, var(--bg-sub), transparent); }
.cat-tabs.fade-l::before { opacity: 1; }
.cat-tabs.fade-r::after  { opacity: 1; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .howit { grid-template-columns: 1fr; }
  .pp-node-label { display: none; }
}

@media (max-width: 560px) {
  /* Tighter 12px side gutters on mobile */
  .wrap { padding: 0 12px; }
  .pp-map-legend { padding: 9px 12px; }

  /* Header — one clean row: drop the long "13 nodes online" pill (the map now
     shows it), keep Sign in + theme toggle. */
  .hdr { padding: 12px 0; }
  .hdr-right { gap: 6px; }
  .hdr-right > .node-count-badge:first-child { display: none; }

  /* Intro text grouped tight above the search */
  .hero { padding: 18px 0 16px; }
  .hero p { font-size: 12.5px; padding: 0 4px; }
  .sec-eyebrow { margin-bottom: 4px; }

  /* Search — stack the input over a full-width button (no truncated text) */
  .sbar { flex-wrap: wrap; row-gap: 10px; padding: 10px 12px; }
  .sbar input { flex: 1 1 140px; font-size: 15px; }
  .sbar-sep { display: none; }
  .sbar .go-btn { flex: 1 1 100%; text-align: center; padding: 12px; font-size: 14px; }

  /* Category tabs — one swipeable row instead of 3 wrapped rows */
  .cat-tabs {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    margin-bottom: 18px;
  }
  .cat-tabs-inner {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cat-tabs-inner::-webkit-scrollbar { display: none; }
  .ctab { flex: 0 0 auto; padding: 8px 15px; }

  /* Trust line — tighter, centred, wraps gracefully */
  .trust { gap: 7px 14px; padding: 10px 4px; font-size: 12px; }

  /* Map banner + legend */
  .hero-map-wrap { margin-bottom: 0; }
  .pp-map-legend { gap: 8px 14px; padding: 9px 16px; font-size: 11px; }
  .pp-map-legend .lg-spacer { margin-left: 0; flex-basis: 100%; }

  /* Sections a little tighter */
  .sec { margin-top: 32px; }
  .sec-head h2 { font-size: 16px; }
  .sec-head .sec-sub { font-size: 12.5px; }

  /* Results */
  .verdict-banner { padding: 14px; gap: 12px; }
  .vb-title { font-size: 14.5px; }
  .vb-text { font-size: 12.5px; }
  .goal { padding: 14px; }
  .report-bar { gap: 10px; }
  .report-actions { flex: 1 1 100%; }
  .report-btn { flex: 1; justify-content: center; }
  .prio-list { gap: 6px; }
  .prio-item { flex: 1 1 100%; }

  /* Bigger, full-width Simple / Advanced toggle */
  .view-toggle { flex: 1 1 100%; }
  .view-toggle button { flex: 1; justify-content: center; padding: 10px 12px; font-size: 13.5px; }

  /* Gradient scrim below the sticky search — content fades in as it scrolls under.
     Starts a few px below so it never covers the card's own bottom border. */
  .sbar::after {
    content: '';
    position: absolute;
    left: 0; right: 0; top: calc(100% + 3px);
    height: 22px;
    background: linear-gradient(to bottom, var(--bg), transparent);
    pointer-events: none;
  }
}
