/* ============================================================
   IQRAM AHMED PORTFOLIO — single.css
   Single case study page
   ============================================================ */

/* ----------------------------------------------------------
   SCROLL PROGRESS INDICATOR
   Fixed thin bar under the nav, fills left to right as the
   reader scrolls through the case study body. JS sets
   --progress (0 to 1) on scroll in main.js.
   Sits at z-index just below the nav so it reads as part of
   the chrome rather than part of the content.
---------------------------------------------------------- */
.cs-progress {
  position: fixed;
  top: var(--nav-height);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--site-max-width);
  height: 2px;
  background: transparent;
  z-index: calc(var(--z-nav) - 1);
  pointer-events: none;
}

.cs-progress__bar {
  height: 100%;
  width: calc(var(--progress, 0) * 100%);
  background: var(--color-accent);
  transition: width 80ms linear;
}

/* ----------------------------------------------------------
   CASE STUDY HEADER
---------------------------------------------------------- */
.cs-header {
  display: grid;
  grid-template-columns: var(--hero-side-width) 1fr var(--hero-side-width);
  border-bottom: var(--border-default);
}

.cs-header__side {
  border-right: var(--border-default);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
}

.cs-header__side--right {
  border-right: none;
  border-left: var(--border-default);
}

.cs-header__side-text {
  font-size: var(--text-xs);
  color: var(--color-text-ghost);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  writing-mode: vertical-rl;
}

.cs-header__main {
  padding: var(--space-7) var(--space-8) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.cs-header__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  text-decoration: none;
  letter-spacing: var(--tracking-wide);
  transition: color var(--transition-base);
  width: fit-content;
}

.cs-header__back:hover {
  color: var(--color-accent);
}

.cs-header__kicker {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.cs-header__category {
  font-size: var(--text-xs);
  color: var(--color-accent);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
}

.cs-header__year {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  letter-spacing: var(--tracking-wide);
}

.cs-header__h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 300;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
  max-width: 720px;
}

/* Hook — one line that opens the story */
.cs-header__hook {
  font-family: var(--font-display);
  font-size: clamp(1.0625rem, 2vw, 1.25rem);
  font-weight: 300;
  font-style: italic;
  line-height: 1.6;
  color: var(--color-text-primary);
  max-width: 640px;
  letter-spacing: var(--tracking-snug);
  border-left: 2px solid var(--color-accent-subtle);
  padding-left: var(--space-3);
}

/* ----------------------------------------------------------
   SNAPSHOT STRIP
---------------------------------------------------------- */
.cs-snapshot {
  display: flex;
  gap: 0;
  border-bottom: var(--border-default);
  overflow-x: auto;
  /* Scrollbar hidden but functional */
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
}

.cs-snapshot::-webkit-scrollbar {
  display: none;
}

/* Right-side fade — signals horizontal scroll on mobile.
   Visible only when content overflows. Clip via parent overflow. */
.cs-snapshot-wrap {
  position: relative;
  border-bottom: var(--border-default);
}

.cs-snapshot-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 48px;
  background: linear-gradient(
    to right,
    transparent 0%,
    var(--color-bg-primary) 100%
  );
  pointer-events: none;
  z-index: 2;
}

/* Remove fade when strip has scrolled all the way right */
.cs-snapshot-wrap.is-scrolled-end::after {
  display: none;
}

