/* Resources (PDF library) styles — loaded alongside /insights/assets/insights.css,
   which supplies all the shared tokens, header/footer, card, button, badge,
   form and admin-table styles. This file only adds what's specific to a
   PDF resource: the upload form, the review/preview area, the generated
   page's "looks like the PDF" reading view, and the pdf.js fallback viewer. */

/* ---- Upload form ---- */
.pdf-upload-field{
  border:2px dashed var(--border);border-radius:var(--radius);padding:1.5rem;text-align:center;background:var(--muted);
}
.pdf-upload-field input[type=file]{display:block;margin:0 auto;font-size:.9rem}
.pdf-upload-current{font-size:.85rem;color:var(--muted-foreground);margin-top:.5rem}

/* ---- Mode indicator on the admin's published-resources list ---- */
.badge-mode{background:var(--teal-soft);color:var(--teal-deep)}

/* ---- A resource post reads better wider than an ordinary blog column. ---- */
.wrap-wide{max-width:56rem;margin:0 auto;padding:0 1.25rem}

/* ---- Resource article header bits ---- */
.pdf-excerpt{font-size:1.08rem;color:var(--muted-foreground);margin:0 0 1.5rem}
.pdf-download-row{margin:1.25rem 0}
.pdf-download-row-bottom{border-top:1px solid var(--border);padding-top:1.75rem;margin-top:2.5rem}

/* ---- First/Previous/Next/Last page footer -- shown on every generated
   post/resource page (PDF or manual entry), see render_pagination_nav()
   in both apps' inc/render.php. Wraps on narrow screens; the disabled
   state (first page's "Previous", last page's "Next", or a single-page
   manual entry's Previous/Next) is a <span>, not a link, so it reads as
   unavailable rather than a dead click. */
.pdf-pagination{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.6rem;margin:2rem 0;padding-top:1.75rem;border-top:1px solid var(--border)}
.pdf-pagination-link.disabled{opacity:.4;cursor:default;box-shadow:none}
.pdf-pagination-link.disabled:hover{transform:none;background:transparent}
.pdf-pagination-status{font-size:.85rem;color:var(--muted-foreground);padding:0 .25rem;white-space:nowrap}

/* ---- "text" mode: a positioned, real-text reconstruction of each PDF page ----
   Each page is one fixed-size "sheet" (sized in pt, matching the PDF's own
   page size) holding absolutely-positioned real text spans, filled rects,
   rule lines and images -- not a picture of the page, actual selectable
   HTML styled to sit exactly where the PDF put it. */
.pdf-doc{width:100%}
/* The black page border lives on .pdf-sheet-wrap, not .pdf-sheet:
   .pdf-sheet is what gets transform:scale(--fit-scale)'d to fit narrow
   viewports, and a border on a scaled/transformed element gets resampled
   along with it, which can blur one edge into gray instead of solid
   black. .pdf-sheet-wrap is never transformed, so a border here always
   paints crisp. That in turn only works if the *wrap's own box* lands on
   a whole device pixel -- render.php now rounds the wrap's width to an
   integer px for exactly this reason (a raw PDF page width in points,
   e.g. A4's 595.32pt, almost never converts to a whole pixel). The wrap
   uses default content-box sizing, so the border sits *outside* its
   declared (pixel-rounded) width/height, with the sheet -- sized in pt,
   matching the wrap almost exactly but not sub-pixel-exactly -- flush
   against the inside of it. overflow:hidden trims that sub-pixel sliver
   and, more importantly, keeps .pdf-sheet's own box-shadow (a soft drop
   shadow around the page) from bleeding across the border itself and
   washing it out at the edge where the two would otherwise overlap. */
