/* ==========================================================================
   CASE STUDIES — shared editorial primitives
   Loaded after style.css on /work/<slug>.html pages only. Reuses the
   :root tokens, .section-heading (letter-reveal), .tag, .capability-divider,
   .work-row-action and .experience-* grid idioms already defined there —
   this file does not redeclare tokens, only new structural classes.
   ========================================================================== */

.cs-page { background: var(--bg-page); }

.cs-main {
  max-width: min(1800px, 96vw);
  margin: 0 auto;
}

/* ── HERO ──────────────────────────────────────────────────────────────── */
.cs-hero {
  padding: 9rem 3rem 5rem;
  border-bottom: 1px solid var(--border);
}

.cs-hero-crumb {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 2.5rem;
  width: fit-content;
}
.cs-hero-crumb svg { stroke: currentColor; transition: transform 0.2s ease; }
.cs-hero-crumb:hover { color: var(--text-primary); }
.cs-hero-crumb:hover svg { transform: translateX(-2px); }

.cs-hero-eyebrow-row {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.cs-hero-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-faint);
}

.cs-hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cs-hero h1.section-heading {
  margin-bottom: 1.5rem;
  font-size: clamp(2.4rem, 6vw, 5.5rem);
}

.cs-hero-subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.05rem, 1.8vw, 1.4rem);
  color: var(--text-secondary);
  max-width: 46ch;
  line-height: 1.5;
  margin-bottom: 3rem;
}

.cs-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 2rem 2.5rem;
  padding-top: 2.25rem;
  border-top: 1px solid var(--border);
}

.cs-meta-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.cs-meta-value {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

/* ── SECTION — asymmetric editorial grid (mirrors .experience-section) ──── */
.cs-section {
  padding: 6.5rem 3rem;
  display: grid;
  grid-template-columns: 32fr 68fr;
  gap: 5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-page);
}

.cs-section--alt { background: var(--bg-alt); }

.cs-section-left {
  position: sticky;
  top: 8rem;
  align-self: start;
  display: flex;
  flex-direction: column;
}

.cs-section-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.4rem;
}

.cs-section-left h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.15;
}

.cs-section-left-rule {
  display: block;
  width: 2.5rem;
  height: 2px;
  background: var(--text-primary);
  margin: 1.4rem 0;
}

.cs-section-left-text {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 32ch;
}

