/* page2: pairs
   "Failures and Successes, Side by Side" (#side-by-side). Everything is scoped to the section id, because the case
   studies section shares the osci-tab / osci-kicker / osci-badge / osci-takeaway classes.

   Layout   underline tab strip with numbered columns; a two-column pair header (title | task sheet); two equal run
            panels whose rows stay level (subgrid from osci-stories.css); analysis as a label | prose | takeaway row. */

body.p2 #side-by-side {
  --pr-pass: #2f8f5b;
  --pr-pass-ink: #1f6f45;
  --pr-fail: #c24141;
  --pr-fail-ink: #a12f2f;
  --pr-mid-ink: #7a4a06;
}

/* ---------- section heading: the template's centring rules outrank base.css, so pin it left here ---------- */
body.p2 #side-by-side .section-heading {
  display: block !important;
  margin: 0 0 56px !important;
  text-align: left !important;
}

body.p2 #side-by-side .section-heading > .column {
  width: 100% !important;
  max-width: 900px !important;
  margin: 0 !important;
  padding: 0 !important;
  text-align: left !important;
}

body.p2 #side-by-side .section-heading .title.is-2,
body.p2 #side-by-side .section-heading .section-deck {
  margin-left: 0 !important;
  margin-right: 0 !important;
  text-align: left !important;
}

body.p2 #side-by-side .section-heading .section-deck { max-width: 64ch; text-wrap: pretty; }

/* ---------- tab strip ---------- */
body.p2 #side-by-side .osci-tabs-block { margin: 0; }

body.p2 #side-by-side .osci-tab-list {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 48px;
  border-top: 1px solid var(--p2-line);
  border-bottom: 1px solid var(--p2-line);
  counter-reset: p2pair;
}

body.p2 #side-by-side .osci-tab {
  position: relative;
  gap: 8px;
  padding: 18px 20px 20px;
  border: 0;
  border-left: 1px solid var(--p2-line);
  border-radius: 0;
  background: transparent;
  color: var(--p2-muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}

body.p2 #side-by-side .osci-tab:first-child { padding-left: 0; border-left: 0; }

body.p2 #side-by-side .osci-tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  transition: background-color 0.15s ease;
}

body.p2 #side-by-side .osci-tab span {
  font: 500 12px/1.3 var(--p2-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--p2-ink-2);
}

body.p2 #side-by-side .osci-tab span::before {
  counter-increment: p2pair;
  content: counter(p2pair, decimal-leading-zero);
  margin-right: 10px;
  color: var(--p2-muted);
}

body.p2 #side-by-side .osci-tab strong {
  font: 500 14.5px/1.38 var(--p2-display);
  letter-spacing: -0.003em;
  color: var(--p2-muted);
  transition: color 0.15s ease;
}

body.p2 #side-by-side .osci-tab:hover strong { color: var(--p2-ink); }
body.p2 #side-by-side .osci-tab:hover::after { background: var(--p2-line-strong); }
body.p2 #side-by-side .osci-tab:focus-visible { outline: 2px solid var(--p2-accent); outline-offset: -2px; }

body.p2 #side-by-side .osci-tab.is-active { background: transparent; }
body.p2 #side-by-side .osci-tab.is-active::after { background: var(--p2-ink); }
body.p2 #side-by-side .osci-tab.is-active span { color: var(--p2-ink); }
body.p2 #side-by-side .osci-tab.is-active span::before { color: var(--p2-accent); }
body.p2 #side-by-side .osci-tab.is-active strong { font-weight: 600; color: var(--p2-ink); }

/* ---------- the active pair ---------- */
body.p2 #side-by-side .osci-pair {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.p2 #side-by-side .osci-pair-head {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: 56px;
  align-items: start;
  margin: 0 0 40px;
}

body.p2 #side-by-side .osci-kicker {
  grid-column: 1 / -1;
  margin: 0 0 18px;
  font: 400 12.5px/1.45 var(--p2-mono);
  letter-spacing: 0.02em;
  color: var(--p2-muted);
}

body.p2 #side-by-side .osci-pair-head h3 {
  margin: 0;
  font: 600 clamp(1.75rem, 2.4vw, 2.2rem)/1.1 var(--p2-display);
  font-stretch: 94%;
  letter-spacing: -0.022em;
  color: var(--p2-ink);
  text-wrap: balance;
}

