/* A question paper or practice set as a web page (utils/webPapers.js), drawn
   in the Sevnty9 question paper design. It sits on top of note-page.css,
   which supplies the site bar, the toolbar and the printed letterhead. */
.is-paper {
  --pq-desk: #e7eaf3;
  --pq-ink: #1b1f33;
  --pq-muted: #5b6178;
  --pq-navy: #1b2a78;
  --pq-gold: #f2b705;
  --pq-line: #d6dbea;
  --pq-tint: #f3f5fb;
  --pq-display: "Montserrat", "Segoe UI", Arial, sans-serif;
  --pq-body: "Source Sans 3", "Segoe UI", Arial, sans-serif;
}
#note-page.is-paper { background: var(--pq-desk); }

/* ---------- The sheet ---------- */
.is-paper .pq-sheet {
  position: relative; overflow: hidden; background: #fff; color: var(--pq-ink);
  border: 0; border-radius: 2px; padding: 40px clamp(18px, 6vw, 64px) 28px;
  box-shadow: 0 1px 2px rgba(10, 20, 60, .08), 0 18px 40px -12px rgba(10, 20, 60, .25);
  font-family: var(--pq-body); font-size: 15px; line-height: 1.5;
}
.is-paper .pq-sheet::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: min(70%, 520px); aspect-ratio: 1;
  transform: translate(-50%, -50%); background: url("/assets/images/optimized/sevnty9-logo.webp") center / contain no-repeat;
  opacity: .06; pointer-events: none;
}
.is-paper .pq-sheet > * { position: relative; }

/* Letterhead on screen */
.pq-lh { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.pq-brand { display: flex; align-items: center; gap: 14px; }
.pq-brand img { width: 64px; height: auto; }
.pq-brand__name { font-family: var(--pq-display); font-weight: 800; font-size: clamp(26px, 4vw, 34px); letter-spacing: .12em; color: var(--pq-navy); line-height: 1; }
.pq-brand p { margin: 6px 0 0; font-family: var(--pq-display); font-weight: 700; font-size: 10.5px; letter-spacing: .28em; color: var(--pq-ink); }
.pq-contact { text-align: right; font-size: 13px; color: var(--pq-muted); line-height: 1.45; }
.pq-rules { margin: 18px 0 0; height: 9px; border-top: 4px solid var(--pq-navy); border-bottom: 2px solid var(--pq-gold); }

/* Paper heading */
.pq-title { text-align: center; margin: 22px 0 14px; }
.pq-eyebrow { font-family: var(--pq-display); font-weight: 700; letter-spacing: .2em; font-size: 12px; color: var(--pq-muted); }
#note-page .pq-title h1 { margin: 6px 0 2px; font-family: var(--pq-display); font-weight: 800; font-size: clamp(20px, 3.2vw, 26px); line-height: 1.25; color: var(--pq-navy); text-wrap: balance; }
.pq-sub { font-weight: 600; }
.pq-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 14px; font-size: 13px; }
.pq-pid { font-variant-numeric: tabular-nums; color: var(--pq-muted); letter-spacing: .06em; }
.pq-subcode { text-align: right; font-weight: 700; }
.pq-roll { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 16px; font-weight: 700; font-size: 13px; }
.pq-boxes { display: flex; }
.pq-boxes i { width: 20px; height: 22px; border: 1px solid var(--pq-ink); border-left: none; }
.pq-boxes i:first-child { border-left: 1px solid var(--pq-ink); }
.pq-facts { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 0; margin-top: 10px; border-top: 1px solid var(--pq-line); border-bottom: 1px solid var(--pq-line); font-weight: 700; }
.pq-facts em { font-style: normal; color: var(--pq-navy); }
.pq-note { margin: 10px 0 0; font-size: 14px; }
.pq-note b { color: var(--pq-navy); }
.pq-note ol { margin: 4px 0 0; padding-left: 20px; }

