/* Performance: CrushFTP 11 vs CrushMFT27, from our own tests.
   Charts are emphasis bars: CrushMFT27 in one data hue, CrushFTP 11 in a recessive gray, one scale per row
   (rows measure different things). Values are printed at the bar ends, so colour never carries a number alone;
   every area also has a table view. Data colours were checked with the dataviz palette validator. */

:root,
:root[data-theme="dark"] {
  --pf-v11: #6f787f;
  --pf-v27: #3987e5;
  --pf-track: #2c2c2c;
  --pf-good: #4ade80;
  --pf-bad: #f87171;
}
:root[data-theme="light"] {
  --pf-v11: #8b959c;
  --pf-v27: #2a78d6;
  --pf-track: #e8ecee;
  --pf-good: #15803d;
  --pf-bad: #b91c1c;
}

.page-performance {
  --pf-gut: clamp(20px, 3.2vw, 56px);
  --pf-nav: 52px;
  --pf-pad: clamp(44px, 4vw, 56px); /* each side: 88–112px from one area's last content to the next heading */
}

/* ------------------------------------------------------------------ head and headline results */
.pf-eyebrow { margin-bottom: 20px; color: var(--muted); font-size: .875rem; font-weight: 700; letter-spacing: .01em; }
.pf-eyebrow span { margin-inline: 6px; color: var(--faint); }
.pf-head h1 { max-width: 18ch; }
.pf-source {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  color: var(--muted); font-size: .875rem; font-weight: 600;
}
.pf-source svg { width: 16px; height: 16px; color: var(--faint); }

.pf-kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
  margin-top: clamp(24px, 3vw, 36px);
}
.pf-kpi > a {
  position: relative;
  display: grid; align-content: start; gap: 0; height: 100%;
  padding: 14px 16px 13px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel);
  transition: border-color var(--t-fast) ease, transform var(--t-med) var(--ease), box-shadow var(--t-med) ease;
}
.pf-kpi > a:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pf-kpi > a:focus-visible { outline-offset: -2px; }
.pf-kpi > a::after {
  content: ""; position: absolute; left: 16px; right: 16px; top: -1px; height: 2px; border-radius: 0 0 2px 2px;
  background: var(--pf-v27);
}
.pf-kpi-fig { display: flex; align-items: baseline; color: var(--strong); font-weight: 750; line-height: 1; letter-spacing: -.04em; }
.pf-kpi-top { display: flex; align-items: baseline; gap: 8px; }
.pf-kpi-pre { position: relative; top: -.32em; margin-right: 2px; color: var(--faint); font-size: 1.375rem; font-weight: 650; }
.pf-kpi-n { font-size: clamp(2.75rem, 2.2rem + 1vw, 3.25rem); }
.pf-kpi-x { margin-left: 1px; font-size: 1.5rem; }
.pf-kpi-tail { color: var(--muted); font-size: .875rem; font-weight: 650; }
.pf-kpi-item { margin-top: 8px; color: var(--strong); font-size: .9375rem; font-weight: 700; line-height: 1.3; }
.pf-kpi-ba {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 3px;
  color: var(--muted); font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pf-kpi-ba > span:last-child { color: var(--strong); }
.pf-kpi-arrow { color: var(--faint); }

/* ------------------------------------------------------------------ area strip, sticky under the top bar */
.pf-nav {
  position: sticky; top: var(--topbar); z-index: 40;
  margin-inline: calc(-1 * var(--pf-gut)); padding-inline: var(--pf-gut);
  border-block: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px); -webkit-backdrop-filter: saturate(1.2) blur(10px);
}
.pf-nav ol {
  display: flex; align-items: center; gap: 4px;
  max-width: var(--measure); height: var(--pf-nav); margin-inline: auto;
  overflow-x: auto; scrollbar-width: none;
}
.pf-nav ol::-webkit-scrollbar { display: none; }
.pf-nav li { flex: none; }
.pf-nav a {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 12px 0 14px; border-radius: var(--r-sm);
  color: var(--muted); font-size: .875rem; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: background-color var(--t-fast) ease, color var(--t-fast) ease;
}
.pf-nav a:hover { background: var(--hover); color: var(--ink); }
.pf-nav a:focus-visible { outline-offset: -2px; }
.pf-nav a[aria-current] { background: var(--sel); color: var(--strong); }
.pf-nav a[aria-current]::before {
  content: ""; position: absolute; left: 0; top: .4rem; bottom: .4rem; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--orange); animation: bar-in var(--t-med) var(--ease);
}
.pf-n { color: var(--faint); font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ areas */
.pf-area {
  max-width: var(--measure); margin-inline: auto;
  padding-block: var(--pf-pad);
  scroll-margin-top: calc(var(--pf-nav) - var(--strip) - var(--pf-pad) + 20px);
}
.pf-area + .pf-area { border-top: 1px solid var(--line); }
.pf-area-head { display: grid; gap: 12px; max-width: 70ch; margin-bottom: clamp(20px, 2.4vw, 28px); }
.pf-area-head h2 { max-width: 24ch; font-size: clamp(1.875rem, 1.2rem + 2.1vw, 2.75rem); line-height: 1.1; letter-spacing: -.025em; text-wrap: balance; }
.pf-area-head > p:not(.pf-kicker) { color: var(--muted); font-size: 1.0625rem; }
.pf-kicker { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .875rem; font-weight: 700; letter-spacing: .01em; }
.pf-kicker .pf-n { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--sel); color: var(--strong); }

