/* ==========================================================================
   Calicut University FYUGP Question Paper — A4 & 2-up A5 Preview/Print Styles
   ========================================================================== */

.paper-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  color: #000000;
  padding: 12mm 13mm 13mm;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.16);
  font-family: 'Times New Roman', Times, serif;
  font-size: 11pt;
  line-height: 1.32;
  position: relative;
}

/* Font Choices */
.paper-sheet.font-times { font-family: 'Times New Roman', Times, serif; }
.paper-sheet.font-georgia { font-family: Georgia, 'Times New Roman', serif; }
.paper-sheet.font-calibri { font-family: Calibri, 'Segoe UI', Arial, sans-serif; }

.paper-sheet.size-10 { font-size: 10pt; }
.paper-sheet.size-11 { font-size: 11pt; }
.paper-sheet.size-12 { font-size: 12pt; }
.paper-sheet.size-13 { font-size: 13pt; }

/* Compact Density (Fits theory papers on 1 A4 page) */
.paper-sheet.density-compact {
  padding: 9mm 11mm 10mm;
  line-height: 1.24;
}

.paper-sheet.density-compact .qp-header {
  margin-bottom: 5px;
}

.paper-sheet.density-compact .qp-affiliation {
  margin: 1px 0 3px;
}

.paper-sheet.density-compact .qp-program,
.paper-sheet.density-compact .qp-exam-title {
  margin: 1px 0;
}

.paper-sheet.density-compact .qp-course {
  margin: 2px 0 5px;
}

.paper-sheet.density-compact .qp-meta-table {
  margin-bottom: 6px;
}

.paper-sheet.density-compact .qp-meta-table td {
  padding: 3px 5px;
}

.paper-sheet.density-compact .qp-section {
  margin-top: 7px;
}

.paper-sheet.density-compact .qp-section-head {
  padding-bottom: 2px;
  margin-bottom: 4px;
}

.paper-sheet.density-compact .qp-q-table td {
  padding: 1.8px 3px;
}

.paper-sheet.density-compact .qp-q-body p {
  margin: 0 0 1.5px;
}

.paper-sheet.density-compact .qp-footer-end {
  margin-top: 10px;
}

/* Paper Header */
.qp-header {
  text-align: center;
  margin-bottom: 8px;
}

.qp-college {
  font-size: 1.15em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin: 0;
}

.qp-affiliation {
  font-size: 0.88em;
  font-style: italic;
  margin: 2px 0 4px;
}

.qp-program {
  font-size: 1em;
  font-weight: 700;
  text-transform: uppercase;
  margin: 2px 0;
}

.qp-exam-title {
  font-size: 1em;
  font-weight: 700;
  text-transform: uppercase;
  margin: 2px 0;
}

.qp-course {
  font-size: 1em;
  font-weight: 700;
  margin: 3px 0 6px;
}

/* Meta Bar */
.qp-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  border-top: 1.5px solid #000;
  border-bottom: 1.5px solid #000;
}

.qp-meta-table td {
  padding: 4px 6px;
  font-weight: 700;
  font-size: 0.94em;
}

.qp-meta-table td.right {
  text-align: right;
}

/* Styled FYUGP Accent Mode */
.paper-sheet.style-fyugp .qp-college {
  color: #1e3a8a;
}

.paper-sheet.style-fyugp .qp-meta-table {
  background: #eff6ff;
  border-color: #1e3a8a;
}

.paper-sheet.style-fyugp .qp-section-head {
  border-bottom: 1.5px solid #1e3a8a;
  color: #1e3a8a;
}

.paper-sheet.style-fyugp .qp-module-divider {
  color: #b91c1c;
}

/* Section Headers */
.qp-section {
  margin-top: 10px;
}

.qp-section-head {
  text-align: center;
  padding-bottom: 3px;
  margin-bottom: 6px;
}

.qp-section-name {
  font-weight: 700;
  font-size: 1.02em;
  display: block;
}

.qp-section-inst {
  font-weight: 700;
  font-size: 0.91em;
  display: block;
}