/* Sections and questions */
.pq-section { margin-top: 26px; }
#note-page .pq-section > h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 4px; font-family: var(--pq-display); font-size: 14px; letter-spacing: .24em; color: var(--pq-navy); break-after: avoid; }
.pq-section > h2::after { content: ""; flex: 1; height: 2px; background: var(--pq-gold); }
.pq-q { margin-top: 14px; }
.pq-qhead { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 6px; font-weight: 700; break-after: avoid; }
.pq-qhead .n { color: var(--pq-navy); margin-right: 6px; font-variant-numeric: tabular-nums; }
.pq-qhead .marks { font-variant-numeric: tabular-nums; white-space: nowrap; background: var(--pq-tint); color: var(--pq-navy); padding: 1px 10px; border-radius: 999px; font-size: 13px; }
.pq-tw { overflow-x: auto; }
.pq-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.pq-table th, .pq-table td { border: 1px solid var(--pq-line); padding: 7px 10px; vertical-align: top; text-align: left; overflow-wrap: anywhere; }
.pq-table th { background: var(--pq-navy); color: #fff; font-family: var(--pq-display); font-weight: 700; font-size: 11.5px; letter-spacing: .1em; border-color: var(--pq-navy); }
.pq-table th:first-child { width: 56px; white-space: nowrap; }
.pq-table th.c, .pq-table td.c { text-align: center; width: 64px; font-variant-numeric: tabular-nums; }
.pq-table td.o { width: 48px; color: var(--pq-navy); font-weight: 700; white-space: nowrap; }
.pq-table tbody tr:nth-child(even) td { background: rgba(27, 42, 120, .035); }
.pq-table td p { margin: 0; }
.pq-table td p + p { margin-top: 6px; }
.pq-table tr { break-inside: avoid; }
.pq-code { margin: 6px 0 0; padding: 8px 10px; background: var(--pq-tint); border-radius: 4px; overflow-x: auto; font: 13px/1.45 Consolas, "Courier New", monospace; white-space: pre; }
.pq-options { display: grid; gap: 5px; list-style: none; margin: 9px 0 2px; padding: 0; }
.pq-option { display: grid; grid-template-columns: minmax(18px, max-content) minmax(0, 1fr); align-items: baseline; gap: 7px; break-inside: avoid; }
.pq-option__label { font-weight: 700; color: var(--pq-navy); }
.pq-option__text { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.pq-answer-choice > span { font-weight: 700; }
.pq-explanation { margin-top: 8px; }
.pq-explanation > strong { display: block; font-size: 12px; margin-bottom: 3px; }
.pq-table tr.pq-ans td { background: #f6fbf7; border-top: 0; color: #1f3d2b; }
.pq-table tr.pq-ans b { display: block; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: #22603a; margin-bottom: 2px; }
.pq-hide-answers .pq-ans { display: none; }

.pq-foot { margin-top: 36px; padding-top: 10px; border-top: 1px solid var(--pq-gold); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; }
.pq-foot b { color: var(--pq-navy); font-family: var(--pq-display); letter-spacing: .04em; }

/* Toolbar: the answers switch sits opposite the Print button. */
.is-paper .np-toolbar { align-items: stretch; gap: 12px; margin-bottom: 18px; }
.is-paper .np-print { min-height: 44px; justify-content: center; }
.pq-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--np-line); border-radius: 10px; background: #fff; font-weight: 600; font-size: 14px; color: var(--np-dark); cursor: pointer; }
.pq-toggle input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--np-blue); }
.pq-toggle { min-height: 44px; }
.is-paper .np-print:focus-visible,
.pq-toggle:has(input:focus-visible) { outline: 3px solid var(--np-blue); outline-offset: 3px; }

@media screen and (max-width: 420px) {
  .is-paper .np-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .is-paper .np-toolbar > * { width: 100%; margin-left: 0; justify-content: center; }
}

@media screen and (max-width: 520px) {
  .pq-contact, .pq-subcode { text-align: left; }
  .pq-brand p { letter-spacing: .14em; font-size: 9.5px; }
  .is-paper .pq-sheet { padding: 24px 14px 20px; }
  .pq-brand img { width: 48px; }
  .pq-table { font-size: 14px; table-layout: fixed; }
  .pq-table th, .pq-table td { padding: 6px 6px; }
  .pq-table th.c, .pq-table td.c { width: 44px; }
  .pq-table th:first-child { width: 42px; }
  .pq-table th { font-size: 10px; letter-spacing: .02em; padding: 6px 4px; }
  .pq-table td.c { padding: 6px 2px; }
  .pq-table td.o { width: 34px; }
  .pq-boxes i { width: 16px; height: 20px; }
}

/* ================= PRINT ================= */
@media print {
  #note-page.is-paper { background: #fff !important; }
  /* The letterhead printed on every sheet replaces the one drawn on screen,
     and the page footer replaces the sheet's own. */
  .pq-lh, .pq-rules, .pq-foot { display: none !important; }
  /* Transparent and unpositioned, so the letterhead and the watermark behind it show through. */
  .is-paper .pq-sheet { position: static; background: transparent; box-shadow: none; padding: 0; overflow: visible; font-family: Arial, Helvetica, sans-serif; font-size: 10.5pt; }
  .is-paper .pq-sheet > * { position: static; }
  .is-paper .pq-sheet::before { display: none; }
  .pq-title { margin-top: 0; }
  #note-page .pq-title h1 { font-size: 16pt; }
  .pq-eyebrow, .pq-section > h2, .pq-table th, .pq-foot b { font-family: Arial, Helvetica, sans-serif; }
  .pq-table { font-size: 10pt; }
  .pq-table th, .pq-table td { padding: 1.4mm 2mm; }
  .pq-tw { overflow: visible; }
  /* A group can contain a whole mixed-format paper. Let it span sheets;
     individual table rows keep each question and its choices together. */
  .pq-q { break-inside: auto; }
  .pq-code { white-space: pre-wrap; font-size: 9pt; }
  .pq-options { display: grid; gap: 1.2mm; margin-top: 1.5mm; }
  .pq-option { break-inside: avoid; }
}

@media screen {
  #note-page.practice-reader { background:#fff; }
  .practice-reader .np-page { max-width:960px; margin:auto; }
  .practice-reader .pq-sheet { padding:14px 0; box-shadow:none; overflow:visible; font-family:inherit; }
  .practice-reader :is(.pq-lh,.pq-rules,.pq-foot,.pq-table thead) { display:none; }
  .practice-reader .pq-title { text-align:left; }
  .practice-reader .pq-table, .practice-reader .pq-table tbody { display:block; }
  .practice-reader .pq-table tr { display:flex; flex-wrap:wrap; padding:8px 0; border-bottom:1px solid var(--pq-line); background:transparent; }
  .practice-reader .pq-table td { border:0; background:transparent; padding:3px 6px; }
  .practice-reader .pq-table td:nth-child(2) { flex:1; }
  .practice-reader .pq-table td.c { width:auto; }
  .practice-reader .pq-ans td:first-child { display:none; }
  .practice-reader .pq-ans td { padding-left:2.5em; }
  .practice-reader.pq-hide-answers .pq-table tr.pq-ans, .practice-reader .pq-hide-answers .pq-table tr.pq-ans { display:none; }
}

@media screen {
  .practice-reader .np-bar__inner { justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
  .practice-reader .np-bar__brand strong { font-size: 16px; }
  .practice-controls, .practice-controls .np-tools { display: flex; align-items: center; gap: 6px; }
  .practice-controls { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .practice-controls .np-tools { flex-wrap: nowrap; width: auto; margin: 0; }
  .practice-controls .pq-toggle, .practice-controls .np-print { padding: 4px 10px; gap: 5px; font-size: 13px; }
  #note-page .practice-controls .np-language { display: inline-flex; margin: 0; gap: 0; padding: 1px; }
  #note-page .practice-controls .np-language :is(a, button) { min-width: 44px; min-height: 40px; padding: 4px 7px; color: var(--np-dark); }
  #note-page .practice-controls .np-language [aria-current="page"] { color: var(--np-blue); }
}
@media screen and (max-width: 540px) {
  .practice-reader .np-bar__inner { padding: 4px 6px; gap: 4px; }
  .practice-controls, .practice-controls .np-tools { gap: 3px; }
  .practice-controls .pq-toggle, .practice-controls .np-print { font-size: 12px; padding: 3px 5px; }
  .practice-controls .pq-toggle { max-width: 78px; line-height: 1.15; }
  .practice-controls .pq-toggle input { width: 15px; height: 15px; flex-shrink: 0; }
  .practice-controls .np-print { min-width: 44px; }
  .practice-controls .np-print svg { display: none; }
  #note-page .practice-controls .np-language :is(a, button) { font-size: 12px; padding: 3px; }
}
