/* ============================================================
   荣誉证书系统 v3.0 — 专业正式证书视觉
   兼容类名：.certificate / .cert-title / .cert-pet-circle / .cert-action-bar 等
   说明：标题不使用 background-clip:text（html2canvas 兼容），用纯色+阴影实现立体金。
   ============================================================ */

/* ---------- 打印基准：A4 横向 ---------- */
@page {
    size: A4 landscape;
    margin: 0;
}

html, body {
    margin: 0;
    padding: 0;
}

/* ---------- 页面背景：深色丝绒展台 ---------- */
body.cert-font-fallback {
    font-family: 'KaiTi', '楷体', 'STKaiti', 'Microsoft YaHei', serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    box-sizing: border-box;
    background:
        radial-gradient(ellipse at 50% 18%, #34495e 0%, #22313f 55%, #101b26 100%);
}

/* ============================================================
   证书主体
   ============================================================ */
.certificate {
    position: relative;
    width: 960px;
    height: 679px; /* 横版 A4 精确比例 297:210 ≈ 1.414 */
    box-sizing: border-box;
    padding: 36px 48px 32px;
    color: #3E2C1C;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(255,253,240,0.95) 0%, rgba(253,247,228,0.9) 55%, rgba(248,238,214,0.95) 100%);
    border-radius: 6px;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.28),
        0 14px 40px rgba(0,0,0,0.45),
        inset 0 0 60px rgba(212,175,55,0.08);
}

/* 水印：荣誉证书 大字淡纹 */
.certificate::after {
    content: '荣誉证书';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-16deg);
    font-size: 150px;
    font-weight: 900;
    letter-spacing: 30px;
    color: #B8860B;
    opacity: 0.045;
    pointer-events: none;
    white-space: nowrap;
    z-index: 0;
}

/* ---------- 三层描金边框 ---------- */
.cert-border-outer {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    border: 3px solid #9A6B1F;
    border-radius: 4px;
    pointer-events: none;
    z-index: 1;
    box-shadow: inset 0 0 0 1px rgba(212,175,55,0.35);
}
.cert-border-outer-dash {
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    bottom: 18px;
    border: 1.5px solid rgba(154,107,31,0.55);
    border-radius: 3px;
    pointer-events: none;
    z-index: 1;
}
.cert-border-inner {
    position: absolute;
    top: 23px;
    left: 23px;
    right: 23px;
    bottom: 23px;
    border: 1px solid rgba(154,107,31,0.30);
    pointer-events: none;
    z-index: 1;
}

