/* Case Study demo styles
 *
 * Port of the `.cs-*` + `.ed-*` rules from the Klypup Colorful design
 * handoff bundle (forntend/design source · case-study.jsx + styles.css).
 *
 * Two color systems coexist on this page:
 *
 *   1. **Outer chrome** (toolbar, shell padding, right-rail panels)
 *      uses the app's `--co-*` theme tokens so it adapts to the user's
 *      brand (aurora / apple / cohere / lime / default) and mode
 *      (bright / dark).
 *   2. **The document itself** (the `.cs-doc` artboard — gradient
 *      band, headline, outcomes, sections, quote, footer) uses the
 *      designer's exact brand hexes — Klypup Purple #7F70FF, Green
 *      #6CE2A1, near-black #1F2128, etc. The document is a deliverable
 *      that the user exports as PDF / publishes verbatim; its colors
 *      are part of the artifact, not the app shell. If the user
 *      flips dark mode in the app, the document still renders in
 *      brand colors on its white paper — that's correct.
 *
 * Class-name convention:
 * - `.kp-case*` for the outer toolbar (sibling to `.kp-carousel`).
 * - `.cs-*` for everything inside the document + right rail. Matches
 *   the design source so any later swap to data-driven Jinja loops
 *   is a structural change, not a class rename.
 */

/* ── 0. Outer toolbar ─────────────────────────────────────── */

