/* ============== PREVIEW MODAL ============== */
.preview-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.36s var(--ease-out-expo);
}
.preview-modal.is-open {
  pointer-events: auto;
  opacity: 1;
}

.preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 22, 40, 0.78);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.preview-modal__shell {
  position: relative;
  width: min(1180px, 92vw);
  height: min(86vh, 940px);
  margin: 4vh auto 0;
  background: var(--white);
  border-radius: var(--r-2xl);
  border: 1px solid var(--line);
  box-shadow: 0 60px 120px -40px rgba(10, 22, 40, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(40px) scale(0.96);
  opacity: 0;
  transition: transform 0.5s var(--ease-out-expo), opacity 0.4s var(--ease-out-expo);
}
.preview-modal.is-open .preview-modal__shell {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Top browser bar */
.preview-modal__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--linen);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.preview-modal__bar-left { display: flex; align-items: center; gap: var(--s-3); }
.preview-modal__bar .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--line-strong);
  display: inline-block;
}
.preview-modal__bar .dot-r { background: #FF5F57; }
.preview-modal__bar .dot-y { background: #FEBC2E; }
.preview-modal__bar .dot-g { background: #28C840; }
.preview-modal__url {
  margin-left: var(--s-3);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--mute);
  background: var(--white);
  padding: 6px var(--s-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-modal__bar-meta { display: flex; align-items: center; gap: var(--s-3); }
.preview-modal__client {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--mute);
  padding: 5px var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}
.preview-modal__open {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 7px var(--s-4);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--white);
  background: var(--orange);
  border: 1px solid var(--orange);
  border-radius: var(--r-pill);
  transition: background var(--d-fast), transform var(--d-fast);
}
.preview-modal__open:hover { background: var(--orange-deep); transform: translateY(-1px); }
.preview-modal__close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--d-fast), background var(--d-fast);
}
.preview-modal__close:hover { background: var(--orange); transform: rotate(90deg); }

/* Viewport — image scroll container */
.preview-modal__viewport {
  position: relative;
  flex: 1;
  background: var(--cream);
  overflow: hidden;
}

.preview-modal__scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--white);
}

.preview-modal__img {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: var(--cream);
}

/* Hint chip */
.preview-modal__hint {
  position: absolute;
  bottom: var(--s-5);
  left: 50%;
  transform: translate(-50%, 0);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 8px var(--s-4);
  background: var(--ink);
  color: var(--white);
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  box-shadow: 0 14px 30px -10px rgba(10, 22, 40, 0.4);
  z-index: 5;
  animation: hintBob 1.8s ease-in-out infinite;
  transition: opacity 0.3s, transform 0.3s;
}
.preview-modal__hint.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
}
@keyframes hintBob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -6px); }
}

/* Loader */
.preview-modal__loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--s-4);
  background: var(--cream);
  z-index: 2;
}
.loader-spin {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--orange);
  animation: spin 0.9s linear infinite;
}
/* @keyframes spin moved to base.css for global availability */
.loader-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--mute);
}

@media (max-width: 768px) {
  .preview-modal__shell { width: 96vw; height: 92vh; margin: 4vh auto; }
  .preview-modal__url { max-width: 130px; font-size: 0.7rem; }
  .preview-modal__client { display: none; }
  .preview-modal__open span { display: none; }
  .preview-modal__open { padding: 7px 10px; }
  .preview-modal__bar { padding: var(--s-3) var(--s-4); }
}

/* =================================================== */
/* ============== VIDEO PREVIEW MODE ================= */
/* =================================================== */

/* Mode toggling — using data-mode attribute on the modal root so we don't
   collide with the [hidden] attribute (whose UA `display:none` rule loses to
   our explicit `display:` rules below). */
.preview-modal[data-mode="image"] .preview-modal__video { display: none; }
.preview-modal[data-mode="video"] .preview-modal__image-stage { display: none; }
/* Also keep the native `hidden` attribute as a fallback for initial paint. */
.preview-modal__video[hidden],
.preview-modal__image-stage[hidden],
.preview-modal__case[hidden] { display: none; }

/* Image stage — single-column by default, 2-column when paired with a
   case study aside (so we mirror the layout used for video previews). */
