/* Keep the photograph's deckled top and stacked bottom proportional.
   Only the center slice grows to accommodate longer quiz copy. */
.examination { background: #1c2023; }

/* Keep the original in-photo dates inside the fixed mobile crop. */
.examination .scene img:is([data-asset$="/q01.webp"], [data-asset$="/q02.webp"], [data-asset$="/q05.webp"], [data-asset$="/q07.webp"]) {
  object-position: right center !important;
}

.examination .paperwrap {
  --paper-edge-gap: 9px;
  --paper-quiet: #eadfcb;
  --paper-mark: var(--accent);
  margin: 0 var(--paper-edge-gap) 18px;
  padding: 0;
  container-type: inline-size;
}

.phone[data-theme="light"] .examination .paperwrap { --paper-mark: #e3cca0; }
.phone[data-theme="light"] .examination .scene .fade {
  background: linear-gradient(transparent 42%, #1c2023) !important;
}
.phone[data-theme="light"] .examination .paperwrap::before { background: none; }

.examination .paperwrap::before {
  inset: 0 calc(-1 * var(--paper-edge-gap)) auto;
  height: 36px;
  background: linear-gradient(var(--base), transparent);
  border: 0;
  box-shadow: none;
  transform: none;
  border-radius: 0;
}

.examination .paper {
  isolation: isolate;
  min-height: 132cqw;
  margin: 0;
  padding: 13.5% 11.5% 15% 13%;
  color: #fff;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.examination .paper .question {
  max-width: none;
  line-height: 1.6;
  margin: 11px auto 12px;
}

.examination .paper .choice {
  gap: 7px;
  padding: 7px 4px;
  line-height: 1.6;
}

.examination .paper .choice .letter { min-width: 20px; }

.examination .paper::before {
  inset: 0 -15px;
  z-index: -1;
  border: solid transparent;
  border-width: min(19vw, 87px) 0 min(21vw, 97px);
  border-width: 19.64cqw 0 21.875cqw;
  border-image: var(--quiz-paper-image, none) 176 0 196 0 fill / 1 / 0 stretch;
  filter: drop-shadow(0 9px 10px #0008);
  opacity: 1;
  transition: none;
}

.examination .paper:not([style*="--quiz-paper-image"])::before {
  background: #302a29;
}

.examination .paper :is(.question, .choice, .exam-nav .primary) { color: #fff; }
.examination .paper :is(.meta, .rule, .letter, .text-button, .folio) { color: var(--paper-quiet); }
.examination .paper :is(.choice, .exam-nav .primary) { border-color: #ebd7b448; }
.examination .paper :is(.rule, .folio) span,
.examination .paper .rule::before,
.examination .paper .rule::after,
.examination .paper .progress span { background: #ebd7b44c; }
.examination .paper .progress span.active { background: var(--paper-mark); }
.examination .paper .choice[aria-checked="true"],
.examination .paper .exam-nav .primary { background: #100d103b; }
.examination .paper .choice[aria-checked="true"] { box-shadow: inset 2px 0 var(--paper-mark); }
.examination .paper .choice[aria-checked="true"] .letter { color: var(--paper-mark); }
.examination .paper .choice[aria-checked="true"] .letter::after { border-color: var(--paper-mark); }

.discovery-certificate {
  position: relative;
  isolation: isolate;
}

.discovery-certificate::before {
  --velvet-width: min(100vw, 460px);
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: #230e13;
  /* At the display width, preserve the proportions of source rows
     0–456 and 596–1104. Only the ornament-free center can grow. */
  border: solid transparent;
  border-width: calc(var(--velvet-width) * 456 / 736) 0 calc(var(--velvet-width) * 508 / 736);
  border-image: url("assets/ui/certificate-velvet.webp") 456 0 508 0 fill / 1 / 0 stretch;
}

.discovery-certificate .certificate {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
}

.discovery-certificate .certificate::before,
.discovery-certificate .certificate::after { content: none; }

.certificate-sheet {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  /* Let the photographic edge reach the phone frame. The imprint shares
     this scale and remains inside the visible center of the photograph. */
  left: 50%;
  width: calc(100% + clamp(51px, 15.5vw, 72px));
  aspect-ratio: 692 / 960;
  margin: 1% 0 0;
  transform: translateX(-50%) rotate(-6.35deg);
}

.certificate-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 11px 12px #0008);
}

/* Match the imprint shear to the lengthened photograph. */
.certificate-imprint {
  --sheet-unit: min(.93vw, 4.3px);
  position: absolute;
  left: 25.43%;
  top: 13.2%;
  width: 63.58%;
  height: 72.9%;
  transform-origin: 0 0;
  transform: matrix(1, .15186, -.13559, 1, 0, 0);
  mix-blend-mode: multiply;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  row-gap: calc(.92 * var(--sheet-unit));
  padding: calc(1.9 * var(--sheet-unit)) calc(2.5 * var(--sheet-unit));
}

@supports (width: 1cqw) {
  .certificate-imprint { --sheet-unit: 1cqw; }
}

.certificate-sheet:not(:has(.certificate-photo)) .certificate-imprint {
  background: #bb9f7d;
  mix-blend-mode: normal;
}

.certificate-imprint .certificate-frame { inset: 0; outline-offset: 2px; opacity: .75; }
.certificate-imprint .certificate-corner { width: calc(6.6 * var(--sheet-unit)); }
.certificate-imprint .certificate-seal {
  width: calc(6.3 * var(--sheet-unit));
  height: calc(6.3 * var(--sheet-unit));
  margin: 0 auto 2px;
  flex: none;
}
.certificate-imprint .certificate-caps { font-size: calc(2.25 * var(--sheet-unit)); letter-spacing: .12em; line-height: 1.14; }
.certificate-imprint .certificate-title { margin: calc(.55 * var(--sheet-unit)) 0; }
.certificate-imprint .certificate-script { font-size: calc(7.1 * var(--sheet-unit)); transform: none; }
.certificate-imprint .certificate-headline { font-size: calc(5.8 * var(--sheet-unit)); line-height: 1.06; }
.certificate-imprint .certificate-subtitle { font-size: calc(3.25 * var(--sheet-unit)); line-height: 1.3; }
.certificate-imprint .certificate-rule { height: calc(2.3 * var(--sheet-unit)); margin: 0 auto; flex: none; }
.certificate .certificate-imprint .engraving {
  width: calc(12.4 * var(--sheet-unit));
  height: calc(12.4 * var(--sheet-unit));
  margin: 0 auto 1px;
  flex: none;
}
.certificate .certificate-imprint .label { font-size: calc(2.8 * var(--sheet-unit)); line-height: 1.2; }
.certificate .certificate-imprint .subject-en { font-size: calc(6.65 * var(--sheet-unit)); line-height: 1.08; margin: 3px 0 2px; }
.certificate .certificate-imprint .subject-zh { font-size: calc(4.65 * var(--sheet-unit)); line-height: 1.25; }
.certificate-imprint .composite-result { width: 100%; }
.certificate-imprint .composite-english {
  margin: calc(.95 * var(--sheet-unit)) 0 calc(.35 * var(--sheet-unit));
  color: #625641;
  font: 600 calc(2.3 * var(--sheet-unit))/1.3 var(--handoff-display);
  letter-spacing: .10em;
  text-transform: uppercase;
}
.certificate-imprint .composite-title {
  margin: 0;
  color: #374a38;
  font: 600 calc(4.6 * var(--sheet-unit))/1.25 var(--handoff-serif);
  letter-spacing: .10em;
}
.certificate-imprint .composite-subjects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(.8 * var(--sheet-unit)) calc(.9 * var(--sheet-unit));
  margin: calc(1.35 * var(--sheet-unit)) 0 0;
  padding: calc(.9 * var(--sheet-unit)) 0;
  border-block: 1px solid #8b806d6b;
  list-style: none;
  font: 500 calc(3.85 * var(--sheet-unit))/1.35 var(--handoff-serif);
  color: #364938;
}
.certificate-imprint .composite-subjects li:last-child:nth-child(odd) { grid-column: 1 / -1; }
.certificate .certificate-imprint .report-note {
  font-size: calc(3.28 * var(--sheet-unit));
  line-height: 1.35;
  margin: calc(.7 * var(--sheet-unit)) auto calc(.55 * var(--sheet-unit));
  max-width: 100%;
}
.certificate-imprint .report-note::after { height: 2px; margin-top: 0; }
.certificate-imprint .certificate-signoff { width: 87%; padding: 2px 0 0; margin: 0; }
.certificate-imprint .certificate-signoff .certificate-seal {
  width: calc(4.9 * var(--sheet-unit));
  height: calc(4.9 * var(--sheet-unit));
}
.certificate .envelope { width: min(78%, 300px); margin: 6px auto 0; }
