/* ===========================================================================
   Dailies · PDF / Document Review  —  C-level Feed extension
   ---------------------------------------------------------------------------
   A faux "paper" asset (a shooting script) rendered with real, natively
   selectable text. The reviewer highlights a passage, drops a comment, and an
   anchored thread opens in the right margin rail (a bottom sheet on mobile)
   where other reviewers and the writer (IC) interact. Themed entirely from
   bsp-tokens.css / dailies-theme.css, loaded AFTER feed-styles.css so the
   .review--pdf layout wins the cascade over the image/video grid.
   =========================================================================== */

/* --- Card thumbnail: a small cream script page ---------------------------- */
.thumb.thumb-pdf {
  background: linear-gradient(160deg, #2a3942 0%, var(--bsp-navy) 100%);
  display: flex; align-items: center; justify-content: center;
}
.thumb-pdf .pg {
  width: 56%; height: 70%;
  background: #f6efe1;
  border-radius: 1px;
  box-shadow: 0 3px 10px -2px rgba(0, 0, 0, 0.5);
  padding: 9px 8px;
  display: flex; flex-direction: column; gap: 3.5px;
  transform: rotate(-1.5deg);
}
.thumb-pdf .pg i { display: block; height: 2px; border-radius: 1px; background: rgba(40, 55, 64, 0.32); }
.thumb-pdf .pg i.c { width: 42%; margin: 2px auto; background: rgba(40, 55, 64, 0.5); }
.thumb-pdf .pg i.s { width: 56%; }
.card.indexcard .thumb-pdf .pg { padding: 7px 6px; gap: 2.5px; }

/* Reviewed-session chip glyph for a document */
.ds-chip-glyph.kind-pdf { transform: rotate(45deg); }

/* --- Shell ----------------------------------------------------------------
   Reuse the .review slide-in panel, but force a deterministic flex column so
   the desktop `.review { display:grid }` rule does not impose the asset grid. */
.review--pdf { display: flex; flex-direction: column; }

.pdf-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  position: relative;            /* anchor the mobile bottom sheet + backdrop */
  overflow: hidden;
}

/* --- The document stage + paper sheet ------------------------------------- */
.pdf-doc {
  flex: 1; min-height: 0;
  overflow-y: auto;
  background: var(--bsp-bg-deep);
  padding: 20px 16px 64px;
  display: flex; flex-direction: column; align-items: center;
}
.pdf-ctx {
  width: 100%;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 auto 16px;
  font-size: 11px; color: var(--bsp-fg-dim);
  letter-spacing: 0.02em;
}
.pdf-ctx .ip {
  font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--bsp-yellow);
  padding: 3px 8px;
  border: 1px solid var(--bsp-border-gold);
  border-radius: var(--bsp-radius-pill);
  font-size: 9.5px;
}
.pdf-ctx .who strong { color: var(--bsp-fg-muted); font-weight: 500; }
.pdf-ctx .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--bsp-fg-dim); }

