/* ==========================================================
   Case study pages (cms-benchmarks.html). Loads after styles.css.
   ========================================================== */

:root {
  /* Chart colors, validated for contrast and color-blind separation on --surface.
     --chart-up (green) and --chart-down (blue) are data colors, kept apart from the brand orange. */
  --chart-up: #79a227;
  --chart-down: #4f8fe8;
  --chart-na: #4a4d55;
  --chart-grid: rgba(255, 255, 255, 0.07);
}

/* ---------- Hero ---------- */
.case-hero { padding: clamp(130px, 16vw, 190px) 0 clamp(72px, 9vw, 110px); position: relative; }
.case-back { display: inline-block; margin-bottom: 28px; font: 500 13px/1 var(--font-mono); color: var(--muted); }
.case-back:hover { color: var(--text); }
.case-hero h1 { margin-top: 18px; font-size: clamp(44px, 7vw, 92px); letter-spacing: -0.04em; max-width: 14ch; }
.case-actions { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }
.case-lede { margin-top: 28px; max-width: 680px; font-size: clamp(18px, 2vw, 21px); color: var(--muted); }

.stats {
  margin-top: 64px; display: grid; gap: 1px; grid-template-columns: repeat(4, 1fr);
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.stat { background: var(--surface); padding: 26px 24px; display: flex; flex-direction: column; gap: 6px; }
.stat__value { font-size: clamp(30px, 3.4vw, 44px); letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat__label { color: var(--muted); font-size: 15px; line-height: 1.4; }
.stat__delta { margin-top: auto; padding-top: 8px; font: 400 12px/1.4 var(--font-mono); color: var(--faint); }

/* ---------- Sections ---------- */
.case-section h2 { max-width: 16ch; }
.case-two { display: grid; grid-template-columns: 1fr 1.25fr; gap: clamp(32px, 6vw, 96px); align-items: start; }
.case-prose { display: grid; gap: 20px; font-size: 18px; color: var(--muted); padding-top: 8px; }

.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; counter-reset: flow; }
.flow li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.flow__n { font: 500 12px/1 var(--font-mono); color: var(--accent); }
.flow h3 { margin-top: 14px; font-size: 22px; }
.flow p { margin-top: 10px; color: var(--muted); font-size: 15px; line-height: 1.55; }

.lessons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.lesson { padding: 28px; }
.lesson h3 { font-size: 21px; line-height: 1.2; }
.lesson p { margin-top: 12px; color: var(--muted); font-size: 15px; line-height: 1.6; }

/* ---------- Charts ---------- */
.chart {
  margin: 0 0 24px; padding: clamp(22px, 3vw, 36px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.chart figcaption h3 { font-size: clamp(22px, 2.4vw, 28px); line-height: 1.15; }
.chart figcaption p { margin-top: 10px; max-width: 760px; color: var(--muted); font-size: 15px; }
.legend { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw--up { background: var(--chart-up); }
.sw--down { background: var(--chart-down); }
.sw--na { background: var(--chart-na); }

.hbars { margin-top: 28px; display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(150px, 290px) 1fr 64px; gap: 16px; align-items: center; min-height: 34px; }
.hbar__label { font-size: 14px; color: var(--text); text-align: right; line-height: 1.3; }
.hbar__track { position: relative; height: 26px; }
/* zero / 1x reference line */
.hbars:not(.hbars--stack) .hbar__track::before {
  content: ""; position: absolute; top: -4px; bottom: -4px; left: var(--center); width: 1px; background: var(--line-strong);
}
.hbar__bar { position: absolute; top: 4px; height: 18px; border-radius: 0 4px 4px 0; cursor: default; outline-offset: 2px; transition: filter 0.2s; }
.hbar__bar--down { border-radius: 4px 0 0 4px; }
.hbar__bar--up { background: var(--chart-up); }
.hbar__bar--down { background: var(--chart-down); }
.hbar__bar:hover, .hbar__bar:focus-visible, .stack__seg:hover, .stack__seg:focus-visible { filter: brightness(1.18); }
.hbar__num { font: 500 12px/1 var(--font-mono); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar--axis { min-height: 22px; }
.axis { height: 18px; border-top: 1px solid var(--chart-grid); }
.axis::before { display: none; }
.axis span { position: absolute; top: 6px; transform: translateX(-50%); font: 400 11px/1 var(--font-mono); color: var(--faint); }

.hbar__track--stack { display: flex; align-items: center; }
.stack { display: flex; gap: 2px; height: 18px; }
.stack__seg { min-width: 2px; height: 100%; }
.stack__seg:last-child { border-radius: 0 4px 4px 0; }
.stack__seg--up { background: var(--chart-up); }
.stack__seg--down { background: var(--chart-down); }
.stack__seg--na { background: var(--chart-na); }

.chart__table { margin-top: 22px; font-size: 14px; }
.chart__table summary { cursor: pointer; color: var(--muted); font: 500 13px/1 var(--font-mono); width: max-content; }
.chart__table summary:hover { color: var(--text); }
.chart__table table { margin-top: 14px; width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.chart__table th, .chart__table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.chart__table th:first-child, .chart__table td:first-child { text-align: left; }
.chart__table th { font-weight: 500; color: var(--muted); font-size: 13px; }
.chart__table { overflow-x: auto; }
.chart__note { margin-top: 18px; font-size: 13px; color: var(--faint); }

.tip {
  position: fixed; z-index: 150; max-width: 300px; padding: 10px 12px; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.45; color: var(--text); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

/* ---------- Briefing quote ---------- */
.briefing { margin: 24px 0 0; padding: clamp(24px, 3vw, 40px); border-radius: var(--radius); border: 1px solid rgba(var(--accent-rgb), 0.22); background: linear-gradient(180deg, var(--accent-soft), transparent 70%); }
.briefing blockquote { margin: 18px 0 0; display: grid; gap: 14px; font-size: clamp(17px, 1.7vw, 19px); line-height: 1.65; color: var(--text); max-width: 900px; }
.briefing__note { margin-top: 20px; font-size: 13px; color: var(--faint); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .case-two { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .flow, .lessons { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 1fr 52px; gap: 4px 10px; }
  .hbar__label { grid-column: 1 / -1; text-align: left; }
  .hbar--axis .hbar__label { display: none; }
  .axis span:nth-child(even) { display: none; }   /* thin the ticks so labels don't collide */
  .chart { padding: 20px 16px; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
}