.preview-modal__image-stage {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}
.preview-modal__image-stage > .preview-modal__viewport {
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.preview-modal__image-stage--with-case {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}
.preview-modal__image-stage--with-case .preview-modal__case {
  background: linear-gradient(160deg, #0a1628 0%, #050b15 100%);
  color: var(--white);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

/* When the image is short and there's empty space below it, blend that
   space into the dark navy of the case aside instead of leaving a
   broken-looking dark void. The image always sits at the top of its
   column so the brand/hero is the focal point; the fade picks up below. */
.preview-modal__image-stage--with-case .preview-modal__viewport {
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream) 56%, #0a1628 100%);
}
.preview-modal__image-stage--with-case .preview-modal__scroll {
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
.preview-modal__image-stage--with-case .preview-modal__img {
  background: transparent;
  flex: 0 0 auto;
}

.preview-modal__video {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  background: linear-gradient(160deg, #0a1628 0%, #050b15 100%);
  color: var(--white);
  overflow: hidden;
  min-height: 0;
}

/* Force the site's Launchy cursor inside the modal so it stays consistent
   with the rest of the page (otherwise the browser falls back to the
   default cursor over <img>, <video>, the scroll container, etc.). */
.preview-modal,
.preview-modal__shell,
.preview-modal__viewport,
.preview-modal__scroll,
.preview-modal__img,
.preview-modal__video,
.preview-modal__video-stage,
.preview-modal__video-frame,
.preview-modal__video video,
.preview-modal__case {
  cursor: url('../assets/logos/cursor-launchy-ink.png') 16 16, auto;
}
.preview-modal a,
.preview-modal button,
.preview-modal [role="button"],
.preview-modal__video-tab {
  cursor: url('../assets/logos/cursor-launchy-ink.png') 16 16, pointer;
}
@media (max-width: 1024px), (pointer: coarse) {
  .preview-modal,
  .preview-modal__shell,
  .preview-modal__viewport,
  .preview-modal__scroll,
  .preview-modal__img,
  .preview-modal__video,
  .preview-modal__video-stage,
  .preview-modal__video-frame,
  .preview-modal__video video,
  .preview-modal__case { cursor: auto; }
  .preview-modal a,
  .preview-modal button,
  .preview-modal [role="button"],
  .preview-modal__video-tab { cursor: pointer; }
}

.preview-modal__video-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 3.5vw, 56px);
  gap: var(--s-4);
  min-height: 0;
}

.preview-modal__video-frame {
  position: relative;
  width: auto;
  height: 100%;
  aspect-ratio: 9 / 16;
  max-height: 100%;
  max-width: 100%;
  border-radius: clamp(18px, 1.6vw, 26px);
  overflow: hidden;
  background: #000;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.06),
    0 30px 60px -20px rgba(0, 0, 0, 0.6),
    0 14px 28px -14px rgba(255, 107, 26, 0.22);
}
.preview-modal__video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.preview-modal__video-tabs {
  display: inline-flex;
  align-items: stretch;
  gap: var(--s-2);
  padding: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-pill);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.preview-modal__video-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: background var(--d-fast), color var(--d-fast), border-color var(--d-fast);
}
.preview-modal__video-tab:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
}
.preview-modal__video-tab.is-active {
  background: var(--orange);
  color: var(--white);
  border-color: var(--orange);
  box-shadow: 0 8px 18px -6px rgba(255, 107, 26, 0.55);
}
.preview-modal__video-tab-num {
  font-weight: 600;
  letter-spacing: 0.08em;
}
.preview-modal__video-tab-label {
  text-transform: none;
  letter-spacing: 0.02em;
  font-family: var(--font-body);
  font-size: 0.78rem;
}

/* Case study aside */
.preview-modal__case {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: clamp(28px, 3vw, 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(255, 255, 255, 0.02);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}
.preview-modal__case-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--orange);
}
.preview-modal__case-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.4vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--white);
}
.preview-modal__case-intro {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.78);
}
.preview-modal__case-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
  margin: var(--s-2) 0 var(--s-3);
}
.preview-modal__case-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-lg);
}
.preview-modal__case-kpi-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  color: var(--white);
  letter-spacing: -0.01em;
  line-height: 1;
}
.preview-modal__case-kpi-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.55);
}
.preview-modal__case-sections {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.preview-modal__case-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: var(--s-3);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.preview-modal__case-section h4 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--orange);
}
.preview-modal__case-section p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.82);
}

/* Top-bar adjustments when in video mode (the shell is dark) */
.preview-modal[data-mode="video"] .preview-modal__bar {
  background: rgba(10, 22, 40, 0.85);
  color: var(--white);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
.preview-modal[data-mode="video"] .preview-modal__url {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}
.preview-modal[data-mode="video"] .preview-modal__client {
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
}
.preview-modal[data-mode="video"] .preview-modal__shell {
  background: #0a1628;
  border-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 900px) {
  .preview-modal__video,
  .preview-modal__image-stage--with-case {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .preview-modal__video-stage {
    padding: var(--s-4);
  }
  .preview-modal__video-frame {
    aspect-ratio: 9 / 16;
    max-height: 56vh;
  }
  .preview-modal__case {
    border-left: 0 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: var(--s-4) var(--s-4) var(--s-5);
  }
  .preview-modal__case-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s-2);
  }
  .preview-modal__case-kpi { padding: 10px 8px; }
  .preview-modal__case-kpi-value { font-size: 1rem; }
}
@media (max-width: 540px) {
  .preview-modal__video-tab-label { display: none; }
  .preview-modal__case-kpis { gap: 6px; }
  .preview-modal__case-kpi-label { font-size: 0.55rem; letter-spacing: 0.1em; }
}
