/* ════════════════════════════════════════════════════════════════════════
   Partner portal — the LAYER family (MAR-2785, RFC-023 T5).

   The shared drawer and the A4 paper frame from pages/partner/_components.html,
   opened and closed by js/partner/ui.js. A native modal <dialog>: the
   browser gives it the top layer, makes the page behind inert and turns
   Escape into a cancel.

   Its OWN sheet, in the shared layer, per the convention portal.css states:
   a new overlay family gets its own portal.family.css rather than growing
   the overlay sheet. Shared because every partner screen that migrates to
   the components loads it.

   Deliberately NOT the invitations screen's drawer class: that screen keeps
   its own drawer until it migrates, and the split test allows exactly one
   owner per class. Every selector stands on its own class; tokens only.
   ══════════════════════════════════════════════════════════════════════ */

.pp-layer { border:0; padding:0; color:inherit; background:var(--bg-surface);
  box-shadow:var(--pp-float-shadow); }
.pp-layer::backdrop { background:var(--pp-scrim); }

/* the drawer: a right-hand panel the full height of the viewport */
.pp-layer--drawer { position:fixed; inset:0 0 0 auto; margin:0;
  width:min(480px, 100vw); max-width:100vw; height:100%; max-height:100%;
  border-radius:var(--r-lg) 0 0 var(--r-lg); }
/* display only while modal: an author display beats the UA's closed-dialog
   display:none on origin, so an unscoped flex would show a CLOSED drawer
   (the overlay sheet's modal rule carries the same trap and the same fix) */
.pp-layer--drawer:modal { display:flex; flex-direction:column;
  animation:pp-layer-slide-in var(--dur-base) var(--ease-out); }
/* MAR-3225: the drawer slides in from the right and its scrim fades; both
   scoped to :modal so the no-JS in-flow fallback below never moves. Keyframes
   rather than @starting-style transitions: closing a top-layer dialog through
   a transition needs `transition-behavior:allow-discrete` on `overlay`, which
   not every engine has. ui.js adds `.pp-layer--closing` and calls close() on
   animationend (with a timeout fallback), so the slide-out plays first.
   The keyframes are shared — the invitations screen's own drawer reuses them. */
@keyframes pp-layer-slide-in { from { transform:translateX(100%); } to { transform:none; } }
@keyframes pp-layer-slide-out { from { transform:none; } to { transform:translateX(100%); } }
@keyframes pp-layer-fade-in { from { opacity:0; } to { opacity:1; } }
@keyframes pp-layer-fade-out { from { opacity:1; } to { opacity:0; } }
.pp-layer--drawer:modal::backdrop { animation:pp-layer-fade-in var(--dur-base) var(--ease-out); }
/* `:modal` on the closing rules too: they must out-rank (or tie and follow)
   the opening rules, or the slide-in would win and nothing would slide out */
.pp-layer--closing:modal { animation:pp-layer-slide-out var(--dur-base) var(--ease-out) forwards; }
.pp-layer--closing:modal::backdrop { animation:pp-layer-fade-out var(--dur-base) var(--ease-out) forwards; }
/* portal.css turns off only `transition` under reduced motion, so an
   animation needs its own explicit override (portal.shell.css says why).
   Same specificity as the rules above and after them, so it wins. */
@media (prefers-reduced-motion: reduce) {
  .pp-layer--drawer:modal, .pp-layer--drawer:modal::backdrop,
  .pp-layer--closing:modal, .pp-layer--closing:modal::backdrop { animation:none; }
}
/* no-JS fallback: server-rendered open without showModal() sits in flow */
.pp-layer--drawer[open]:not(:modal) { position:static; width:auto; height:auto;
  max-height:none; margin:22px 0 0; border-radius:var(--r-lg);
  border:1px solid var(--rule); box-shadow:none; }

.pp-layer__hd { display:flex; align-items:flex-start; justify-content:space-between;
  gap:12px; padding:20px 20px 14px; border-bottom:1px solid var(--rule); }
