/* ============================================================
   CASESTUDY.CSS — Case study detail page styles
   Depends on: main.css, layout.css, theme.css (custom properties)
   ============================================================ */

/* ── Section sub-navigation ─────────────────────────────────── */
.cs-subnav {
  position: sticky;
  top: 60px;
  z-index: 89;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: stretch;
  padding: 0.35rem 0.75rem;
  gap: 0;
}

.cs-subnav-track {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  gap: 0.25rem;
}
.cs-subnav-track::-webkit-scrollbar { display: none; }

.cs-subnav-item {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  position: relative;
  transition: color 0.18s ease, background 0.18s ease;
  flex-shrink: 0;
}

/* Gold bottom-border indicator */
.cs-subnav-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.cs-subnav-item:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.cs-subnav-item.is-active {
  color: var(--accent);
}
.cs-subnav-item.is-active::after {
  transform: scaleX(1);
}

/* ← Work back link — same style as .card-cta on landing page */
.cs-subnav-back {
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 6px;
  margin: auto 0.75rem auto 0;
  padding: 0.5rem 1.2rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base);
}
.cs-subnav-back:hover {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}
.cs-subnav-back::after { display: none; }

[data-theme="light"] .cs-subnav-back {
  border-color: rgba(0,0,0,0.22);
}

/* Divider between back link and tabs */
.cs-subnav-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}

/* Figma NDA — pushed to the right */
.cs-subnav-figma {
  margin-left: auto;
  border-right: none;
  border-left: 1px solid var(--border);
}
.cs-subnav-figma.is-active {
  color: var(--text-muted);
}
.cs-subnav-figma.is-active::after {
  transform: scaleX(0);
}

/* Light mode adjustment */
[data-theme="light"] .cs-subnav-item:hover {
  background: rgba(0,0,0,0.03);
}

/* ── Figma request modal ─────────────────────────────────────── */
.cs-figma-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.cs-figma-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.cs-figma-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 380px;
  width: 100%;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cs-figma-overlay.is-open .cs-figma-modal {
  transform: translateY(0) scale(1);
}

/* Figma header */
.cs-figma-modal-header {
  position: relative;
  padding: 2rem 2rem 1.75rem;
  background: #111113;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* X close — top-left, consistent with drawer */
.cs-figma-modal-x {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.32);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  z-index: 4;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cs-figma-modal-x:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.55);
}

/* Figma logo mark */
.cs-figma-modal-logo {
  display: block;
  width: 56px;
  height: auto;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
}

/* Body */
.cs-figma-modal-body {
  padding: 1.5rem 1.75rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.cs-figma-modal-icon {
  color: var(--accent);
  line-height: 1;
}

.cs-figma-modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.cs-figma-modal-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0;
}

/* Copy-email button */
.cs-figma-copy-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  margin-top: 0.25rem;
  transition: border-color 0.15s ease, background 0.15s ease;
  width: 100%;
}
.cs-figma-copy-btn:hover {
  border-color: var(--accent);
  background: rgba(201, 168, 76, 0.06);
}
.cs-figma-copy-btn.is-copied {
  border-color: var(--accent);
}