.cs-section-index {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.cs-section-index-num { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.cs-section-index-rule { flex: 1; max-width: 4rem; height: 1px; background: var(--border); }

.cs-section-right { min-width: 0; }

.cs-section-right > * + * { margin-top: 1.5rem; }

.cs-body {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.75;
  max-width: 68ch;
}
.cs-body strong { color: var(--text-primary); font-weight: 600; }

.cs-subhead {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  color: var(--text-primary);
  margin-top: 2.25rem !important;
  margin-bottom: -0.5rem;
}

/* Compact mono fact list — relationships, room types, payment formula, etc. */
.cs-facts {
  border-top: 1px solid var(--border);
  max-width: 68ch;
}
.cs-fact {
  display: grid;
  grid-template-columns: minmax(120px, 30%) 1fr;
  gap: 1.5rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.cs-fact-term {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 0.15rem;
}
.cs-fact-desc {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Full-width breakout — used sparingly for large diagrams / hero media */
.cs-full {
  padding: 6.5rem 3rem;
  border-top: 1px solid var(--border);
  background: var(--bg-page);
}
.cs-full--alt { background: var(--bg-alt); }
.cs-full-head { max-width: 60ch; margin: 0 auto 3.5rem; text-align: center; }
.cs-full-head .cs-section-eyebrow { justify-content: center; }
.cs-full-head h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  color: var(--text-primary);
  margin-top: 0.75rem;
}

/* ── MEDIA — screenshots ─────────────────────────────────────────────── */
.cs-media {
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.cs-media img {
  display: block;
  width: 100%;
  height: auto;
}
.cs-media--framed img { object-fit: cover; }
.cs-caption {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-top: 0.9rem;
}

.cs-media-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.cs-media-pair.cs-media-pair--offset .cs-media:last-child { margin-top: 3rem; }

.cs-media-full { width: 100%; }
.cs-media-full .cs-media img { max-height: 78vh; object-fit: cover; object-position: top; }

/* Browser-chrome frame for full desktop screenshots used as large breaks */
.cs-browser {
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.cs-browser-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.cs-browser-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.cs-browser img { display: block; width: 100%; height: auto; }

/* ── TECH STACK ──────────────────────────────────────────────────────── */
.cs-tech-group { margin-bottom: 1.5rem; }
.cs-tech-group:last-child { margin-bottom: 0; }
.cs-tech-group-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}
.cs-tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── PROCESS FLOW — numbered step sequence (adapted from .experience-timeline) */
.cs-process {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.cs-process-step {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 1.75rem;
}
.cs-process-step:not(:last-child) { margin-bottom: 2rem; }
.cs-process-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.cs-process-marker-index {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #0284c7;
}
.cs-process-marker-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  background: var(--bg-page);
  flex-shrink: 0;
}
.cs-process-step:first-child .cs-process-marker-dot,
.cs-process-marker-dot--active {
  border-color: var(--text-primary);
  background: var(--text-primary);
}
.cs-process-step:not(:last-child) .cs-process-marker::after {
  content: '';
  position: absolute;
  top: 1.9rem;
  bottom: -2rem;
  left: 50%;
  width: 1px;
  background: var(--border);
}
.cs-process-body { padding-top: 0.05rem; }
.cs-process-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.cs-process-desc {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 56ch;
}
.cs-process-branch {
  margin-top: 0.6rem;
  padding-left: 1rem;
  border-left: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.cs-process-branch-item {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.cs-process-branch-item .or {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.65rem;
  color: var(--text-faint);
  margin-right: 0.5rem;
}

/* Horizontal variant for short linear pipelines (RAG, MeetMind pipeline) */
.cs-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
}
.cs-flow-step {
  flex: 1 1 0;
  min-width: 130px;
  padding: 1.6rem 1.4rem;
  border-right: 1px solid var(--border);
  position: relative;
}
.cs-flow-step:last-child { border-right: none; }
.cs-flow-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -1px;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-top: 1.5px solid var(--text-muted);
  border-right: 1.5px solid var(--text-muted);
  transform: translateY(-50%) rotate(45deg);
  background: var(--bg-page);
}
.cs-flow-index {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #0284c7;
  margin-bottom: 0.6rem;
  display: block;
}
.cs-flow-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.3;
}
.cs-flow-sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.5;
}

/* ── ARCHITECTURE DIAGRAM — boxes + connectors ──────────────────────── */
.cs-diagram {
  border: 1px solid var(--border);
  padding: 3rem 2.5rem;
  background: var(--surface);
}
.cs-diagram-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.cs-diagram-node {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 1.1rem 1.5rem;
  border: 1px solid var(--text-primary);
  background: var(--bg-page);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.3;
}
.cs-diagram-node--muted {
  border: 1px solid var(--border);
  font-weight: 400;
  color: var(--text-secondary);
}
.cs-diagram-node small {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cs-diagram-arrow {
  width: 1px;
  height: 2.25rem;
  background: var(--border);
  position: relative;
}
.cs-diagram-arrow::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: translateX(-50%) rotate(45deg);
}
.cs-diagram-branches {
  display: flex;
  justify-content: center;
  gap: 3rem;
  width: 100%;
  margin-top: 0;
  flex-wrap: wrap;
}
.cs-diagram-branch {
  flex: 1 1 200px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cs-diagram-branch-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0.75rem 0 0.5rem;
}

/* Concept diagram — 3-node horizontal chain (Karim Connect <-> Optical site) */
.cs-chain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.cs-chain-node {
  padding: 1rem 1.6rem;
  border: 1px solid var(--text-primary);
  background: var(--bg-page);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  text-align: center;
}
.cs-chain-node--muted { border-color: var(--border); font-weight: 400; color: var(--text-secondary); }
.cs-chain-arrow {
  width: 2.25rem;
  height: 1px;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
}
.cs-chain-arrow::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  border-top: 1.5px solid var(--text-muted);
  border-right: 1.5px solid var(--text-muted);
  transform: translateY(-50%) rotate(45deg);
}

/* ── CALLOUT / concept summary ───────────────────────────────────────── */
.cs-callout {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}
.cs-callout-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-heading);
  font-size: 0.92rem;
}
.cs-callout-row:last-child { border-bottom: none; }
.cs-callout-from { color: var(--text-muted); font-weight: 300; }
.cs-callout-arrow { font-family: var(--font-mono); color: var(--text-faint); flex-shrink: 0; }
.cs-callout-to { color: var(--text-primary); font-weight: 600; text-align: right; }