/* the chart card */
.pf-chart { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); overflow: clip; }
.pf-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  color: var(--ink); font-size: .8125rem; font-weight: 650;
}
.pf-legend li { display: inline-flex; align-items: center; gap: 8px; }
.pf-legend li span { color: var(--faint); font-weight: 600; }
.pf-legend i { width: 14px; height: 10px; border-radius: 0 3px 3px 0; background: var(--pf-v11); }
.pf-legend i.v27 { background: var(--pf-v27); }
.pf-legend .pf-legend-note { margin-left: auto; color: var(--faint); font-weight: 600; }

.pf-row {
  position: relative;
  display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 2.3fr) minmax(150px, .7fr);
  align-items: center; gap: 10px 32px;
  padding: 18px 24px;
  transition: background-color var(--t-fast) ease;
}
.pf-row + .pf-row { border-top: 1px solid var(--rule); }
.pf-row { scroll-margin-top: calc(var(--pf-nav) - var(--strip) + 12px); }
.pf-row:hover { background: var(--sel-soft); }
.pf-row:target { background: var(--sel); }
.pf-label { display: grid; gap: 3px; min-width: 0; }
.pf-label h3 { font-size: .9688rem; font-weight: 650; line-height: 1.35; letter-spacing: -.005em; }
.pf-label code { padding: 1px 5px; border-radius: 5px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); font-size: .85em; }
.pf-hint { color: var(--faint); font-size: .8125rem; font-weight: 500; }

/* paired bars: 12px, square at the baseline, 4px rounded data end, value at the tip */
.pf-bars { display: grid; gap: 7px; min-width: 0; }
.pf-bar { --c: var(--pf-v11); display: flex; align-items: center; gap: 10px; min-height: 18px; min-width: 0; }
.pf-bar.v27 { --c: var(--pf-v27); }
.pf-fill {
  flex: none; height: 12px;
  width: max(3px, calc((100% - 12.5rem) * var(--f)));
  border-radius: 0 4px 4px 0;
  /* a recorded range: solid to the low figure, a lighter run to the high one */
  background: linear-gradient(90deg, var(--c) var(--split), color-mix(in srgb, var(--c) 42%, transparent) var(--split));
  transform-origin: left center;
}
.pf-val { color: var(--muted); font-size: .875rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-bar.v27 .pf-val { color: var(--strong); }
.pf-fail {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 5px;
  border-radius: 6px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink); font-size: .75rem; font-weight: 700; white-space: nowrap;
}
.pf-fail svg { width: 12px; height: 12px; color: var(--pf-bad); }
.pf-fail.ok svg { color: var(--pf-good); }

/* did not finish: the bar runs out of the scale, hatched and fading, never a made-up length */
.pf-open .pf-fill {
  width: calc(100% - 12.5rem);
  background: repeating-linear-gradient(135deg, var(--c) 0 5px, color-mix(in srgb, var(--c) 35%, transparent) 5px 9px);
  -webkit-mask-image: linear-gradient(90deg, #000 70%, transparent);
  mask-image: linear-gradient(90deg, #000 70%, transparent);
}
/* share of the work done: the fill on a full-width track */
.pf-meter .pf-fill {
  width: calc(100% - 15rem);
  background: linear-gradient(90deg, var(--c) var(--split), var(--pf-track) var(--split));
  border-radius: 4px;
}
.pf-point .pf-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--panel); }
.pf-meter .pf-val { white-space: normal; max-width: 15rem; line-height: 1.3; font-size: .8125rem; }