.pdf-page {
  width: 100%;
  background: #f6efe1;
  color: #25333b;
  font-family: var(--bsp-font-mono);
  font-size: 14.5px; line-height: 1.72;
  padding: clamp(28px, 5vw, 64px) clamp(22px, 5vw, 72px);
  border-radius: 2px;
  box-shadow: var(--bsp-shadow-lift);
  position: relative;
}
.pdf-page::selection,
.pdf-page ::selection { background: rgba(255, 200, 0, 0.45); color: #1a2329; }

.pdf-page-head { text-align: center; margin-bottom: 2.4em; }
.pdf-page-title {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 16px;
}
.pdf-page-sub { margin-top: 0.5em; font-size: 13px; color: #3c4c55; }
.pdf-page-slug {
  margin-top: 1.1em; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: #6a7780;
}
.pdf-page-foot {
  margin-top: 3em; padding-top: 1.1em;
  border-top: 1px solid rgba(40, 55, 64, 0.15);
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: #8a949b; text-align: right;
}

/* --- Screenplay typography ------------------------------------------------ */
.pdf-b { margin: 0; }
.pdf-b.scene {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  margin: 1.9em 0 0.7em;
}
.pdf-b.scene:first-of-type { margin-top: 0; }
.pdf-b.action { margin: 0.7em 0; }
.pdf-b.character { text-transform: uppercase; letter-spacing: 0.05em; margin: 1.1em 0 0 17ch; }
.pdf-b.paren { margin: 0 0 0 13ch; max-width: 30ch; color: #44545d; }
.pdf-b.dialogue { margin: 0 0 0 9ch; max-width: 40ch; }
.pdf-b.transition { text-transform: uppercase; letter-spacing: 0.06em; text-align: right; margin: 1.1em 0; }

/* --- Highlights (anchored to threads) ------------------------------------- */
.pdf-hl {
  background: rgba(255, 200, 0, 0.30);
  box-shadow: inset 0 -2px 0 0 rgba(220, 170, 0, 0.85);
  color: inherit; cursor: pointer; border-radius: 1px;
  padding: 0.5px 0; transition: background var(--bsp-dur-fast) var(--bsp-ease-out);
}
.pdf-hl:hover { background: rgba(255, 200, 0, 0.46); }
.pdf-hl.active {
  background: rgba(255, 200, 0, 0.62);
  box-shadow: inset 0 -2px 0 0 rgba(200, 150, 0, 1), 0 0 0 2px rgba(255, 200, 0, 0.35);
}
.pdf-hl.resolved {
  background: rgba(120, 140, 150, 0.20);
  box-shadow: inset 0 -2px 0 0 rgba(120, 140, 150, 0.55);
}
.pdf-hl.resolved.active { background: rgba(120, 140, 150, 0.36); }

/* --- Floating "Comment" button (on text selection) ------------------------ */
.pdf-add-btn {
  position: absolute; z-index: 320;
  transform: translate(-50%, calc(-100% - 12px));
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bsp-yellow); color: var(--bsp-accent-on);
  border: none; border-radius: var(--bsp-radius-pill);
  padding: 8px 13px; cursor: pointer;
  font-family: var(--bsp-font-body); font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: var(--bsp-shadow-gold), 0 6px 18px -6px rgba(0, 0, 0, 0.5);
  animation: pdf-pop 0.16s var(--bsp-ease-out);
}
.pdf-add-btn::after {
  content: ""; position: absolute; left: 50%; bottom: -5px;
  width: 10px; height: 10px; background: var(--bsp-yellow);
  transform: translateX(-50%) rotate(45deg); border-radius: 0 0 2px 0;
}
.pdf-add-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }
@keyframes pdf-pop { from { opacity: 0; transform: translate(-50%, calc(-100% - 4px)) scale(0.9); } }

/* --- The notes rail ------------------------------------------------------- */
.pdf-rail {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bsp-bg-deep);
}
.pdf-sheet-handle { display: none; }
.pdf-rail-head {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--bsp-border);
}
.pdf-rail-lbl {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--bsp-yellow);
}
.pdf-rail-count { font-size: 11px; color: var(--bsp-fg-dim); letter-spacing: 0.02em; }
.pdf-sheet-close {
  margin-left: auto; display: none;
  background: none; border: none; color: var(--bsp-fg-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.pdf-rail-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.pdf-rail-empty {
  font-size: 13px; line-height: 1.55; color: var(--bsp-fg-dim);
  font-weight: 300; padding: 8px 4px;
}

/* --- Thread card ---------------------------------------------------------- */
.pdf-card {
  background: var(--bsp-bg-elev);
  border: 1px solid var(--bsp-border);
  border-radius: var(--bsp-radius-1);
  padding: 13px 14px; cursor: pointer;
  transition: border-color var(--bsp-dur-fast) var(--bsp-ease-out),
              box-shadow var(--bsp-dur-fast) var(--bsp-ease-out);
}
.pdf-card:hover { border-color: var(--bsp-border-hi); }
.pdf-card.active {
  border-color: var(--bsp-border-gold);
  box-shadow: 0 0 0 1px var(--bsp-border-gold), var(--bsp-shadow-card);
  cursor: default;
}
.pdf-card.resolved { opacity: 0.72; }
.pdf-card.resolved.active { opacity: 1; }

.pdf-card-quote {
  font-style: italic; font-size: 12.5px; line-height: 1.5;
  color: var(--bsp-fg-dim);
  border-left: 2px solid var(--bsp-border-gold);
  padding-left: 9px; margin-bottom: 11px;
}
.pdf-card.resolved .pdf-card-quote { border-left-color: var(--bsp-border-hi); }

.pdf-resolved-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: #7fd1a8; margin-bottom: 10px;
}
.pdf-resolved-tag svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2.4; }

