/* ==========================
   AGREEMENT PREVIEW
========================== */

#agreementPreview {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.98);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 9999;
  padding: 24px;
}

#agreementPreview.hidden {
  display: none;
}

.certificate-shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.certificate-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0 0 20px;
}

/* ==========================
   PAGE
========================== */

.certificate-page {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto 30px;
}

.certificate-inner {
  background: #fffdf7;
  color: #1f1a12;
  border: 10px double #2f2a1f;
  outline: 3px solid #b89b5e;
  outline-offset: -18px;
  box-shadow: 0 0 0 1px #d8c79a inset;
  padding: 32px 38px 30px;
  font-family: Georgia, "Times New Roman", serif;
  background-image: url("../images/logo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 340px;
  background-blend-mode: overlay;
}

/* ==========================
   HEADER
========================== */

.certificate-top {
  text-align: center;
}

.certificate-logo {
  display: block;
  margin: 0 auto 14px;
  max-width: 480px;
  max-height: 138px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.certificate-title {
  margin: 0;
  font-size: 2.1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: 1.08;
}

.certificate-title::after {
  content: "";
  display: block;
  width: 220px;
  height: 2px;
  background: #b89b5e;
  margin: 10px auto 5px;
}

.certificate-subtitle {
  margin: 8px 0 14px;
  font-size: 1.08rem;
  font-style: italic;
}

/* ==========================
   INTRO / CERTIFICATION TEXT
========================== */

.certificate-intro {
  text-align: center;
  max-width: 840px;
  margin: 10px auto 14px;
  line-height: 1.35;
  font-size: 0.92rem;
}

.certificate-certification {
  max-width: 820px;
  margin: 12px auto 18px;
  text-align: center;
  font-size: 1rem;
  line-height: 1.4;
  font-style: italic;
  color: #3b3529;
}

/* ==========================
   LIST
========================== */

.certificate-body {
  margin-top: 10px;
}

.certificate-list {
  margin: 0;
  padding-left: 0;
  list-style-position: inside;
  text-align: center;
  font-size: 1.02rem;
  line-height: 1.32;
}

.certificate-list li {
  margin-bottom: 11px;
  padding-bottom: 8px;
  border-bottom: 1px dotted #ccb98b;
  text-align: center;
}

.certificate-name {
  display: block;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

.certificate-person-subtitle {
  display: block;
  font-size: 0.78rem;
  opacity: 0.8;
  margin-top: 1px;
  line-height: 1.02;
  text-align: center;
}

.agreement-empty {
  text-align: center;
  margin: 20px 0;
  font-size: 0.98rem;
}

/* ==========================
   SIGNATURES
========================== */

.certificate-signatures {
  margin-top: 12px;
}

.single-certificate-signatures {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 14px;
  align-items: end;
}

.certificate-sign-block {
  text-align: center;
  min-width: 0;
}

.certificate-sign-line {
  border-top: 1px solid #000;
  margin-top: 20px;
  margin-bottom: 5px;
  width: 100%;
  box-sizing: border-box;
}

.certificate-sign-label {
  font-size: 0.8rem;
  line-height: 1.15;
}

.date-block {
  width: 140px;
  max-width: 140px;
  justify-self: end;
}

/* ==========================
   COUPLES
========================== */

.certificate-couples-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.certificate-panel {
  background: rgba(255,252,244,.82);
  border: 1px solid #ccb98b;
  padding: 12px 12px 14px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.certificate-panel h3 {
  text-align: center;
  margin: 0 0 8px;
  font-size: 0.95rem;
  line-height: 1.15;
}

.certificate-panel .certificate-list {
  font-size: 0.84rem;
  line-height: 1.12;
  padding-left: 18px;
  text-align: left;
  list-style-position: outside;
}

.certificate-panel .certificate-list li {
  margin-bottom: 4px;
  padding-bottom: 3px;
  text-align: left;
}

.certificate-panel .certificate-name {
  text-align: left;
}

.certificate-panel .certificate-person-subtitle {
  font-size: 0.68rem;
  line-height: 1;
  text-align: left;
}

.panel-certificate-signatures {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 8px;
  align-items: end;
  margin-top: auto;
  padding-top: 12px;
}

.panel-certificate-signatures .date-block {
  width: 82px;
  max-width: 82px;
}

/* ==========================
   FOOTER
========================== */

.certificate-footer {
  margin-top: 14px;
  text-align: center;
  font-size: 0.62rem;
  color: #5a5144;
  line-height: 1.04;
}

/* ==========================
   PRINT
========================== */

@media print {

  @page {
    size: letter landscape;
    margin: 0.15in;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
    height: auto;
    background: white !important;
    overflow: visible !important;
  }

  body > *:not(#agreementPreview) {
    display: none !important;
  }

  #agreementPreview {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    overflow: visible !important;
  }

  .certificate-actions,
  .no-print,
  .site-footer {
    display: none !important;
  }

  .certificate-shell,
  .certificate-page {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .certificate-inner {
    width: 100% !important;
    min-height: 7.9in !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 28px 32px 24px !important;
    box-shadow: none !important;
    outline-offset: -10px !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    background-image: none !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
  }

  .certificate-top {
    margin-bottom: 6px !important;
  }

  .certificate-logo {
    max-width: 440px !important;
    max-height: 110px !important;
    margin: 0 auto 10px !important;
  }

  .certificate-title {
    font-size: 2rem !important;
    letter-spacing: 1px !important;
    line-height: 1.08 !important;
  }

  .certificate-title::after {
    width: 170px !important;
    height: 1px !important;
    margin: 8px auto 4px !important;
  }

  .certificate-subtitle {
    font-size: 1.15rem !important;
    margin: 8px 0 14px !important;
  }

  .certificate-intro {
    font-size: 0.84rem !important;
    line-height: 1.24 !important;
    margin: 6px auto 10px !important;
    max-width: none !important;
  }

  .certificate-certification {
    font-size: 0.94rem !important;
    line-height: 1.3 !important;
    margin: 10px auto 16px !important;
    max-width: 88% !important;
  }

  .certificate-body {
    margin-top: 16px !important;
    flex: 1 1 auto !important;
  }

  .certificate-list {
    font-size: 1.08rem !important;
    line-height: 1.34 !important;
    padding-left: 0 !important;
    margin: 0 auto !important;
    width: 92% !important;
    list-style: none !important;
    text-align: center !important;
  }

  .certificate-list li {
    margin-bottom: 8px !important;
    padding-bottom: 6px !important;
  }

  .certificate-name {
    line-height: 1.12 !important;
    text-align: center !important;
  }

  /* tighter subtitle spacing to keep page one */
  .certificate-person-subtitle {
    font-size: 0.78rem !important;
    margin-top: 1px !important;
    line-height: 1.02 !important;
    text-align: center !important;
  }

  .certificate-couples-grid {
    gap: 10px !important;
    margin-top: 8px !important;
    align-items: stretch !important;
  }

  .certificate-panel {
    padding: 10px 10px 12px !important;
    box-shadow: inset 0 0 0 1px #e3d6b2;
  }

  .certificate-panel h3 {
    font-size: 0.86rem !important;
    margin: 0 0 6px !important;
    line-height: 1.1 !important;
  }

  .certificate-panel .certificate-list {
    width: 100% !important;
    font-size: 0.76rem !important;
    line-height: 1.1 !important;
    padding-left: 0 !important;
    text-align: center !important;
    list-style: none !important;
  }

  .certificate-panel .certificate-list li {
    margin-bottom: 4px !important;
    padding-bottom: 3px !important;
    text-align: center !important;
  }

  .certificate-panel .certificate-name {
    text-align: center !important;
  }

  .certificate-panel .certificate-person-subtitle {
    font-size: 0.62rem !important;
    line-height: 1.02 !important;
    text-align: center !important;
  }

  /* tighter signature spacing */
  .certificate-signatures {
    margin-top: 12px !important;
  }

  .single-certificate-signatures {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 125px !important;
    gap: 12px !important;
    align-items: end !important;
  }

  .panel-certificate-signatures {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 78px !important;
    gap: 6px !important;
    align-items: end !important;
    margin-top: 10px !important;
  }

  .certificate-sign-line {
    margin-top: 20px !important;
    margin-bottom: 5px !important;
    border-top: 1px solid #222 !important;
  }

  .certificate-sign-label {
    font-size: 0.7rem !important;
    line-height: 1.08 !important;
  }

  .date-block,
  .panel-certificate-signatures .date-block {
    width: auto !important;
    max-width: none !important;
    justify-self: stretch !important;
  }

  /* tighter footer so it stays on page */
  .certificate-footer {
    margin-top: 8px !important;
    font-size: 0.6rem !important;
    line-height: 1.04 !important;
  }

}

/* ==========================
   MOBILE
========================== */

@media screen and (max-width: 800px) {
  .certificate-couples-grid,
  .single-certificate-signatures,
  .panel-certificate-signatures {
    display: flex;
    flex-direction: column;
  }

  .date-block,
  .panel-certificate-signatures .date-block {
    width: 100%;
    max-width: none;
  }

  .certificate-inner {
    padding: 24px 18px;
    background-size: 240px;
  }

  .certificate-title {
    font-size: 1.75rem;
  }

  .certificate-logo {
    max-width: 400px;
  }
}