/* =========================================================
   REÂM — Case Study Detail Pages (Fixed Masonry Layout)
   ========================================================= */

:root {
  --cs-gap: 24px;
  --cs-r: 16px;
}

/* ---------- HERO ---------- */
.cs-hero {
  padding: 48px 0;
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--color-orange) 10%, transparent),
    transparent
  );
}
.cs-hero .wrap {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--cs-gap);
  align-items: center;
  max-width: min(1200px, 94vw);
  margin: 0 auto;
}
.cs-hero__media {
  border-radius: var(--cs-r);
  overflow: hidden;
  box-shadow: 0 20px 40px color-mix(in oklab, var(--color-black) 15%, transparent);
}

[data-theme="light"] .cs-hero__media {
  box-shadow: 0 20px 40px color-mix(in oklab, var(--color-text-light) 8%, transparent);
}

.cs-hero__media img,
.cs-hero__media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cs-hero__text .eyebrow {
  font-size: .9rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .9;
  color: var(--color-ink-dim);
}

[data-theme="light"] .cs-hero__text .eyebrow {
  color: var(--color-text-light-dim);
}

.cs-hero__text .title {
  font-size: clamp(32px, 5vw, 48px);
  margin: .5em 0;
  color: var(--color-orange);
  line-height: 1.2;
}
.cs-hero__text .lead { 
  opacity: .9; 
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--color-ink);
}

[data-theme="light"] .cs-hero__text .lead {
  color: var(--color-text-light);
}

/* ---------- KPIs ---------- */
.kpis {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 24px 0;
}
.kpi {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--color-elev-1);
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid var(--color-elev-2);
  flex: 1;
  min-width: 140px;
}

[data-theme="light"] .kpi {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border-light);
}

.kpi strong { 
  font-size: 1.5rem; 
  color: var(--color-orange);
}
.meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
  color: var(--color-ink-dim);
}

[data-theme="light"] .meta {
  color: var(--color-text-light-dim);
}

.m-key { 
  font-weight: 600; 
  color: var(--color-white); 
}

[data-theme="light"] .m-key {
  color: var(--color-text-light);
}

/* ---------- BODY ---------- */
.cs-body { 
  padding: 48px 0 64px; 
  max-width: min(1200px, 94vw);
  margin: 0 auto;
  background: var(--color-black);
}

[data-theme="light"] .cs-body {
  background: var(--color-bg-light-2);
}

.cs-body .grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--cs-gap);
  align-items: start;
}

/* Main content area */
.cs-body .main {
  min-width: 0;
}

.pillar {
  background: var(--color-elev-1);
  border: 1px solid var(--color-elev-2);
  padding: 24px;
  border-radius: var(--cs-r);
  margin-bottom: var(--cs-gap);
}

[data-theme="light"] .pillar {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border-light);
}

.pillar h2 { 
  margin-top: 0; 
  color: var(--color-orange);
  margin-bottom: 16px;
}
.steps, .bullets { 
  margin: 0; 
  padding-left: 18px; 
  color: var(--color-ink);
}

[data-theme="light"] .steps,
[data-theme="light"] .bullets {
  color: var(--color-text-light);
}

/* ---------- GALLERY — CSS Grid Masonry with Tighter Gaps ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; /* Reduced from 24px to 16px */
  margin: 40px 0; /* Reduced from 60px */
  align-items: start;
}

.gallery .shot {
  overflow: hidden;
  background: var(--color-elev-1);
  border: 1px solid var(--color-elev-2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

[data-theme="light"] .gallery .shot {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border-light);
}

/* Let content determine height naturally */
.gallery .shot img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: calc(var(--cs-r) - 1px);
}

/* VIDEOS in grid - use fluid containers */
.gallery .shot .fluid-media {
  position: relative;
  width: 100%;
  background: var(--color-elev-2);
  border-radius: calc(var(--cs-r) - 1px);
  overflow: hidden;
  flex-shrink: 0;
}

[data-theme="light"] .gallery .shot .fluid-media {
  background: var(--color-bg-light-2);
}

/* Aspect ratio classes for videos */
.gallery .shot .fluid-media { aspect-ratio: 16/9; }
.gallery .shot .fluid-media.reel { aspect-ratio: 9/16; }
.gallery .shot .fluid-media.square { aspect-ratio: 1/1; }
.gallery .shot .fluid-media.portrait { aspect-ratio: 4/5; }
.gallery .shot .fluid-media.cinematic { aspect-ratio: 21/9; }

/* Video element styling */
.gallery .shot .fluid-media video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--color-elev-2);
}

