/* Certificate of Enjoyment (/certificate/).
   The certificate itself stays paper-colored in dark mode: it is a document,
   not a theme. Everything inside it is sized in container units (cqi) so the
   preview, the 375px layout and the printed page share one set of proportions. */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.cert-layout {
  display: grid;
  gap: 28px;
  margin: 32px 0 48px;
  align-items: start;
}
@media (min-width: 900px) {
  .cert-layout { grid-template-columns: minmax(280px, 330px) 1fr; }
}

/* ---- Form --------------------------------------------------------- */

.cert-form label {
  display: block;
  font-weight: 600;
  margin: 16px 0 6px;
}
.cert-form h2 + label { margin-top: 6px; }
.cert-form input,
.cert-form select {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 12px;
  color-scheme: light dark;
}
.cert-form input::placeholder { color: var(--ink-soft); opacity: 1; }
.cert-form input:focus-visible,
.cert-form select:focus-visible,
.cert-form button:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}
.cert-form .fineprint { margin: 6px 0 0; }
.cert-form .buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 4px;
}
.cert-form .buttons button { flex: 1 1 auto; }
#cert-status {
  min-height: 1.5em;
  font-weight: 600;
  color: var(--red);
  margin: 10px 0 0;
  text-wrap: pretty;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #cert-status { color: var(--yellow); }
}
:root[data-theme="dark"] #cert-status { color: var(--yellow); }

/* ---- Certificate -------------------------------------------------- */

.cert-stage { container-type: inline-size; }

.cert {
  --c-paper: #fbf6ea;
  --c-ink: #2b2622;
  --c-soft: #5a4f46;
  --c-red: #9e2424;
  --c-gold: #a87a22;
  --c-pen: #1f3a6b;
  --serif: Georgia, 'Times New Roman', Times, serif;

  position: relative;
  aspect-ratio: 11 / 8.5;
  color: var(--c-ink);
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, .7), rgba(255, 255, 255, 0) 70%),
    repeating-radial-gradient(circle at 50% 50%, rgba(168, 122, 34, .05) 0 1px, transparent 1px 7px),
    var(--c-paper);
  border: 1.4cqi solid var(--c-red);
  box-shadow: var(--shadow-soft);
  font-family: var(--serif);
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.cert-inner {
  position: absolute;
  inset: 1.3cqi;
  border: max(3px, .55cqi) double var(--c-gold);
  box-shadow: inset 0 0 0 .6cqi var(--c-paper), inset 0 0 0 .8cqi rgba(168, 122, 34, .45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4.2cqi 7cqi 2.4cqi;
}
.cert-inner p { margin: 0; }

.cert-corner {
  position: absolute;
  width: 9cqi;
  height: 9cqi;
  fill: none;
  stroke: var(--c-gold);
  stroke-width: 3;
  stroke-linecap: round;
}
.cert-corner circle { fill: var(--c-red); stroke: none; }
.cert-corner--tl { top: 1cqi; left: 1cqi; }
.cert-corner--tr { top: 1cqi; right: 1cqi; transform: scaleX(-1); }
.cert-corner--bl { bottom: 1cqi; left: 1cqi; transform: scaleY(-1); }
.cert-corner--br { bottom: 1cqi; right: 1cqi; transform: scale(-1, -1); }

.cert-org {
  font-size: 1.75cqi;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--c-soft);
}
.cert-title {
  font-size: 4.9cqi;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: .04em;
  color: var(--c-red);
  line-height: 1;
}
.cert-presented,
.cert-for {
  font-size: 1.9cqi;
  font-style: italic;
  color: var(--c-soft);
}
.cert-name {
  font-size: 5cqi;
  font-style: italic;
  min-width: 60%;
  max-width: 100%;
  padding: 0 2cqi .5cqi;
  border-bottom: max(1px, .2cqi) solid var(--c-gold);
  overflow-wrap: anywhere;
}
.cert-name[data-size="long"] { font-size: 3.9cqi; }
.cert-name[data-size="xlong"] { font-size: 3cqi; }
.cert-award {
  font-size: 2.9cqi;
  font-weight: 700;
  max-width: 82%;
  text-wrap: balance;
}
.cert-award[data-size="long"] { font-size: 2.4cqi; }

.cert-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 4cqi;
  width: 100%;
}
.cert-sign-line {
  font-size: 1.9cqi;
  padding-bottom: .5cqi;
  border-bottom: max(1px, .15cqi) solid var(--c-ink);
  white-space: nowrap;
}
.cert-signature {
  display: inline-block;
  font-family: 'Permanent Marker', 'Marker Felt', 'Comic Sans MS', cursive;
  font-size: 2.6cqi;
  line-height: 1;
  color: var(--c-pen);
  transform: rotate(-3deg);
}
.cert-sign-label {
  font-size: 1.3cqi;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-soft);
  margin-top: .6cqi !important;
}

.cert-seal {
  width: 14cqi;
  height: auto;
  overflow: visible;
  margin-bottom: -1cqi;
}
.seal-ribbon { fill: var(--c-red); stroke: #6e1818; stroke-width: 2; }
.seal-burst { fill: var(--c-gold); stroke: #7d5a17; stroke-width: 2; }
.seal-ring { fill: none; stroke: #fbf1d2; stroke-width: 2.5; }
.seal-text, .seal-mid, .seal-small { fill: #fff8e6; font-family: Georgia, 'Times New Roman', serif; font-weight: 700; }
.seal-text { font-size: 13px; letter-spacing: 1.5px; }
.seal-mid { font-size: 30px; }
.seal-small { font-size: 14px; letter-spacing: 2px; }

.cert-fine {
  font-size: 1.05cqi;
  font-style: italic;
  color: var(--c-soft);
}

/* ---- Print: the certificate, alone, on one landscape page ---------- */

@page {
  size: landscape;
  margin: 0.35in;
}

@media print {
  html, body { background: #fff !important; }
  body > :not(.wrap),
  .wrap > header,
  .wrap > footer,
  .hero,
  .cert-form,
  .visually-hidden { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .cert-layout { display: block; margin: 0; }
  /* 9.6in wide keeps the 11:8.5 certificate inside the printable area of
     both US Letter and A4 landscape at 0.35in margins. */
  .cert-stage {
    width: 9.6in;
    margin: 0 auto;
    break-inside: avoid;
  }
  .cert { box-shadow: none; }
}