body.p2 #side-by-side .osci-pair-task {
  margin: 0;
  padding: 18px 24px 20px;
  border: 1px solid var(--p2-line);
  border-radius: var(--p2-radius);
  background: var(--p2-surface-2);
  font: 400 1.05rem/1.6 var(--p2-serif);
  color: var(--p2-ink-2);
}

body.p2 #side-by-side .osci-pair-task > span:first-child {
  display: block;
  margin: 0 0 8px;
  font: 500 12px/1.3 var(--p2-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--p2-muted);
}

/* ---------- run panels ---------- */
body.p2 #side-by-side .osci-pair-runs { gap: 24px; margin: 0; }

body.p2 #side-by-side .osci-run {
  --pr-rule: var(--p2-line-strong);
  --pr-kind: var(--p2-ink-2);
  padding: 0 24px;
  border: 1px solid var(--p2-line);
  border-radius: var(--p2-radius);
  background: var(--p2-surface);
  box-shadow: inset 0 2px 0 var(--pr-rule);
}

body.p2 #side-by-side .osci-run.is-success { --pr-rule: var(--pr-pass); --pr-kind: var(--pr-pass-ink); border-top-color: var(--p2-line); }
body.p2 #side-by-side .osci-run.is-failure { --pr-rule: var(--pr-fail); --pr-kind: var(--pr-fail-ink); border-top-color: var(--p2-line); }

body.p2 #side-by-side .osci-run-kind {
  margin: 0 -24px 20px;
  padding: 15px 24px 13px;
  border-bottom: 1px solid var(--p2-line);
  font: 500 12px/1.3 var(--p2-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pr-kind);
}

body.p2 #side-by-side .osci-run-head h4 {
  margin: 0 0 12px;
  font: 600 1.3rem/1.2 var(--p2-display);
  letter-spacing: -0.012em;
}

body.p2 #side-by-side .osci-model-chip { gap: 9px; font-weight: 600; color: var(--p2-ink); }
body.p2 #side-by-side .osci-model-chip img { width: 18px; height: 18px; flex-basis: 18px; }

body.p2 #side-by-side .osci-run-badges { gap: 6px; margin: 0 0 12px; }

body.p2 #side-by-side .osci-badge {
  padding: 4px 8px 3px;
  border: 1px solid var(--p2-line-strong);
  border-radius: 2px;
  background: transparent;
  font: 500 12px/1.35 var(--p2-mono);
  letter-spacing: 0.04em;
  color: var(--p2-ink-2);
  font-variant-numeric: tabular-nums;
}

body.p2 #side-by-side .osci-badge.is-pass { color: var(--pr-pass-ink); border-color: rgba(47, 143, 91, 0.45); background: rgba(47, 143, 91, 0.06); }
body.p2 #side-by-side .osci-badge.is-fail { color: var(--pr-fail-ink); border-color: rgba(194, 65, 65, 0.42); background: rgba(194, 65, 65, 0.05); }
body.p2 #side-by-side .osci-badge.is-mid { color: var(--pr-mid-ink); border-color: rgba(122, 74, 6, 0.4); background: rgba(122, 74, 6, 0.05); }
body.p2 #side-by-side .osci-badge.is-score { color: var(--p2-ink); border-color: var(--p2-line-strong); background: var(--p2-surface-2); }

body.p2 #side-by-side .osci-run-meta {
  margin: 0 0 12px;
  font: 400 12.5px/1.5 var(--p2-mono);
  color: var(--p2-muted);
  font-variant-numeric: tabular-nums;
}

body.p2 #side-by-side .osci-run-meta abbr {
  text-decoration: underline dotted var(--p2-line-strong);
  text-underline-offset: 3px;
}

body.p2 #side-by-side .osci-run-result {
  margin: 0 0 20px;
  font: 400 15px/1.5 var(--p2-display);
  color: var(--p2-ink);
}

body.p2 #side-by-side .osci-run-note {
  margin: -8px 0 20px;
  padding-left: 12px;
  border-left: 1px solid var(--p2-line-strong);
  font: italic 400 14.5px/1.5 var(--p2-serif);
  color: var(--p2-muted);
}

/* ---------- step viewer ---------- */
body.p2 #side-by-side .osci-step img {
  border: 1px solid var(--p2-line);
  border-radius: 2px;
  background: var(--p2-night);
  transition: border-color 0.15s ease;
}

body.p2 #side-by-side .osci-figure-link:hover img { border-color: var(--p2-ink-2); }

body.p2 #side-by-side .osci-step figcaption {
  margin-top: 16px;
  font: 400 14.5px/1.55 var(--p2-display);
  color: var(--p2-ink-2);
}