.kp-case {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.kp-case-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.kp-case-toolbar-meta { min-width: 0; }
.kp-case-toolbar-mono {
  font-family: var(--co-font-mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--co-slate, #64748b);
  font-weight: 500;
  margin: 0 0 8px;
}
.kp-case-toolbar-title {
  font-family: var(--co-font-display, var(--co-font-sans, system-ui));
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.6px;
  color: var(--co-ink, #0b0b0c);
  margin: 0;
}
.kp-case-toolbar-title .sep {
  font-style: italic;
  color: #8C84D8;
  margin: 0 4px;
}
.kp-case-toolbar-title .muted {
  color: var(--co-slate, #64748b);
  font-weight: 400;
}
.kp-case-toolbar-sub {
  font-size: 14px;
  color: var(--co-slate, #64748b);
  line-height: 1.5;
  max-width: 580px;
  margin: 8px 0 0;
}
.kp-case-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Pill family. The carousel editor ships an equivalent set scoped
   under `.kp-carousel` in carousel.css — we duplicate them here under
   `.kp-case` rather than loosening the carousel scope, so each page
   stays self-contained and a future template can adopt one set
   without dragging both. Three variants:
   - `.kp-pill-ghost-purple` — subtle purple tint, brand-purple ink
     (secondary action like "Tighten draft" that nods to AI-assist)
   - `.kp-pill-ghost-green`  — subtle green tint, deep-green ink
     (secondary action like "Export PDF" that nods to "done")
   - `.kp-pill-cherry`       — solid cherry gradient with white ink
     (primary CTA — "Publish")
*/
.kp-case .kp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  line-height: 1;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.kp-case .kp-pill svg { flex-shrink: 0; }
.kp-case .kp-pill-ghost-purple {
  background: rgba(127, 112, 255, 0.10);
  border-color: rgba(127, 112, 255, 0.32);
  color: #5A48E8;
}
.kp-case .kp-pill-ghost-purple:hover {
  background: rgba(127, 112, 255, 0.18);
}
.kp-case .kp-pill-ghost-green {
  background: rgba(108, 226, 161, 0.18);
  border-color: rgba(43, 184, 119, 0.34);
  color: #1F7A4F;
}
.kp-case .kp-pill-ghost-green:hover {
  background: rgba(108, 226, 161, 0.28);
}
.kp-case .kp-pill-cherry {
  background: linear-gradient(135deg, #D86072 0%, #A93A4D 100%);
  color: #fff;
  border-color: rgba(169, 58, 77, 0.45);
  box-shadow: 0 6px 16px -8px rgba(169, 58, 77, 0.45);
}
.kp-case .kp-pill-cherry:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -10px rgba(169, 58, 77, 0.55);
}

/* ── 1. Page shell — doc + right rail ─────────────────────── */

.cs-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .cs-shell { grid-template-columns: 1fr; }
}

/* Document wrapper — glass panel sits inside the page canvas */
.cs-doc-wrap {
  background: var(--co-surface-soft, rgba(255, 250, 243, 0.45));
  border: 1px solid var(--co-hairline, rgba(15, 23, 42, 0.10));
  border-radius: 24px;
  padding: 20px;
  backdrop-filter: blur(8px);
  min-width: 0;
}
/* The deliverable is composed of one or more A4 "pages" (.cs-page),
   following the explicit-page model in docs/adr/0002-pdf-pagination.md:
   `allocate_case_study_pages` decides which blocks live on which page and
   WeasyPrint only ever breaks BETWEEN pages. The editor preview and the
   PDF share this exact markup (_preview_case_study.html). `.cs-doc` is just
   the stacking container; each `.cs-page` is the white sheet. */
.cs-doc {
  font-family: 'Lato', system-ui, -apple-system, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.cs-page {
  position: relative;
  display: flex;
  flex-direction: column;
  /* No page padding: each block carries its own horizontal padding, so
     the gradient band and the footer bleed to the paper edge. */
  padding: 0;
  background: #FFFFFF;
  color: #3E424D;
  overflow: hidden;
  /* Screen: an A4-proportioned white card, capped at the A4 width and
     centered, scaling down responsively on narrow viewports. The PDF
     overrides this to a fixed 210×297mm sheet (print-case-study.html). */
  width: 100%;
  max-width: 210mm;
  margin: 0 auto;
  border-radius: 18px;
  border: 1px solid rgba(62, 66, 77, 0.10);
  box-shadow:
    0 20px 50px -20px rgba(15, 23, 42, 0.30),
    0 4px 0 rgba(15, 23, 42, 0.04);
}

/* Flex-grow spacer rendered immediately before `.cs-foot`. Absorbs the
   remaining vertical space so the footer anchors to the bottom edge of its
   page — works whether the footer shares a page or sits alone (unlike
   `justify-content`, a no-op for a single item). Mirrors `.bc-spacer`. */
.cs-spacer {
  flex: 1 1 auto;
  min-height: 0;
}

/* ── 2. Brand header band ─────────────────────────────────── */

.cs-band {
  background: linear-gradient(120deg, #7F70FF 0%, #5A48E8 45%, #6CE2A1 100%);
  padding: 28px 36px 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
/* Mix-blend grain softens the gradient banding — same SVG noise the
   carousel slides use, kept inline so the doc renders without extra
   asset fetches. */
.cs-band::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
  opacity: 0.55;
  pointer-events: none;
}
.cs-band > * { position: relative; z-index: 1; }

.cs-band-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 11px;
  opacity: 0.92;
  margin-bottom: 24px;
}
.cs-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}
.cs-logo svg { flex-shrink: 0; }
/* The real brand SVG (963×340 ratio) contains the wordmark + the
   two-arrow purple/green accent. Set height-only so the aspect ratio
   holds; the white-variant file uses #FFF for the wordmark and keeps
   the purple/green accents saturated so it reads on both the
   gradient band and the dark footer. */
.cs-logo-img {
  height: 18px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.cs-logo-tail {
  font-family: 'Lato', system-ui;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 11px;
  text-transform: uppercase;
  opacity: 0.92;
}
.cs-kind {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.30);
  font-weight: 700;
}

.cs-customer {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 16px;
  align-items: center;
}
.cs-cust-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.30);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -1px;
  color: #fff;
  backdrop-filter: blur(4px);
}
.cs-cust-body { min-width: 0; }
.cs-cust-name {
  font-weight: 900;
  font-size: 30px;
  letter-spacing: -0.8px;
  line-height: 1.0;
}
.cs-cust-meta {
  font-size: 12.5px;
  opacity: 0.85;
  margin-top: 4px;
  font-weight: 400;
}
.cs-cust-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 280px;
}
.cs-pill {
  font-family: var(--co-font-mono, ui-monospace, monospace);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.30);
  white-space: nowrap;
}

/* ── 3. Headline + outcomes + sections + timeline + quote ─ */

.cs-headline {
  padding: 26px 36px 8px;
}
.cs-headline h1 {
  font-weight: 900;
  font-size: 32px;
  letter-spacing: -0.8px;
  line-height: 1.1;
  color: #1F2128;
  margin: 0;
  text-wrap: pretty;
}
.cs-headline .em {
  color: #7F70FF;
  font-style: italic;
}
.cs-headline p {
  font-size: 14.5px;
  color: #5C6070;
  margin: 10px 0 0;
  line-height: 1.5;
  max-width: 640px;
  font-weight: 400;
}

