/* BY THE STANDARD · the certificate, fixed for export
   ---------------------------------------------------------------------
   cert.css draws the certificate the way a SCREEN wants it: fluid, sized
   in clamp() against the viewport, and folded into a 3D flip. All three
   are wrong for a PDF.

   * `clamp(a, Nvw, b)` resolves against the VIEWPORT, not the element. An
     export rendered on a phone and the same export rendered on a desktop
     would be two different documents, and neither would be the artefact
     that was approved.
   * The flip relies on `preserve-3d` and `backface-visibility`, which
     html2canvas does not implement. The back face would come out blank or
     mirrored.

   So this file pins the card at the design's own maximum — 860 x 520, the
   size cert.css tops out at — and flattens the flip so each face can be
   rasterised on its own. Nothing here changes a measurement: every value
   is the upper bound of the matching clamp() in cert.css. If a clamp in
   cert.css changes, the matching value here has to change with it, and
   tools/check-cert-design.mjs will say so.

   Scoped to .cexport so it can only ever affect the offscreen export
   container — the live card on /profile is untouched. */

/* The export container. Two uses: parked offscreen in the live document
   (older approach, kept because it is also how the card is measured), and
   as the ROOT of the SVG <foreignObject> the PDF is actually rendered
   from. .cexport-page is the second case — inside the SVG there is no
   page to be offscreen from, so it must sit at the origin at full size. */
.cexport {
  position: fixed;
  left: -10000px;
  top: 0;
  /* Rendered at the real pixel size rather than scaled with a transform:
     html2canvas reads layout, not transforms, so a scaled container would
     rasterise at the unscaled size and come out soft. */
  width: 860px;
  background: #F2F2F0;
  /* Not display:none and not visibility:hidden — both stop layout, and a
     container with no layout has nothing to photograph. Parked offscreen
     is the only version of "invisible" that still measures. */
  pointer-events: none;
  z-index: -1;
}

.cexport .ccard { width: 860px; max-width: 860px; }

/* Flat, not folded. Each face becomes an ordinary block the renderer can
   see, and only one is in the box at a time (export.js hides the other). */
.cexport .ccert { width: 860px; height: 520px; perspective: none; cursor: default; }
.cexport .ccert-inner { position: static; transform: none !important; transform-style: flat; }
.cexport .ccert-face {
  position: static;
  width: 860px;
  height: 520px;
  transform: none !important;
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
  border-radius: 0;          /* a rounded corner on a PDF page is a white notch */
  border: 0;                 /* the page edge is the border */
}

/* ---- every clamp() in cert.css, pinned to its maximum --------------- */

.cexport .ccert-mark { width: 56px; }

.cexport .ccert-rail { padding: 28px 20px; }   /* width is a % + max-width, already deterministic */
.cexport .ccert-word { font-size: 20px; margin: 26px 0 0; }
.cexport .ccert-traits { font-size: 10.5px; }

.cexport .ccert-main { padding: 34px 38px; }
.cexport .ccert-kicker { font-size: 12px; margin: 0 0 18px; }
.cexport .ccert-title { font-size: 42px; margin: 0 0 22px; }
.cexport .ccert-label { font-size: 11.5px; }
.cexport .ccert-name { font-size: 29px; margin: 0 0 16px; }
.cexport .ccert-rule { margin: 0 0 18px; }
.cexport .ccert-for { font-size: 14px; }
.cexport .ccert-sub { font-size: 12px; }

.cexport .ccert-sigrow { gap: 30px; padding-top: 16px; }
.cexport .ccert-signame { font-size: 15px; }
.cexport .ccert-sigrole { font-size: 10.5px; }
.cexport .ccert-metaval { font-size: 15px; }
.cexport .ccert-metasub { font-size: 10.5px; }

.cexport .ccert-back { padding: 38px 42px; }
.cexport .ccert-backtop { margin-bottom: 30px; }
.cexport .ccert-word2 { font-size: 14px; }
.cexport .ccert-bname { font-size: 37px; margin: 0 0 16px; }
.cexport .ccert-confirm { font-size: 16px; margin: 0 0 26px; }
.cexport .ccert-rule2 { margin: 0 0 22px; }
.cexport .ccert-grid { gap: 24px 36px; overflow-y: visible; }   /* a scrollbar cannot be printed */
.cexport .ccert-flabel { font-size: 10.5px; }
.cexport .ccert-fval { font-size: 16px; }
.cexport .ccert-edu { font-size: 16px; }
.cexport .ccert-dsc { margin: 22px 0 0; margin-top: auto; padding-top: 16px; font-size: 9.4px; }
.cexport .ccert-dsc b { font-size: 8px; }

/* Never in an export: it is an instruction to the person at the screen. */
.cexport .ccert-hint { display: none; }