/* Module Divider */
.qp-module-divider {
  font-weight: 700;
  font-size: 0.9em;
  margin: 6px 0 3px;
  letter-spacing: 0.2px;
}

/* Questions List Table */
.qp-q-table {
  width: 100%;
  border-collapse: collapse;
}

.qp-q-table td {
  vertical-align: top;
  padding: 2.5px 4px;
}

.qp-q-num {
  width: 26px;
  font-weight: 400;
  white-space: nowrap;
}

.qp-q-body {
  text-align: left;
}

.qp-q-body p {
  margin: 0 0 2px;
}

.qp-q-body p:last-child {
  margin-bottom: 0;
}

/* Embedded Tables inside Questions */
.qp-inline-table {
  border-collapse: collapse;
  margin: 4px 0;
  font-size: 0.9em;
  width: auto;
  min-width: 55%;
}

.qp-inline-table th,
.qp-inline-table td {
  border: 1px solid #222;
  padding: 3px 6px;
  text-align: left;
}

.qp-inline-table th {
  background: #f1f5f9;
  font-weight: 700;
}

/* Inline Math Formatting */
.qp-math {
  font-family: 'Cambria Math', 'Times New Roman', serif;
  font-style: italic;
}

.qp-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  font-size: 0.85em;
  line-height: 1.05;
  margin: 0 2px;
}

.qp-frac-num {
  border-bottom: 1px solid currentColor;
  padding: 0 3px;
}

.qp-frac-den {
  padding: 0 3px;
}

.qp-footer-end {
  text-align: center;
  margin-top: 14px;
  font-size: 0.88em;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ==========================================================================
   2-Up A5 on 1 A4 Landscape Layouts (Save 50% Paper)
   ========================================================================== */

/* Mode A: Duplicate Copy (2 x A5 of same paper side-by-side) */
.paper-sheet.layout-2up-copy {
  width: 297mm;
  min-height: 210mm;
  padding: 7mm 8mm;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10mm;
  font-size: 8.8pt;
  line-height: 1.2;
}

.paper-sheet.layout-2up-copy .a5-half {
  position: relative;
}

.paper-sheet.layout-2up-copy .a5-half:first-child::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: -5mm;
  border-right: 1px dashed #94a3b8;
}

/* Mode B: 2-Page Spread (Page 1 | Page 2 flowing across 2 A5 columns) */
.paper-sheet.layout-2up-spread {
  width: 297mm;
  min-height: 210mm;
  height: 210mm;
  padding: 7mm 8mm;
  font-size: 8.8pt;
  line-height: 1.2;
  column-count: 2;
  column-gap: 10mm;
  column-rule: 1px dashed #94a3b8;
  column-fill: auto;
}

.paper-sheet.layout-2up-copy .qp-header,
.paper-sheet.layout-2up-spread .qp-header {
  margin-bottom: 4px;
}

.paper-sheet.layout-2up-copy .qp-meta-table,
.paper-sheet.layout-2up-spread .qp-meta-table {
  margin-bottom: 4px;
}

.paper-sheet.layout-2up-copy .qp-section,
.paper-sheet.layout-2up-spread .qp-section {
  margin-top: 5px;
}

.paper-sheet.layout-2up-copy .qp-q-table td,
.paper-sheet.layout-2up-spread .qp-q-table td {
  padding: 1.2px 2.5px;
}

.paper-sheet.layout-2up-copy .qp-q-num,
.paper-sheet.layout-2up-spread .qp-q-num {
  width: 20px;
}

/* Print Media Rules */
@media print {
  html, body {
    background: #ffffff !important;
    height: auto !important;
    overflow: visible !important;
  }

  .topbar,
  .mobile-tabs,
  .editor-pane,
  .preview-toolbar,
  .modal-backdrop,
  .toast {
    display: none !important;
  }

  .workspace {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .preview-pane {
    display: block !important;
    padding: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
  }

  .paper-sheet {
    width: 100% !important;
    min-height: auto !important;
    height: auto !important;
    padding: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .paper-sheet.layout-2up-spread {
    height: 194mm !important;
  }

  .qp-section-head,
  .qp-q-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
