/* Fabio Santos Overview — slide viewer
   Dark shell, letterboxed 16:9 stage, chrome that fades when idle. */

:root {
  --bg: #0d0d0f;
  --bg-bar: rgba(13, 13, 15, 0.72);
  --fg: #f4f4f5;
  --fg-dim: #8b8b93;
  --accent: #d8f11f;
  --hairline: rgba(255, 255, 255, 0.12);

  --bar-h: 3.5rem;
  --stage-pad: 1.5rem;
  --chrome: calc(var(--bar-h) * 2 + var(--stage-pad) * 2);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.4 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.deck {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh; /* dvh, so collapsing mobile browser chrome never clips the slide */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- bars ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--bar-h);
  padding: 0 1rem;
  background: var(--bg-bar);
  backdrop-filter: blur(12px);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}

.bar-top { border-bottom: 1px solid var(--hairline); }
.bar-bottom { border-top: 1px solid var(--hairline); justify-content: flex-start; }

/* Chrome recedes while reading, returns on any input. */
.deck.idle .bar { opacity: 0; pointer-events: none; }
.deck.idle .bar-top { transform: translateY(-0.35rem); }
.deck.idle .bar-bottom { transform: translateY(0.35rem); }
.deck.idle .stage { cursor: none; }

.deck-mark {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  display: block;
  /* The mark carries its own padding, so pull the title back into optical range. */
  margin-right: -0.3rem;
}

.deck-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Anchors the bottom-right corner, opposite the controls. */
.bar-download { margin-left: auto; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.btn:hover { color: var(--fg); background: rgba(255, 255, 255, 0.07); }
.btn:disabled { opacity: 0.3; cursor: default; background: transparent; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-text { height: 2rem; padding: 0 0.625rem; font-size: 0.8125rem; }
.btn-icon { width: 2.25rem; height: 2.25rem; }

.btn-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.counter {
  margin: 0;
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
}

/* ---------- progress ---------- */

/* Spans the full page width, sitting on the bar's top edge, so the deck's
   position reads as one continuous rule rather than a cluster of ticks. */
.progress {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  gap: 2px;
}

.progress-step {
  flex: 1;                /* steps divide the width evenly, however many there are */
  height: 3px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

.progress-step:hover { background: rgba(255, 255, 255, 0.4); }
.progress-step[aria-current="true"] { background: var(--accent); }
.progress-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.bar-bottom { position: relative; }

/* ---------- stage ---------- */

.stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: var(--stage-pad);
  min-height: 0; /* lets the grid row actually shrink */
  touch-action: pan-y pinch-zoom;
}

/* Whichever runs out first, width or height, decides the size. */
.slide {
  position: relative;
  aspect-ratio: 16 / 9;
  width: min(100%, calc((100dvh - var(--chrome)) * 16 / 9));
  container-type: size;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.45);
}

.slide-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.18s var(--ease);
}

.slide-image.loading { opacity: 0; }

/* ---------- selectable text layer ---------- */
/* Invisible words pinned over the artwork so the slide can be selected and
   copied. Percentages come from the PDF word boxes, so it scales for free. */

.text-layer {
  position: absolute;
  inset: 0;
  line-height: 1;
  color: transparent;
  user-select: text;
}

.text-layer span {
  position: absolute;
  white-space: pre;
  transform-origin: 0 0;
  cursor: text;
}

.text-layer ::selection { background: rgba(216, 241, 31, 0.4); }

/* ---------- hint ---------- */

.stage-hint {
  position: absolute;
  bottom: 0.25rem;
  margin: 0;
  font-size: 0.75rem;
  color: var(--fg-dim);
  opacity: 0;
  animation: hint 5s var(--ease) forwards;
  pointer-events: none;
}

@keyframes hint {
  0%, 12% { opacity: 0; }
  25%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- narrow screens ---------- */

@media (max-width: 40rem) {
  :root { --bar-h: 3rem; --stage-pad: 0.75rem; }
  .btn-icon { width: 2.75rem; height: 2.75rem; } /* comfortable touch targets */
  .btn-text { display: none; }
  /* .progress stays visible now that it's full-bleed — it was hidden here only
     because fixed-width ticks crowded a narrow bar. */
  .counter { min-width: 5rem; }
  .slide { border-radius: 4px; }
}

/* Landscape phones: reclaim every pixel of height for the slide. */
@media (max-height: 30rem) and (orientation: landscape) {
  :root { --bar-h: 2.5rem; --stage-pad: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .stage-hint { opacity: 0; }
}

/* ---------- offscreen but readable ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.noscript {
  position: fixed;
  inset: auto 1rem 5rem;
  padding: 1rem;
  border-radius: 0.5rem;
  background: #1a1a1e;
  text-align: center;
}

.noscript a { color: var(--accent); }

/* ---------- print: one slide per page ---------- */

@media print {
  .bar, .stage-hint { display: none; }
  .deck { height: auto; display: block; }
  .slide { width: 100%; box-shadow: none; }
}
