:root{
  --paper:#FBF8F0;
  --paper-tint:#F3EEE0;
  --ink:#1E1B14;
  --body:#3A342A;
  --muted:#7A7263;
  --rule:#C9BFA6;
  --gold:#9C7C33;
  --accent:#8C2F39;
  --stage-bg:#2A2620;
}

*{ box-sizing:border-box; }

html,body{
  margin:0;
  padding:0;
  background:var(--stage-bg);
  color:var(--ink);
  font-family:'Inter',system-ui,-apple-system,sans-serif;
  -webkit-font-smoothing:antialiased;
}

[hidden]{ display:none !important; }

.stage{
  min-height:100vh;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:22px;
  padding:40px 20px 48px;
}

/* ---- sheet scales the fixed A4-landscape certificate to fit ---- */

.sheet{
  width:100%;
  max-width:1123px;
}

.cert{
  width:1123px;
  height:794px;
  transform-origin:top left;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(156,124,51,.07), transparent 55%),
    var(--paper);
  box-shadow:0 18px 50px rgba(0,0,0,.45);
  padding:16px;
}

.border-outer{
  height:100%;
  border:3px double var(--gold);
  padding:9px;
}

.border-inner{
  position:relative;
  height:100%;
  border:1px solid var(--rule);
  padding:34px 66px 26px;
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
}

.flourish{
  position:absolute;
  width:26px;
  height:26px;
  border:1px solid var(--gold);
}
.flourish.tl{ top:9px; left:9px; border-right:0; border-bottom:0; }
.flourish.tr{ top:9px; right:9px; border-left:0; border-bottom:0; }
.flourish.bl{ bottom:9px; left:9px; border-right:0; border-top:0; }
.flourish.br{ bottom:9px; right:9px; border-left:0; border-top:0; }

/* ---- head ---- */

.issuer{
  font-size:11px;
  letter-spacing:.14em;
  color:var(--muted);
  text-transform:uppercase;
}

.doc-title{
  font-family:'Cormorant Garamond',Georgia,serif;
  font-weight:700;
  font-size:58px;
  line-height:1;
  letter-spacing:.1em;
  margin:8px 0 0;
  text-transform:uppercase;
}

.doc-sub{
  font-family:'Cormorant Garamond',Georgia,serif;
  font-style:italic;
  font-size:20px;
  color:var(--accent);
  margin-top:4px;
}

.head-rule{
  display:flex;
  align-items:center;
  gap:9px;
  margin:14px 0 18px;
}
.head-rule span{
  display:block;
  width:120px;
  height:1px;
  background:linear-gradient(90deg,transparent,var(--gold));
}
.head-rule span:last-child{ background:linear-gradient(90deg,var(--gold),transparent); }
.head-rule i{
  width:7px;
  height:7px;
  background:var(--gold);
  transform:rotate(45deg);
}

/* ---- recipient ---- */

.awarded{
  font-size:13.5px;
  color:var(--muted);
  margin:0;
}

.recipient{
  font-family:'Cormorant Garamond',Georgia,serif;
  font-weight:600;
  font-size:52px;
  line-height:1.1;
  margin:8px 0 0;
  padding:0 40px 8px;
  border-bottom:1px solid var(--rule);
}

/* ---- statement ---- */

.statement{
  max-width:820px;
  margin:22px 0 0;
  font-size:13.4px;
  line-height:1.62;
  color:var(--body);
  text-align:justify;
  hyphens:auto;
}
.statement p{ margin:0 0 8px; }
.statement p:last-child{ margin-bottom:0; }
.statement b{ color:var(--ink); font-weight:600; }
.statement i{ font-style:italic; }

/* ---- validity ---- */

.validity{
  margin:16px 0 0;
  padding:11px 0 0;
  border-top:1px solid var(--rule);
  width:100%;
  max-width:820px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:3px;
}
.validity-label{
  font-size:9.5px;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:var(--muted);
}
.validity-value{
  font-family:'Cormorant Garamond',Georgia,serif;
  font-size:19px;
  font-weight:600;
  color:var(--accent);
}

/* ---- foot ---- */

.foot{
  margin-top:auto;
  width:100%;
  max-width:820px;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  gap:70px;
  padding-top:14px;
}

.sig{ width:280px; padding-bottom:2px; }

.sig-mark{
  font-family:'Mrs Saint Delafield',cursive;
  font-size:52px;
  line-height:.9;
  color:#25325A;
  height:44px;
  margin-bottom:2px;
  transform:rotate(-2.5deg);
  transform-origin:bottom center;
}

.sig-line{
  height:1px;
  background:var(--ink);
  margin-bottom:6px;
}
.sig-name{
  font-family:'Cormorant Garamond',Georgia,serif;
  font-size:19px;
  font-weight:600;
}
.sig-role{
  font-size:9.5px;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--muted);
  margin-top:2px;
}

.seal{ color:var(--gold); text-align:center; }
.seal svg{ width:78px; height:78px; display:block; margin:0 auto; }
.seal-caption{
  font-family:'Cormorant Garamond',Georgia,serif;
  font-size:10.5px;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--muted);
  margin-top:4px;
  line-height:1.3;
}

.credential{
  margin-top:12px;
  font-size:9.5px;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--muted);
}
.credential b{ color:var(--ink); font-weight:600; font-variant-numeric:tabular-nums; }

/* ---- actions ---- */

.actions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:center; }

.btn{
  font:inherit;
  font-size:14px;
  font-weight:500;
  color:var(--ink);
  background:var(--paper);
  border:1px solid var(--rule);
  border-radius:6px;
  padding:10px 18px;
  cursor:pointer;
  text-decoration:none;
}
.btn:hover{ border-color:var(--gold); }
.btn:focus-visible{ outline:2px solid var(--gold); outline-offset:2px; }
.btn-primary{ background:var(--ink); color:var(--paper); border-color:var(--ink); }
.btn-primary:hover{ background:#332e24; border-color:#332e24; }

/* ---- fallback ---- */

.plain-card{ text-align:center; max-width:400px; color:var(--paper); }
.plain-card h1{
  font-family:'Cormorant Garamond',Georgia,serif;
  font-size:32px;
  font-weight:600;
  margin:0 0 10px;
}
.plain-card p{ color:#b8b0a0; line-height:1.6; margin:0; }

/* ---- screen scaling: JS sets --cert-scale so proportions never break ---- */

.sheet{ overflow:hidden; }
.cert{ transform:scale(var(--cert-scale,1)); }

/* ---- print: real A4 landscape ---- */

@page{ size:A4 landscape; margin:0; }

@media print{
  html,body{ background:#fff; }
  .stage{ padding:0; min-height:0; display:block; }
  .actions{ display:none; }
  .sheet{ max-width:none; overflow:visible; }
  .cert{
    width:297mm;
    height:210mm;
    transform:none !important;
    box-shadow:none;
    page-break-after:avoid;
  }
  .border-inner{ padding:30px 58px 22px; }
}

@media (prefers-reduced-motion:reduce){
  *{ transition:none !important; animation:none !important; }
}