.cs-figma-copy-email {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.cs-figma-copy-icon {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s ease;
}
.cs-figma-copy-btn:hover .cs-figma-copy-icon,
.cs-figma-copy-btn.is-copied .cs-figma-copy-icon {
  color: var(--accent);
}

/* ── Back link ─────────────────────────────────────────────── */
.cs-back {
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-block;
  margin-bottom: 2rem;
  transition: opacity 0.2s ease;
}

.cs-back:hover {
  opacity: 0.7;
}

/* ── Hero section ───────────────────────────────────────────── */
.cs-hero {
  padding-top: 8rem;
  background: var(--bg-primary);
}

.cs-hero h1 {
  margin-top: 0.75rem;
  margin-bottom: 2rem;
}

/* ── Meta strip (Role / Year / Tags) ───────────────────────── */
.cs-meta {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.cs-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cs-meta-label {
  font-family: 'Courier New', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cs-meta-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Hero image placeholder ─────────────────────────────────── */
.cs-hero-image {
  margin-top: 0;
}

.cs-hero-image img {
  width: 100%;
  display: block;
  object-fit: cover;
  border-radius: 18px;
}

.cs-image-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  /* Replace with <img> when ready */
}

/* ── Generic content section ────────────────────────────────── */
.cs-section {
  padding: 80px 0;
}

/* ── Lead paragraph ─────────────────────────────────────────── */
.cs-lead {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
  max-width: none;
  margin-bottom: 5rem;
}

/* Word-by-word scroll highlight */
.cs-lead-word {
  display: inline-block;
  color: var(--text-muted);
  transition: color 0.18s ease;
}

.cs-lead-word.is-lit {
  color: var(--text-primary);
}

@media (prefers-reduced-motion: reduce) {
  .cs-lead-word {
    color: var(--text-primary);
    transition: none;
  }
}

/* ── Two-column layout (Challenge / Process) ────────────────── */
.cs-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
}

.cs-col h3 {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.cs-col p {
  font-size: 0.95rem;
  line-height: 1.75;
}

.cs-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.cs-list li {
  font-size: 0.95rem;
  line-height: 1.65;
  padding-left: 1.25rem;
  position: relative;
  color: var(--text-secondary);
}

.cs-list li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.8rem;
  top: 0.15em;
}

/* ── Images / Screens section ───────────────────────────────── */
.cs-images-section {
  background: var(--bg-secondary);
}

.cs-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

/* ── Outcome section — same grid as hero ────────────────────── */
.cs-outcome-section {
  position: relative;
  background-color: var(--bg-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70'%3E%3Cpath d='M 70 0 L 0 0 0 70' fill='none' stroke='%23a0c8e8' stroke-width='0.5' opacity='0.18'/%3E%3C/svg%3E");
  background-size: 70px 70px;
  background-repeat: repeat;
}

[data-theme="light"] .cs-outcome-section {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2020/svg' width='70' height='70'%3E%3Cpath d='M 70 0 L 0 0 0 70' fill='none' stroke='%231a3880' stroke-width='0.5' opacity='0.12'/%3E%3C/svg%3E");
}

.cs-outcome-section h2 {
  margin: 0.5rem 0 0;
}


.cs-outcome {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin: 2.5rem 0;
}

.cs-outcome-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.8rem;
}

.cs-outcome-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(2.2rem, 4.5vw, 3rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  line-height: 1;

  /* Tile appearance */
  background: linear-gradient(
    180deg,
    #2e2e2e 0%,
    #222 49%,
    #1c1c1c 51%,
    #131313 100%
  );
  border-radius: 6px;
  padding: 0.5em 0.7em;
  box-shadow:
    0 6px 24px rgba(0,0,0,0.75),
    0 2px 6px rgba(0,0,0,0.5);
  width: fit-content;
}

/* Centre split line — same as .tile::after */
.cs-outcome-number::after {
  content: '';
  position: absolute;
  top: calc(50% - 1px);
  left: 0;
  right: 0;
  height: 2px;
  background: #000;
  opacity: 0.6;
  z-index: 2;
  pointer-events: none;
}

.cs-outcome-label {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  line-height: 1.5;
}

.cs-outcome-note {
  max-width: 680px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ── Next project strip ─────────────────────────────────────── */
.cs-next {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.cs-next-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 4rem 2rem;
  text-align: center;
  transition: background 0.2s ease;
}

.cs-next-link:hover {
  background: var(--accent-dim);
}

.cs-next-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  transition: color 0.2s ease;
}

.cs-next-link:hover .cs-next-title {
  color: var(--accent);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cs-hero {
    padding-top: 6rem;
  }

  .cs-meta {
    gap: 1.5rem;
  }

  .cs-cols {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .cs-images {
    grid-template-columns: 1fr;
  }

  .cs-outcome {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .cs-section {
    padding: 60px 0;
  }
}

@media (max-width: 600px) {
  .cs-outcome {
    padding: 1.5rem;
  }

  .cs-images {
    gap: 1rem;
  }
}

/* ── Scroll reveal — base state ─────────────────────────────── */
.cs-reveal {
  opacity: 0;
  transform: translateY(36px);
  transition:
    opacity  0.65s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--delay, 0s);
  will-change: opacity, transform;
}

.cs-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Screens: slightly more pronounced lift */
#cs-screens .cs-reveal {
  transform: translateY(48px);
}

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

/* ── KPI counter — completion pulse ─────────────────────────── */
@keyframes cs-stat-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.1); }
  70%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.cs-outcome-number.is-done {
  animation: cs-stat-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block; /* scale needs block-level */
}

/* ── At a Glance ─────────────────────────────────────────────── */
.cs-glance {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
}

.cs-glance-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem 2rem;
}

.cs-glance-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}

.cs-glance-label {
  font-family: 'Courier New', monospace;
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

.cs-glance-text {
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .cs-glance { flex-direction: column; }
  .cs-glance-divider { width: 100%; height: 1px; }
}

/* ── Section Divider ─────────────────────────────────────────── */
.cs-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  pointer-events: none;
}

