/* ==========================================================================
   QED CASE STUDY — SHARED CHROME + SECTION PRIMITIVES
   --------------------------------------------------------------------------
   Approach B: shared frame, distinct souls.
   This file defines the universal structure (nav, hero pattern, sections,
   pullquotes, stats, gallery, footer, prev/next rail). Each case study
   sets its own --theme-* CSS variables (in case-study-themes.css) to
   express its subsidiary brand inside this frame.
   ========================================================================== */

:root {
  /* Defaults — overridden by per-case-study theme block */
  --theme-void:        #0A0A0E;
  --theme-base:        #0F0E14;
  --theme-surface:     #16141C;
  --theme-lift:        #1E1B26;
  --theme-rule:        #2A2535;
  --theme-rule-hi:     #3A3445;
  --theme-dim:         #4A4458;
  --theme-muted:       #7A7290;
  --theme-body:        #B0A8C2;
  --theme-light:       #D8D2E5;
  --theme-bright:      #F0EBF8;

  --theme-accent:      #C8A4F0;       /* QED lavender default */
  --theme-accent-pale: rgba(200,164,240,0.10);
  --theme-accent-dim:  rgba(200,164,240,0.22);
  --theme-accent-bright: #E0C8FF;
  --theme-secondary:   #C9A84C;       /* secondary accent default */

  --theme-font-display: 'Cormorant Garamond', Georgia, serif;
  --theme-font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --theme-font-mono:    'DM Mono', 'JetBrains Mono', monospace;

  --cs-max-w: 1200px;
  --cs-max-w-wide: 1320px;
  --cs-pad-x: clamp(24px, 5vw, 72px);
  --cs-pad-y: clamp(80px, 12vh, 160px);
  --cs-gutter: clamp(24px, 4vw, 60px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body.case-study {
  background: var(--theme-void);
  color: var(--theme-light);
  font-family: var(--theme-font-body);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

::selection {
  background: var(--theme-accent-dim);
  color: var(--theme-bright);
}

/* ==========================================================================
   NAV STRIP — universal across all case studies
   ========================================================================== */

.cs-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px var(--cs-pad-x);
  background: color-mix(in srgb, var(--theme-void) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--theme-rule);
}

.cs-nav-back {
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  transition: color 220ms ease;
  justify-self: start;
}
.cs-nav-back:hover { color: var(--theme-accent); }
.cs-nav-back::before { content: "←"; font-size: 1.1em; }

.cs-nav-breadcrumb {
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-muted);
  justify-self: center;
}
.cs-nav-breadcrumb .sep { opacity: 0.55; margin: 0 0.6em; }
.cs-nav-breadcrumb .here { color: var(--theme-light); }

.cs-nav-mark {
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-muted);
  text-decoration: none;
  justify-self: end;
  transition: color 220ms ease;
}
.cs-nav-mark:hover { color: var(--theme-accent); }
.cs-nav-mark span { color: var(--theme-accent); }

@media (max-width: 720px) {
  .cs-nav { grid-template-columns: 1fr 1fr; }
  .cs-nav-breadcrumb { display: none; }
}

/* ==========================================================================
   LAYOUT WRAPPERS
   ========================================================================== */

.cs-section {
  position: relative;
  padding: var(--cs-pad-y) var(--cs-pad-x);
}

.cs-section--tight { padding: clamp(60px, 8vh, 100px) var(--cs-pad-x); }
.cs-section--surface { background: var(--theme-base); }
.cs-section--surface-2 { background: var(--theme-surface); }
.cs-section--lift { background: var(--theme-lift); }

.cs-container {
  max-width: var(--cs-max-w);
  margin: 0 auto;
}
.cs-container--wide { max-width: var(--cs-max-w-wide); }

/* ==========================================================================
   HERO — universal structure
   ========================================================================== */

.cs-hero {
  position: relative;
  min-height: 100vh;
  padding: clamp(120px, 18vh, 180px) var(--cs-pad-x) clamp(80px, 12vh, 140px);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.cs-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* Theme can override with gradient/pattern. Default is subtle. */
  background:
    radial-gradient(ellipse 80% 60% at 50% 30%, var(--theme-accent-pale), transparent 70%),
    var(--theme-void);
}

.cs-hero-content {
  position: relative;
  z-index: 1;
  max-width: var(--cs-max-w);
  margin: 0 auto;
  width: 100%;
}

.cs-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 1em;
  margin-bottom: 2.5em;
}

.cs-hero-eyebrow .cs-tag-num {
  display: inline-block;
  padding: 0.5em 1.2em;
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--theme-accent);
  border: 1px solid var(--theme-accent-dim);
  background: var(--theme-accent-pale);
}
.cs-hero-eyebrow .cs-tag-cat {
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-muted);
}

.cs-hero-subsidiary {
  font-family: var(--theme-font-mono);
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--theme-secondary);
  margin-bottom: 1.5em;
}

