* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #eef2f5;
  font-family: 'Montserrat', sans-serif;
  color: #111;
  padding-bottom: 60px;
}

/* ==========================================================
   Portal Navigation Bar
========================================================== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 3rem;
  background-color: #0b1d3a;
  color: #fff;
  border-bottom: 2px solid #d4af37;
}

.navbar .logo {
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #d4af37;
  letter-spacing: 1px;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: #d4af37;
  font-weight: 600;
}

/* ==========================================================
   Verification Search Component
========================================================== */
.search-card {
  background: #fff;
  max-width: 500px;
  margin: 2.5rem auto;
  padding: 2.2rem 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
  text-align: center;
  border-top: 4px solid #0b1d3a;
}

.search-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.45rem;
  margin-bottom: 0.5rem;
  color: #0b1d3a;
}

.search-card p {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.input-group {
  margin-bottom: 1.2rem;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #0b1d3a;
}

.input-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 4px;
  font-size: 1rem;
  outline: none;
}

.input-group input:focus {
  border-color: #d4af37;
}

.btn-verify {
  width: 100%;
  padding: 0.85rem;
  background: #0b1d3a;
  color: #d4af37;
  border: 1px solid #d4af37;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.25s ease;
}

.btn-verify:hover {
  background: #162c52;
  color: #fff;
}

.error-box {
  margin-top: 1rem;
  padding: 0.8rem;
  background: #ffebee;
  color: #c62828;
  border-radius: 4px;
  font-size: 0.9rem;
}

