/* =============================================================================
   PlugMySite - Scan report styles (pms-scan-report.css)            [HS-S-5]
   Markup + behaviour: /content/js/pms-scan-report.js. Design: docs/DESIGN-FRAMEWORK.md.
   - Mobile-first (375). Desktop (>= 900) puts the speed card beside the findings; DOM order never changes.
   - Every class is `sr-` prefixed. No selector touches .nav-inner, .nav-links, #authNav or .nav-burger.
   - Tokens come from pms-design-system.css; each var() carries a literal fallback.
   - Reserved height: the host keeps min-height of one viewport while loading and after, so swapping the
     loader for the report moves nothing that is on screen (measured in test/scan-report-ui.js: CLS 0).
   - Targets are >= 44px. Inputs are 16px. Motion is off under prefers-reduced-motion.
   ============================================================================= */

.sr-vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* The host is the legacy .analysis-box: neutralise its chrome and reserve its height. */
.analysis-box.sr-host {
  padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none;
  min-height: 100vh; min-height: 100svh;
  margin-top: 16px; scroll-margin-top: 88px; animation: none;
}
.analysis-box.sr-host.visible { min-height: 100vh; min-height: 100svh; animation: none; }

.sr-wrap { --sr-ink: var(--pms-ink-primary, #0f172a); --sr-mute: var(--pms-ink-muted, #586578); --sr-line: var(--pms-border, rgba(15, 23, 42, .08));
  --sr-brand: var(--pms-primary, #0e6b4b); --sr-brand-d: var(--pms-primary-600, #0b543b); --sr-surface: var(--pms-surface-1, #fff); --sr-tint: var(--pms-surface-2, #f3f5f1);
  --sr-good: #0e6b4b; --sr-good-bg: #e8f5ee; --sr-warn: #8a5a00; --sr-warn-bg: #fdf3dc; --sr-bad: #a32d2d; --sr-bad-bg: #fbeaea;
  color: var(--sr-ink); font-size: 15px; line-height: 1.45; text-align: left; }
.sr-wrap * { box-sizing: border-box; }
.sr-wrap :focus-visible { outline: 2px solid var(--pms-brand-500, #22b673); outline-offset: 2px; }
.sr-h { margin: 0; font-size: 17px; line-height: 1.25; font-weight: 800; letter-spacing: -.005em; color: var(--sr-ink); }
.sr-h:focus { outline: none; }

/* ---- planner chrome: once the report hosts the scan, the old URL row / value strip / questionnaire summary are noise ---- */
#planner.sr-active #plannerValueStrip,
#planner.sr-active #urlBlock > :not(#analysisOutput),
#planner.sr-active #plannerDetected,
#planner.sr-active #plannerActions,
#planner.sr-active #plannerFreeNote { display: none !important; }
/* ...and the planner card around the report is a second frame we do not need. */
#planner.sr-active { padding: 0 !important; background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important; overflow: visible !important; max-width: 1040px; margin-top: 0; }
/* The hero status line ("Scanning ...") is cleared when the scan ends. Keep its line reserved so clearing it moves nothing. */
html.sr-scan-used .hx-scan-status:empty { display: block; min-height: 1.4em; }

/* ---- shared controls ---------------------------------------------------- */
.sr-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1.5px solid transparent;
  font: inherit; font-size: 15px; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer; text-align: center;
  transition: transform .15s ease, box-shadow .2s ease, background-color .15s ease, border-color .15s ease; }
.sr-btn--primary { background: var(--pms-gradient-brand, linear-gradient(135deg, #0e6b4b, #047857)); color: #fff; box-shadow: 0 1px 2px rgba(6, 40, 30, .18), 0 6px 14px rgba(14, 107, 75, .18); }
.sr-btn--primary:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(6, 40, 30, .2), 0 10px 20px rgba(14, 107, 75, .24); }
.sr-btn--ghost { background: var(--sr-surface); color: var(--sr-brand); border-color: var(--pms-border-strong, rgba(15, 23, 42, .14)); }
.sr-btn--ghost:hover { border-color: var(--sr-brand); transform: translateY(-1px); }
.sr-btn[disabled] { opacity: .6; cursor: default; transform: none; }
.sr-link { background: none; border: 0; padding: 12px 4px; min-height: 44px; font: inherit; font-weight: 700; color: var(--sr-brand); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---- loader ------------------------------------------------------------- */
.sr-loader { background: var(--sr-surface); border: 1px solid var(--sr-line); border-radius: 20px; padding: 20px 18px 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 12px 32px rgba(15, 23, 42, .07); }
.sr-loader-head { margin-bottom: 12px; }
.sr-loader .sr-h { word-break: break-word; }
.sr-steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 2px; }
.sr-step { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; min-height: 40px; color: var(--sr-mute); font-size: 14px; }
.sr-step-n { display: none; }
.sr-step-t { font-weight: 600; }
.sr-step-s { min-width: 84px; text-align: right; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--sr-mute); }
.sr-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--pms-border-strong, rgba(15, 23, 42, .18)); background: transparent; margin-left: 4px; }
.sr-step.is-active { color: var(--sr-ink); }
.sr-step.is-active .sr-dot { border-color: var(--sr-brand); background: radial-gradient(circle, var(--sr-brand) 0 38%, transparent 42%); }
.sr-step.is-active .sr-step-s { color: var(--sr-brand); }
.sr-step.is-done .sr-dot { border-color: var(--sr-good); background: var(--sr-good); position: relative; }
.sr-step.is-done .sr-dot::after { content: ""; position: absolute; left: 3px; top: 0; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.sr-step.is-done .sr-step-s { color: var(--sr-good); }
.sr-step.is-fail .sr-dot { border-color: var(--sr-warn); background: var(--sr-warn-bg); }
.sr-step.is-fail .sr-step-s { color: var(--sr-warn); }
.sr-bar { height: 8px; border-radius: 99px; background: var(--sr-tint); overflow: hidden; }
.sr-bar-fill { display: block; height: 100%; width: 100%; background: var(--pms-gradient-brand, linear-gradient(135deg, #0e6b4b, #047857)); border-radius: 99px;
  transform-origin: left center; transform: scaleX(.04); transition: transform .6s cubic-bezier(.4, 0, .2, 1); will-change: transform; }
.sr-hint { margin: 10px 0 12px; font-size: 13px; color: var(--sr-mute); }
.sr-loader .sr-btn { width: 100%; }

.sr-skel { display: grid; gap: 14px; margin-top: 14px; }
.sr-skel i { display: block; border-radius: 18px; background: var(--sr-tint); }
.sr-skel-a { height: 96px; } .sr-skel-b { height: 250px; } .sr-skel-c { height: 190px; }
@media (prefers-reduced-motion: no-preference) {
  .sr-skel i { background: linear-gradient(100deg, var(--sr-tint) 30%, #fafbf8 50%, var(--sr-tint) 70%); background-size: 200% 100%; animation: sr-shimmer 1.6s linear infinite; }
  .sr-step.is-active .sr-dot { animation: sr-pulse 1.4s ease-in-out infinite; }
}
@keyframes sr-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes sr-pulse { 50% { box-shadow: 0 0 0 5px rgba(14, 107, 75, .16); } }
@media (prefers-reduced-motion: reduce) { .sr-bar-fill { transition: none; } .sr-btn, .sr-btn:hover { transition: none; transform: none; } }

/* ---- message cards (failure / cancelled) -------------------------------- */
.sr-msg { background: var(--sr-surface); border: 1px solid var(--sr-line); border-radius: 20px; padding: 20px 18px; box-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 12px 32px rgba(15, 23, 42, .07); }
.sr-msg p { margin: 8px 0 14px; color: var(--sr-mute); }
.sr-msg-actions { display: grid; gap: 10px; }

/* ---- report ------------------------------------------------------------- */
.sr-report { display: grid; gap: 10px; }
.sr-sum, .sr-speed, .sr-ins, .sr-recs { background: var(--sr-surface); border: 1px solid var(--sr-line); border-radius: 18px; padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 22px rgba(15, 23, 42, .05); }

.sr-sum { display: grid; grid-template-columns: 46px 1fr; gap: 4px 12px; align-items: center; }
.sr-grade { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; font-weight: 900; color: #fff; background: var(--sr-good); }
.sr-grade.is-watch { background: #8a5a00; } .sr-grade.is-issue { background: #a32d2d; }
.sr-sum-main { min-width: 0; }
.sr-sum-main .sr-h { font-size: 16px; }
.sr-host-n { overflow-wrap: anywhere; }
.sr-sum-sub { margin: 2px 0 0; font-size: 13px; color: var(--sr-mute); }
.sr-sum-sub strong { color: var(--sr-ink); }

/* speed card */
.sr-speed-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sr-speed-head .sr-h { font-size: 15px; flex: 1 1 auto; min-width: 0; }
.sr-seg { flex: none; display: inline-flex; padding: 3px; border-radius: 99px; background: var(--sr-tint); border: 1px solid var(--sr-line); }
.sr-tab { min-height: 44px; min-width: 74px; padding: 0 12px; border: 0; border-radius: 99px; background: transparent; color: var(--sr-mute); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.sr-tab[aria-selected="true"] { background: var(--sr-surface); color: var(--sr-brand); box-shadow: 0 1px 3px rgba(15, 23, 42, .14); }
.sr-panel { min-height: 138px; }
.sr-panel:focus-visible { outline-offset: 4px; border-radius: 12px; }
.sr-ring { --c: var(--sr-good); position: relative; flex: 0 0 72px; width: 72px; height: 72px; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p, 0) * 1%), var(--sr-tint) 0); display: grid; place-items: center; }
.sr-ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--sr-surface); }
.sr-ring span { position: relative; font-size: 24px; font-weight: 900; color: var(--c); }
.sr-ring.is-needs-work { --c: #8a5a00; } .sr-ring.is-poor { --c: #a32d2d; } .sr-ring.is-none { --c: var(--sr-mute); }
.sr-pb-h { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--sr-mute); }
.sr-pb-s { margin: 8px 0 0; font-size: 12.5px; color: var(--sr-mute); }
.sr-chips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sr-chip { display: grid; gap: 1px; align-content: start; min-height: 84px; padding: 8px 4px; border-radius: 12px; background: var(--sr-tint); text-align: center; border: 1px solid transparent; }
.sr-chip-l { font-size: 11.5px; font-weight: 700; color: var(--sr-mute); letter-spacing: .04em; }
.sr-chip-v { font-size: 17px; font-weight: 800; color: var(--sr-ink); line-height: 1.2; white-space: nowrap; }
.sr-chip--score .sr-chip-v { font-size: 22px; }
.sr-chip-r { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 4px; line-height: 1.25; font-size: 11.5px; font-weight: 700; color: var(--sr-mute); }
.sr-chip-i { width: 8px; height: 8px; border-radius: 50%; background: var(--sr-mute); display: inline-block; }
.sr-chip.is-good { background: var(--sr-good-bg); } .sr-chip.is-good .sr-chip-r { color: var(--sr-good); } .sr-chip.is-good .sr-chip-i { background: var(--sr-good); }
.sr-chip.is-needs-work { background: var(--sr-warn-bg); } .sr-chip.is-needs-work .sr-chip-r { color: var(--sr-warn); } .sr-chip.is-needs-work .sr-chip-i { background: var(--sr-warn); border-radius: 2px; }
.sr-chip.is-poor { background: var(--sr-bad-bg); } .sr-chip.is-poor .sr-chip-r { color: var(--sr-bad); } .sr-chip.is-poor .sr-chip-i { background: var(--sr-bad); border-radius: 0; transform: rotate(45deg) scale(.85); }
.sr-note { margin: 8px 0 0; font-size: 12px; color: var(--sr-mute); }
.sr-unavail, .sr-pl { min-height: 138px; display: grid; align-content: center; justify-items: start; gap: 12px; padding: 4px 0; }
.sr-unavail p, .sr-pl p { margin: 0; color: var(--sr-mute); }
.sr-unavail strong { color: var(--sr-ink); }
.sr-spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--sr-tint); border-top-color: var(--sr-brand); }
@media (prefers-reduced-motion: no-preference) { .sr-spin { animation: sr-rot .9s linear infinite; } }
@keyframes sr-rot { to { transform: rotate(360deg); } }

/* insights */
.sr-ins .sr-h, .sr-recs .sr-h { margin-bottom: 8px; }
.sr-in-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sr-in { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 6px 0; border-top: 1px solid var(--sr-line); }
.sr-in:first-child { border-top: 0; padding-top: 2px; }
.sr-in-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--sr-tint); color: var(--sr-mute); }
.sr-in.is-good .sr-in-ic { background: var(--sr-good-bg); color: var(--sr-good); }
.sr-in.is-watch .sr-in-ic { background: var(--sr-warn-bg); color: var(--sr-warn); }
.sr-in.is-issue .sr-in-ic { background: var(--sr-bad-bg); color: var(--sr-bad); }
.sr-in-ic .sr-ic { width: 16px; height: 16px; }
.sr-in-b { min-width: 0; }
.sr-in-t { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.sr-in-tag { display: inline-block; margin-left: 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--sr-mute); }
.sr-in-ev { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; margin-top: 1px; font-size: 13px; line-height: 1.35; color: var(--sr-mute); }

/* recommendations */
.sr-rec-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sr-rec { display: grid; grid-template-columns: 32px 1fr; gap: 6px 10px; align-items: start; padding: 8px 10px 10px; border-radius: 14px; border: 1px solid var(--sr-line); background: var(--sr-surface); }
.sr-rec-ic { grid-row: 1 / 3; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--sr-good-bg); color: var(--sr-good); }
.sr-rec-b { display: contents; }
.sr-rec-top { grid-column: 2; align-self: end; display: flex; align-items: baseline; justify-content: space-between; gap: 2px 8px; flex-wrap: wrap; }
.sr-rec-n { font-size: 15px; font-weight: 800; }
.sr-rec-p { font-size: 13px; font-weight: 700; color: var(--sr-brand); white-space: nowrap; }
.sr-rec-l { grid-column: 1 / -1; margin: 2px 0 0; font-size: 13px; color: var(--sr-mute); overflow: hidden; line-height: 1.35; }
.sr-rec-why { grid-column: 2; align-self: start; font-size: 12px; font-weight: 600; color: var(--sr-ink); display: block; line-height: 1.3; }
.sr-rec-cta { grid-column: 1 / -1; width: 100%; }
.sr-more { border: 1px solid var(--sr-line); border-radius: 14px; background: var(--sr-surface); margin-top: 10px; }
.sr-more > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 0 14px; font-weight: 700; color: var(--sr-brand); cursor: pointer; list-style: none; border-radius: 14px; }
.sr-more > summary::-webkit-details-marker { display: none; }
.sr-more[open] > summary .sr-chev { transform: rotate(180deg); }
.sr-more > .sr-rec-list { padding: 0 10px 10px; }
.sr-chev { width: 20px; height: 20px; flex: none; }
.sr-extra { display: grid; gap: 10px; }
.sr-extra .sr-more { margin-top: 0; }
.sr-dl-wrap { padding: 0 14px 14px; display: grid; gap: 6px; }
.sr-dl-wrap h4 { margin: 10px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--sr-mute); }
.sr-dl { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--sr-ink); display: grid; gap: 6px; }
.sr-dl--grid { list-style: none; padding-left: 0; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.sr-dl li.is-no { color: var(--sr-mute); }
.sr-dl-fix { color: var(--sr-mute); }
.sr-dl-p, .sr-dl-note { margin: 4px 0 0; font-size: 13px; color: var(--sr-mute); }

/* save by email + footer actions */
.sr-actions { display: flex; flex-wrap: wrap; gap: 0 18px; }
.sr-actions .sr-link { padding: 10px 2px; }
.sr-save-f { background: var(--sr-surface); border: 1px solid var(--sr-line); border-radius: 14px; padding: 14px; display: grid; gap: 8px; }
.sr-save-f[hidden] { display: none; }
.sr-lab { font-size: 13px; font-weight: 700; }
.sr-save-row { display: grid; gap: 8px; }
.sr-save-row input { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--pms-border-strong, rgba(15, 23, 42, .14)); font: inherit; font-size: 16px; background: var(--sr-surface); color: var(--sr-ink); }
.sr-save-row input[aria-invalid="true"] { border-color: var(--sr-bad); }
.sr-save-n, .sr-save-m { margin: 0; font-size: 12.5px; color: var(--sr-mute); }
.sr-save-n a { color: var(--sr-brand); }
.sr-foot { margin: 0; font-size: 12.5px; color: var(--sr-mute); }

/* ---- desktop: speed card beside the findings; same DOM order ----------- */
@media (min-width: 900px) {
  .sr-wrap { font-size: 15px; }
  .sr-report { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
  .sr-sum, .sr-recs, .sr-extra, .sr-foot { grid-column: 1 / -1; }
  .sr-rec-list { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
  .sr-more > .sr-rec-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sr-rec { align-content: start; }
  .sr-rec-cta { align-self: end; }
  .sr-save-row { grid-template-columns: 1fr auto; }
  .sr-msg-actions { grid-template-columns: repeat(3, auto); justify-content: start; }
  .sr-loader { max-width: 760px; }
  .sr-loader .sr-btn { width: auto; }
  .sr-skel { grid-template-columns: 5fr 7fr; max-width: none; }
  .sr-skel-a { grid-column: 1 / -1; height: 84px; } .sr-skel-b { height: 230px; } .sr-skel-c { height: 230px; }
}
