/* --- Design Tokens --- */
:root {
    --cert-bg: #ffffff;
    --cert-bg-subtle: #faf8f5;
    --cert-border: #e8e2da;
    --cert-text: #2d2926;
    --cert-text-muted: #7a7068;
    --cert-text-faint: #9a8e80;
    --cert-radius-card: 20px;
    --cert-radius-inner: 12px;
    --cert-radius-img: 10px;
    --cert-padding-x: 56px;
    --cert-padding-y: 52px;
}

/* --- Scoped Reset --- */
.cert *, .cert *::before, .cert *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.cert dialog {
    margin: auto;
    border: none;
    background: none;
}

/* --- Card --- */
.cert {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: var(--cert-text);
    max-width: 780px;
    width: 100%;
    background: var(--cert-bg);
    border-radius: var(--cert-radius-card);
    margin: 0 auto;
    padding: var(--cert-padding-y) var(--cert-padding-x) 44px;
    box-shadow:
        0 1px 2px rgba(0,0,0,0.04),
        0 4px 16px rgba(0,0,0,0.04),
        0 12px 40px rgba(0,0,0,0.06);
}

/* --- Header --- */
.cert-header {
    text-align: center;
    padding-bottom: 2em;
}

.cert-registry-label {
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--cert-text-faint);
    margin-bottom: 0.6em;
}

.cert-number {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 2em;
    color: #1a1714;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.cert-name {
    font-family: 'Fraunces', serif;
    font-size: 1.05em;
    color: var(--cert-text-muted);
    font-style: italic;
    margin-top: 0.5em;
    line-height: 1.4;
}

/* --- Dividers --- */
.cert-divider {
    height: 1px;
    margin: 2em 0;
    background: var(--cert-border);
}

.cert-divider-ornate {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 2em 0;
}

.cert-divider-ornate::before,
.cert-divider-ornate::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--cert-border);
}

.cert-divider-ornate::before {
    margin-right: -8px;
}

.cert-divider-ornate::after {
    margin-left: -8px;
}

.cert-divider-ornate .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #c4b9aa;
}

/* --- Section Titles --- */
.cert-section-title {
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--cert-text-faint);
    margin-bottom: 1.2em;
}

/* --- Section Text (events, notes) --- */
.cert-section p {
    font-size: 0.92em;
    line-height: 1.7;
}

/* --- Properties --- */
.cert-properties {
    background: var(--cert-bg-subtle);
    border-radius: var(--cert-radius-inner);
    padding: 4px 0;
    overflow: hidden;
}

.cert-property {
    display: flex;
    padding: 12px 20px;
}

.cert-property + .cert-property {
    border-top: 1px solid var(--cert-border);
}

.cert-property-key {
    font-size: 0.88em;
    font-weight: 500;
    color: var(--cert-text-muted);
    white-space: nowrap;
    width: 36%;
    flex-shrink: 0;
}

.cert-property-value {
    font-size: 0.92em;
}

/* --- Photo Gallery --- */
.cert-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.cert-gallery img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--cert-radius-img);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.cert-gallery img:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

/* --- Lightbox --- */
.cert-lightbox {
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    border: none;
    border-radius: 16px;
    background: var(--cert-bg);
    box-shadow: 0 24px 80px rgba(0,0,0,0.3);
}

.cert-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    display: block;
}

.cert-lightbox::backdrop {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* --- Event Separator --- */
.cert-event-separator {
    border-top: 1px solid var(--cert-border);
    margin: 0.6em 0;
}

/* --- Internal Notes (admin-only) --- */
.cert-internal {
    background: var(--cert-bg-subtle);
    border-left: 3px solid var(--cert-text-faint);
    padding: 1em 1.5em;
    border-radius: 0 var(--cert-radius-inner) var(--cert-radius-inner) 0;
    margin-top: 0.5em;
}

/* --- Verification Badge --- */
.cert-verify-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 10px;
    background: #e8f5e8;
    color: #3d7a3d;
    font-size: 0.75em;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.02em;
    text-transform: none;
    vertical-align: middle;
}

.cert-verify-icon--fail {
    background: #f5e8e8;
    color: #7a3d3d;
}

/* --- Footer --- */
.cert-footer {
    text-align: center;
    padding-top: 2em;
}

.cert-footer-text {
    font-size: 0.72em;
    font-weight: 500;
    color: #b0a798;
    letter-spacing: 0.04em;
}

/* --- Back Link (below card) --- */
.cert-back {
    text-align: center;
    margin-top: 2em;
}

.cert-back a {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--cert-text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.cert-back a:hover {
    color: var(--cert-text);
}

/* --- Responsive: Tablet --- */
@media (max-width: 768px) {
    :root {
        --cert-padding-x: 28px;
        --cert-padding-y: 36px;
        --cert-radius-card: 16px;
    }

    .cert {
        box-shadow:
            0 1px 2px rgba(0,0,0,0.04),
            0 4px 16px rgba(0,0,0,0.06);
    }

    .cert-number { font-size: 1.6em; }
    .cert-name { font-size: 1em; }
    .cert-gallery { grid-template-columns: repeat(3, 1fr); }
    .cert-property-key { white-space: normal; width: 40%; }
}

/* --- Responsive: Mobile --- */
@media (max-width: 480px) {
    :root {
        --cert-padding-x: 20px;
        --cert-padding-y: 28px;
        --cert-radius-card: 14px;
        --cert-radius-inner: 10px;
        --cert-radius-img: 8px;
    }

    .cert-number { font-size: 1.35em; }
    .cert-name { font-size: 0.95em; }
    .cert-section-title { font-size: 0.68em; }
    .cert-gallery { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .cert-divider, .cert-divider-ornate { margin: 1.5em 0; }
    .cert-property-key, .cert-property-value { font-size: 0.86em; }
    .cert-property { padding: 10px 14px; }
}

/* --- Print --- */
@media print {
    .cert {
        box-shadow: none;
        margin: 0;
        max-width: none;
        border-radius: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .cert-gallery img:hover { transform: none; box-shadow: none; }
    .cert-lightbox { display: none; }
}