.pdf-c { display: flex; gap: 10px; margin-bottom: 11px; }
.pdf-c:last-child { margin-bottom: 0; }
.pdf-c-av {
  width: 27px; height: 27px; flex-shrink: 0;
  border-radius: var(--bsp-radius-pill);
  background: var(--bsp-navy-light); border: 1px solid var(--bsp-border-hi);
  color: var(--bsp-fg-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.04em;
}
.pdf-c-av.me { background: var(--bsp-yellow); color: var(--bsp-accent-on); border-color: var(--bsp-yellow); }
.pdf-c-body { min-width: 0; flex: 1; }
.pdf-c-head { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; margin-bottom: 2px; }
.pdf-c-head .n { font-size: 12px; font-weight: 500; color: var(--bsp-fg); }
.pdf-c-head .r { font-size: 10px; color: var(--bsp-fg-dim); }
.pdf-c-head .w { font-size: 10px; color: var(--bsp-fg-dim); margin-left: auto; }
.pdf-c-text { font-size: 13px; line-height: 1.5; color: var(--bsp-fg-muted); font-weight: 300; }

/* --- Composer ------------------------------------------------------------- */
.pdf-composer {
  display: flex; align-items: flex-end; gap: 7px;
  margin-top: 11px; padding-top: 11px;
  border-top: 1px solid var(--bsp-border);
}
.pdf-input {
  flex: 1; min-width: 0;
  background: var(--bsp-bg-card); border: 1px solid var(--bsp-border-hi);
  border-radius: 11px; color: var(--bsp-fg);
  font-family: var(--bsp-font-body); font-size: 13px; line-height: 1.45;
  padding: 8px 11px; resize: none; min-height: 38px; max-height: 140px;
  outline: none; transition: border-color var(--bsp-dur-fast) var(--bsp-ease-out);
}
.pdf-input:focus { border-color: var(--bsp-border-gold); }
.pdf-input::placeholder { color: var(--bsp-fg-dim); }
.pdf-mic, .pdf-send-c, .pdf-cancel {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 1px solid var(--bsp-border-hi); background: var(--bsp-bg-card);
  color: var(--bsp-fg-muted); transition: all var(--bsp-dur-fast) var(--bsp-ease-out);
}
.pdf-mic:hover, .pdf-cancel:hover { border-color: var(--bsp-border-hi); color: var(--bsp-fg); transform: translateY(-1px); }
.pdf-mic svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.pdf-send-c { background: var(--bsp-yellow); border-color: var(--bsp-yellow); color: var(--bsp-accent-on); }
.pdf-send-c svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.pdf-send-c:hover { background: var(--bsp-yellow-hi); border-color: var(--bsp-yellow-hi); transform: translateY(-1px); }
.pdf-send-c:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.pdf-cancel { width: 34px; height: 34px; font-size: 18px; line-height: 1; }

/* --- Card footer (resolve / reopen) --------------------------------------- */
.pdf-card-foot { display: flex; align-items: center; gap: 12px; margin-top: 11px; }
.pdf-resolve, .pdf-reopen {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; padding: 2px 0;
  font-family: var(--bsp-font-body); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; color: var(--bsp-fg-dim);
  transition: color var(--bsp-dur-fast) var(--bsp-ease-out);
}
.pdf-resolve:hover { color: #7fd1a8; }
.pdf-reopen:hover { color: var(--bsp-yellow); }
.pdf-resolve svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.2; }

/* --- Footer action bar ---------------------------------------------------- */
.pdf-foot {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px calc(env(safe-area-inset-bottom, 0px) + 16px);
  border-top: 1px solid var(--bsp-border);
}
.pdf-foot-meta { font-size: 12px; color: var(--bsp-fg-dim); display: flex; align-items: center; gap: 10px; }
.pdf-foot-meta strong { color: var(--bsp-fg-muted); font-weight: 600; }
.pdf-foot-open { color: var(--bsp-yellow); font-weight: 500; }
.pdf-foot-actions { display: flex; align-items: center; gap: 10px; }
.pdf-notes-toggle {
  background: var(--bsp-bg-card); border: 1px solid var(--bsp-border-hi);
  color: var(--bsp-fg-muted); border-radius: var(--bsp-radius-pill);
  padding: 9px 16px; cursor: pointer;
  font-family: var(--bsp-font-body); font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
}
.pdf-send-review {
  background: var(--bsp-yellow); border: 1px solid var(--bsp-yellow); color: var(--bsp-accent-on);
  border-radius: var(--bsp-radius-pill); padding: 9px 20px; cursor: pointer;
  font-family: var(--bsp-font-body); font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  transition: all var(--bsp-dur-fast) var(--bsp-ease-out);
}
.pdf-send-review:hover { background: var(--bsp-yellow-hi); border-color: var(--bsp-yellow-hi); transform: translateY(-1px); }

/* --- Mobile bottom sheet + backdrop --------------------------------------- */
.pdf-sheet-backdrop {
  position: absolute; inset: 0; z-index: 18;
  background: rgba(0, 0, 0, 0.5);
  animation: pdf-fade 0.25s var(--bsp-ease-out);
}
@keyframes pdf-fade { from { opacity: 0; } }

@media (max-width: 1099px) {
  /* The feed frame grows with its content, so the absolute panel would be
     taller than the screen — pin the document review to the viewport so the
     sheet and footer stay on-screen. */
  .review--pdf { position: fixed; inset: 0; height: 100dvh; }
  .pdf-notes-toggle { display: inline-flex; align-items: center; }
  .pdf-rail {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
    max-height: 76%;
    background: var(--bsp-bg-elev);
    border-top: 1px solid var(--bsp-border-hi);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, 0.7);
    transform: translateY(101%);
    transition: transform var(--bsp-dur-base) var(--bsp-ease-out);
    pointer-events: none;
  }
  .pdf-rail.sheet-open { transform: translateY(0); pointer-events: auto; }
  .pdf-sheet-handle {
    display: block; width: 40px; height: 4px; border-radius: 999px;
    background: var(--bsp-border-hi); margin: 9px auto 2px;
  }
  .pdf-sheet-close { display: block; }
  .pdf-rail-head { padding-top: 8px; }
}