.cs-hero-title {
  font-family: var(--theme-font-display);
  font-size: clamp(2.6rem, 6.4vw, 5.6rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.01em;
  color: var(--theme-bright);
  margin-bottom: 0.8em;
  max-width: 18ch;
}
.cs-hero-title em { font-style: italic; color: var(--theme-secondary); font-weight: 400; }

.cs-hero-subtitle {
  font-family: var(--theme-font-display);
  font-style: italic;
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  font-weight: 300;
  line-height: 1.4;
  color: var(--theme-light);
  margin-bottom: 2.5em;
  max-width: 36ch;
}

.cs-hero-intro {
  max-width: 56ch;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--theme-body);
}

/* ==========================================================================
   STATS STRIP — used in hero or as standalone section
   ========================================================================== */

.cs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0;
  border-top: 1px solid var(--theme-rule);
  border-bottom: 1px solid var(--theme-rule);
}

.cs-stat {
  padding: 2.4rem var(--cs-gutter);
  border-right: 1px solid var(--theme-rule);
}
.cs-stat:last-child { border-right: none; }

.cs-stat-val {
  font-family: var(--theme-font-display);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 600;
  line-height: 1;
  color: var(--theme-bright);
  margin-bottom: 0.4em;
}
.cs-stat-val em {
  font-style: italic;
  color: var(--theme-secondary);
  font-weight: 400;
}
.cs-stat-val .unit {
  font-family: var(--theme-font-body);
  font-size: 0.5em;
  font-weight: 300;
  color: var(--theme-muted);
  margin-left: 0.3em;
  letter-spacing: 0.05em;
}

.cs-stat-label {
  font-family: var(--theme-font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--theme-muted);
  line-height: 1.5;
}

/* ==========================================================================
   SECTION HEADERS
   ========================================================================== */

.cs-section-label {
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--theme-accent);
  display: inline-flex;
  align-items: center;
  gap: 1em;
  margin-bottom: 1.6em;
}
.cs-section-label::before {
  content: "";
  display: inline-block;
  width: 32px;
  height: 1px;
  background: var(--theme-accent);
}

.cs-section-title {
  font-family: var(--theme-font-display);
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--theme-bright);
  margin-bottom: 0.8em;
  max-width: 22ch;
}
.cs-section-title em { font-style: italic; color: var(--theme-secondary); }

.cs-section-deck {
  font-family: var(--theme-font-display);
  font-style: italic;
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  font-weight: 300;
  line-height: 1.5;
  color: var(--theme-light);
  margin-bottom: 2em;
  max-width: 40ch;
}

.cs-prose {
  max-width: 64ch;
  font-size: 1rem;
  line-height: 1.85;
  color: var(--theme-body);
}
.cs-prose > * + * { margin-top: 1.4em; }
.cs-prose strong { color: var(--theme-light); font-weight: 500; }
.cs-prose em { color: var(--theme-light); font-style: italic; }
.cs-prose a {
  color: var(--theme-accent);
  text-decoration: underline;
  text-decoration-color: var(--theme-accent-dim);
  text-underline-offset: 3px;
}
.cs-prose a:hover { text-decoration-color: var(--theme-accent); }
.cs-prose h3 {
  font-family: var(--theme-font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--theme-bright);
  margin-top: 2.2em;
  margin-bottom: 0.6em;
  letter-spacing: -0.005em;
}
.cs-prose ul, .cs-prose ol {
  padding-left: 1.4em;
  margin-top: 1em;
}
.cs-prose li { margin-bottom: 0.5em; padding-left: 0.4em; }
.cs-prose li::marker { color: var(--theme-accent); }

/* ==========================================================================
   PULL QUOTE
   ========================================================================== */

