/* PageSpeed section and history view of the QA status page (LM-13558).
   Uses the colour tokens of the theme stylesheets, so every theme works. */

/* !important: the slot script shows #envs-title through an inline style. */
body[data-view="pagespeed"] main > :not(#pagespeed-history),
body[data-view="pagespeed"] .slot-controls { display: none !important; }
body:not([data-view="pagespeed"]) #pagespeed-history { display: none; }

.ps-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 1.6rem 0 0.75rem;
}
.ps-head .section-title { margin: 0; }
.ps-state { font-size: 0.78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ps-state.is-bad { color: var(--bad); }
.ps-button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 0.4rem;
  padding: 0.28rem 0.7rem;
  cursor: pointer;
  text-decoration: none;
}
.ps-button:hover:not([aria-disabled="true"]) { background: var(--accent); color: var(--bg); }
.ps-button[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.ps-button:focus-visible, .ps-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ps-button.is-quiet { background: transparent; border-color: var(--line); color: var(--text-dim); }
.ps-link { font-size: 0.78rem; font-weight: 550; color: var(--accent); text-decoration: none; }
.ps-link:hover { text-decoration: underline; }
.ps-empty { font-size: 0.8rem; color: var(--text-faint); }
.ps-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ps-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.ps-table th, .ps-table td { text-align: left; padding: 0.35rem 0.4rem; border-top: 1px solid var(--line); vertical-align: middle; }
.ps-table thead th {
  border-top: 0;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ps-table tbody th { font-weight: 600; color: var(--text); }
.ps-caption { caption-side: top; text-align: left; font-size: 0.72rem; color: var(--text-faint); padding-bottom: 0.3rem; }
.ps-cell { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.ps-score {
  display: inline-block;
  min-width: 2.1rem;
  text-align: center;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
}
.ps-score.ok { background: var(--ok-bg); color: var(--ok); }
.ps-score.warn { background: var(--warn-bg); color: var(--warn); }
.ps-score.bad { background: var(--bad-bg); color: var(--bad); }
.ps-score.none { background: var(--free-bg); color: var(--free); }
.ps-delta { font-size: 0.7rem; font-weight: 650; white-space: nowrap; }
.ps-delta.better { color: var(--ok); }
.ps-delta.worse { color: var(--bad); }
.ps-delta.same { color: var(--text-faint); }
.ps-cwv { font-size: 0.6rem; padding: 0.12rem 0.4rem; }

.ps-toolbar { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ps-toolbar h2 { font-size: 1rem; font-weight: 650; margin-right: auto; }
.ps-select {
  font: inherit;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.3rem 0.5rem;
}
.ps-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.ps-charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.ps-charts.is-wide { grid-template-columns: 1fr; }
.ps-chart h3 { font-size: 0.8rem; font-weight: 650; color: var(--text); display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.ps-chart h3 small { font-weight: 500; color: var(--text-faint); font-size: 0.72rem; }
.ps-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.ps-chart .axis { stroke: var(--line); stroke-width: 1; }
.ps-chart .tick { fill: var(--text-faint); font-size: 10px; font-family: system-ui, sans-serif; }
.ps-chart .limit { stroke: var(--ok); stroke-width: 1.2; stroke-dasharray: 4 4; }
.ps-chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ps-chart .point { stroke: var(--panel); stroke-width: 1.5; }
.ps-legend { display: flex; gap: 0.8rem; flex-wrap: wrap; font-size: 0.72rem; color: var(--text-dim); }
.ps-legend i { display: inline-block; width: 0.7rem; height: 0.18rem; border-radius: 2px; vertical-align: middle; margin-right: 0.3rem; }

.ps-runs { overflow-x: auto; }
.ps-runs .ps-table td, .ps-runs .ps-table th { white-space: nowrap; }
.ps-error { color: var(--bad); white-space: normal !important; max-width: 28rem; }

.ps-dialog {
  margin: auto;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  box-shadow: var(--shadow);
  padding: 1.2rem 1.3rem;
  width: min(26rem, calc(100vw - 2rem));
}
.ps-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.ps-dialog h2 { font-size: 1rem; font-weight: 650; margin-bottom: 0.9rem; }
.ps-dialog fieldset { border: 0; margin-bottom: 0.9rem; }
.ps-dialog legend { font-size: 0.78rem; font-weight: 650; margin-bottom: 0.4rem; }
.ps-stores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.35rem 0.6rem; }
.ps-stores label { font-size: 0.85rem; display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.ps-dialog .ps-field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.78rem; font-weight: 650; }
.ps-dialog input[type="password"] {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.4rem 0.55rem;
}
.ps-dialog input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ps-hint { font-size: 0.72rem; font-weight: 400; color: var(--text-faint); }
.ps-message { min-height: 1.2rem; font-size: 0.8rem; color: var(--bad); margin: 0.6rem 0; }
.ps-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

@media (max-width: 700px) {
  .ps-stores { grid-template-columns: repeat(2, 1fr); }
  .ps-charts { grid-template-columns: 1fr; }
}