.loading-spinner {
  font-size: 0.9rem;
  color: #0b1d3a;
  font-weight: 600;
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

/* ==========================================================
   Certificate Viewport Container
========================================================== */
#certWrapper {
  width: 100%;
  padding: 20px 10px;
  display: none;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.verification-status-banner {
  width: 11.69in;
  max-width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  gap: 10px;
}

.status-badge {
  background: #1b7937;
  color: white;
  padding: 0.55rem 1.3rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 2px 6px rgba(27, 121, 55, 0.25);
}

.btn-print {
  background: #0b1d3a;
  color: #d4af37;
  border: 1px solid #d4af37;
  padding: 0.55rem 1.3rem;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.btn-print:hover {
  background: #d4af37;
  color: #0b1d3a;
}

/* Outer scaling wrapper that responds to screen boundaries */
.cert-mobile-frame {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
  cursor: pointer;
}

/* Mobile tap indicator */
.tap-zoom-badge {
  display: none;
  margin-top: 12px;
  background: #0b1d3a;
  color: #d4af37;
  border: 1px solid #d4af37;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================
   EXACT A4 LANDSCAPE PHYSICAL CANVAS (Strict 11.69in x 8.27in)
========================================================== */
.a4-cert-sheet {
  position: relative;
  width: 11.69in;
  height: 8.27in;
  min-width: 11.69in;
  min-height: 8.27in;
  max-width: 11.69in;
  max-height: 8.27in;
  background-color: #ffffff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  transform-origin: top center;
}

/* Layer 1: Border SVG Layer (Exactly 20.4576px margin on all sides) */
.cert-border-svg {
  position: absolute;
  top: 15px;
  left: 17px;
  right: 17px;
  bottom: 15px;
  width: calc(11.69in - (17px * 2)) !important;
  height: calc(8.27in - (15px * 2)) !important;
  object-fit: fill;
  pointer-events: none;
  z-index: 1;
}

/* Layer 2: Inner Layout Container */
.cert-inner-layout {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  /* Padding inside the SVG border */
  padding: 58px 90px 56px 90px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Microtext Body SVG Watermark (Trapped within the SVG border inner line) */
.cert-inner-layout::before {
  content: "";
  position: absolute;
  top: 42px;
  left: 48px;
  right: 48px;
  bottom: 42px;
  background-image: url('assets/cert-body.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  opacity: 0.38;
  pointer-events: none;
  z-index: -1;
}

/* ==========================================================
   Header Section
========================================================== */
.cert-header {
  text-align: center;
  margin: 21px auto 0px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Monotype Old English Regular: 33.2923pt */
.academy-name {
  font-family: 'Monotype Old English Text W01', 'Old English Text MT', 'UnifrakturMaguntia', serif;
  font-size: 33.2923pt;
  font-weight: normal;
  color: #111111;
  letter-spacing: -0.052em;
  line-height: 1;
  white-space: nowrap;
  display: block;
  margin: 0 auto 5px auto;
}

/* Myriad Variable Concept Semibold SemiCondensed: 19.5003pt */
.exam-subtitle {
  font-family: 'Myriad Variable Concept', 'Myriad Pro SemiCondensed', 'Myriad Pro', 'Segoe UI SemiCondensed', 'Arial Narrow', sans-serif;
  font-size: 19.5003pt;
  font-weight: 500;
  font-stretch: semi-condensed;
  color: #111111;
  letter-spacing: -0.055em;
  line-height: 1.1;
  white-space: nowrap;
  margin: 0 auto;
}

/* ==========================================================
   Emblem Logo & QR Code Row (Horizontal Alignment)
========================================================== */
.cert-emblem-qr-row {
  display: grid;
  grid-template-columns: 1.3007in 1fr 1.3007in;
  align-items: center;
  width: 100%;
  height: 1.2098in;
  margin: -32px 0 0 0;
}

.emblem-spacer-left {
  width: 1.3007in;
}

/* Logo Box (Centered: 1.3007in x 1.2098in) */
.logo-box {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 1.2098in;
}

.inst-logo {
  width: 1.3007in !important;
  height: 1.2098in !important;
  object-fit: contain;
}

/* QR Code Box (Aligned horizontally with the emblem) */
.qr-box-right {
  width: 1in;
  height: 1in;
  background-color: #ffffff;
  padding: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.qr-box-right canvas,
.qr-box-right img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  display: block;
}

/* ==========================================================
   ID & Registration Meta Row
========================================================== */
.cert-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: -30px 0 -35px 0;
  font-family: 'Myriad Variable Concept', 'Myriad Pro SemiCondensed', 'Myriad Pro', 'Segoe UI SemiCondensed', 'Arial Narrow', sans-serif;
  font-size: 18pt;
  font-style: italic;
  color: #111;
  line-height: 1;
}

.meta-item {
  display: flex;
  align-items: baseline;
  position: relative;
}

.id-item {
  width: 28%;
}

.reg-item {
  width: 40%;
}

.meta-label {
  white-space: nowrap;
  padding-right: 6px;
  font-style: italic;
  line-height: 1;
}

/* ==========================================================
   Body Content & Dotted Alignment with Side Text
========================================================== */
.cert-body-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.cert-line {
  display: flex;
  align-items: baseline;
  width: 100%;
  line-height: 1;
  position: relative;
}

/* Static Side Text Labels */
.gothic-text {
  font-family: 'Monotype Old English Text W01', 'Old English Text MT', 'UnifrakturMaguntia', serif;
  font-size: 18pt;
  font-weight: normal;
  color: #111111;
  white-space: nowrap;
  margin-right: 6px;
  line-height: 1;
  display: inline-block;
}

.plain-serif-text {
  font-family: 'Myriad Variable Concept', 'Myriad Pro SemiCondensed', 'Myriad Pro', 'Segoe UI SemiCondensed', 'Arial Narrow', sans-serif;
  font-style: normal;
  font-size: 18pt;
  color: #111111;
  white-space: nowrap;
  margin-right: 6px;
  line-height: 1;
  display: inline-block;
}

/* Dynamic Line Fill - Now strictly using Libre Baskerville */
.line-fill,
.meta-line {
  flex-grow: 1;
  font-family: 'Libre Baskerville', serif;
  font-weight: 700;
  font-style: normal;
  color: #0b1d3a;
  font-size: 15pt;
  text-align: start;
  margin: 0;
  border-bottom: none !important;
  position: relative;

  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='4' viewBox='0 0 10 4'><polygon points='5,0 8,2 5,4 2,2' fill='%23111111'/></svg>");
  background-repeat: repeat-x;
  background-position: left bottom 2px;
  background-size: 7px 4px;

  transform: translateY(-2px);
  padding: 6px 6px 5px 95px;
}

/* Student name field display */
.student-name-fill {
  font-size: 16pt;
  color: #0b1d3a;
}

.course-name-fill {
  color: #0b1d3a;
}

/* Includes modules styling */
.includes-fill {
  font-size: 12.5pt;
  padding-left: 14px;
}

/* Blank continuation line for second module line */
.blank-dotted-line {
  height: 18pt;
}

.blank-dotted-line .line-fill {
  min-height: 18pt;
  transform: none;
}

.includes-extra-fill {
  width: 100%;
  text-align: center;
  font-size: 12.5pt;
  transform: translateY(-2px) !important;
  padding: 6px 10px 5px 10px;
}

/* Lowered duration dates row to sit flush above baseline */
.split-date-line .date-fill {
  flex: 1;
  transform: translateY(-2px) !important;
}

.grade-fill {
  max-width: 90px;
  flex-grow: 0;
  text-align: center;
  font-size: 18pt;
}

.issue-fill {
  max-width: 240px;
  flex-grow: 0;
}

/* ==========================================================
   Signatures Row (Institutional Green)
========================================================== */
.cert-signatures-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 10px;
  margin-bottom: 22px;
  position: relative;
  z-index: 5;
}

.sig-col {
  text-align: center;
  min-width: 130px;
}

.sig-title {
  font-family: 'Myriad Variable Concept', 'Myriad Pro SemiCondensed', 'Myriad Pro', 'Segoe UI SemiCondensed', 'Arial Narrow', sans-serif;
  font-size: 14pt;
  font-weight: 500;
  color: #388e3c;
  letter-spacing: 0.2px;
  line-height: 1;
}

/* ==========================================================
   Full Screen Zoom Modal (Popup)
========================================================== */
.cert-zoom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 25, 0.96);
  z-index: 999999;
  display: none;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 60px 10px 30px 10px;
}

.cert-zoom-close {
  position: fixed;
  top: 15px;
  right: 18px;
  background: #d4af37;
  color: #0b1d3a;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-zoom-content {
  width: 11.69in;
  height: 8.27in;
  margin: 0 auto;
}

/* Mobile Media Queries: Fit without changing physical inches */
@media (max-width: 1150px) {
  .navbar {
    padding: 1rem 1.2rem;
  }
  .tap-zoom-badge {
    display: inline-block;
  }
  .verification-status-banner {
    flex-direction: column;
    text-align: center;
  }
  .verification-status-banner .btn-print {
    width: 100%;
  }
}

/* ==========================================================
   PRINT CONFIGURATION (A4 LANDSCAPE)
========================================================== */
@page {
  size: 11.69in 8.27in landscape;
  margin: 0;
}

@media print {
  html, body {
    width: 11.69in;
    height: 8.27in;
    background: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .navbar,
  .search-card,
  .verification-status-banner,
  .tap-zoom-badge,
  .cert-zoom-modal {
    display: none !important;
  }

  #certWrapper {
    display: flex !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  .cert-mobile-frame {
    overflow: visible !important;
    height: auto !important;
    width: 11.69in !important;
  }

  .a4-cert-sheet {
    transform: none !important;
    width: 11.69in !important;
    height: 8.27in !important;
    min-width: 11.69in !important;
    min-height: 8.27in !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    page-break-after: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}