.cs-pullquote {
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 80px) 0;
  text-align: center;
  position: relative;
}
.cs-pullquote::before {
  content: """;
  display: block;
  font-family: var(--theme-font-display);
  font-size: 8rem;
  line-height: 0.5;
  color: var(--theme-accent);
  opacity: 0.35;
  margin-bottom: 0.2em;
}
.cs-pullquote-text {
  font-family: var(--theme-font-display);
  font-style: italic;
  font-size: clamp(1.5rem, 3.2vw, 2.4rem);
  font-weight: 400;
  line-height: 1.35;
  color: var(--theme-bright);
  letter-spacing: -0.005em;
  margin-bottom: 1.4em;
}
.cs-pullquote-attr {
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--theme-muted);
}
.cs-pullquote-attr::before { content: "— "; color: var(--theme-accent); }

/* ==========================================================================
   TWO-COLUMN BLOCK
   ========================================================================== */

.cs-twocol {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(40px, 6vw, 80px);
  align-items: start;
}
@media (max-width: 880px) {
  .cs-twocol { grid-template-columns: 1fr; }
}

.cs-twocol--narrow-left { grid-template-columns: 1fr 1.6fr; }
@media (max-width: 880px) { .cs-twocol--narrow-left { grid-template-columns: 1fr; } }

/* ==========================================================================
   FACT LIST (sidebar-style key/value pairs)
   ========================================================================== */

.cs-facts {
  border-top: 1px solid var(--theme-rule);
}
.cs-fact-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 2em;
  padding: 1.2em 0;
  border-bottom: 1px solid var(--theme-rule);
  align-items: baseline;
}
.cs-fact-key {
  font-family: var(--theme-font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--theme-muted);
  line-height: 1.5;
}
.cs-fact-val {
  font-size: 0.95rem;
  color: var(--theme-light);
  line-height: 1.6;
}
.cs-fact-val em { color: var(--theme-secondary); font-style: italic; }

/* ==========================================================================
   DETAIL CARD (bordered box with title + body)
   ========================================================================== */

.cs-card {
  border: 1px solid var(--theme-rule);
  background: var(--theme-surface);
  padding: clamp(24px, 3vw, 40px);
  position: relative;
  transition: border-color 240ms ease, transform 240ms ease;
}
.cs-card:hover {
  border-color: var(--theme-accent-dim);
  transform: translateY(-2px);
}

.cs-card-tag {
  font-family: var(--theme-font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--theme-accent);
  margin-bottom: 1em;
}
.cs-card-title {
  font-family: var(--theme-font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--theme-bright);
  line-height: 1.2;
  margin-bottom: 0.8em;
  letter-spacing: -0.005em;
}
.cs-card-body {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--theme-body);
}

.cs-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(16px, 2vw, 24px);
}

/* ==========================================================================
   CHIP / TAG LIST (used in hero + meta strips)
   ========================================================================== */

.cs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  margin-top: 2em;
}
.cs-chip {
  font-family: var(--theme-font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-muted);
  padding: 0.55em 1em;
  border: 1px solid var(--theme-rule);
  background: transparent;
  white-space: nowrap;
}

/* ==========================================================================
   GALLERY — flexible image grid
   ========================================================================== */

.cs-gallery {
  display: grid;
  gap: clamp(12px, 1.5vw, 20px);
}
.cs-gallery--2 { grid-template-columns: repeat(2, 1fr); }
.cs-gallery--3 { grid-template-columns: repeat(3, 1fr); }
.cs-gallery--asymm {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.cs-gallery--asymm > :first-child { grid-row: span 2; }

@media (max-width: 720px) {
  .cs-gallery--2,
  .cs-gallery--3,
  .cs-gallery--asymm {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .cs-gallery--asymm > :first-child { grid-row: auto; }
}

.cs-gallery-item {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--theme-rule);
  background: var(--theme-surface);
}
.cs-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 600ms ease;
}
.cs-gallery-item:hover img { transform: scale(1.03); }
.cs-gallery-item-caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1em 1.4em;
  background: linear-gradient(to top, var(--theme-void) 0%, transparent 100%);
  font-family: var(--theme-font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-light);
}

/* ==========================================================================
   CLOSING / NEXT-UP RAIL
   ========================================================================== */

.cs-closing {
  border-top: 1px solid var(--theme-rule);
  padding: clamp(80px, 10vh, 140px) var(--cs-pad-x);
  text-align: center;
  background: var(--theme-base);
}
.cs-closing-label {
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--theme-muted);
  margin-bottom: 1.2em;
}
.cs-closing-title {
  font-family: var(--theme-font-display);
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 500;
  line-height: 1.1;
  color: var(--theme-bright);
  margin-bottom: 1.6em;
  max-width: 22ch;
  margin-left: auto;
  margin-right: auto;
}

.cs-prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--theme-rule);
}
.cs-prevnext-cell {
  padding: clamp(28px, 4vw, 48px) var(--cs-pad-x);
  text-decoration: none;
  color: inherit;
  border-right: 1px solid var(--theme-rule);
  transition: background 240ms ease;
}
.cs-prevnext-cell:last-child { border-right: none; }
.cs-prevnext-cell:hover { background: var(--theme-surface); }
.cs-prevnext-dir {
  font-family: var(--theme-font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--theme-accent);
  margin-bottom: 0.8em;
}
.cs-prevnext-title {
  font-family: var(--theme-font-display);
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 500;
  color: var(--theme-light);
  line-height: 1.2;
}
.cs-prevnext-cell--next { text-align: right; }

@media (max-width: 720px) {
  .cs-prevnext { grid-template-columns: 1fr; }
  .cs-prevnext-cell { border-right: none; border-bottom: 1px solid var(--theme-rule); }
  .cs-prevnext-cell--next { text-align: left; }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.cs-footer {
  padding: 2.4rem var(--cs-pad-x);
  border-top: 1px solid var(--theme-rule);
  background: var(--theme-void);
  text-align: center;
}
.cs-footer p {
  font-family: var(--theme-font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-muted);
  line-height: 1.8;
}
.cs-footer p span { color: var(--theme-accent); }

/* ==========================================================================
   FADE-IN ON SCROLL (reuses simple IntersectionObserver pattern)
   ========================================================================== */

.cs-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 800ms ease, transform 800ms ease;
}
.cs-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .cs-reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
