/* =============================================================
   /portfolio-preview viewer
   Builds on shared.css tokens. Slides are the owner's finished artwork:
   this file only frames and navigates them, it never restyles them.
   ============================================================= */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- header ---------- */
.pp-head { padding: clamp(48px, 8vw, 104px) 0 clamp(28px, 4vw, 48px); }
.pp-head .eyebrow { margin-bottom: 28px; }
.pp-title {
  font-size: var(--t-h-display);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  max-width: 16ch;
  margin-bottom: 24px;
  text-wrap: balance;
}
.pp-head .lede { margin: 0 0 32px; }
.pp-meta {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 16px 32px;
}
.pp-meta-size { text-transform: none; opacity: .8; }
.pp-updated {
  margin: 0;
  font-size: 12px; letter-spacing: var(--ls-mono); text-transform: uppercase;
  color: var(--fg-3);
}
.pp-updated time { color: var(--fg-2); }
.btn { min-height: 44px; }
.btn:focus-visible { box-shadow: var(--focus); }

/* ---------- viewer ---------- */
.pp-viewer { padding-bottom: clamp(56px, 8vw, 112px); }
.pp-carousel { position: relative; }

.pp-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}
.pp-toolbar[hidden] { display: none; }
.pp-count {
  margin: 0;
  font-size: 12px; letter-spacing: var(--ls-mono);
  color: var(--fg-3);
}
.pp-count [data-pp-current] { color: var(--fg); }
.pp-controls, .pp-lb-actions { display: flex; align-items: center; gap: 8px; }

.pp-btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 44px; height: 44px;
  padding: 0 10px;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 0;
  cursor: pointer;
  font: inherit;
  transition: border-color .15s, background .15s, color .15s;
}
.pp-btn svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: square; stroke-linejoin: miter;
}
.pp-btn .mono { font-size: 11px; letter-spacing: var(--ls-mono); text-transform: uppercase; }
.pp-btn:hover:not(:disabled) { border-color: var(--fg-3); background: var(--bg-2); }
.pp-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.pp-btn:disabled { color: var(--fg-4); cursor: default; opacity: .55; }
.pp-btn-wide { padding: 0 14px; }

/* the track works with or without JS: native swipe + scroll-snap */
.pp-track {
  list-style: none; margin: 0; padding: 0;
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 16px;
  align-items: start;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pp-track::-webkit-scrollbar { display: none; }
.pp-track:focus-visible { outline: none; box-shadow: var(--focus); }
.pp-slide { scroll-snap-align: start; scroll-snap-stop: always; min-width: 0; }
.pp-figure { margin: 0; }

.pp-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--placeholder-bg);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.pp-frame img { width: 100%; height: 100%; object-fit: contain; }
.pp-open {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  background: transparent; border: 0; padding: 0;
  cursor: zoom-in;
}
.pp-open[hidden] { display: none; }
.pp-open:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--accent); }

.pp-caption {
  display: flex; align-items: baseline; gap: 12px;
  padding: 14px 0 0;
  font-size: 15px; color: var(--fg);
}
.pp-caption-n { font-size: 12px; color: var(--accent); letter-spacing: var(--ls-mono); }

.pp-text { margin-top: 10px; border-top: 1px solid var(--rule-soft); }
.pp-text summary {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px;
  font-size: 11px; letter-spacing: var(--ls-mono); text-transform: uppercase;
  color: var(--fg-3);
  cursor: pointer;
  list-style: none;
}
.pp-text summary::-webkit-details-marker { display: none; }
.pp-text summary::before { content: "+"; font-size: 14px; width: 12px; color: var(--accent); }
.pp-text[open] summary::before { content: "−"; }
.pp-text summary:hover { color: var(--fg); }
.pp-text summary:focus-visible { outline: none; box-shadow: var(--focus); }
.pp-text-body { padding: 4px 0 8px; max-width: 68ch; }
.pp-text-h { font-size: 18px; margin: 0 0 8px; letter-spacing: -0.01em; }
.pp-text-body p { margin: 0; color: var(--fg-2); line-height: 1.6; }

/* ---------- thumbnails ---------- */
.pp-thumbs-nav { margin-top: 28px; border-top: 1px solid var(--rule); padding-top: 20px; }
.pp-thumbs {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.pp-thumb {
  display: block;
  color: var(--fg-3);
  transition: color .15s;
}
.pp-thumb img {
  width: 100%; height: auto;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--rule);
  opacity: .62;
  transition: opacity .15s, border-color .15s;
}
.pp-thumb-l {
  display: block; margin-top: 8px;
  font-size: 13px; line-height: 1.3;
}
.pp-thumb-l .mono { font-size: 11px; color: var(--fg-3); margin-right: 4px; }
.pp-thumb:hover { color: var(--fg); }
.pp-thumb:hover img { opacity: 1; }
.pp-thumb[aria-current="true"] { color: var(--fg); }
.pp-thumb[aria-current="true"] img { opacity: 1; border-color: var(--accent); }
.pp-thumb[aria-current="true"] .mono { color: var(--accent); }
.pp-thumb:focus-visible { outline: none; box-shadow: var(--focus); }

