/* =========================================================
   Deck viewer — minimal chrome, max focus on the slide.
   ========================================================= */

.viewer-body {
  background: var(--midnight-slate);
  color: var(--white);
  min-height: 100vh;
  /* Belt-and-braces: never let anything cause horizontal scroll on mobile.
     The shell should already fit but iOS Safari + aspect-ratio + flexbox
     has produced sub-pixel overflows in the past. */
  overflow-x: hidden;
  /* Disable text selection inside slides (prevents copy of text content) */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
/* Re-enable system cursor on viewer pages — no custom cursor here */
.viewer-body, .viewer-body a, .viewer-body button { cursor: default !important; }
.viewer-body .viewer-shell { cursor: pointer; }
.viewer-body button:hover { cursor: pointer !important; }
.viewer-body a { cursor: pointer !important; }

/* Top nav */
.viewer-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem var(--gutter);
  background: rgba(62, 73, 93, 0.75);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.viewer-back {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--sky-light);
  font-size: 0.875rem; font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.2s var(--ease-out-quart);
}
.viewer-back:hover { color: var(--sky); }
.back-arrow { font-size: 1.2rem; line-height: 1; }

.viewer-title-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.15rem;
  text-align: center;
}
.viewer-eyebrow {
  font-size: 0.65rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--sky);
}
.viewer-title {
  font-size: 1rem; font-weight: 600; color: var(--white);
  letter-spacing: -0.005em;
}

