/* =====================================================================
 * PAC Benchmarking Portal -- export panel, preview and print stylesheet
 *
 * Three layers:
 *   1. the trigger button and options panel (screen only)
 *   2. the on-screen preview, styled as a page so what you see is what
 *      prints, which also makes it demonstrable without printing
 *   3. @media print, which hides the application and prints the document
 * ===================================================================== */

/* --- 1. trigger + options panel ----------------------------------------- */

.pac-exp-btn {
  padding: 9px 15px; background: #fff; color: #b11e3a; border: 1.5px solid #f5c0cc;
  border-radius: 8px; font-family: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; white-space: nowrap; align-self: flex-start; margin-left: auto;
}
.pac-exp-btn:hover { background: #fdf2f4; border-color: #b11e3a; }

.pac-exp-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 120;
}
.pac-exp-overlay.show { display: block; }

.pac-exp-panel {
  display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px);
  overflow-y: auto; background: #fff; border-radius: 14px; z-index: 121;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25); padding: 26px 28px 28px;
}
.pac-exp-panel.show { display: block; }
.pac-exp-head { display: flex; justify-content: space-between; align-items: flex-start; }
.pac-exp-head h3 { font-size: 17px; font-weight: 800; color: #1a1a1b; }
.pac-exp-x {
  background: none; border: none; font-size: 26px; line-height: 1; color: #95a5a6;
  cursor: pointer; padding: 0 2px;
}
.pac-exp-x:hover { color: #34495e; }
.pac-exp-intro { font-size: 13px; color: #5d7080; line-height: 1.6; margin: 8px 0 20px; }
.pac-exp-group { margin-bottom: 20px; }
.pac-exp-label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.7px; color: #95a5a6; margin-bottom: 9px;
}
.pac-exp-radio, .pac-exp-check {
  display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: #2c3e50;
  padding: 7px 10px; border-radius: 7px; cursor: pointer; line-height: 1.45;
}
.pac-exp-radio:hover, .pac-exp-check:hover { background: #f8f9fa; }
.pac-exp-radio input, .pac-exp-check input { margin-top: 2px; accent-color: #b11e3a; }
.pac-exp-check em { color: #7f8c8d; font-style: normal; }
.pac-exp-go {
  width: 100%; padding: 13px; background: #b11e3a; color: #fff; border: none;
  border-radius: 9px; font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.pac-exp-go:hover { background: #8b1730; }
.pac-exp-go:disabled { background: #95a5a6; cursor: default; }
.pac-exp-xl { margin-top: 8px; background: #fff; color: #b11e3a; border: 1px solid #b11e3a; }
.pac-exp-xl:hover { background: #fdf2f4; }
.pac-exp-xlnote { font-size: 12px; color: #7f8c8d; margin: 6px 0 0; }

/* --- 2. on-screen preview ----------------------------------------------- */

.pac-exp-preview {
  display: none; position: fixed; inset: 0; background: #52565b; z-index: 130; overflow-y: auto;
}
.pac-exp-preview.show { display: block; }
.pac-exp-bar {
  position: sticky; top: 0; z-index: 2; background: #2c3136; color: #fff;
  padding: 12px 20px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; font-size: 12.5px;
}
.pac-exp-bar strong { color: #fff; }
.pac-exp-bar > div { display: flex; gap: 8px; flex-shrink: 0; }
.pac-exp-print {
  padding: 9px 16px; background: #b11e3a; color: #fff; border: none; border-radius: 7px;
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.pac-exp-print:hover { background: #d22348; }
.pac-exp-close {
  padding: 9px 16px; background: rgba(255,255,255,0.12); color: #fff;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 7px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.pac-exp-close:hover { background: rgba(255,255,255,0.22); }
.pac-exp-page {
  background: #fff; max-width: 820px; margin: 28px auto 60px; padding: 54px 60px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

/* --- document body (shared by preview and print) ------------------------ */

#pacExpDoc { color: #1a1a1b; font-size: 12.5px; line-height: 1.6; }

.pex-cover { border-bottom: 3px solid #b11e3a; padding-bottom: 26px; margin-bottom: 30px; }
.pex-eyebrow {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
  color: #b11e3a; margin-bottom: 8px;
}
.pex-cover h1 { font-size: 23px; font-weight: 800; line-height: 1.25; margin-bottom: 20px; }
.pex-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 28px; margin-bottom: 20px;
}
.pex-meta div { display: flex; flex-direction: column; gap: 2px; }
.pex-meta span {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: #95a5a6;
}
.pex-meta strong { font-size: 13px; font-weight: 600; color: #2c3e50; }
.pex-handoff { background: #f8f9fa; border-radius: 9px; padding: 16px 18px; }
.pex-hrow {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 11px; font-size: 11.5px;
}
.pex-hrow > span:first-child {
  font-weight: 700; color: #5d7080; width: 88px; flex-shrink: 0;
}
.pex-hrow .pex-rule { flex: 1; border-bottom: 1px solid #adb5bd; height: 13px; }
.pex-handoff p { font-size: 11.5px; color: #5d7080; line-height: 1.6; margin-top: 4px; }

.pex-section { margin-bottom: 34px; }
.pex-sechead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  border-bottom: 1.5px solid #e0e4e9; padding-bottom: 7px; margin-bottom: 4px;
}
.pex-sechead h2 { font-size: 16.5px; font-weight: 800; color: #b11e3a; }
.pex-seccount { font-size: 10.5px; font-weight: 600; color: #95a5a6; white-space: nowrap; }
.pex-secdesc { font-size: 11.5px; color: #7f8c8d; margin-bottom: 18px; }

.pex-q { padding: 16px 0 18px; border-bottom: 1px solid #eef1f4; }
.pex-q:last-child { border-bottom: none; }
.pex-qnum {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  color: #95a5a6; margin-bottom: 4px;
}
.pex-new {
  background: #fdf2f4; color: #b11e3a; padding: 1px 6px; border-radius: 4px;
  font-size: 8.5px; letter-spacing: 0.5px; margin-left: 4px;
}
.pex-qtitle { font-size: 14px; font-weight: 700; line-height: 1.4; margin-bottom: 9px; }

/* The left rule is an inset shadow rather than a border. A border paints on
   the zero-height fragment Chromium leaves behind when the block's content
   moves to the next page, which shows up as a stray vertical line at the
   foot of the page. An inset shadow on a zero-height box paints nothing. */
.pex-def {
  background: #f8f9fa; box-shadow: inset 3px 0 0 #d6dce2; border-radius: 0 7px 7px 0;
  padding: 11px 15px; margin-bottom: 10px;
}
.pex-deflabel {
  display: block; font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: #95a5a6; margin-bottom: 5px;
}
.pex-def p { font-size: 11px; line-height: 1.62; color: #34495e; margin-bottom: 7px; }
.pex-def p:last-child { margin-bottom: 0; }

.pex-prior {
  font-size: 11px; color: #5d7080; background: #eaf3fb; border-radius: 6px;
  padding: 7px 12px; margin-bottom: 10px;
}
.pex-prior strong { color: #1a5276; }

.pex-answer { margin-top: 11px; }
.pex-alabel {
  display: block; font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: #b11e3a; margin-bottom: 7px;
}
.pex-line { border-bottom: 1px solid #adb5bd; height: 22px; }
.pex-fields { display: flex; flex-wrap: wrap; gap: 10px 26px; }
.pex-field { display: inline-flex; align-items: baseline; gap: 8px; }
.pex-flabel { font-size: 11px; font-weight: 600; color: #5d7080; }
.pex-box {
  display: inline-flex; align-items: baseline; gap: 4px; min-width: 120px;
}
.pex-box-wide { min-width: 220px; }
.pex-box .pex-rule { display: inline-block; flex: 1; border-bottom: 1px solid #adb5bd; height: 17px; }
.pex-affix { font-size: 11px; color: #7f8c8d; font-weight: 600; }
.pex-sublabel { font-size: 10.5px; color: #7f8c8d; margin: 9px 0 6px; }
.pex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 30px; }
.pex-grid-row { display: flex; align-items: baseline; gap: 9px; }
.pex-gname { font-size: 11px; color: #34495e; min-width: 118px; flex-shrink: 0; }
.pex-total {
  display: flex; align-items: baseline; gap: 9px; margin-top: 9px; padding-top: 8px;
  border-top: 1px solid #e0e4e9;
}
.pex-total .pex-gname { font-weight: 700; }
.pex-note { font-size: 10px; color: #95a5a6; }
.pex-opts { display: flex; flex-wrap: wrap; gap: 7px 22px; }
.pex-opt { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: #34495e; }
.pex-tick {
  width: 12px; height: 12px; border: 1.2px solid #7f8c8d; border-radius: 2px;
  display: inline-block; flex-shrink: 0;
}

/* --- 3. print ------------------------------------------------------------ */

@media print {
  /* Hide the application. Only the export document prints. */
  body > *:not(.pac-exp-preview) { display: none !important; }

  /* The app's grey page background otherwise prints as a filled block below
     the end of the document on the final page. */
  html, body { background: #fff !important; }

  .pac-exp-preview {
    display: block !important; position: static; background: #fff; overflow: visible;
  }
  .pac-exp-bar { display: none !important; }
  .pac-exp-page {
    max-width: none; margin: 0; padding: 0; box-shadow: none; background: #fff;
  }

  #pacExpDoc { font-size: 10.5pt; orphans: 2; widows: 2; }
  .pex-def p { orphans: 2; widows: 2; }

  /* Pagination. Questions are deliberately allowed to split: several PAC
     definitions run close to a full page on their own, so "keep the whole
     question together" strands most of a page above every long one and adds
     about 40% to the page count. What must not split is the answer space,
     and no heading may be left at the foot of a page without its content. */
  .pex-qnum, .pex-qtitle, .pex-alabel, .pex-sublabel,
  .pex-sechead, .pex-secdesc { break-after: avoid; page-break-after: avoid; }
  .pex-answer, .pex-fields, .pex-opts, .pex-total, .pex-prior {
    break-inside: avoid; page-break-inside: avoid;
  }
  .pex-grid-row, .pex-hrow { break-inside: avoid; page-break-inside: avoid; }
  .pex-cover { break-after: page; page-break-after: always; }

  /* Backgrounds carry meaning here (the definition block, the prior-year
     note), so ask the browser to keep them rather than print white boxes. */
  .pex-def, .pex-prior, .pex-handoff {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

@page { margin: 16mm 15mm; }