[data-theme="light"] .gallery .shot .fluid-media video {
  background: var(--color-bg-light-2);
}

.gallery .shot figcaption {
  padding: 12px; /* Reduced from 16px */
  color: var(--color-ink-dim);
  font-size: .85rem; /* Slightly smaller */
  line-height: 1.4;
  background: color-mix(in oklab, var(--color-black) 6%, transparent);
  border-top: 1px solid var(--color-elev-2);
  flex-shrink: 0;
}

[data-theme="light"] .gallery .shot figcaption {
  color: var(--color-text-light-dim);
  background: color-mix(in oklab, var(--color-text-light) 3%, transparent);
  border-top: 1px solid var(--color-border-light);
}

/* Hover effects */
.gallery .shot:hover {
  transform: translateY(-2px); /* Reduced from -4px */
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25); /* Reduced shadow */
  border-color: var(--color-orange);
}

[data-theme="light"] .gallery .shot:hover {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* =========================================================
   INSTAGRAM STYLE GALLERY
   ========================================================= */

/* ---------- GALLERY — Exact Instagram Grid ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 40px 0;
  background: var(--color-black);
  border: none;
  border-radius: 0;
  overflow: hidden;
  width: 100%;
}

[data-theme="light"] .gallery {
  background: var(--color-bg-light-2);
}

.gallery .shot {
  position: relative;
  aspect-ratio: 1/1;
  background: var(--color-black);
  transition: all 0.3s ease;
  overflow: hidden;
  cursor: pointer;
  border: none;
  margin: 0;
  padding: 0;
}

[data-theme="light"] .gallery .shot {
  background: var(--color-bg-light);
}

/* Wide items (16:9) */
.gallery .shot.wide { 
  grid-column: span 2; 
  aspect-ratio: 2/1; 
}

/* Tall items (9:16 reels) */
.gallery .shot.tall { 
  grid-row: span 2; 
  aspect-ratio: 1/2; 
}

.gallery .shot img,
.gallery .shot .fluid-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  border-radius: 0;
  display: block;
}

.gallery .shot .fluid-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

/* Video play icon overlay - Always visible like Instagram */
.gallery .shot[data-type="video"]::before {
  content: "▶";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: 2;
  opacity: 1;
  border: 2px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

/* Multiple content indicator (for carousels) */
.gallery .shot[data-count]:not([data-count="1"])::after {
  content: "";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 2;
  pointer-events: none;
}

.gallery .shot[data-count="2"]::after { content: "2"; }
.gallery .shot[data-count="3"]::after { content: "3"; }
.gallery .shot[data-count="4"]::after { content: "4"; }
.gallery .shot[data-count="5"]::after { content: "5+"; }

/* Hover effects */
.gallery .shot:hover img,
.gallery .shot:hover .fluid-media {
  transform: scale(1.02);
}

/* Hide caption in grid view (Instagram doesn't show captions) */
.gallery .shot figcaption {
  display: none;
}

/* ---------- FULL SCREEN OVERLAY — Instagram Style ---------- */
.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.fullscreen-overlay.active {
  display: flex;
  opacity: 1;
}

.fullscreen-content {
  position: relative;
  max-width: 100vw;
  max-height: 100vh;
  background: #000;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-content img,
.fullscreen-content video {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  display: block;
}

.fullscreen-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  font-size: 1rem;
  text-align: center;
  z-index: 10002;
}

/* Navigation controls */
.fullscreen-nav {
  position: absolute;
  top: 50%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  transform: translateY(-50%);
  z-index: 10002;
  pointer-events: none;
}

.fullscreen-nav button {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  font-weight: 300;
  pointer-events: all;
}

.fullscreen-nav button:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Close button */
.fullscreen-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 10002;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  font-weight: 300;
}

.fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Video styling in fullscreen */
.fullscreen-content video {
  background: #000;
  width: auto;
  height: auto;
  max-width: 100vw;
  max-height: 100vh;
}

/* Instagram-style dot indicators */
.fullscreen-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10002;
}

.fullscreen-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: all 0.3s ease;
  cursor: pointer;
}

.fullscreen-dot.active {
  background: rgba(255, 255, 255, 0.9);
  transform: scale(1.2);
}

/* ---------- SIDEBAR ---------- */
.side {
  display: grid;
  gap: var(--cs-gap);
  align-content: start;
  position: sticky;
  top: 32px;
  height: fit-content; /* Only take needed height */
}

.card {
  background: var(--color-elev-1);
  border: 1px solid var(--color-elev-2);
  padding: 24px;
  border-radius: var(--cs-r);
}

[data-theme="light"] .card {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border-light);
}