.pp-layer__t { margin:0; font-size:19px; font-weight:600; letter-spacing:-.02em; }
.pp-layer__close { min-width:24px; min-height:24px; flex:none; }
/* the one scroller: min-height:0 lets a column item shrink below its content */
.pp-layer__bd { flex:1 1 auto; min-height:0; overflow:auto; padding:16px 20px 20px;
  display:flex; flex-direction:column; gap:12px; }
.pp-layer__bd > p { margin:0; }

/* a row that opens or navigates (clickable_row) */
tr[data-pp-row-href], tr[data-pp-open] { cursor:pointer; }
tr[data-pp-row-href]:focus-visible, tr[data-pp-open]:focus-visible {
  outline:2px solid var(--mp-navy); outline-offset:-2px; }

/* the A4 frame: portrait 210:297 paper, white page, soft shadow, scaled to
   whatever holds it */
.pp-a4 { margin:0; display:flex; justify-content:center; }
.pp-a4__page { width:100%; max-width:595px; aspect-ratio:210 / 297; overflow:auto;
  padding:24px; box-sizing:border-box; background:var(--bg-surface);
  border:1px solid var(--rule-soft); border-radius:var(--r-sm);
  box-shadow:var(--pp-float-shadow); }

/* MAR-2875: a filed document previewed on the page, and the worded stamp laid
   over it (EXPIRED) — the word is the signal, the colour only repeats it */
.pp-a4__page { position:relative; }
.pp-a4__doc { display:block; width:100%; height:100%; border:0; }
.pp-a4__stamp { position:absolute; top:18%; left:50%; margin:0;
  transform:translateX(-50%) rotate(-12deg); padding:6px 18px;
  border:3px solid var(--status-danger-fg); border-radius:var(--r-sm);
  color:var(--status-danger-fg); font-weight:800; font-size:28px;
  letter-spacing:.12em; text-transform:uppercase; pointer-events:none; }

/* MAR-3221: the sealed-PDF viewer (`_pdf_viewer.html`) — one canvas per page
   of the STORED bytes inside the A4 frame. A multi-page document stacks, so
   the frame's page drops its fixed 210:297 ratio here and grows with them. */
.pp-a4__page:has(> .pp-pdfv) { aspect-ratio:auto; overflow:visible; }
.pp-pdfv { display:flex; flex-direction:column; gap:12px; }
.pp-pdfv__page { display:block; width:100%; height:auto;
  box-shadow:0 0 0 1px var(--rule-soft); }
.pp-pdfv__status { margin:0; color:var(--text-muted); }
.pp-pdfv__open { align-self:flex-start; }
.pp-pdfv__open[hidden], .pp-pdfv__status[hidden] { display:none; }
/* MAR-3405: a page-limited viewer (`pages=N`, the CoP detail's "Sealed
   document" thumbnail) keeps its status line and its text fallback (name +
   doc label) compact. Scoped on the viewer's own attribute, so these rules
   stay in the sheet that owns the .pp-pdfv family. */
.pp-pdfv[data-pp-pdf-pages] { gap:6px; }
.pp-pdfv[data-pp-pdf-pages] .pp-pdfv__status { font-size:11px; color:var(--ink-2); }
.pp-pdfv__fallback { display:block; align-self:stretch; padding:8px 4px; }
.pp-pdfv__fallback[hidden] { display:none; }
.pp-pdfv-page { max-width:760px; margin:0 auto; }
.pp-pdfv-page__note { margin-top:12px; text-align:center; }

/* Print: the document only, one canvas per A4 page — no portal chrome. */
@media print {
  @page { size:A4; margin:0; }
  .pp-pdfv-page__back, .pp-pdfv-page__head, .pp-pdfv-page__note, .pp-pdfv__status, .pp-pdfv__open { display:none !important; }
  .pp-pdfv-page { max-width:none; margin:0; padding:0; }
  .pp-pdfv-page .pp-a4__page { max-width:none; padding:0; border:0;
    border-radius:0; box-shadow:none; background:none; }
  .pp-pdfv { gap:0; }
  .pp-pdfv__page { box-shadow:none; break-after:page; page-break-after:always; }
  .pp-pdfv__page:last-child { break-after:auto; page-break-after:auto; }
}

@media (max-width:700px) {
  .pp-layer--drawer { width:100vw; border-radius:0; }
  .pp-a4__page { padding:14px; }
}