.pdf-sheet-wrap{margin:0 auto 1.5rem;border:1px solid #000;overflow:hidden}
.pdf-sheet-wrap:last-child{margin-bottom:0}
/* "Page layout: Single page" (see write_single_pdf_page() in inc/render.php,
   both insights/ and resources/) -- every PDF page's own reconstruction
   (each wrapped in its own .pdf-page-frame as it's concatenated) stacked
   top to bottom on one HTML page, with a small visible gap between them so
   each still reads as a distinct page, exactly like the original PDF. The
   gap is a small vertical space plus a light rule, not a hard page break --
   :first-child skips the gap above the very first page. */
.pdf-multi-page{width:100%}
.pdf-page-frame:not(:first-child){margin-top:2.5rem;padding-top:2.5rem;border-top:1px dashed var(--border,#d8d2c4)}
.pdf-sheet{position:relative;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,.15)}
/* The reconstruction positions text from the PDF's own glyph advances, so draw it the same way: no browser kerning or ligature substitution. */
.pdf-sheet{font-kerning:none;font-variant-ligatures:none;font-feature-settings:"kern" 0,"liga" 0,"clig" 0}
.pdf-sheet .pdf-run{position:absolute;white-space:pre;line-height:1;margin:0;-webkit-font-smoothing:antialiased}
/* A .pdf-para promoted to <h2> (see build_layout_mode_page_html() --
   paragraphs the PDF itself renders bold and meaningfully larger than body
   text are emitted as a real <h2> instead of a <div>, for SEO/structure).
   Every visual property (position, size, color, weight) is already set by
   the same inline style a .pdf-para div would carry -- the only thing an
   <h2> adds beyond that is the browser's default heading margin, which
   would shift it off its absolute top:/left: position and duplicate the
   spacing the PDF's own layout already accounts for. Reset that away so an
   .pdf-heading looks pixel-identical to the .pdf-para it replaced. */
.pdf-sheet .pdf-heading{margin:0;font:inherit;color:inherit}
/* A real (or admin-checked plain-text) hyperlink wrapping one or more
   .pdf-run spans (see build_layout_mode_page_html()) -- the <a> itself is
   an ordinary, unpositioned inline element; its .pdf-run child carries all
   the actual position/size/color styling, same as an unlinked run. Reset to
   inherit the run's own look (already colored/sized to match the PDF)
   rather than the browser's default link blue+underline.

   Because the .pdf-run child is position:absolute, the <a> itself
   contributes no in-flow content and collapses to a zero-size box
   wherever normal document flow happens to place it -- NOT at the
   .pdf-run's own absolute position. Chrome still paints that box's own
   text-decoration line (at that unrelated flow position, sized by the
   collapsed box rather than the visible run), so any text-decoration
   that survives on the <a> shows up as a stray underline/dash floating
   near -- not under -- the actual linked text, and can visually stretch
   well before or after it. `all:unset` alone isn't reliably enough to
   suppress that: a host page's own prose-link rule can still be MORE
   SPECIFIC than the single-class `.pdf-run-link` selector (e.g.
   Insights' "article.post .content a{text-decoration:underline}", at
   0,2,2 vs. this rule's 0,1,0) and wins on specificity regardless of
   load order, re-underlining the collapsed <a> box after `all:unset`
   reset it. !important on text-decoration closes that gap for good,
   whatever prose-link styling a page that loads this stylesheet adds
   later.

   The !important override has to live in its OWN rule, below, not
   appended into this same declaration block: a `text-decoration:none
   !important` written right after `all:unset` in one block gets
   silently dropped by the browser's parser (verified -- the computed
   style still comes out as the `all:unset`-reset value, not `none`,
   when the two are combined into a single rule). Two separate rules
   with the same selector cascade normally and the !important one
   wins as expected. */
.pdf-run-link{all:unset;cursor:pointer}
.pdf-run-link{text-decoration:none !important}
.pdf-sheet .pdf-rect{position:absolute}
.pdf-sheet .pdf-line{position:absolute}
.pdf-sheet .pdf-img{position:absolute;width:100%;height:100%;object-fit:fill}
/* a host page's prose rules for .content img (margin, radius, max-width) must never move or round a positioned PDF image */
.pdf-sheet .pdf-img{margin:0 !important;border-radius:0 !important;max-width:none !important}
/* A PDF-clipped image (see pdf_layout_extract()'s $onImage / build_layout_mode_html()):
   the wrapper is sized/positioned to the *visible* window the source PDF
   actually reveals and clips to it; the .pdf-img inside sits at its full,
   unclipped natural size/position (offset relative to this wrapper), so
   only the part the PDF meant to show shows here too. position:absolute
   here (rather than position:relative) both places the wrapper itself and
   -- since any non-static position establishes a containing block for
   absolutely-positioned descendants -- makes the inner .pdf-img position
   relative to *this* wrapper instead of the outer .pdf-sheet. */
.pdf-sheet .pdf-img-clip{position:absolute;overflow:hidden}
.pdf-sheet .pdf-path{position:absolute;overflow:visible}

/* ---- "image" mode: pdf.js-rendered canvases, one per PDF page (fallback
   for the rare PDF this reconstruction can't faithfully handle -- rotated/
   sheared content, or an image format we can't decode server-side). ---- */
.pdf-viewer{display:flex;flex-direction:column;align-items:center;gap:1.25rem;padding:1rem 0}
.pdf-viewer-pages{display:flex;flex-direction:column;align-items:center;gap:1.25rem;width:100%}
.pdf-page-canvas{max-width:100%;height:auto;border-radius:6px;box-shadow:0 4px 24px rgba(0,0,0,.12);border:1px solid var(--border)}
.pdf-viewer-status{padding:2rem 0}

/* ---- Admin review: preview + actions ---- */
.review-preview{max-height:70vh;overflow:auto;padding:1.5rem}
.pdf-source-embed{width:100%;height:70vh;border:1px solid var(--border);border-radius:var(--radius);background:var(--muted)}
.mode-note{font-size:.82rem;color:var(--muted-foreground);background:var(--muted);border-radius:.5rem;padding:.75rem 1rem;margin-bottom:1rem}