/* Inside the SVG. The foreignObject IS the page: no offscreen parking, no
   margins, and an explicit box so the flattened faces fill it exactly.
   
   The font-family here is not decoration. app.css sets the base typeface on
   `body`, and inside a foreignObject the root is this DIV — there is no
   body to inherit from, so every element that does not name a family of its
   own (which is most of the card) fell all the way through to the XML
   default and rendered in Times. On screen it was invisible because the
   real page does have a body; it only showed up in the export, as a
   certificate that looked like a court summons. */
.cexport.cexport-page {
  font-family: var(--txt);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  color: var(--fg);
  position: static;
  left: auto;
  width: 860px;
  height: 520px;
  margin: 0;
  overflow: hidden;
}
.cexport.cexport-page .ccard { margin: 0; }


/* ---- US LETTER, LANDSCAPE, FULL BLEED ------------------------------
   11 x 8.5in, ink to every edge.

   Two things make this a re-layout rather than a resize.

   First, the shape. The certificate's own ratio is 1.654:1 and Letter
   landscape is 1.294:1, so the artwork cannot simply be scaled into it —
   either it is cropped (losing the rail off one side and the certificate
   number off the other) or the layout is handed the taller canvas.

   Second, and this is what the first attempt got wrong: a canvas that is
   merely BIGGER is not a canvas that is FILLED. Scaling every measurement
   by the width ratio (1100/860 = 1.279) left the type looking small on a
   large sheet and dumped ~200px of dead air above the signature row,
   because .ccert-sigrow's margin-top:auto swallows all slack in one place.
   It read as a landscape certificate adrift on bigger paper.

   So the type is scaled by ~1.5x instead — a printed certificate is read
   from further away than a screen, and at this size it earns the sheet —
   and what slack remains is split between two gaps rather than pooling in
   one. The name is the largest thing on the page, which is correct: it is
   the reason the document exists. */
.cexport.cexport-letter,
.cexport.cexport-letter .ccard { width: 1100px; }
.cexport.cexport-letter { height: 850px; }
.cexport.cexport-letter .ccert,
.cexport.cexport-letter .ccert-face { width: 1100px; height: 850px; }

.cexport.cexport-letter .ccert-mark { width: 84px; }

/* The rail is sized to its own words, not scaled blindly: at 1.5x the
   type, "STANDARD" overran the black band and sat on the white. Measured
   against the box rather than eyeballed — 163px of word in 168px of rail. */
.cexport.cexport-letter .ccert-rail { max-width: 224px; padding: 42px 28px; }
.cexport.cexport-letter .ccert-word { font-size: 28px; margin: 38px 0 0; }
.cexport.cexport-letter .ccert-traits { font-size: 15.5px; }

.cexport.cexport-letter .ccert-main { padding: 51px 57px; }
.cexport.cexport-letter .ccert-kicker { font-size: 18px; margin: 0 0 26px; }
.cexport.cexport-letter .ccert-title { font-size: 63px; margin: 0 0 40px; }
.cexport.cexport-letter .ccert-label { font-size: 17px; margin: 0 0 9px; }
.cexport.cexport-letter .ccert-name { font-size: 50px; margin: 0 0 30px; }
.cexport.cexport-letter .ccert-rule { margin: 0 0 32px; }
/* The second gap. Without this the whole remainder pools above the
   signatures and the middle of the page falls out. */
.cexport.cexport-letter .ccert-for { font-size: 21px; margin: auto 0 7px; }
.cexport.cexport-letter .ccert-sub { font-size: 18px; }

.cexport.cexport-letter .ccert-sigrow { gap: 44px; padding-top: 30px; }
.cexport.cexport-letter .ccert-signame { font-size: 22.5px; }
.cexport.cexport-letter .ccert-sigrole { font-size: 16px; }
.cexport.cexport-letter .ccert-metaval { font-size: 22.5px; }
.cexport.cexport-letter .ccert-metasub { font-size: 16px; }

.cexport.cexport-letter .ccert-back { padding: 57px 63px; }
.cexport.cexport-letter .ccert-backtop { margin-bottom: 46px; }
.cexport.cexport-letter .ccert-word2 { font-size: 21px; }
.cexport.cexport-letter .ccert-bname { font-size: 55px; margin: 0 0 24px; }
.cexport.cexport-letter .ccert-confirm { font-size: 24px; margin: 0 0 40px; }
.cexport.cexport-letter .ccert-confirm .dot { width: 13px; height: 13px; }
.cexport.cexport-letter .ccert-rule2 { margin: 0 0 34px; }
.cexport.cexport-letter .ccert-grid { gap: 38px 54px; }
.cexport.cexport-letter .ccert-flabel { font-size: 15.5px; }
.cexport.cexport-letter .ccert-fval { font-size: 24px; }
.cexport.cexport-letter .ccert-edu { font-size: 24px; }
.cexport.cexport-letter .ccert-dsc { margin: 34px 0 0; margin-top: auto; padding-top: 24px; font-size: 14px; }
.cexport.cexport-letter .ccert-dsc b { font-size: 12px; }
