/* ─── CASE STUDY & WORK PAGE SHARED STYLES ──────── */
@import url('../new-style.css');

/* ─── PAGE TRANSITION ────────────────────────────── */
.page-transition {
  position: fixed;
  inset: 0;
  background: #080808;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.page-transition.entering {
  opacity: 1;
}

/* ─── CASE STUDY HERO ────────────────────────────── */
.cs-hero {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 140px 0 80px;
  position: relative;
  overflow: hidden;
  background: #080808;
}

.cs-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0,255,65,0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 30%, rgba(0,255,65,0.04) 0%, transparent 45%);
  pointer-events: none;
  animation: orbDrift1 9s ease-in-out infinite;
}

.cs-hero-inner {
  position: relative;
  z-index: 2;
}

.cs-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  margin-bottom: 48px;
  transition: color 0.2s, gap 0.2s;
}

.cs-back:hover {
  color: var(--white);
  gap: 12px;
}

.cs-back svg {
  transition: transform 0.2s;
}

.cs-back:hover svg {
  transform: translateX(-3px);
}

.cs-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.cs-tag {
  padding: 5px 14px;
  border: 1px solid rgba(0,255,65,0.3);
  color: var(--green);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 20px;
}

.cs-hero h1 {
  font-size: clamp(2.4rem, 5vw, 5rem);
  margin-bottom: 24px;
  max-width: 800px;
}

.cs-hero h1 em {
  font-style: normal;
  color: var(--green);
}

.cs-result-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: rgba(0,255,65,0.06);
  border: 1px solid rgba(0,255,65,0.2);
  border-radius: 40px;
  font-size: 0.9rem;
  color: var(--white);
  margin-bottom: 48px;
}

.cs-result-pill span {
  color: var(--green);
  font-weight: 600;
}

.cs-result-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  flex-shrink: 0;
}

/* Hero cover image */
.cs-hero-cover {
  width: 100%;
  height: 480px;
  object-fit: cover;
  object-position: top;
  border-radius: 16px;
  margin-top: 48px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow:
    0 40px 80px rgba(0,0,0,0.6),
    0 0 0 1px rgba(0,255,65,0.05);
  display: block;
}

/* ─── CASE STUDY CONTENT ─────────────────────────── */
.cs-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 80px 32px;
}

.cs-section {
  margin-bottom: 72px;
}

.cs-section-label {
  font-size: 0.7rem;
  color: var(--green);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.cs-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(0,255,65,0.2), transparent);
}

.cs-section h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 20px;
  line-height: 1.2;
}

.cs-section p {
  color: #aaaaaa;
  font-size: 1rem;
  line-height: 1.85;
  margin-bottom: 16px;
}

/* Results metrics */
.cs-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 32px;
}

.cs-metric {
  background: linear-gradient(
    145deg,
    rgba(255,255,255,0.06) 0%,
    rgba(255,255,255,0.02) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 1px 0 0 rgba(255,255,255,0.12) inset,
    0 -1px 0 0 rgba(0,0,0,0.4) inset,
    0 8px 32px rgba(0,0,0,0.3);
}

.cs-metric::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 16px;
  padding: 1px;
  background: conic-gradient(
    from var(--angle),
    transparent 65%,
    rgba(255,255,255,0.4) 75%,
    rgba(255,255,255,0.7) 82%,
    rgba(255,255,255,0.4) 88%,
    transparent 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box,
                linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: trainBorder 2.5s linear infinite;
  pointer-events: none;
}

.cs-metric-value {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 500;
  color: var(--green);
  line-height: 1;
  margin-bottom: 8px;
}

.cs-metric-label {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ─── IMAGE GALLERY ──────────────────────────────── */
.cs-gallery {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px 80px;
}

.cs-gallery-label {
  font-size: 0.7rem;
  color: var(--green);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.cs-gallery-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(0,255,65,0.2), transparent);
}

/* ── Grid: two columns, height driven by first image ── */
.cs-gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  /* Height is NOT set here — it's driven by the first image's natural height */
  align-items: stretch;
}

/* ── Both items stretch to fill the row height ── */
.cs-gallery-item {
  position: relative;
  border-radius: 14px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  overflow: hidden;
  /* Each item fills the full height of the grid row */
  display: flex;
  flex-direction: column;
}

/* ── First image: natural size sets the row height ── */
.cs-gallery-item:first-child {
  /* Let the image dictate height naturally */
}