/* ---------- 四角回纹 ---------- */
.corner-diamond {
    position: absolute;
    width: 26px;
    height: 26px;
    z-index: 2;
    pointer-events: none;
    background:
        linear-gradient(45deg, transparent 42%, #9A6B1F 43%, #9A6B1F 50%, transparent 51%),
        linear-gradient(-45deg, transparent 42%, #9A6B1F 43%, #9A6B1F 50%, transparent 51%),
        linear-gradient(45deg, transparent 45%, #D4AF37 46%, #D4AF37 54%, transparent 55%),
        linear-gradient(-45deg, transparent 45%, #D4AF37 46%, #D4AF37 54%, transparent 55%);
    background-size: 100% 100%, 100% 100%, 55% 55%, 55% 55%;
    background-position: 0 0, 0 0, 50% 50%, 50% 50%;
    background-repeat: no-repeat;
}
.corner-diamond.tl { top: 26px; left: 26px; }
.corner-diamond.tr { top: 26px; right: 26px; transform: rotate(90deg); }
.corner-diamond.bl { bottom: 26px; left: 26px; transform: rotate(-90deg); }
.corner-diamond.br { bottom: 26px; right: 26px; transform: rotate(180deg); }

/* ============================================================
   页眉：校名 / 标题 / 副标题
   ============================================================ */
.cert-header {
    position: relative;
    z-index: 3;
    text-align: center;
    margin-bottom: 8px;
}

.cert-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}
.cert-logo img {
    height: 30px;
    width: auto;
    object-fit: contain;
    opacity: 0.92;
}

/* 麦穗饰条（弱化，与金色标题协调） */
.cert-wheat-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 0;
}
.cert-wheat-bar {
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #C9A227 50%, transparent);
}
.wheat {
    font-size: 15px;
    line-height: 1;
    opacity: 0.55;
}

.cert-subtitle {
    font-size: 12px;
    letter-spacing: 6px;
    color: #8B6D3F;
    margin-bottom: 3px;
}

.cert-title {
    font-family: 'KaiTi', '楷体', 'STKaiti', 'SimSun', serif;
    font-size: 40px;
    font-weight: 900;
    letter-spacing: 12px;
    text-indent: 12px;
    color: #8B6914;
    line-height: 1.1;
    text-shadow:
        0 1px 0 #F5E6B8,
        0 2px 2px rgba(139,105,20,0.35),
        0 5px 14px rgba(139,105,20,0.25);
}

.cert-star-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 0;
    color: #B8860B;
    font-size: 14px;
    letter-spacing: 4px;
}

/* ============================================================
   左上：级别印章（珍藏 · 唯一）
   ============================================================ */
.cert-seal {
    position: absolute;
    top: 30px;
    left: 36px;
    width: 92px;
    height: 92px;
    z-index: 4;
    pointer-events: none;
}
.cert-seal-ring-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(180,60,0,0.72);
    background: radial-gradient(circle, rgba(255,240,220,0.35) 0%, rgba(255,228,196,0.55) 100%);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.5), inset 0 0 6px rgba(180,60,0,0.18);
}
.cert-seal-ring-mid {
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    border: 1px solid rgba(180,60,0,0.5);
}
.cert-seal-ring-inner {
    position: absolute;
    inset: 11px;
    border-radius: 50%;
    border: 1.5px solid rgba(180,60,0,0.55);
}
.cert-seal-year {
    position: absolute;
    inset: 13px 0 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cert-seal-text {
    position: absolute;
    inset: 23px 0 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 900;
    color: #C41E3A;
    font-family: 'KaiTi', '楷体', serif;
    line-height: 1.15;
    text-shadow: 0 0 2px rgba(255,255,255,0.6);
}
.cert-seal-unique {
    position: absolute;
    bottom: 13px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 4px;
    font-size: 9px;
    color: #B03020;
    font-weight: 700;
    letter-spacing: 2px;
}
.cert-seal svg {
    width: 100% !important;
    height: 100% !important;
}
.cert-seal-dot {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #C41E3A;
}

/* ============================================================
   正文区（左右两栏）
   ============================================================ */
.cert-body-wrap {
    position: relative;
    z-index: 3;
    display: flex;
    gap: 30px;
    margin-top: 6px;
}

.cert-left {
    flex: 1 1 58%;
    padding-top: 2px;
}

.cert-greeting {
    font-size: 18px;
    color: #3E2C1C;
    line-height: 1.5;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.cert-greeting .sname {
    font-size: 24px;
    font-weight: 900;
    color: #7A4A0B;
    border-bottom: 2px solid #D4AF37;
    padding: 0 4px 1px;
}

.cert-encouragement {
    font-size: 16px;
    color: #4A3828;
    line-height: 1.7;
    letter-spacing: 0.5px;
    text-align: justify;
    text-indent: 2em;
    margin-bottom: 8px;
}

/* 落款区 */
.cert-closing-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}
.cert-gold-bar {
    width: 4px;
    height: 30px;
    background: linear-gradient(180deg, #D4AF37, #9A6B1F);
    border-radius: 2px;
    box-shadow: 0 0 4px rgba(212,175,55,0.5);
}
.cert-closing {
    font-size: 17px;
    color: #3E2C1C;
    font-weight: 700;
    letter-spacing: 2px;
}

/* ---------- 右侧：宠物徽章 + 落款公章 ---------- */
.cert-right {
    flex: 0 0 36%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.cert-pet-wrapper {
    text-align: center;
}

.cert-pet-circle {
    width: 128px;
    height: 128px;
    margin: 0 auto 6px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 35% 30%, #FFF9E6 0%, #F5E6C8 70%);
    border: 4px solid #D4AF37;
    box-shadow:
        0 0 0 2px #9A6B1F,
        0 6px 18px rgba(90,62,11,0.35),
        inset 0 0 18px rgba(212,175,55,0.35);
}
.cert-pet-circle img {
    width: 90%;
    height: 90%;
    object-fit: contain;
}
.cert-pet-fallback {
    font-size: 64px;
    line-height: 1;
}

.cert-pet-name-box {
    text-align: center;
}
.pet-name {
    font-size: 20px;
    font-weight: 900;
    color: #5A3E0B;
    letter-spacing: 3px;
}
.pet-race {
    font-size: 12px;
    color: #8B6D3F;
    margin-top: 0;
    letter-spacing: 1px;
}

/* 右下落款：学校 / 签发人 / 公章 / 日期 */
.cert-right-bottom {
    margin-top: 92px; /* 落款+奖章整体下移约55px，位置协调 */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.cert-info-right {
    position: relative;
    z-index: 1;
    text-align: right;
    font-size: 14px;
    color: #4A3828;
    line-height: 1.5;
    letter-spacing: 1px;
    margin-bottom: 2px;
    padding-right: 6px;
}
.cert-issuer-row {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 8px;
}
.issuer-label {
    font-size: 14px;
    color: #8B6D3F;
}
.cert-signature-text {
    font-size: 22px;
    font-weight: 900;
    color: #3E2C1C;
    font-family: 'KaiTi', '楷体', serif;
    letter-spacing: 2px;
    border-bottom: 2px solid rgba(62,44,28,0.45);
    padding: 0 2px 1px;
}

/* 公章（红章 · 环形校名 · 五角星） */
.cert-stamp {
    position: absolute;
    top: 6px;
    right: 0;
    width: 92px;
    height: 92px;
    margin: 0;
    transform: rotate(-8deg);
    opacity: 0.85;
    filter: saturate(1.05);
    z-index: 6;
    pointer-events: none;
}
.cert-stamp-bg {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,245,240,0.75) 0%, rgba(255,228,220,0.55) 100%);
    border: 2px solid #C41E3A;
    box-shadow: 0 0 0 1px rgba(196,30,58,0.35), inset 0 0 8px rgba(196,30,58,0.12);
}
.cert-stamp-ring {
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    border: 1px solid rgba(196,30,58,0.55);
}
.cert-stamp-inner {
    position: absolute;
    inset: 24px;
    border-radius: 50%;
    border: 1.5px solid #C41E3A;
    background: radial-gradient(circle, rgba(255,238,232,0.5) 0%, rgba(255,220,210,0.35) 100%);
}
.cert-stamp-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #C41E3A;
}
.cert-stamp-dot.top { top: 8px; left: 50%; transform: translateX(-50%); }
.cert-stamp-dot.bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }
.cert-stamp-dot.left { left: 8px; top: 50%; transform: translateY(-50%); }
.cert-stamp-dot.right { right: 8px; top: 50%; transform: translateY(-50%); }
.cert-stamp-text-ring {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cert-stamp-text-ring svg {
    width: 100%;
    height: 100%;
}
.cert-stamp-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    font-weight: 900;
    color: #C41E3A;
    font-family: 'KaiTi', '楷体', serif;
    text-shadow: 0 0 2px rgba(255,255,255,0.5);
}