@media (max-width: 900px) {
  .pp-thumbs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 12px; }
}
@media (max-width: 600px) {
  /* outreach links are mostly opened on phones: get the first slide above the fold */
  .pp-head { padding: 28px 0 20px; }
  .pp-head .eyebrow { margin-bottom: 14px; }
  .pp-title { font-size: 34px; margin-bottom: 12px; }
  .pp-head .lede { font-size: 17px; margin-bottom: 20px; }
  .pp-lede-hint { display: none; }
  .pp-meta { gap: 12px; }
  .pp-meta .btn-row { gap: 8px; flex-wrap: nowrap; }
  .pp-meta .btn { padding: 10px 12px; }
  .pp-meta-size { display: none; } /* size stays in the link's accessible name via the visually hidden copy */
  .pp-toolbar { padding: 10px 0; }
  .pp-track { gap: 12px; }
  .pp-btn-wide .mono { display: none; }
  .pp-btn-wide { padding: 0 10px; }
  .pp-thumbs {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 42%;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .pp-thumbs::-webkit-scrollbar { display: none; }
  .pp-thumbs li { scroll-snap-align: start; }
  .pp-meta { align-items: stretch; }
  .pp-meta .btn-row { width: 100%; }
  .pp-meta .btn { flex: 1 1 0; justify-content: center; min-width: 0; }
}

/* ---------- full-screen lightbox ---------- */
.pp-lightbox {
  /* always dark, whatever the site theme, so its own tokens are pinned here */
  --bg:    oklch(10% 0.004 60);
  --bg-2:  oklch(17.5% 0.004 60);
  --rule:  #232b44;
  --fg:    oklch(96% 0.003 60);
  --fg-2:  oklch(78% 0.004 60);
  --fg-3:  oklch(66% 0.004 60);
  --fg-4:  oklch(55% 0.004 60);
  --accent: #7fc8ff;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; max-height: none;
  margin: 0; padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}
.pp-lightbox[open] { display: grid; grid-template-rows: auto 1fr auto; }
.pp-lightbox::backdrop { background: oklch(8% 0.004 60 / .92); }
.pp-lightbox:fullscreen { width: 100vw; height: 100vh; }

.pp-lb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--rule);
}
.pp-lb-title {
  margin: 0; min-width: 0;
  font-size: 12px; letter-spacing: var(--ls-mono);
  color: var(--fg-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pp-lb-t { color: var(--fg); text-transform: none; }
.pp-lb-zoom {
  margin: 0; min-width: 44px; text-align: center;
  font-size: 11px; letter-spacing: var(--ls-mono); color: var(--fg-2);
}
.pp-lb-sep { width: 1px; height: 24px; background: var(--rule); margin: 0 2px; }

.pp-lb-stage {
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  touch-action: pan-x pan-y pinch-zoom;
  scrollbar-color: var(--fg-4) transparent;
}
.pp-lb-stage.is-zoomed { cursor: grab; }
.pp-lb-stage.is-zoomed .pp-lb-img { cursor: zoom-out; }
.pp-lb-stage.is-dragging, .pp-lb-stage.is-dragging .pp-lb-img { cursor: grabbing; }
.pp-lb-img {
  display: block;
  flex: none;
  margin: auto; /* centres when smaller than the stage; auto margins collapse to 0 on overflow so nothing is clipped */
  max-width: none;
  user-select: none; -webkit-user-select: none;
  background: var(--placeholder-bg);
}
.pp-lb-stage:not(.is-zoomed) .pp-lb-img { cursor: zoom-in; }
.pp-lb-hint {
  margin: 0;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  font-size: 11px; letter-spacing: var(--ls-mono);
  color: var(--fg-3); text-align: center;
}
@media (max-width: 600px), (pointer: coarse) {
  .pp-lb-hint { display: none; }
  .pp-lb-sep { display: none; }
  .pp-lb-actions { gap: 4px; }
  .pp-lb-title .pp-lb-t { display: none; }
}
/* short phones (e.g. 375x667, 320x568): drop the lede so the first slide still lands above the fold */
@media (max-width: 600px) and (max-height: 700px) {
  .pp-head { padding-top: 20px; }
  .pp-head .lede { display: none; }
  .pp-title { font-size: 30px; }
}

@media (max-width: 380px) {
  .pp-lb-zoom { display: none; }
  /* shared nav overflows at 320px site-wide; contained here only for this page (see docs/portfolio-preview.md) */
  .pp-page .nav-links { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .pp-track { scroll-behavior: auto; }
}

@media print {
  .nav, .pp-toolbar, .pp-thumbs-nav, .pp-text summary, .pp-lightbox, footer.site { display: none !important; }
  .pp-track { display: block; overflow: visible; }
  .pp-slide { break-inside: avoid; margin-bottom: 16px; }
  .pp-text { display: none; }
}