.cs-gallery-item:first-child img {
  width: 100%;
  height: auto; /* Natural height — this sets the row height */
  object-fit: unset;
  object-position: unset;
  display: block;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Second image: fills same height, shows from top, no side crop ── */
.cs-gallery-item:not(:first-child) {
  /* Fills the same height as the first item */
  min-height: 100%;
}

.cs-gallery-item:not(:first-child) img {
  width: 100%;
  height: 100%;
  /* Cover height but constrain to width — no side cropping */
  object-fit: cover;
  object-position: top;
  display: block;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Subtle zoom on hover for both */
.cs-gallery-item:hover img {
  transform: scale(1.02);
}

/* Overlay on hover */
.cs-gallery-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 50%,
    rgba(0,0,0,0.4) 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
  pointer-events: none;
}

.cs-gallery-item:hover::after {
  opacity: 1;
}

/* Expand icon */
.cs-gallery-expand {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cs-gallery-item:hover .cs-gallery-expand {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ─── LIGHTBOX ───────────────────────────────────── */
.cs-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(12px);
}

.cs-lightbox.open {
  opacity: 1;
  pointer-events: all;
}

.cs-lightbox-inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  gap: 24px;
}

/* Full page screenshots scroll vertically in lightbox */
.cs-lightbox img {
  max-width: 80vw;
  max-height: 85vh;
  object-fit: contain;
  object-position: top;
  border-radius: 12px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.8);
  border: 1px solid rgba(255,255,255,0.08);
  /* Allow tall images to scroll inside lightbox */
  overflow-y: auto;
  display: block;
}

.cs-lightbox-close {
  position: absolute;
  top: -48px;
  right: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
  font-family: var(--font);
}

.cs-lightbox-close:hover { color: var(--white); }

.cs-lightbox-nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--white);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
  font-family: var(--font);
}

.cs-lightbox-nav:hover {
  background: rgba(255,255,255,0.12);
}

.cs-lightbox-counter {
  position: absolute;
  bottom: -36px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.1em;
}

/* ─── NEXT PROJECT ───────────────────────────────── */
.cs-next {
  border-top: 1px solid var(--border);
  padding: 80px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto;
  text-decoration: none;
  transition: gap 0.2s;
  gap: 24px;
}

.cs-next:hover .cs-next-arrow {
  transform: translateX(8px);
}

.cs-next-label {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.cs-next-title {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 500;
  color: var(--white);
  line-height: 1.2;
}

.cs-next-title em {
  font-style: normal;
  color: var(--green);
}

.cs-next-arrow {
  font-size: 2rem;
  color: var(--green);
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

/* ─── WORK PAGE — PORTFOLIO GRID ─────────────────── */
.work-hero {
  padding: 160px 0 80px;
  position: relative;
  overflow: hidden;
}

.work-hero::before {
  content: '';
  position: absolute;
  top: -100px; left: 50%;
  transform: translateX(-50%);
  width: 800px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,255,65,0.06) 0%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  animation: breatheGlow 8s ease-in-out infinite;
}

.work-hero-inner { position: relative; z-index: 2; }

.work-hero h1 { margin-bottom: 16px; }
.work-hero h1 em { font-style: normal; color: var(--green); }
.work-hero p { color: var(--muted); max-width: 480px; }

/* Filter buttons */
.work-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 48px;
}

.work-filter-btn {
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--font);
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all 0.2s;
}

.work-filter-btn:hover {
  border-color: rgba(255,255,255,0.2);
  color: var(--white);
}

.work-filter-btn.active {
  background: rgba(0,255,65,0.08);
  border-color: rgba(0,255,65,0.3);
  color: var(--green);
}

/* Portfolio grid */
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 0 0 120px;
}

/* Portfolio card */
.work-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  display: block;
  background: linear-gradient(
    145deg,
    rgba(255,255,255,0.05) 0%,
    rgba(255,255,255,0.02) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 1px 0 0 rgba(255,255,255,0.12) inset,
    0 -1px 0 0 rgba(0,0,0,0.4) inset,
    0 8px 32px rgba(0,0,0,0.35);
  transition: transform 0.35s cubic-bezier(0.25,0.46,0.45,0.94),
              box-shadow 0.35s ease,
              border-color 0.35s ease;
}

.work-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 16px;
  padding: 1px;
  background: conic-gradient(
    from var(--angle),
    transparent 65%,
    rgba(255,255,255,0.45) 75%,
    rgba(255,255,255,0.75) 82%,
    rgba(255,255,255,0.45) 88%,
    transparent 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box,
                linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: trainBorder 2s linear infinite;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.work-card:hover::before { opacity: 1; }

.work-card:hover {
  transform: translateY(-8px);
  border-color: rgba(255,255,255,0.14);
  box-shadow:
    0 1px 0 0 rgba(255,255,255,0.18) inset,
    0 -1px 0 0 rgba(0,0,0,0.5) inset,
    0 24px 60px rgba(0,0,0,0.55),
    0 0 40px rgba(0,255,65,0.05);
}

.work-card-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: top;
  display: block;
  transition: transform 0.5s cubic-bezier(0.25,0.46,0.45,0.94);
}

.work-card:hover .work-card-img { transform: scale(1.04); }