/* rows with no figures to draw */
.pf-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; }
.pf-compare p { display: grid; gap: 2px; color: var(--muted); font-size: .9375rem; line-height: 1.4; }
.pf-compare p + p { color: var(--strong); font-weight: 650; }
.pf-who { color: var(--faint); font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.pf-state { display: inline-flex; align-items: center; gap: 6px; }
.pf-state svg { width: 16px; height: 16px; }
.pf-state.bad svg { color: var(--pf-bad); }
.pf-state.good svg { color: var(--pf-good); }

/* the change column */
.pf-change { display: grid; justify-items: end; gap: 6px; text-align: right; }
.pf-change strong { color: var(--strong); font-size: 1.125rem; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.pf-change.is-text strong { font-size: .9375rem; font-weight: 650; line-height: 1.4; }
.pf-change.is-none { color: var(--faint); }
.pf-badge {
  display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 8px;
  border-radius: 6px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--strong); font-size: .75rem; font-weight: 750; white-space: nowrap;
}
.pf-badge svg { width: 13px; height: 13px; }
.pf-badge.good svg { color: var(--pf-good); }
.pf-badge.worse svg { color: var(--pf-bad); }
.pf-badge.note { white-space: normal; text-align: right; }
.pf-row.is-regression { background: color-mix(in srgb, var(--pf-bad) 7%, transparent); }
.pf-row.is-regression:hover { background: color-mix(in srgb, var(--pf-bad) 10%, transparent); }

/* table view */
.pf-table { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.pf-table summary {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 16px;
  border-radius: calc(var(--r-md) - 1px);
  color: var(--strong); font-size: .875rem; font-weight: 700; cursor: pointer; list-style: none;
}
.pf-table summary::-webkit-details-marker { display: none; }
.pf-table summary svg { width: 16px; height: 16px; color: var(--muted); }
.pf-table summary::after {
  content: ""; width: 8px; height: 8px; margin-left: auto; margin-right: 4px;
  border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint);
  transform: translateY(-2px) rotate(45deg); transition: transform var(--t-med) var(--ease);
}
.pf-table[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.pf-table summary:hover { background: var(--hover); }
.pf-table summary:focus-visible { outline-offset: -2px; }
.pf-table-scroll { overflow-x: auto; border-top: 1px solid var(--line); }
.pf-table table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.pf-table caption { padding: 12px 16px 4px; color: var(--faint); font-size: .8125rem; text-align: left; }
.pf-table :is(th, td) { padding: 10px 16px; border-top: 1px solid var(--rule); text-align: left; vertical-align: top; }
.pf-table thead th { border-top: 0; color: var(--faint); font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.pf-table tbody th { color: var(--strong); font-weight: 600; }
.pf-table td { color: var(--ink); font-variant-numeric: tabular-nums; }
.pf-table tr.is-regression { background: color-mix(in srgb, var(--pf-bad) 7%, transparent); }

/* how we tested */
.pf-method { padding-bottom: clamp(48px, 6vw, 80px); }
.pf-method-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 24px 48px;
  padding: clamp(28px, 4vw, 48px);
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel);
}
.pf-method-card > div:first-child { display: grid; gap: 14px; }
.pf-method-card h2 { font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem); line-height: 1.1; letter-spacing: -.025em; }
.pf-method-card p:not(.pf-kicker) { max-width: 68ch; color: var(--muted); }
.pf-method-card .actions { margin-top: 0; }

/* ------------------------------------------------------------------ narrower screens */
@media (max-width: 1100px) {
  .pf-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-row { grid-template-columns: minmax(160px, 1fr) minmax(0, 2fr); }
  .pf-change { grid-column: 2; justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; align-items: center; gap: 10px; }
  .pf-badge.note { text-align: left; }
}
@media (max-width: 760px) {
  .page-performance { --pf-gut: 16px; --pf-nav: 48px; --pf-pad: 40px; }
  .pf-kpis { gap: 10px; }
  .pf-kpi > a { padding: 12px 12px 11px; }
  .pf-kpi > a::after { left: 12px; right: 12px; }
  .pf-kpi-top { flex-wrap: wrap; column-gap: 6px; }
  .pf-kpi-n { font-size: 2.5rem; }
  .pf-kpi-pre { font-size: 1.125rem; }
  .pf-kpi-x { font-size: 1.25rem; }
  .pf-kpi-item { margin-top: 6px; font-size: .875rem; }
  .pf-kpi-ba { font-size: .75rem; }
  .pf-legend { padding: 12px 16px; }
  .pf-legend .pf-legend-note { margin-left: 0; width: 100%; }
  .pf-row { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 16px; }
  .pf-change { grid-column: 1; }
  .pf-fill { width: max(3px, calc((100% - 7.5rem) * var(--f))); }
  .pf-open .pf-fill { width: calc(100% - 9.5rem); }
  .pf-meter { flex-wrap: wrap; row-gap: 4px; }
  .pf-meter .pf-fill { width: 100%; }
  .pf-meter .pf-val { max-width: none; }
  .pf-bar:has(.pf-fail) { flex-wrap: wrap; row-gap: 4px; }
  .pf-compare { grid-template-columns: minmax(0, 1fr); }
  .pf-method-card { grid-template-columns: minmax(0, 1fr); align-items: start; }
}