/* ── PAGER ───────────────────────────────────────────────────────────── */
.cs-pager {
  border-top: 1px solid var(--border);
  padding: 4.5rem 3rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 2rem;
}
.cs-pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-decoration: none;
  max-width: 32ch;
}
.cs-pager-link--next { align-items: flex-end; text-align: right; margin-left: auto; }
.cs-pager-dir {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cs-pager-link--next .cs-pager-dir { flex-direction: row-reverse; }
.cs-pager-dir svg { stroke: currentColor; transition: transform 0.2s ease; }
.cs-pager-link:hover .cs-pager-dir { color: var(--text-primary); }
.cs-pager-link:hover .cs-pager-dir svg { transform: translateX(-3px); }
.cs-pager-link--next:hover .cs-pager-dir svg { transform: translateX(3px); }
.cs-pager-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: var(--text-primary);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.cs-pager-link:hover .cs-pager-title { border-color: var(--text-primary); }
.cs-pager-back {
  justify-self: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.cs-pager-back:hover { color: var(--text-primary); border-color: var(--text-primary); }

/* ── SCROLL REVEAL — lightweight, IntersectionObserver-driven (app.js) ─── */
.cs-reveal {
  opacity: 0;
  transform: translateY(1.75rem);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-reveal.is-visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .cs-reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .cs-hero { padding: 8rem 2rem 3.5rem; }
  .cs-section,
  .cs-full { padding: 5rem 2rem; }
  .cs-section { grid-template-columns: 1fr; gap: 2.5rem; }
  .cs-section-left { position: static; }
  .cs-section-index { margin-top: 1.5rem; }
  .cs-media-pair { grid-template-columns: 1fr; }
  .cs-media-pair.cs-media-pair--offset .cs-media:last-child { margin-top: 0; }
  .cs-diagram-branches { gap: 2rem; }
  .cs-pager { padding: 3.5rem 2rem; }
}

@media (max-width: 767px) {
  .cs-hero { padding: 7rem 1.5rem 3rem; }
  .cs-hero-subtitle { max-width: none; }
  .cs-section,
  .cs-full { padding: 4rem 1.5rem; }
  .cs-full-head { text-align: left; margin-bottom: 2.5rem; }
  .cs-full-head .cs-section-eyebrow { justify-content: flex-start; }
  .cs-process-step { grid-template-columns: 2.25rem 1fr; gap: 1rem; }
  .cs-process-step:not(:last-child) .cs-process-marker::after { top: 1.7rem; bottom: -1.5rem; }
  .cs-flow { flex-direction: column; }
  .cs-flow-step { border-right: none; border-bottom: 1px solid var(--border); }
  .cs-flow-step:last-child { border-bottom: none; }
  .cs-flow-step:not(:last-child)::after {
    top: auto; bottom: -1px; right: 50%;
    transform: translateX(50%) rotate(135deg);
  }
  .cs-diagram { padding: 2rem 1.25rem; }
  .cs-diagram-branches { flex-direction: column; align-items: center; }
  .cs-chain { flex-direction: column; }
  .cs-chain-arrow { width: 1px; height: 1.75rem; }
  .cs-chain-arrow::after { right: 50%; top: auto; bottom: 0; transform: translateX(50%) rotate(135deg); }
  .cs-callout-row { flex-direction: column; gap: 0.3rem; }
  .cs-callout-to { text-align: left; }
  .cs-pager { grid-template-columns: 1fr; text-align: left; padding: 3rem 1.5rem; }
  .cs-pager-link--next { align-items: flex-start; text-align: left; margin-left: 0; }
  .cs-pager-link--next .cs-pager-dir { flex-direction: row; }
  .cs-pager-back { justify-self: start; order: -1; margin-bottom: 0.5rem; }
}

@media (max-width: 480px) {
  .cs-hero { padding: 6.5rem 1.2rem 2.5rem; }
  .cs-section,
  .cs-full { padding: 3.25rem 1.2rem; }
  .cs-meta-row { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
  .cs-fact { grid-template-columns: 1fr; gap: 0.4rem; }
  .cs-pager { padding: 2.5rem 1.2rem; }
}