@media (min-width: 1100px) {
  .pdf-notes-toggle { display: none; }
  .pdf-sheet-backdrop { display: none; }
  .pdf-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 384px;
    grid-template-rows: minmax(0, 1fr);
  }
  .pdf-rail { border-left: 1px solid var(--bsp-border); }
  .pdf-doc { padding: 32px 28px 80px; }
  .pdf-foot { padding: 16px 40px; }
}

/* --- Narrow screens: tighten screenplay indents so dialogue never clips --- */
@media (max-width: 560px) {
  .pdf-page { font-size: 13px; }
  .pdf-b.character { margin-left: 10ch; }
  .pdf-b.paren { margin-left: 7ch; max-width: none; }
  .pdf-b.dialogue { margin-left: 4ch; max-width: none; }
}

/* ===========================================================================
   Full-screen (theater) reading mode
   In-browser, not OS fullscreen: the panel already fills the viewport; here we
   drop the rail/header/footer, widen + enlarge the page to fit, and turn every
   thread into a highlight-anchored popover.
   =========================================================================== */

/* Floating "Full screen" pill — bottom-left of the document view */
.pdf-fs-fab {
  position: absolute; left: 16px; bottom: 16px; z-index: 16;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 15px;
  background: var(--bsp-bg-elev); border: 1px solid var(--bsp-border-hi);
  border-radius: var(--bsp-radius-pill); color: var(--bsp-fg);
  cursor: pointer;
  font-family: var(--bsp-font-body); font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em;
  box-shadow: var(--bsp-shadow-lift);
  transition: border-color var(--bsp-dur-fast) var(--bsp-ease-out),
              transform var(--bsp-dur-fast) var(--bsp-ease-out);
}
.pdf-fs-fab:hover { border-color: var(--bsp-border-gold); transform: translateY(-1px); }
.pdf-fs-fab svg { width: 15px; height: 15px; stroke: var(--bsp-yellow); fill: none; stroke-width: 2; }
@media (min-width: 1100px) {
  .pdf-fs-fab { left: 24px; bottom: 24px; padding: 11px 17px; font-size: 13px; }
}