.cs-snapshot__item {
  padding: 20px var(--space-5);
  border-right: var(--border-default);
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.cs-snapshot__item:last-child {
  border-right: none;
}

.cs-snapshot__label {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

.cs-snapshot__value {
  font-size: var(--text-md);
  color: var(--color-text-primary);
  font-weight: 400;
}

/* ----------------------------------------------------------
   HERO IMAGE
---------------------------------------------------------- */
.cs-hero-image {
  border-bottom: var(--border-default);
  background: var(--color-bg-raised);
  overflow: hidden;
  max-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cs-hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cs-hero-image--placeholder {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cs-hero-image--placeholder span {
  font-size: var(--text-sm);
  color: var(--color-text-deep);
}

/* ----------------------------------------------------------
   CASE STUDY BODY
---------------------------------------------------------- */
.cs-body {
  display: grid;
  grid-template-columns: var(--hero-side-width) 1fr var(--hero-side-width);
}

.cs-body__side {
  border-right: var(--border-default);
}

.cs-body__side--right {
  border-right: none;
  border-left: var(--border-default);
}

.cs-body__content {
  padding: var(--space-8) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  max-width: 760px;

  /*
   * Images inside .cs-body__content use .cs-image--breakout to escape
   * rightward past the right side rail. The left rail gap is intentional —
   * it mirrors the editorial grid used across the whole site.
   * overflow: visible lets breakout images extend beyond this column.
   */
  overflow: visible;
}

/* Section within the body */
.cs-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cs-section__label {
  font-size: var(--text-sm);
  color: var(--color-accent);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  padding-bottom: var(--space-2);
  border-bottom: var(--border-subtle);
}

.cs-section__text {
  font-size: 1rem;
  line-height: var(--leading-loose);
  color: var(--color-text-secondary);
}

/* Key decisions — each one separated */
.cs-decisions {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.cs-decision {
  padding: var(--space-4);
  background: var(--color-bg-secondary);
  border: var(--border-default);
  border-radius: var(--radius-lg);
  border-left: 2px solid var(--color-accent-subtle);
  /* Border pulses to full accent when card enters viewport.
     JS adds .decision-entered via IntersectionObserver in main.js */
  transition: border-left-color 600ms ease;
}

/* On entry — flash to full accent then settle back to subtle */
.cs-decision.decision-entered {
  animation: decision-pulse 900ms ease forwards;
}

@keyframes decision-pulse {
  0%   { border-left-color: var(--color-accent-subtle); }
  25%  { border-left-color: var(--color-accent); }
  100% { border-left-color: var(--color-accent-subtle); }
}

.cs-decision__text {
  font-size: var(--text-base);
  line-height: var(--leading-loose);
  color: var(--color-text-secondary);
}

/* Outcome highlight */
.cs-outcome-highlight {
  display: flex;
  align-items: flex-start;
  gap: var(--space-5);
  padding: var(--space-5);
  background: var(--color-bg-secondary);
  border: var(--border-default);
  border-radius: var(--radius-lg);
}

.cs-outcome-highlight__num {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 200;
  color: var(--color-accent);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  flex-shrink: 0;
}

.cs-outcome-highlight__text {
  font-size: var(--text-base);
  line-height: var(--leading-loose);
  color: var(--color-text-tertiary);
  padding-top: 6px;
}

/* Retrospective */
.cs-retrospective {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 300;
  font-style: italic;
  line-height: 1.65;
  color: var(--color-text-secondary);
  border-left: 2px solid var(--color-accent-subtle);
  padding-left: var(--space-3);
  letter-spacing: var(--tracking-snug);
}

/* ----------------------------------------------------------
   IN-BODY IMAGES
   Two variants:
   1. .cs-image            — normal width, fits within the content column
   2. .cs-image--breakout  — breaks out rightward past the right rail
                             Left gap is kept intentionally (editorial grid)
---------------------------------------------------------- */

/* Base image block */
.cs-image {
  width: 100%;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: var(--border-default);
  background: var(--color-bg-raised);
}

.cs-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* ----------------------------------------------------------
   IMAGE REVEAL WIPE
   Replaces the plain fade-up for images specifically.
   A left-to-right clip-path wipe feels more crafted than
   opacity alone — like the image is being uncovered rather
   than just appearing. JS adds .is-revealed via the same
   IntersectionObserver used for .fade-up (see main.js).
   Falls back gracefully — if JS never adds the class,
   the image is still fully visible (clip-path starts open
   only on the .cs-section-images.fade-up parent state).
---------------------------------------------------------- */
.cs-section-images .cs-image,
.cs-section-images .cs-image-group .cs-image {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 550ms cubic-bezier(0.65, 0, 0.35, 1);
}

.cs-section-images.is-visible .cs-image,
.cs-section-images.is-visible .cs-image-group .cs-image {
  clip-path: inset(0 0 0 0);
}

/* Stagger multi-image groups slightly so they don't reveal
   in perfect unison — each image trails the previous by 90ms */
.cs-image-group .cs-image:nth-child(1) { transition-delay: 0ms; }
.cs-image-group .cs-image:nth-child(2) { transition-delay: 90ms; }
.cs-image-group .cs-image:nth-child(3) { transition-delay: 180ms; }

/*
 * Breakout variant — image extends rightward past the right side rail.
 * Width: content column + right rail (var(--hero-side-width)) + content padding.
 * This keeps the left editorial rail gap intact while using all available
 * horizontal space on the right.

 *
 * The calc() works because .cs-body__content has a known right padding
 * of var(--space-8). We extend by that padding + the right rail width.
 */
.cs-image--breakout {
  width: calc(100% + var(--space-8) + var(--hero-side-width));
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  /* Right corners are square against the viewport edge */
}

/* Multi-image group — side by side when 2+ images in one section */
.cs-image-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  width: 100%;
}

.cs-image-group--breakout {
  width: calc(100% + var(--space-8) + var(--hero-side-width));
  grid-template-columns: 1fr 1fr;
}

.cs-image-group .cs-image,
.cs-image-group--breakout .cs-image {
  width: 100%;
  border-radius: var(--radius-lg);
  margin: 0;
}

/* Stacked group — single column, good for portrait/tall images */
.cs-image-group--stack {
  grid-template-columns: 1fr;
}

/* Caption — sits below image or image group */
.cs-image-caption {
  font-size: var(--text-xs);
  color: var(--color-text-deep);
  letter-spacing: var(--tracking-wide);
  margin-top: var(--space-2);
  padding-left: 2px;
  line-height: 1.6;
}

/* ----------------------------------------------------------
   SECTION IMAGE WRAPPER
   Wraps an image (or group) that belongs directly to a section.
   Adds consistent top spacing between section text and its image(s).
---------------------------------------------------------- */
.cs-section-images {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

/* ----------------------------------------------------------
   NEXT / PREV NAVIGATION
---------------------------------------------------------- */
.cs-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: var(--border-default);
  border-bottom: var(--border-default);
}

.cs-nav__item {
  padding: var(--space-5) var(--space-6);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cs-nav__item--next {
  border-left: var(--border-default);
  text-align: right;
}

.cs-nav__item:hover {
  background: var(--color-bg-secondary);
}

.cs-nav__dir {
  font-size: var(--text-xs);
  color: var(--color-text-ghost);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

.cs-nav__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-snug);
  line-height: 1.3;
  transition: color var(--transition-fast);
}

.cs-nav__item:hover .cs-nav__title {
  color: var(--color-accent);
}

/* ----------------------------------------------------------
   RESPONSIVE
---------------------------------------------------------- */
@media (max-width: 768px) {
  .cs-header {
    grid-template-columns: 1fr;
  }

  .cs-header__side {
    display: none;
  }

  .cs-header__main {
    padding: var(--space-5) var(--space-3);
  }

  .cs-snapshot {
    padding: 0 var(--space-3);
  }

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

  .cs-body__side {
    display: none;
  }

  .cs-body__content {
    padding: var(--space-5) var(--space-3);
    gap: var(--space-4);
  }

  /* On mobile the rails are gone — breakout resets to full width */
  .cs-image--breakout,
  .cs-image-group--breakout {
    width: 100%;
    border-radius: var(--radius-lg);
  }

  .cs-image-group,
  .cs-image-group--breakout {
    grid-template-columns: 1fr;
  }

  .cs-outcome-highlight {
    flex-direction: column;
    gap: var(--space-3);
  }

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

  .cs-nav__item--next {
    border-left: none;
    border-top: var(--border-default);
    text-align: left;
  }
}