body.p2 #side-by-side .osci-step-no {
  margin-bottom: 6px;
  font: 500 12px/1.4 var(--p2-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--p2-ink);
}

body.p2 #side-by-side .osci-step-no em { margin-left: 2px; font-weight: 400; letter-spacing: 0.04em; color: var(--p2-muted); }

body.p2 #side-by-side .osci-stepper-controls { gap: 12px; margin-top: 20px; }

body.p2 #side-by-side .osci-step-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--p2-line-strong);
  border-radius: 2px;
  background: var(--p2-surface);
  font: 500 13px/1 var(--p2-display);
  color: var(--p2-ink);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

body.p2 #side-by-side .osci-step-btn:hover:not(:disabled) { border-color: var(--p2-ink); background: var(--p2-surface-2); }
body.p2 #side-by-side .osci-step-btn:focus-visible { outline: 2px solid var(--p2-accent); outline-offset: 2px; }
body.p2 #side-by-side .osci-step-btn:disabled { opacity: 0.38; }

body.p2 #side-by-side .osci-step-count {
  font: 500 12.5px/1 var(--p2-mono);
  letter-spacing: 0.08em;
  color: var(--p2-ink-2);
}

body.p2 #side-by-side .osci-run-narration {
  margin: 20px -24px 0;
  padding: 14px 24px 16px;
  border-top: 1px solid var(--p2-line);
  border-radius: 0 0 3px 3px;
  background: var(--p2-surface-2);
  font: 400 13.5px/1.5 var(--p2-display);
  color: var(--p2-ink-2);
}

body.p2 #side-by-side .osci-run-narration span {
  display: block;
  margin: 0 0 4px;
  font: 500 12px/1.3 var(--p2-mono);
  letter-spacing: 0.14em;
  color: var(--p2-muted);
}

/* ---------- analysis and takeaway ---------- */
body.p2 #side-by-side .osci-pair-analysis {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 300px;
  column-gap: 48px;
  align-items: start;
  max-width: none;
  margin: 64px 0 0;
  padding-top: 32px;
  border-top: 1px solid var(--p2-line);
}

body.p2 #side-by-side .osci-pair-analysis h4 {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 1;
  margin: 7px 0 0;
  font: 500 12px/1.4 var(--p2-mono);
  letter-spacing: 0.14em;
  color: var(--p2-muted);
}

body.p2 #side-by-side .osci-pair-analysis h4::before {
  content: "";
  flex: none;
  width: 24px;
  height: 2px;
  background: currentColor;
  opacity: 0.8;
}

body.p2 #side-by-side .osci-pair-analysis > p {
  grid-column: 2;
  max-width: 68ch;
  margin: 0;
  font: 400 1.1rem/1.62 var(--p2-serif);
  color: var(--p2-ink-2);
  text-wrap: pretty;
}

/* the takeaway's ink rule sits on the row's hairline, like an index tab over the column */
body.p2 #side-by-side .osci-takeaway {
  grid-column: 3;
  margin: -33px 0 0;
  padding: 31px 0 0;
  border: 0;
  border-top: 2px solid var(--p2-ink);
  border-radius: 0;
  background: transparent;
}

body.p2 #side-by-side .osci-takeaway span {
  margin: 0 0 12px;
  font: 500 12px/1.3 var(--p2-mono);
  letter-spacing: 0.14em;
  color: var(--p2-accent);
}

body.p2 #side-by-side .osci-takeaway p {
  font: 600 1.05rem/1.5 var(--p2-display);
  letter-spacing: -0.004em;
  color: var(--p2-ink);
}

/* ---------- definitions footnote ---------- */
body.p2 #side-by-side .osci-pair-defs {
  max-width: none;
  margin: 56px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--p2-line);
  font: 400 13px/1.6 var(--p2-display);
  color: var(--p2-muted);
  text-align: left;
}

body.p2 #side-by-side .osci-pair-defs em {
  padding: 0;
  border: 0;
  background: transparent !important;
  font-family: var(--p2-serif);
  font-size: 1.08em;
  color: var(--p2-ink-2);
}

/* ---------- narrower desktops: the takeaway moves under the prose ---------- */
@media (max-width: 1100px) {
  body.p2 #side-by-side .osci-pair-analysis { grid-template-columns: 160px minmax(0, 1fr); column-gap: 40px; }
  body.p2 #side-by-side .osci-takeaway { grid-column: 2; max-width: 68ch; margin-top: 28px; padding-top: 16px; }
}