/* Theater layout */
.review--pdf.fullscreen { position: fixed; inset: 0; }
.review--pdf.fullscreen .review-head,
.review--pdf.fullscreen .pdf-foot,
.review--pdf.fullscreen .pdf-rail,
.review--pdf.fullscreen .pdf-sheet-backdrop { display: none; }
.review--pdf.fullscreen .pdf-body { display: flex; flex-direction: column; }
.review--pdf.fullscreen .pdf-doc { padding: 72px clamp(16px, 4vw, 64px) 96px; }
.review--pdf.fullscreen .pdf-page {
  font-size: 16.5px; line-height: 1.82;
  padding: clamp(40px, 5vw, 88px) clamp(34px, 6vw, 104px);
}

/* Floating top bar (title + exit) */
.pdf-fs-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px calc(env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, rgba(var(--bsp-navy-rgb), 0.94) 30%, rgba(var(--bsp-navy-rgb), 0));
  pointer-events: none;
}
.pdf-fs-bar > * { pointer-events: auto; }
.pdf-fs-title {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--bsp-fg-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pdf-fs-exit {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  background: var(--bsp-bg-card); border: 1px solid var(--bsp-border-hi);
  color: var(--bsp-fg-muted); border-radius: var(--bsp-radius-pill);
  padding: 8px 14px; cursor: pointer;
  font-family: var(--bsp-font-body); font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
  transition: color var(--bsp-dur-fast) var(--bsp-ease-out), border-color var(--bsp-dur-fast) var(--bsp-ease-out);
}
.pdf-fs-exit:hover { color: var(--bsp-fg); border-color: var(--bsp-border-gold); }
.pdf-fs-exit svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ----- Anchored thread popover -----
   Preview (hover): 75% opacity, look-don't-touch. Pinned (click): full opacity
   and interactive. */
.pdf-pop {
  position: absolute; z-index: 38;
  opacity: 0.75;
  transition: opacity var(--bsp-dur-fast) var(--bsp-ease-out);
  animation: pdf-pop-in 0.14s var(--bsp-ease-out);
  cursor: pointer;
}
.pdf-pop.pinned { opacity: 1; cursor: default; }
.pdf-pop:not(.pinned) .pdf-card { pointer-events: none; }   /* preview = click to engage */
.pdf-pop .pdf-card {
  cursor: inherit;
  box-shadow: 0 20px 48px -16px rgba(0, 0, 0, 0.65), var(--bsp-shadow-card);
}
.pdf-pop .pdf-card-comments { max-height: 34vh; overflow-y: auto; }
.pdf-pop-close {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bsp-bg-card); border: 1px solid var(--bsp-border-hi);
  color: var(--bsp-fg-dim); font-size: 16px; line-height: 1; cursor: pointer;
}
.pdf-pop-close:hover { color: var(--bsp-fg); }
@keyframes pdf-pop-in {
  from { opacity: 0; transform: translateY(-4px); }
}
.pdf-pop.above { animation-name: pdf-pop-in-up; }
@keyframes pdf-pop-in-up {
  from { opacity: 0; transform: translateY(4px); }
}
