/* ============================================================
   Design Viewer Component
   All styles namespaced with .dv- and scoped under .design-viewer
   so the component can't leak into surrounding case study styles.
   ============================================================ */

.design-viewer { width: 100%; max-width: 900px; margin: 48px auto 0; }

/* ---------- Controls bar (above stage) ---------- */
.design-viewer .dv-controls { display: flex; justify-content: space-between; align-items: center; padding: 0 0 12px 0; }

.design-viewer .dv-group { display: flex; position: relative; border: 0.5px solid #d0d0ce; border-radius: 100px; background: #eaeae8; padding: 2px; transition: transform 0.15s cubic-bezier(0.32, 0.72, 0, 1); }
.design-viewer .dv-group:active { transform: scale(0.97); }

/* Sliding active pill */
.design-viewer .dv-group::before {
  content: '';
  position: absolute;
  top: 2px; bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  background: #1a1a1a;
  border-radius: 100px;
  transform: translateX(0);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 0;
}
.design-viewer .dv-group[data-active="1"]::before { transform: translateX(calc(100% + 0px)); }

.design-viewer .dv-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-family: inherit;
  padding: 7px 16px;
  border: none;
  background: transparent;
  color: #888;
  cursor: pointer;
  font-weight: 400;
  white-space: nowrap;
  flex: 1;
  justify-content: center;
  transition: color 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
/* Hover surface */
.design-viewer .dv-btn::before {
  content: '';
  position: absolute;
  top: 2px; bottom: 2px;
  left: 4px; right: 4px;
  border-radius: 100px;
  background: #d8d8d4;
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: -1;
}
.design-viewer .dv-btn:not(.is-active):hover { color: #1a1a1a; }
.design-viewer .dv-btn:not(.is-active):hover::before { opacity: 1; }
.design-viewer .dv-btn.is-active { color: #ffffff; }
.design-viewer .dv-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1); }

/* ---------- Mode toggle (single icon button) ---------- */
.design-viewer .dv-mode-toggle { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 100px; border: 0.5px solid #d0d0ce; background: #eaeae8; color: #1a1a1a; cursor: pointer; flex-shrink: 0; padding: 0; transition: background 0.2s cubic-bezier(0.32, 0.72, 0, 1), transform 0.15s cubic-bezier(0.32, 0.72, 0, 1); }
.design-viewer .dv-mode-toggle:hover { background: #d8d8d4; }
.design-viewer .dv-mode-toggle:active { transform: scale(0.92); }
.design-viewer .dv-mode-toggle svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; display: block; }
.design-viewer .dv-mode-toggle .dv-sun-icon { display: none; }
.design-viewer .dv-mode-toggle.is-dark .dv-moon-icon { display: none; }
.design-viewer .dv-mode-toggle.is-dark .dv-sun-icon { display: block; }

/* ---------- Stage ---------- */
.design-viewer .dv-stage { background: #2a2a28; min-height: min(520px, 70vh); border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 0 0; gap: 10px; position: relative; transition: background 0.15s; }
/* Light stage state (active when viewing dark designs) */
.design-viewer .dv-stage.is-light-stage { background: #e8e8e4; }

/* ---------- Desktop view ---------- */
.design-viewer .dv-desktop-view { width: 88%; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.design-viewer .dv-desktop-screen { width: 100%; border-radius: 10px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,0.5); flex-shrink: 0; transition: box-shadow 0.2s; }
.design-viewer .dv-desktop-screen img { width: 100%; height: auto; display: block; border-radius: 8px; }

/* ---------- Mobile view ---------- */
.design-viewer .dv-mobile-view { display: none; gap: 14px; justify-content: center; align-items: center; width: 100%; flex: 1; min-height: 0; padding: 8px 0; }
.design-viewer .dv-phone { flex-shrink: 0; width: 180px; border-radius: 36px; background: #1c1c1e; padding: 5px; box-shadow: 0 0 0 1.5px #3a3a3c, 0 12px 40px rgba(0,0,0,0.6); position: relative; max-height: 100%; transition: box-shadow 0.2s; }
/* Left side: volume up + volume down */
.design-viewer .dv-phone::before { content: ''; position: absolute; left: -3px; top: 72px; width: 3px; height: 28px; background: #3a3a3c; border-radius: 2px 0 0 2px; box-shadow: 0 38px 0 #3a3a3c; pointer-events: none; }
/* Right side: power button */
.design-viewer .dv-phone::after { content: ''; position: absolute; right: -3px; top: 88px; width: 3px; height: 44px; background: #3a3a3c; border-radius: 0 2px 2px 0; pointer-events: none; }
/* Screen — inner radius = outer (36) minus padding (5), forced to phone aspect ratio */
.design-viewer .dv-phone-screen { width: 100%; aspect-ratio: 9/19.5; overflow: hidden; border-radius: 31px; background: #e8e8e6; font-size: 9px; color: #aaa; text-transform: uppercase; letter-spacing: 0.06em; }
.design-viewer .dv-phone-screen img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.design-viewer .dv-phone.is-hidden { display: none; }

/* Soft shadows when on light stage */
.design-viewer .dv-stage.is-light-stage .dv-desktop-screen { box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.design-viewer .dv-stage.is-light-stage .dv-phone { box-shadow: 0 0 0 1.5px #3a3a3c, 0 8px 24px rgba(0,0,0,0.18); }

/* ---------- Nav arrows + counter ---------- */
.design-viewer .dv-nav { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; flex-shrink: 0; }
.design-viewer .dv-arrow { width: 32px; height: 32px; border-radius: 50%; border: 0.5px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); color: #ffffff; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s cubic-bezier(0.32, 0.72, 0, 1), border-color 0.2s cubic-bezier(0.32, 0.72, 0, 1), transform 0.15s cubic-bezier(0.32, 0.72, 0, 1); padding: 0; }
.design-viewer .dv-arrow svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; transition: transform 0.2s cubic-bezier(0.32, 0.72, 0, 1); }
.design-viewer .dv-arrow:hover:not(:disabled) { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.32); }
.design-viewer .dv-arrow.is-prev:hover:not(:disabled) svg { transform: translateX(-1.5px); }
.design-viewer .dv-arrow.is-next:hover:not(:disabled) svg { transform: translateX(1.5px); }
.design-viewer .dv-arrow:active:not(:disabled) { transform: scale(0.92); }
.design-viewer .dv-arrow:disabled { opacity: 0.25; cursor: default; }
.design-viewer .dv-counter { font-size: 11px; color: rgba(255,255,255,0.3); min-width: 48px; text-align: center; transition: color 0.2s ease; }

/* Light stage recolor for arrows, fs button, and counter */
.design-viewer .dv-stage.is-light-stage .dv-arrow,
.design-viewer .dv-stage.is-light-stage .dv-fs-btn { border-color: rgba(0,0,0,0.15); background: rgba(0,0,0,0.06); color: #1a1a1a; }
.design-viewer .dv-stage.is-light-stage .dv-arrow:hover:not(:disabled),
.design-viewer .dv-stage.is-light-stage .dv-fs-btn:hover { background: rgba(0,0,0,0.14); }
.design-viewer .dv-stage.is-light-stage .dv-counter { color: rgba(0,0,0,0.45); }

/* ---------- Fullscreen button ---------- */
.design-viewer .dv-fs-btn:hover { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.32); }
.design-viewer .dv-fs-btn:active { transform: scale(0.92); }
.design-viewer .dv-fs-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.design-viewer .dv-fs-btn .dv-icon-collapse { display: none; }

/* Icon swap when fullscreen */
.design-viewer .dv-stage.is-fullscreen .dv-fs-btn .dv-icon-expand,
.design-viewer .dv-stage:fullscreen .dv-fs-btn .dv-icon-expand { display: none; }
.design-viewer .dv-stage.is-fullscreen .dv-fs-btn .dv-icon-collapse,
.design-viewer .dv-stage:fullscreen .dv-fs-btn .dv-icon-collapse { display: block; }

/* ---------- Fullscreen overlay toggles (top corners) ---------- */
.design-viewer .dv-fs-overlay { display: none; position: absolute; top: 16px; left: 16px; right: 16px; justify-content: space-between; align-items: center; pointer-events: none; z-index: 5; }
.design-viewer .dv-fs-overlay > * { pointer-events: auto; }
.design-viewer .dv-stage.is-fullscreen .dv-fs-overlay,
.design-viewer .dv-stage:fullscreen .dv-fs-overlay { display: flex; }

/* ---------- Fullscreen layout (CSS fallback + native) ----------
   Stage is a flex column: preview area grows to fill (flex: 1),
   then arrows and the bottom-row stack naturally below it. Static
   positioning means tall callouts can't slide back over the arrows. */
.design-viewer .dv-stage.is-fullscreen { position: fixed; inset: 0; z-index: 9999; height: 100vh; min-height: unset; width: 100vw; border-radius: 0; padding: 72px 0 0; justify-content: flex-start; overflow: hidden; gap: 10px; }
.design-viewer .dv-stage:fullscreen { min-height: unset; padding: 72px 0 0; border-radius: 0; justify-content: flex-start; overflow: hidden; gap: 10px; }

.design-viewer .dv-stage.is-fullscreen .dv-desktop-view,
.design-viewer .dv-stage:fullscreen .dv-desktop-view { width: 100%; max-width: min(1400px, calc((100vh - 72px - 92px - 32px - 16px) * 1.6)); padding: 0 48px; flex: 1 1 0; min-height: 0; justify-content: center; }
.design-viewer .dv-stage.is-fullscreen .dv-desktop-screen img,
.design-viewer .dv-stage:fullscreen .dv-desktop-screen img { width: 100%; height: auto; display: block; border-radius: 8px; }

.design-viewer .dv-stage.is-fullscreen .dv-mobile-view,
.design-viewer .dv-stage:fullscreen .dv-mobile-view { flex: 1 1 0; min-height: 0; }
.design-viewer .dv-stage.is-fullscreen .dv-phone,
.design-viewer .dv-stage:fullscreen .dv-phone { width: auto; height: 85%; }
.design-viewer .dv-stage.is-fullscreen .dv-phone .dv-phone-screen,
.design-viewer .dv-stage:fullscreen .dv-phone .dv-phone-screen { width: auto; height: 100%; aspect-ratio: 9/19.5; }
.design-viewer .dv-stage.is-fullscreen .dv-phone .dv-phone-screen img,
.design-viewer .dv-stage:fullscreen .dv-phone .dv-phone-screen img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }

.design-viewer .dv-stage.is-fullscreen .dv-mobile-arrows,
.design-viewer .dv-stage:fullscreen .dv-mobile-arrows { position: static; flex-shrink: 0; z-index: 2; }
.design-viewer .dv-stage.is-fullscreen .dv-bottom-row,
.design-viewer .dv-stage:fullscreen .dv-bottom-row { position: static; flex-shrink: 0; padding: 0 24px 16px; }

/* ---------- Responsive (≤ 768px) ---------- */
@media (max-width: 768px) {
  .design-viewer .dv-stage { padding: 20px 20px 16px; min-height: min(560px, 75vh); height: auto; position: relative; }
  .design-viewer .dv-bottom-row { padding-right: 16px; }
  .design-viewer .dv-desktop-view { width: 100%; }
  .design-viewer .dv-phone { width: auto; height: 100%; padding: 6px; border-radius: 28px; }
  .design-viewer .dv-phone .dv-phone-screen { width: auto; height: 100%; aspect-ratio: 9/19.5; border-radius: 22px; }
  .design-viewer .dv-phone .dv-phone-screen img { width: 100%; height: 100%; object-fit: cover; }
  .design-viewer .dv-controls { gap: 8px; flex-wrap: wrap; }
}

/* ---------- Bottom row (callouts + fs button inline) ---------- */
.design-viewer .dv-bottom-row { display: flex; align-items: flex-start; gap: 12px; width: 100%; flex-shrink: 0; padding: 0 24px 16px; }
.design-viewer .dv-callout-strip { display: flex; gap: 10px; flex: 1; }
.design-viewer .dv-callout-strip:empty { display: none; }
.design-viewer .dv-fs-btn { width: 32px; height: 32px; flex-shrink: 0; align-self: flex-end; border-radius: 8px; border: 0.5px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); color: #ffffff; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s cubic-bezier(0.32, 0.72, 0, 1), border-color 0.2s cubic-bezier(0.32, 0.72, 0, 1), transform 0.15s cubic-bezier(0.32, 0.72, 0, 1); padding: 0; flex-shrink: 0; }

.design-viewer .dv-callout {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 13px 15px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.design-viewer .dv-callout-num {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #555CF4;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.design-viewer .dv-callout-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.design-viewer .dv-callout-label {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.3;
  display: block;
}

.design-viewer .dv-callout-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.5;
  display: block;
}

.design-viewer .dv-stage.is-light-stage .dv-callout {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

.design-viewer .dv-stage.is-light-stage .dv-callout-label {
  color: rgba(0, 0, 0, 0.8);
}

.design-viewer .dv-stage.is-light-stage .dv-callout-text {
  color: rgba(0, 0, 0, 0.45);
}

@media (max-width: 768px) {
  /* Fullscreen button: top-right corner, always above the preview container */
  .design-viewer .dv-fs-btn { position: absolute; top: 12px; right: 12px; align-self: auto; z-index: 50; }
  /* Push the preview container down so its content never slides behind the fs button */
  .design-viewer .dv-desktop-view { padding-top: 36px; }
  .design-viewer .dv-mobile-view { padding-top: 36px; }

  .design-viewer .dv-callout-strip {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  .design-viewer .dv-bottom-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 0 16px 12px;
  }

  /* ── Fullscreen on mobile: restore fixed positioning and use natural
     column flow so arrows/callouts never overlap the phone frame ── */
  .design-viewer .dv-stage.is-fullscreen,
  .design-viewer .dv-stage:fullscreen {
    position: fixed;
    inset: 0;
    height: 100vh;
    padding: 64px 0 0;
    overflow-y: auto;
    overflow-x: hidden;
    justify-content: flex-start;
    gap: 8px;
  }
  .design-viewer .dv-stage.is-fullscreen .dv-mobile-view,
  .design-viewer .dv-stage:fullscreen .dv-mobile-view {
    flex: 0 0 auto;
    height: auto;
    padding: 0 16px;
  }
  .design-viewer .dv-stage.is-fullscreen .dv-phone,
  .design-viewer .dv-stage:fullscreen .dv-phone {
    height: min(62vh, 460px);
    width: auto;
  }
  .design-viewer .dv-stage.is-fullscreen .dv-mobile-arrows,
  .design-viewer .dv-stage:fullscreen .dv-mobile-arrows {
    position: static;
    flex-shrink: 0;
  }
  .design-viewer .dv-stage.is-fullscreen .dv-bottom-row,
  .design-viewer .dv-stage:fullscreen .dv-bottom-row {
    position: static;
    flex-shrink: 0;
    padding: 0 16px 24px;
  }
  /* In fullscreen, sit the fs button next to the dark-mode toggle
     (which the .dv-fs-overlay pins at right:16px, 34px wide).
     58px = 16px overlay offset + 34px toggle width + 8px gap. */
  .design-viewer .dv-stage.is-fullscreen .dv-fs-btn,
  .design-viewer .dv-stage:fullscreen .dv-fs-btn {
    position: absolute;
    top: 16px;
    right: 58px;
  }
}