/* ============================================================
   底部信息行 + 防伪
   ============================================================ */
.cert-info-row {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 4px;
    border-top: 1px solid rgba(154,107,31,0.30);
}
.cert-info-left {
    font-size: 12.5px;
    color: #6B5637;
    line-height: 1.7;
    letter-spacing: 0.5px;
}
.cert-no-box {
    display: inline-block;
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: 700;
    font-size: 13px;
    color: #7A4A0B;
    background: rgba(212,175,55,0.14);
    border: 1px solid rgba(154,107,31,0.45);
    border-radius: 3px;
    padding: 1px 8px;
    letter-spacing: 0.5px;
}
.cert-info-left .lbl {
    color: #9A7B4F;
    margin-right: 4px;
}
.cert-verify-tip {
    font-size: 11.5px;
    color: #A08060;
    letter-spacing: 1px;
    max-width: 300px;
    text-align: right;
    line-height: 1.6;
}

/* ---------- 底部饰条 ---------- */
.cert-bottom-ornament {
    position: relative;
    z-index: 3;
    text-align: center;
    margin-top: 3px;
}
.cert-bottom-gold-line {
    width: 220px;
    height: 3px;
    margin: 0 auto 4px;
    background: linear-gradient(90deg, transparent, #C9A227 30%, #9A6B1F 70%, transparent);
    border-radius: 2px;
}
.cert-bottom-motto {
    font-size: 15px;
    color: #8B6D3F;
    letter-spacing: 3px;
    font-style: italic;
}

/* ============================================================
   工具栏（悬浮右下，玻璃卡片）
   ============================================================ */
.cert-action-bar {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(20,30,45,0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.cert-btn {
    border: none;
    cursor: pointer;
    font-family: 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    letter-spacing: 1px;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.cert-btn:hover {
    transform: translateY(-2px);
    opacity: 0.92;
}
.cert-btn:active {
    transform: translateY(0);
}
.cert-btn:disabled {
    opacity: 0.55;
    cursor: wait;
    transform: none;
}

.cert-btn-png  { background: linear-gradient(135deg, #2E7D32, #43A047); }
.cert-btn-pdf  { background: linear-gradient(135deg, #C62828, #E53935); }
.cert-btn-print{ background: linear-gradient(135deg, #1565C0, #42A5F5); }
.cert-btn-close{ background: linear-gradient(135deg, #546E7A, #90A4AE); }

/* ============================================================
   10 种风格主题（class .style-0 .. .style-9）
   ============================================================ */
.certificate.style-0 { background: radial-gradient(ellipse at 50% 0%, rgba(255,253,231,0.95) 0%, rgba(253,246,222,0.9) 55%, rgba(250,240,210,0.95) 100%); }
.certificate.style-1 { background: radial-gradient(ellipse at 50% 0%, rgba(255,248,240,0.95) 0%, rgba(254,241,230,0.9) 55%, rgba(251,230,215,0.95) 100%); }
.certificate.style-2 { background: radial-gradient(ellipse at 50% 0%, rgba(240,248,255,0.95) 0%, rgba(228,240,252,0.9) 55%, rgba(215,231,248,0.95) 100%); }
.certificate.style-3 { background: radial-gradient(ellipse at 50% 0%, rgba(253,240,255,0.95) 0%, rgba(246,230,252,0.9) 55%, rgba(240,220,248,0.95) 100%); }
.certificate.style-4 { background: radial-gradient(ellipse at 50% 0%, rgba(240,255,255,0.95) 0%, rgba(226,248,248,0.9) 55%, rgba(212,240,240,0.95) 100%); }
.certificate.style-5 { background: radial-gradient(ellipse at 50% 0%, rgba(240,255,240,0.95) 0%, rgba(228,250,228,0.9) 55%, rgba(214,244,214,0.95) 100%); }
.certificate.style-6 { background: radial-gradient(ellipse at 50% 0%, rgba(255,245,240,0.95) 0%, rgba(253,234,226,0.9) 55%, rgba(250,222,212,0.95) 100%); }
.certificate.style-7 { background: radial-gradient(ellipse at 50% 0%, rgba(255,253,247,0.95) 0%, rgba(252,246,235,0.9) 55%, rgba(248,238,222,0.95) 100%); }
.certificate.style-8 { background: radial-gradient(ellipse at 50% 0%, rgba(255,255,240,0.95) 0%, rgba(252,250,228,0.9) 55%, rgba(248,244,214,0.95) 100%); }
.certificate.style-9 { background: radial-gradient(ellipse at 50% 0%, rgba(255,251,240,0.95) 0%, rgba(253,244,228,0.9) 55%, rgba(250,236,214,0.95) 100%); }

.certificate.style-2 .cert-title,
.certificate.style-4 .cert-title { color: #1565C0; text-shadow: 0 1px 0 #E3F2FD, 0 2px 2px rgba(21,101,192,0.3); }
.certificate.style-3 .cert-title { color: #6A1B9A; text-shadow: 0 1px 0 #F3E5F5, 0 2px 2px rgba(106,27,154,0.3); }
.certificate.style-5 .cert-title { color: #2E7D32; text-shadow: 0 1px 0 #E8F5E9, 0 2px 2px rgba(46,125,50,0.3); }
.certificate.style-1 .cert-title,
.certificate.style-6 .cert-title,
.certificate.style-9 .cert-title { color: #BF360C; text-shadow: 0 1px 0 #FFE0B2, 0 2px 2px rgba(191,54,12,0.3); }
.certificate.style-7 .cert-title { color: #5D4037; text-shadow: 0 1px 0 #EFEBE9, 0 2px 2px rgba(93,64,55,0.3); }
.certificate.style-8 .cert-title { color: #558B2F; text-shadow: 0 1px 0 #F1F8E9, 0 2px 2px rgba(85,139,47,0.3); }

/* ============================================================
   打印样式：A4 横版精确输出
   ============================================================ */
@media print {
    body.cert-font-fallback {
        background: #fff !important;
        padding: 0 !important;
        display: block;
    }
    .cert-action-bar,
    .cert-toolbar {
        display: none !important;
    }
    .certificate {
        width: 297mm;
        min-height: 210mm;
        margin: 0;
        padding: 14mm 16mm 12mm;
        border-radius: 0;
        box-shadow: none !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .cert-border-outer { top: 6mm; left: 6mm; right: 6mm; bottom: 6mm; }
    .cert-border-outer-dash { top: 9mm; left: 9mm; right: 9mm; bottom: 9mm; }
    .cert-border-inner { top: 12mm; left: 12mm; right: 12mm; bottom: 12mm; }
    .cert-title { font-size: 18mm; }
    .cert-encouragement { font-size: 5.2mm; line-height: 1.85; }
    .cert-greeting { font-size: 6mm; }
    .cert-greeting .sname { font-size: 8mm; }
    .cert-pet-circle { width: 52mm; height: 52mm; }
    .pet-name { font-size: 7mm; }
    .cert-stamp { width: 34mm; height: 34mm; top: 2mm; right: 0; z-index: 6; }
    .cert-right-bottom { margin-top: 28mm; }
    .cert-info-row { margin-top: 6mm; }
    .cert-signature-text { font-size: 7mm; }
    .cert-seal { width: 26mm; height: 26mm; top: 8mm; left: 8mm; }
    .cert-no-box { font-size: 3.6mm; }
    .cert-verify-tip { font-size: 3.2mm; }
    .cert-bottom-motto { font-size: 4mm; }
}

/* ============================================================
   移动端适配（预览窗口缩放）
   ============================================================ */
@media screen and (max-width: 1100px) {
    body.cert-font-fallback {
        align-items: flex-start;
        padding: 16px 8px;
        overflow-x: auto;
    }
    .certificate {
        width: 960px;
        margin: 0 auto;
        transform-origin: top center;
    }
    .cert-action-bar {
        right: 12px;
        bottom: 12px;
        gap: 8px;
        padding: 10px;
    }
    .cert-btn {
        padding: 9px 14px;
        font-size: 13px;
    }
}