.work-card-img-wrap {
  overflow: hidden;
  position: relative;
}

.work-card-img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.3) 100%);
  pointer-events: none;
}

.work-card-body {
  padding: 28px 28px 32px;
  position: relative;
  z-index: 3;
}

.work-card-tag {
  font-size: 0.68rem;
  color: var(--green);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.work-card-title {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--white);
  line-height: 1.3;
  margin-bottom: 10px;
}

.work-card-result {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

.work-card-result strong { color: var(--green); }

.work-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--green);
  letter-spacing: 0.04em;
  transition: gap 0.2s;
}

.work-card:hover .work-card-cta { gap: 10px; }

.work-card.hidden { display: none; }

/* ─── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 1024px) {
  .work-grid { grid-template-columns: repeat(2, 1fr); }
  .cs-metrics { grid-template-columns: repeat(2, 1fr); }

  /* Stack gallery on tablet */
  .cs-gallery-grid {
    grid-template-columns: 1fr;
  }

  /* Both images go back to natural auto height when stacked */
  .cs-gallery-item:first-child img {
    width: 100%;
    height: auto;
    object-fit: unset;
  }

  .cs-gallery-item:not(:first-child) {
    min-height: unset;
    height: 320px;
  }

  .cs-gallery-item:not(:first-child) img {
    height: 100%;
    object-fit: cover;
    object-position: top;
  }
}

@media (max-width: 600px) {
  .work-grid { grid-template-columns: 1fr; }
  .cs-metrics { grid-template-columns: 1fr; }

  .cs-gallery-item:not(:first-child) {
    height: 240px;
  }
}

/* ════════════════════════════════════════════════
   CASE STUDY MOBILE FIX
   ════════════════════════════════════════════════ */

@media (max-width: 768px) {

  .cs-hero { padding: 100px 0 50px; min-height: auto; }
  .cs-back { margin-bottom: 28px; font-size: 0.8rem; }
  .cs-tags { gap: 6px; margin-bottom: 16px; }
  .cs-tag { font-size: 0.68rem; padding: 4px 10px; }
  .cs-hero h1 { font-size: 1.9rem; margin-bottom: 16px; }

  .cs-result-pill {
    font-size: 0.8rem;
    padding: 7px 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
  }

  .cs-hero-cover {
    height: 220px !important;
    margin-top: 28px;
    border-radius: 12px;
  }

  .cs-content { padding: 48px 20px; }
  .cs-section { margin-bottom: 44px; }
  .cs-section h2 { font-size: 1.4rem; }
  .cs-section p { font-size: 0.92rem; line-height: 1.75; }

  .cs-metrics {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .cs-metric { padding: 22px 18px; }
  .cs-metric-value { font-size: 1.6rem; }

  /* Gallery — 2 image version */
  .cs-gallery { padding: 0 20px 50px; }
  .cs-gallery-label { margin-bottom: 18px; }

  .cs-gallery-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .cs-gallery-item:first-child img {
    width: 100% !important;
    height: auto !important;
    object-fit: unset !important;
  }

  .cs-gallery-item:not(:first-child) {
    min-height: unset !important;
    height: 220px !important;
  }

  .cs-gallery-item:not(:first-child) img {
    height: 100% !important;
    object-fit: cover !important;
    object-position: top !important;
  }

  /* Gallery — 3 image version (market intel) */
  .cs-gallery-grid-3 {
    grid-template-columns: 1fr !important;
  }

  .cs-gallery-grid-3 .cs-gallery-item {
    aspect-ratio: 16/9 !important;
    height: auto !important;
  }

  .cs-gallery-grid-3 .cs-gallery-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  /* Lightbox */
  .cs-lightbox-inner { max-width: 94vw; gap: 8px; }
  .cs-lightbox img { max-width: 86vw; max-height: 70vh; }
  .cs-lightbox-nav { width: 36px; height: 36px; font-size: 1rem; }
  .cs-lightbox-close { top: -40px; font-size: 1.2rem; }
  .cs-lightbox-counter { bottom: -30px; font-size: 0.72rem; }

  /* Next project */
  .cs-next { padding: 48px 20px; gap: 16px; }
  .cs-next-title { font-size: 1.3rem; }
  .cs-next-arrow { flex-shrink: 0; }

  /* Work index hero */
  .work-hero { padding: 100px 0 50px; }
  .work-hero h1 { font-size: 1.9rem; }
  .work-hero p { font-size: 0.9rem; }
  .work-filters { margin-top: 28px; gap: 8px; }
  .work-filter-btn { padding: 7px 14px; font-size: 0.76rem; }

  .work-grid { grid-template-columns: 1fr !important; padding: 0 0 60px; }
  .work-card-img { height: 180px; }

}

@media (max-width: 480px) {
  .cs-hero h1 { font-size: 1.6rem; }
  .cs-hero-cover { height: 180px !important; }
}