.cs-divider-track {
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(
    to right,
    var(--border) 0px,
    var(--border) 3px,
    transparent 3px,
    transparent 7px
  );
}

.cs-divider-label {
  font-family: 'Courier New', monospace;
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.5;
}

.cs-divider-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.6;
  flex-shrink: 0;
}

/* ── Pull Quote ──────────────────────────────────────────────── */
.cs-pullquote-section {
  padding: 3rem 0;
}

.cs-pullquote {
  margin: 0;
  padding: 0 0 0 2rem;
  border-left: 3px solid var(--accent);
}

.cs-pullquote p {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.cs-pullquote-author {
  margin-top: 1.25rem;
  font-family: 'Courier New', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ── Story — sticky split layout ────────────────────────────── */
.cs-story-section {
  padding-top: 8rem;
}

.cs-story-layout {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 3.5rem;
  align-items: start;
}

/* ── Scroll column ── */
.cs-story-scroll {
  display: flex;
  flex-direction: column;
}

.cs-story-stage {
  min-height: 55vh;
  padding: 2rem 0 3rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.9rem;
  opacity: 0.3;
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.cs-story-stage:first-child { padding-top: 0; }

/* Stage icon */
.cs-stage-icon {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  flex-shrink: 0;
  transition: color 0.35s ease;
}

.cs-stage-icon svg {
  width: 100%;
  height: 100%;
}

/* Active stage */
.cs-story-stage.is-active {
  opacity: 1;
}

.cs-story-stage.is-active .cs-stage-icon {
  color: var(--accent);
}

.cs-story-stage h3 {
  color: var(--text-secondary);
  margin: 0 0 0.4rem;
  transition: color 0.35s ease;
}

.cs-story-stage.is-active h3 {
  color: var(--text-primary);
}

.cs-story-sub-h3 {
  margin-top: 2rem !important;
}

.cs-story-stage p {
  font-size: 1.125rem;
  line-height: 1.75;
}

/* ── Sticky image panel ── */
.cs-story-sticky {
  position: sticky;
  top: 130px;
  align-self: start;
}

.cs-story-visual {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
}

.cs-story-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.94) translateY(24px);
  transition:
    opacity   0.7s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.cs-story-img.is-active {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Mobile-only inline image — hidden on desktop */
.cs-stage-img-mobile {
  display: none;
}

@media (max-width: 900px) {
  .cs-story-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Hide the sticky panel — images are inline per stage instead */
  .cs-story-sticky {
    display: none;
  }

  .cs-story-stage {
    min-height: auto;
    padding: 2.5rem 0;
    opacity: 1;
    border-bottom: 1px solid var(--border);
  }

  .cs-story-stage:last-child {
    border-bottom: none;
  }

  /* Show inline image above each stage */
  .cs-stage-img-mobile {
    display: block;
    width: 100%;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    object-fit: contain;
  }
}

/* ── Flow Gallery — scroll parallax ─────────────────────────── */
.cs-flow-section {
  overflow: hidden;
  padding-bottom: 5rem;
  background-color: var(--bg-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70'%3E%3Cpath d='M 70 0 L 0 0 0 70' fill='none' stroke='%23a0c8e8' stroke-width='0.5' opacity='0.18'/%3E%3C/svg%3E");
  background-size: 70px 70px;
  background-repeat: repeat;
}

[data-theme="light"] .cs-flow-section {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70'%3E%3Cpath d='M 70 0 L 0 0 0 70' fill='none' stroke='%231a3880' stroke-width='0.5' opacity='0.12'/%3E%3C/svg%3E");
}

.cs-flow-gallery {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 0 4rem;
  max-width: 1200px;
  margin: 0 auto;
  will-change: transform;
}

.cs-flow-card {
  flex: 0 0 auto;
  width: 36%;
  border-radius: 12px;
  overflow: visible;
  background: transparent;
  will-change: transform;
}

.cs-flow-card[data-flow="left"]   { transform: translateY(80px)  scale(0.78); }
.cs-flow-card[data-flow="center"] { transform: translateY(0px)   scale(1);    width: 42%; }
.cs-flow-card[data-flow="right"]  { transform: translateY(100px) scale(0.75); }

.cs-flow-card .cs-image-placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  border-radius: 12px;
}

.cs-flow-card img {
  width: 100%;
  display: block;
  object-fit: contain; /* preserve transparency — no cropping */
  background: transparent;
}

@media (max-width: 768px) {
  .cs-flow-gallery {
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
  }
  .cs-flow-card,
  .cs-flow-card[data-flow="center"] {
    width: 100%;
    transform: none !important;
  }
}
