/* ==========================================
   ICQA Certificate Layout (A4, refined)
   ========================================== */
/* 인증서 색상 팔레트 정의 */
:root {
  --cert-primary: #0ea5e9;
  --cert-title: #1f2937;
  --cert-text: #111827;
  --cert-paper: #ffffff;
  --cert-muted: #6b7280;
}

/* A4 크기 전체 레이아웃 및 기본 카드 스타일 */
.certificate {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  width: min(794px, 100%);
  aspect-ratio: 210 / 297;
  background: var(--cert-paper);
  color: var(--cert-text);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  position: relative;
  overflow: hidden;
}

/* 중앙 워터마크 배경 영역 */
.certificate__watermark {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: multiply;
}

/* 워터마크 이미지 크기 및 톤 보정 */
.certificate__watermark img {
  max-width: 80%;
  height: auto;
  margin: 0 auto;
  filter: saturate(.9) contrast(.95);
}

/* 우측 상단 원형 리본 장식 */
.certificate__ribbon {
  position: absolute;
  right: -40px;
  top: -40px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #0b1726 0%, #122131 55%, var(--cert-primary) 100%);
  opacity: .85;
}

/* 상단 헤더 컨테이너 여백 */
.certificate__header {
  position: relative;
  padding: 28mm 18mm 8mm;
}

/* 로고와 브랜드명을 수평 정렬 */
.certificate__brand {
  display: flex;
  align-items: center;
  gap: 10mm;
}

/* 로고 영역 기본값 초기화 */
.certificate__logo {
  width: auto;
  height: auto;
  min-width: 28mm;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 로고 이미지 최대 높이 제한 */
.certificate__logo img {
  display: block;
  max-height: 20mm;
  width: auto;
}

/* 브랜드 타이틀 텍스트 */
.certificate__brand h3 {
  margin: 0;
  letter-spacing: .06em;
  font-weight: 800;
  color: #ffffff;
  font-size: 7mm;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  font-family: 'Inter', system-ui, sans-serif;
}

/* 본문 컨텐츠 여백 */
.certificate__body {
  position: relative;
  padding: 8mm 18mm 16mm;
}

/* 메인 인증서 제목 */
.certificate__title {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-size: 13mm;
  font-weight: 900;
  letter-spacing: .02em;
  color: var(--cert-title);
  border-bottom: 4mm solid var(--cert-primary);
  padding-bottom: 4mm;
  margin: 10mm 0 6mm;
}

/* 서브타이틀 안내 문구 */
.certificate__subtitle {
  color: var(--cert-muted);
  letter-spacing: .08em;
  font-weight: 600;
  font-size: 3.6mm;
}

/* 수상자 이름 강조 */
.certificate__name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 11mm;
  font-weight: 900;
  margin: 4mm 0 2mm;
}

/* 상세 정보 2열 그리드 */
.certificate__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6mm;
  margin-top: 4mm;
}

/* 필드 라벨 스타일 */
.certificate__field .label {
  color: var(--cert-muted);
  font-size: 3.5mm;
  letter-spacing: .06em;
}

/* 필드 값 강조 */
.certificate__field .value {
  font-weight: 700;
  font-size: 4mm;
  margin-top: 1.5mm;
}

/* 서명과 봉인을 정렬 */
.certificate__footer {
  margin-top: 14mm;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8mm;
}

/* 서명 라인 스타일 */
.certificate__sign .line {
  width: 60mm;
  height: .8mm;
  background: var(--cert-primary);
}

/* 서명 라벨 */
.certificate__sign .label {
  margin-top: 2mm;
  color: var(--cert-muted);
  font-size: 3.5mm;
}

/* 하단 봉인 배지 */
.certificate__seal {
  width: 26mm;
  height: 26mm;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fde68a, #f59e0b 60%, #b45309 100%);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .25), 0 4px 12px rgba(0, 0, 0, .2);
  border: 1.2mm solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #312e81;
  font-weight: 800;
  font-size: 6mm;
}

/* 투명 고스트 버튼 */
.button.ghost {
  background: transparent;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
}

/* 고스트 버튼 호버 효과 */
.button.ghost:hover {
  background: rgba(147, 197, 253, .12);
}

/* 결과 모달 내부 여백 조정 */
#result-body {
  padding: 3.25rem 0.75rem 0.75rem;
}

/* 인쇄 전용 페이지 설정 */
@page {
  size: A4 portrait;
  margin: 12mm;
}

/* 인쇄 시 모달만 노출 */
@media print {
  html,
  body {
    background: #fff;
  }

  body {
    margin: 0;
    min-height: 0;
  }

  #page-wrapper,
  body > *:not(#result-modal) {
    display: none !important;
  }

  #result-modal {
    position: static !important;
    inset: auto;
    margin: 0;
    padding: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: transparent !important;
  }

  /* 모달 배경/딤 숨김 */
  #result-modal::backdrop {
    display: none;
  }

  #result-modal .modal__dialog {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none;
    background: transparent;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* 인쇄에서는 모달 상단 여백 제거 */
  #result-modal #result-body {
    padding: 0 !important;
  }

  #result-modal .modal__close {
    display: none !important;
  }

  body * {
    visibility: hidden !important;
  }

  #result-modal .certificate,
  #result-modal .certificate *,
  #result-modal .cert-canvas,
  #result-modal .cert-canvas * {
    visibility: visible !important;
  }

  #result-modal .certificate,
  #result-modal .cert-canvas {
    position: static;
    margin: 0 auto;
    box-shadow: none;
    width: 210mm;
    height: 297mm;
    transform: none;
  }

  .modal__actions,
  .cert-nav,
  .no-print {
    display: none !important;
  }
}