.cs-outcomes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 20px 36px 8px;
}
.cs-outcome {
  background: #F4F4F6;
  border: 1px solid rgba(62, 66, 77, 0.10);
  border-radius: 14px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.cs-outcome.brand-green {
  background: linear-gradient(135deg, #E5FAEF 0%, #B7F2D4 100%);
  border-color: rgba(43, 184, 119, 0.30);
}
.cs-outcome.brand-purple {
  background: linear-gradient(135deg, #ECE9FF 0%, #C9C2FF 100%);
  border-color: rgba(127, 112, 255, 0.30);
}
.cs-outcome.brand-dark {
  background: linear-gradient(135deg, #4E525E 0%, #3E424D 60%, #1F2128 100%);
  color: #fff;
  border-color: rgba(62, 66, 77, 0.45);
}
.cs-outcome::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.0' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
  opacity: 0.5;
  pointer-events: none;
}
.cs-outcome > * { position: relative; z-index: 1; }
.cs-outcome .lbl {
  font-family: var(--co-font-mono, ui-monospace, monospace);
  font-size: 9.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.72;
  margin-bottom: 8px;
}
.cs-outcome .num {
  font-weight: 900;
  font-size: 40px;
  line-height: 0.95;
  letter-spacing: -1.5px;
  color: #1F2128;
  font-feature-settings: 'tnum';
}
.cs-outcome.brand-dark .num { color: #6CE2A1; }
.cs-outcome.brand-green .num { color: #2BB877; }
.cs-outcome.brand-purple .num { color: #5A48E8; }
.cs-outcome .num sup {
  font-size: 22px;
  vertical-align: super;
  font-weight: 900;
}
.cs-outcome .foot {
  font-size: 11.5px;
  margin-top: 6px;
  opacity: 0.78;
  line-height: 1.35;
  font-weight: 400;
}

.cs-section { padding: 18px 36px; }
.cs-section-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--co-font-mono, ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  font-weight: 700;
  color: #5A48E8;
  margin-bottom: 8px;
}
.cs-section-tag .step {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #7F70FF;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
}
.cs-section.s-solution .cs-section-tag { color: #2BB877; }
.cs-section.s-solution .cs-section-tag .step {
  background: #6CE2A1;
  color: #1F2128;
}
.cs-section.s-results .cs-section-tag { color: #1F2128; }
.cs-section.s-results .cs-section-tag .step {
  background: #3E424D;
  color: #6CE2A1;
}
.cs-section h2 {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.5px;
  margin: 0 0 8px;
  color: #1F2128;
  text-wrap: pretty;
}
.cs-section p {
  font-weight: 400;
  font-size: 13.5px;
  line-height: 1.55;
  color: #3E424D;
  margin: 0 0 10px;
}
.cs-data {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(127, 112, 255, 0.14);
  color: #5A48E8;
  font-weight: 700;
  font-feature-settings: 'tnum';
}
.cs-section.s-solution .cs-data {
  background: rgba(108, 226, 161, 0.18);
  color: #1F7A4F;
}

.cs-timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.cs-tl-step {
  background: #F4F4F6;
  border: 1px solid rgba(62, 66, 77, 0.10);
  border-radius: 10px;
  padding: 10px 12px;
  position: relative;
}
.cs-tl-step .when {
  font-family: var(--co-font-mono, ui-monospace, monospace);
  font-size: 9.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #5A48E8;
  font-weight: 700;
  margin-bottom: 4px;
}
.cs-tl-step .what {
  font-weight: 700;
  font-size: 12.5px;
  color: #1F2128;
  line-height: 1.25;
}
.cs-tl-step.done {
  background: linear-gradient(135deg, #E5FAEF, #B7F2D4);
  border-color: rgba(43, 184, 119, 0.30);
}
.cs-tl-step.done .when { color: #1F7A4F; }
.cs-tl-step .dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #6CE2A1;
  box-shadow: 0 0 6px rgba(108, 226, 161, 0.7);
}

.cs-bullets {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
}
@media (max-width: 720px) {
  .cs-bullets { grid-template-columns: 1fr; }
  .cs-outcomes { grid-template-columns: 1fr; }
  .cs-timeline { grid-template-columns: repeat(2, 1fr); }
}
.cs-bullets li {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: #3E424D;
  font-weight: 400;
}
.cs-bullets li strong { color: #1F2128; font-weight: 700; }
.cs-bullets .check {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #6CE2A1;
  color: #1F2128;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.cs-quote {
  margin: 6px 36px 24px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #ECE9FF 0%, #F4F4F6 100%);
  border-left: 4px solid #7F70FF;
  border-radius: 14px;
  position: relative;
}
.cs-quote .mark {
  position: absolute;
  top: 6px;
  right: 18px;
  font-weight: 900;
  font-size: 64px;
  color: rgba(127, 112, 255, 0.25);
  line-height: 1;
}
.cs-quote blockquote {
  margin: 0;
  padding: 0;
  font-weight: 700;
  font-style: italic;
  font-size: 18px;
  line-height: 1.4;
  color: #1F2128;
  letter-spacing: -0.3px;
}
.cs-quote .by {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.cs-quote .avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7F70FF, #6CE2A1);
}
.cs-quote .by-name {
  font-weight: 700;
  font-size: 13px;
  color: #1F2128;
}
.cs-quote .by-title {
  font-size: 11.5px;
  color: #5C6070;
}

.cs-foot {
  background: #1F2128;
  color: #CFCFCF;
  padding: 14px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--co-font-mono, ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  gap: 12px;
}
.cs-foot .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #6CE2A1;
  font-weight: 700;
}
.cs-foot-img {
  height: 14px;
  width: auto;
  display: block;
}
.cs-foot .url {
  opacity: 0.65;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 4. Right rail — Cohere assist + panels ──────────────── */

.cs-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.cs-panel {
  background: var(--co-surface-soft, rgba(255, 250, 243, 0.55));
  border: 1px solid var(--co-hairline, rgba(15, 23, 42, 0.10));
  border-radius: 18px;
  padding: 16px 18px;
  backdrop-filter: blur(8px);
}
.cs-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--co-font-mono, ui-monospace, monospace);
  font-size: 10.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--co-slate, #64748b);
  font-weight: 600;
  margin-bottom: 14px;
  gap: 12px;
}
.cs-panel-title .muted {
  color: var(--co-slate, #94a3b8);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 11px;
}
.cs-panel-title .dot.live {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #6CE2A1;
  box-shadow: 0 0 6px rgba(108, 226, 161, 0.7);
  flex-shrink: 0;
}

.cs-outcome-edit {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px dashed var(--co-hairline, rgba(15, 23, 42, 0.10));
  align-items: center;
}
.cs-outcome-edit:first-of-type { border-top: 0; padding-top: 0; }
.cs-outcome-edit .swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
}
.cs-outcome-edit .swatch.brand-green  { background: linear-gradient(135deg, #B7F2D4, #2BB877); }
.cs-outcome-edit .swatch.brand-purple { background: linear-gradient(135deg, #C9C2FF, #5A48E8); }
.cs-outcome-edit .swatch.brand-dark   { background: linear-gradient(135deg, #4E525E, #1F2128); }
.cs-outcome-edit .vals {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cs-outcome-edit .num-input {
  font-family: 'Lato', system-ui;
  font-weight: 900;
  font-size: 18px;
  color: var(--co-ink, #0b0b0c);
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0;
  letter-spacing: -0.5px;
  max-width: 100%;
}
.cs-outcome-edit .lbl-input {
  font: inherit;
  font-size: 11.5px;
  color: var(--co-slate, #64748b);
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0;
  max-width: 100%;
}
.cs-outcome-edit input:focus {
  background: rgba(127, 112, 255, 0.06);
  border-radius: 4px;
  outline: 1px solid rgba(127, 112, 255, 0.30);
  outline-offset: 2px;
}

/* Customer KV rows — read-only key/value pairs in the editor's
   right-rail Customer panel. Replaces the demo's `.cs-kv` (deleted
   along with the rest of the editor's visual-only chrome). */
.cs-kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--co-line, rgba(0, 0, 0, 0.06));
  font-size: 12px;
}
.cs-kv-row:last-child { border-bottom: none; }
.cs-kv-row .k { color: var(--co-slate, #64748b); }
.cs-kv-row .v { color: var(--co-ink, #0b0b0c); text-align: right; }