.card h3 { 
  margin-top: 0; 
  color: var(--color-orange);
  margin-bottom: 16px;
}
.ticks { 
  margin: 0; 
  padding-left: 18px; 
  color: var(--color-ink);
}

[data-theme="light"] .ticks {
  color: var(--color-text-light);
}

.card.quote blockquote {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  line-height: 1.5;
  font-style: italic;
  color: var(--color-ink-dim);
}

[data-theme="light"] .card.quote blockquote {
  color: var(--color-text-light-dim);
}

.w-100 { display: inline-flex; justify-content: center; width: 100%; }

/* ---------- Case Study Lists ---------- */
.steps, .bullets, .ticks {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}
.steps li,
.bullets li,
.ticks li {
  position: relative;
  padding-left: 32px;
  line-height: 1.6;
  color: var(--color-ink);
}

[data-theme="light"] .steps li,
[data-theme="light"] .bullets li,
[data-theme="light"] .ticks li {
  color: var(--color-text-light);
}

.steps li::before,
.bullets li::before,
.ticks li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .4em;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--color-orange), var(--color-orange-2));
  -webkit-mask: no-repeat center / contain;
          mask: no-repeat center / contain;
  opacity: .9;
}
.steps li::before {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10"/></svg>');
          mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10"/></svg>');
}
.bullets li::before {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 6L9 17l-5-5" stroke="black" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>');
          mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 6L9 17l-5-5" stroke="black" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>');
}
.ticks li::before {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 2h9l5 5v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1z" fill="black"/></svg>');
          mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 2h9l5 5v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1z" fill="black"/></svg>');
}

/* ---------- Next Case Study CTA ---------- */
.cs-next {
  padding: 60px 0 80px;
  text-align: center;
  max-width: min(1200px, 94vw);
  margin: 0 auto;
}
.cs-next .next {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 18px 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-orange), var(--color-orange-2));
  color: var(--color-white);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .2px;
  text-decoration: none;
  transition: transform .3s ease, box-shadow .3s ease, filter .3s ease;
  box-shadow: 0 8px 24px rgba(255, 102, 0, .4);
}
.cs-next .next .hint { display: none; }
.cs-next .next .n-title {
  font-size: 1.1rem;
  font-weight: 700;
}
.cs-next .next::after {
  content: "➝";
  font-size: 1.3rem;
  opacity: .85;
  transition: transform .3s ease, opacity .3s ease;
}
.cs-next .next:hover {
  transform: translateY(-4px);
  filter: brightness(1.1);
  box-shadow: 0 12px 32px rgba(255, 102, 0, .5);
}
.cs-next .next:hover::after {
  transform: translateX(6px);
  opacity: 1;
}

/* ---------- BUTTONS ---------- */
.btn--primary {
  background: var(--color-orange);
  border-color: transparent;
  color: var(--color-white);
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 8px;
  transition: all 0.3s ease;
}
.btn--ghost { 
  background: transparent; 
  border: 1px solid var(--color-elev-2);
  padding: 12px 24px;
  border-radius: 8px;
  transition: all 0.3s ease;
  color: var(--color-ink);
}

[data-theme="light"] .btn--ghost {
  border: 1px solid var(--color-border-light);
  color: var(--color-text-light);
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 102, 0, 0.3);
}

/* ---------- RESPONSIVE DESIGN ---------- */
@media (max-width: 1024px) {
  .gallery { 
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
  }
}

@media (max-width: 960px) {
  .cs-hero .wrap { 
    grid-template-columns: 1fr; 
    gap: 32px;
  }
  .cs-body .grid { 
    grid-template-columns: 1fr; 
    gap: 32px;
  }
  .side {
    position: static;
    height: auto;
  }
  
  .gallery {
    margin: 40px 0;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  :root {
    --cs-gap: 20px;
  }
  
  .cs-hero {
    padding: 32px 0;
  }
  
  .cs-body {
    padding: 32px 0 48px;
  }
  
  .pillar {
    padding: 20px;
  }
  
  .kpis {
    gap: 12px;
  }
  
  .kpi {
    min-width: calc(50% - 12px);
  }
  
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
}

@media (max-width: 640px) {
  .gallery { 
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

@media (max-width: 480px) {
  .cs-hero__text .title {
    font-size: clamp(28px, 8vw, 36px);
  }
  
  .kpi {
    min-width: 100%;
  }
  
  .card {
    padding: 20px;
  }
  
  /* Instagram grid mobile */
  .gallery { 
    grid-template-columns: repeat(2, 1fr); 
  }
}

/* Ensure no other styles interfere */
.gallery .shot * {
  box-sizing: border-box;
}