/* ============================================================
   结业证书（certificate.html + 闯关通关页共用）
   结构：certificate > cert-border > 印章 / 标题 / 姓名 / 说明 / 关卡清单 / 落款
   设计：白卡面 + 柔和阴影 + 内嵌发丝边框（替代粗重主色描边），
        字号层级：标题 3xl / 姓名 2xl / 正文 md / 明细 sm / 落款 xs
   ============================================================ */

/* ---------- 独立页容器 ---------- */
.cert-view {
  max-width: 680px;
  margin: 0 auto;
}

/* 页内工具条（打印 / 返回），仅独立页使用 */
.cert-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 var(--space-group);
  flex-wrap: wrap;
}
.cert-view .btn-primary,
.cert-view .btn-ghost {
  min-height: 38px;
  padding: 0 20px;
  border-radius: var(--radius-full);
  font: inherit;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cert-view .btn-primary {
  border: none;
  background: var(--color-primary);
  color: var(--color-on-primary);
}
.cert-view .btn-primary:hover { background: var(--color-primary-hover); }
.cert-view .btn-ghost {
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
}
.cert-view .btn-ghost:hover { color: var(--color-primary); border-color: var(--color-primary); }

/* ---------- 未达成态 ---------- */
.cert-state {
  padding: var(--spacing-xl) var(--spacing-lg);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), var(--shadow-e1);
  text-align: center;
}
.cert-state .cert-state-ico {
  width: 52px;
  height: 52px;
  margin: 0 auto var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--icon-surface);
  color: var(--icon-fg);
}
.cert-state .cert-state-ico svg { width: 26px; height: 26px; }
.cert-state h2 {
  margin: 0 0 6px;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text-primary);
}
.cert-state p {
  margin: 0 0 var(--spacing-lg);
  font-size: var(--font-size-sm);
  line-height: 1.8;
  color: var(--color-text-secondary);
}

/* ---------- 证书主体 ---------- */
.certificate {
  margin: 0 auto;
  max-width: 560px;
}

.cert-border {
  position: relative;
  padding: 44px 40px 32px;
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), var(--shadow-e1);
  text-align: center;
  overflow: hidden;
}
/* 内嵌发丝边框：替代原先 3px 主色粗描边，克制且有证书感 */
.cert-border::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid color-mix(in srgb, var(--color-primary) 22%, transparent);
  border-radius: calc(var(--radius-xl) - 6px);
  pointer-events: none;
}

.cert-seal {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--icon-surface);
  color: var(--icon-fg);
}
.cert-seal svg { width: 30px; height: 30px; }

.cert-title {
  margin: 0;
  font-size: var(--font-size-3xl);
  font-weight: 800;
  letter-spacing: var(--letter-spacing-tight);
  color: var(--color-text-primary);
}
.cert-sub {
  margin-top: 6px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}

.cert-recipient {
  margin: var(--spacing-lg) 0 var(--space-tight);
  padding-bottom: var(--space-tight);
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: var(--letter-spacing-snug);
  color: var(--color-text-primary);
}

.cert-text {
  max-width: 30em;
  margin: 0 auto var(--space-block);
  font-size: var(--font-size-md);
  line-height: 1.9;
  color: var(--color-text-secondary);
}

/* ---------- 关卡清单 ---------- */
.cert-stages {
  max-width: 420px;
  margin: 0 auto var(--space-block);
  padding: 0;
  list-style: none;
  text-align: left;
}
.cert-stage {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--color-border-subtle);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}
.cert-stage:last-child { border-bottom: none; }
.cert-stage-no {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--color-text-tertiary);
}
.cert-stage-name {
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cert-stage-meta {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}
.cert-stage.is-done .cert-stage-meta { color: var(--status-emerald); }
.cert-stage.is-done .cert-stage-no { color: var(--color-primary); }

/* ---------- 落款 ---------- */
.cert-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: var(--space-block);
  padding-top: var(--space-tight);
  border-top: 1px solid var(--color-border-subtle);
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}
.cert-org { font-weight: 600; color: var(--color-text-secondary); }

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
  .cert-border { padding: 32px 20px 24px; }
  .cert-border::before { inset: 8px; }
  .cert-title { font-size: var(--font-size-2xl); }
  .cert-recipient { font-size: var(--font-size-xl); }
  .cert-stage { grid-template-columns: 24px 1fr auto; gap: 8px; }
  .cert-stage-name { font-size: var(--font-size-xs); }
}

/* ---------- 打印：只保留证书，落纸为白底黑字 ---------- */
@media print {
  body * { visibility: hidden; }

  .certificate,
  .certificate * { visibility: visible; }

  .certificate {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .cert-border {
    box-shadow: none;
    border: 1px solid #9CA3AF;
    background: #FFFFFF;
  }
  .cert-border::before { border-color: #C7CBD1; }
  .cert-seal {
    background: #FFFFFF;
    border: 1px solid #9CA3AF;
    color: #374151;
  }
  .cert-title,
  .cert-stage-name,
  .cert-recipient { color: #111827; }
  .cert-sub,
  .cert-text,
  .cert-stage,
  .cert-stage-no,
  .cert-stage-meta,
  .cert-date { color: #4B5563; }
  .cert-stage.is-done .cert-stage-meta { color: #047857; }
  .cert-stage { border-color: #D1D5DB; }
  .cert-recipient,
  .cert-foot { border-color: #D1D5DB; }
}