.viewer-controls {
  display: flex; align-items: center; gap: 1rem;
}
.vctrl {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--white);
  font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  transition:
    background 0.2s var(--ease-out-quart),
    transform 0.2s var(--ease-out-quart),
    border-color 0.2s var(--ease-out-quart);
}
.vctrl:hover {
  background: rgba(101, 149, 215, 0.22);
  border-color: var(--sky);
  transform: scale(1.05);
}
.vctrl:active { transform: scale(0.96); }
.vctrl[disabled] { opacity: 0.3; pointer-events: none; }
.vctrl-dl {
  width: auto; height: 36px; border-radius: 999px;
  padding: 0 14px; gap: 8px; font-size: 0.82rem;
  letter-spacing: 0.02em; font-weight: 600;
  text-decoration: none;
  background: rgba(101, 149, 215, 0.18);
  border-color: rgba(101, 149, 215, 0.38);
  color: var(--sky-light, #DDE4EB);
  margin-right: 0.4rem;
}
.vctrl-dl:hover { background: var(--sky, #6595D7); color: #fff; border-color: var(--sky, #6595D7); }
.vctrl-dl svg { display: block; }
.vctrl-dl[hidden] { display: none; }
.page-indicator {
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem; color: var(--sky-light);
  letter-spacing: 0.05em;
  min-width: 60px; text-align: center;
}

/* Stage */
.viewer-stage {
  min-height: 100vh;
  padding: 6rem 2rem 3rem;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.viewer-shell {
  position: relative;
  max-width: min(92vw, 1500px);
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 32px 64px -16px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  transition:
    transform 0.6s var(--ease-out-expo),
    box-shadow 0.6s var(--ease-out-expo);
}
#pdf-canvas {
  width: 100%; height: 100%; display: block;
  /* Disable right-click on canvas via JS, but also visually as a hint */
}
/* Image-mode surface — used for BFF (pre-rasterized JPGs). Displayed at
   shell size but retains its 2400px source resolution, so pinch-zoom on
   mobile scales the ORIGINAL pixels instead of an already-downsampled canvas.
   Text stays crisp at any zoom level, which is what LPs expect. */
#pdf-image {
  width: 100%; height: 100%; display: block;
  object-fit: contain; object-position: center;
  /* Let the browser choose its best downscaling algorithm (bilinear/bicubic).
     Do NOT set `crisp-edges` — that forces nearest-neighbor which is designed
     for pixel art and looks terrible on text/photos, especially on retina
     desktops where the source JPG has to be downscaled slightly. */
  image-rendering: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;  /* clicks go to shell for slide-advance */
}
#pdf-image[hidden] { display: none; }
.viewer-watermark {
  position: absolute; bottom: 14px; right: 18px;
  font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(62, 73, 93, 0.30); pointer-events: none;
  user-select: none;
  /* Never let the watermark wrap and eat the slide surface. */
  white-space: nowrap;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Loader */
.viewer-loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem;
  background: var(--midnight-slate);
  color: var(--sky-light);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  z-index: 10;
  transition: opacity 0.5s var(--ease-out-quart), visibility 0.5s var(--ease-out-quart);
}
.viewer-loader.hidden {
  opacity: 0; visibility: hidden;
}
.loader-mark {
  width: 80px; height: 80px;
  color: var(--sand);
  animation: loader-spin 6s linear infinite;
}
@keyframes loader-spin { to { transform: rotate(360deg); } }

/* Slide-change animation — barely visible, snappy */
.viewer-shell.is-changing {
  opacity: 0.85;
}
.viewer-shell { will-change: transform; }
#pdf-canvas { will-change: contents; }

/* Print + selection lockdown */
@media print { .viewer-stage { display: none; } body::after { content: 'This document is private and not available for print.'; display: block; padding: 4rem; text-align: center; font-size: 1.5rem; } }

/* =========================================================
   MOBILE — Keep the reader focused. Nav must not eat the slide.
   ========================================================= */
@media (max-width: 720px) {
  /* Header shrinks so the shell has more room. */
  .viewer-nav { padding: 0.7rem 0.9rem; gap: 0.5rem; }
  /* Hide the "Data Room" label — the arrow alone is unambiguous on mobile
     and buys us horizontal space for the title + controls. */
  .viewer-back span:not(.back-arrow) { display: none; }
  .viewer-back { padding: 0.25rem; }
  .back-arrow { font-size: 1.5rem; }
  /* Tighter title, one line, ellipsis if too long. */
  .viewer-title-wrap { flex: 1; min-width: 0; padding: 0 0.4rem; }
  .viewer-eyebrow { display: none; }
  .viewer-title {
    font-size: 0.82rem; line-height: 1.15;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
  }
  /* Controls stay compact — hide download label, chevrons + counter only. */
  .viewer-controls { gap: 0.35rem; }
  .vctrl { width: 32px; height: 32px; font-size: 1.15rem; }
  .vctrl-dl { padding: 0 8px; height: 32px; font-size: 0.72rem; }
  .vctrl-dl span { display: none; }
  .page-indicator { font-size: 0.78rem; min-width: 42px; }
  /* Stage gets less padding so the slide feels centered, not squeezed. */
  .viewer-stage {
    padding: 4.5rem 0.75rem 1.5rem;
    min-height: 100vh;
    /* Modern iOS also respects dynamic viewport units — falls back to 100vh. */
    min-height: 100dvh;
    box-sizing: border-box;
  }
  /* Explicitly size the shell on mobile so it can NEVER overflow the viewport.
     The width is min(viewport-width-minus-padding, viewport-height-minus-nav * 16/9).
     Whichever is smaller wins — the shell always fits both dimensions, and
     aspect-ratio 16/9 gives us the matching height. This is what was silently
     failing before: the base `max-width: min(92vw, 1500px) + width: 100%` was
     letting the shell exceed viewport height, and the canvas mapped from the
     stretched shell was overflowing right on tall portrait screens. */
  .viewer-shell {
    width: min(calc(100vw - 1.5rem), calc((100vh - 6.5rem) * 16 / 9));
    width: min(calc(100vw - 1.5rem), calc((100dvh - 6.5rem) * 16 / 9));
    max-width: none;
    margin: 0 auto;
  }
  /* Watermark: smaller + never wraps; on very small screens shorten to just
     "CONFIDENTIAL" so it doesn't dominate the slide. */
  .viewer-watermark {
    font-size: 0.55rem; letter-spacing: 0.12em;
    bottom: 8px; right: 10px;
    max-width: 55%;
  }
}
@media (max-width: 480px) {
  /* On phones, kill the "Silicon Badia · Private and" prefix — the tiny
     shell can't afford it. Keep just the CONFIDENTIAL badge. */
  .viewer-watermark { font-size: 0.52rem; }
  .viewer-watermark span.wm-full { display: none; }
}
