/* ============================================================
   SECTION 8: pinned 16-card "slow 90° edge flip" showcase.
   Sits directly after Section 7 (cube assembly) with no dead
   scroll space in between — same pin-flush pattern as every
   other section on the page.

   Ported from the standalone Section-8-final.html demo and
   reskinned to match the site's Fraunces/Inter typography and
   dark stage background:
     - cyan accent (#00e5ff) swapped for off-white/gray
     - card + grid imagery kept in FULL, TRUE COLOR — each
       project keeps its own brand palette instead of a
       uniform black/white treatment
     - label styled the same way as the other section labels
   ============================================================ */

.s8-stage {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
}

.s8-stage .label {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  z-index: 6;
}

/* 16-CARD FINALE GRID */
.s8-grid-container {
  position: absolute;
  width: 90vw;
  max-width: 1200px;
  height: 80vh;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

.s8-grid-card {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.s8-grid-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.s8-grid-card:hover img {
  transform: scale(1.06);
}

.s8-grid-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 16px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.s8-grid-card:hover .s8-grid-caption {
  opacity: 1;
  transform: translateY(0);
}

.s8-grid-caption em {
  font-style: normal;
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

/* Per-card description — only used on mobile/tablet (see media
   query below). Hidden on desktop, where the long-form copy
   lives in the .s8-text-box overlays instead. */
.s8-grid-desc {
  display: none;
}

/* MAIN ACTIVE 3D CANVAS FRAME */
.s8-scrolly-card {
  position: absolute;
  z-index: 5;
  transform-style: preserve-3d;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);

  /* INITIAL DOCKED STATE: Left Side Card */
  width: 48vw;
  height: 65vh;
  top: 17.5vh;
  left: 6vw;
  border-radius: 16px;
  will-change: transform, width, height, top, left, opacity;
}

.s8-scrolly-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* TEXT OVERLAYS */
.s8-text-box {
  position: absolute;
  width: 38%;
  z-index: 4;
  opacity: 0;
  will-change: transform, opacity;
}

.s8-text-box.left { left: 6vw; text-align: left; }
.s8-text-box.right { right: 6vw; text-align: right; }

.s8-step-num {
  font-size: 0.75rem;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
}

.s8-step-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  margin-bottom: 10px;
  line-height: 1.2;
  font-weight: 600;
  color: #fff;
}

.s8-step-meta {
  display: block;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #9fb4ff;
  margin-bottom: 14px;
}

.s8-step-desc {
  font-family: var(--font-body);
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}

/* ============================================================
   SECTION 8 — MOBILE / TABLET LAYOUT
   The pinned 90° flip carousel (rotateY, absolute 6vw/46vw
   text overlays, a 32000px scroll runway) is a desktop-only
   trick — on touch screens it fights the scroll and crops
   every image via object-fit: cover.

   Below 768px we skip the carousel entirely: the finale grid
   becomes the *only* layout, shown immediately, in normal
   document flow. Each project is a simple stacked card — full
   image (object-fit: contain, nothing cropped) with its title,
   location and description underneath. section8.js checks the
   same breakpoint and skips creating the pin/timeline so mobile
   visitors just scroll the page normally.
   ============================================================ */
@media (max-width: 768px) {
  .s8-stage {
    height: auto;
    min-height: 0;
    overflow: visible;
    display: block;
    padding: 90px 20px 70px;
  }

  .s8-stage .label {
    position: static;
    display: block;
    transform: none;
    text-align: center;
    margin-bottom: 28px;
  }

  /* Desktop-only scrolly hero card + side text overlays */
  .s8-scrolly-card,
  .s8-text-box {
    display: none !important;
  }

  /* Finale grid becomes the primary, always-visible layout */
  .s8-grid-container {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    grid-template-columns: 1fr;
    gap: 32px;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .s8-grid-card {
    height: auto;
    display: block;
    border-radius: 14px;
  }

  .s8-grid-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #0a0a0a;
  }

  .s8-grid-card:hover img {
    transform: none;
  }

  .s8-grid-caption {
    position: static;
    opacity: 1 !important;
    transform: none !important;
    background: #111;
    padding: 16px 18px 4px;
    pointer-events: auto;
  }

  .s8-grid-desc {
    display: block;
    background: #111;
    margin: 0;
    padding: 8px 18px 18px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.55);
  }
}

@media (max-width: 480px) {
  .s8-grid-container {
    gap: 22px;
  }

  .s8-grid-card img {
    aspect-ratio: 1 / 1;
  }

  .s8-step-title {
    font-size: 1.6rem;
  }
}
