/* ==========================================================================
   INTERNATIONAL DIPLOMATIC TREATY & TERRITORIAL REGISTRY (UN / ICJ STYLE)
   Official Diplomatic Styling Sheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700;800;900&family=Cormorant+Garamond:ital,wght@0,500;0,600;0,700;1,400;1,600&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    --diplomatic-navy-dark: #081225;
    --diplomatic-navy: #0C1E3C;
    --diplomatic-blue-light: #1E3A8A;
    --treaty-gold: #C5A880;
    --treaty-gold-light: #F3E8D6;
    --treaty-gold-dark: #8C6D3F;
    --diplomatic-paper: #FDFBF7;
    --diplomatic-border: #CBD5E1;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--diplomatic-navy-dark);
    color: #F8FAFC;
    overflow-x: hidden;
}

.font-serif-treaty {
    font-family: 'Cormorant Garamond', 'Cinzel', serif;
}

.font-serif-royal {
    font-family: 'Cinzel', serif;
}

.font-mono-diplomatic {
    font-family: 'JetBrains Mono', monospace;
}

/* Diplomatic Header & Nav */
.diplomatic-header-bg {
    background: linear-gradient(180deg, #060D1A 0%, #0C1E3C 100%);
    border-bottom: 2px solid var(--treaty-gold-dark);
}

.diplomatic-gold-border {
    border-color: var(--treaty-gold);
}

.diplomatic-gold-text {
    color: var(--treaty-gold);
}

/* ==========================================================================
   OFFICIAL DIPLOMATIC TREATY INSTRUMENT (CERTIFICATE)
   Styled after International Court of Justice / UN Treaties
   ========================================================================== */

.diplomatic-treaty-container {
    background-color: var(--diplomatic-paper);
    color: #0A1120;
    position: relative;
    border-radius: 4px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 0 2px var(--treaty-gold);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(197, 168, 128, 0.04) 0%, transparent 80%),
        repeating-linear-gradient(45deg, rgba(140, 109, 63, 0.02) 0, rgba(140, 109, 63, 0.02) 1px, transparent 0, transparent 20px);
}

/* Diplomatic Guilloche & Gold Embossed Border */
.diplomatic-guilloche-border {
    position: relative;
    border: 3px double #0C1E3C;
    outline: 2px solid var(--treaty-gold);
    outline-offset: 6px;
}

.diplomatic-corner-seal {
    position: absolute;
    width: 26px;
    height: 26px;
    background: radial-gradient(circle, #F3E8D6 20%, #C5A880 60%, #0C1E3C 100%);
    border: 2px solid #FFF;
    border-radius: 50%;
    z-index: 10;
}
.corner-tl { top: -15px; left: -15px; }
.corner-tr { top: -15px; right: -15px; }
.corner-bl { bottom: -15px; left: -15px; }
.corner-br { bottom: -15px; right: -15px; }

/* Grand Imperial Diploma Opulent Frame */
.diplomatic-grand-diploma {
    border: 4px double #0C1E3C !important;
    outline: 3px solid var(--treaty-gold) !important;
    outline-offset: 8px !important;
    box-shadow: 0 30px 75px -15px rgba(0, 0, 0, 0.85), 0 0 0 1px #8C6D3F, inset 0 0 70px rgba(197, 168, 128, 0.08) !important;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(197, 168, 128, 0.06) 0%, transparent 85%),
        repeating-linear-gradient(45deg, rgba(140, 109, 63, 0.025) 0, rgba(140, 109, 63, 0.025) 1px, transparent 0, transparent 24px) !important;
}

.diplomatic-grand-corner {
    position: absolute;
    width: 32px;
    height: 32px;
    background: radial-gradient(circle, #FFF 10%, #F3E8D6 25%, #C5A880 55%, #8C6D3F 80%, #0C1E3C 100%);
    border: 2.5px solid #FFF;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    z-index: 10;
}
.diplomatic-grand-corner.corner-tl { top: -18px; left: -18px; }
.diplomatic-grand-corner.corner-tr { top: -18px; right: -18px; }
.diplomatic-grand-corner.corner-bl { bottom: -18px; left: -18px; }
.diplomatic-grand-corner.corner-br { bottom: -18px; right: -18px; }

/* Diplomatic Sovereign Seal & Hologram Apposition Box */
.diplomatic-seal-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    margin: 0;
}

.diplomatic-seal-svg,
.hologram-apposition-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Diplomatic Guilloche Security Watermark (Banknote / Treaty Grade) */
.treaty-guilloche-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.22;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.cert-deed-portrait-sheet .treaty-guilloche-watermark {
    width: 78% !important;
    max-width: 460px !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    top: 48% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.cert-deed-landscape-sheet .treaty-guilloche-watermark {
    width: 92% !important;
    max-width: 860px !important;
    height: 90% !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.treaty-watermark-text-subtle {
    position: absolute;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-25deg);
    font-size: 4.2rem;
    font-weight: 900;
    font-family: 'Cinzel', serif;
    color: rgba(140, 109, 63, 0.15);
    letter-spacing: 0.35em;
    pointer-events: none;
    white-space: nowrap;
    user-select: none;
    z-index: 1;
}

/* Unpaid Draft / Preview Watermark Overlay (Before Checkout) */
.cert-draft-watermark-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cert-draft-watermark-overlay.hidden {
    display: none !important;
}

.draft-diagonal-ribbon {
    transform: rotate(-28deg);
    background: linear-gradient(90deg, transparent 0%, rgba(220, 38, 38, 0.12) 15%, rgba(220, 38, 38, 0.18) 50%, rgba(220, 38, 38, 0.12) 85%, transparent 100%);
    border-top: 2px dashed rgba(220, 38, 38, 0.35);
    border-bottom: 2px dashed rgba(220, 38, 38, 0.35);
    width: 150%;
    padding: 14px 0;
    text-align: center;
    color: rgba(185, 28, 28, 0.75);
    font-family: 'Cinzel', serif;
    font-weight: 900;
    letter-spacing: 0.28em;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.draft-stamp-box {
    margin-top: 15px;
    transform: rotate(-8deg);
    border: 3px solid rgba(220, 38, 38, 0.45);
    border-radius: 8px;
    padding: 6px 18px;
    color: rgba(185, 28, 28, 0.65);
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    background: rgba(254, 242, 242, 0.35);
}

/* ==========================================================================
   GIS SATELLITE DEMARCATION MAP STYLING
   ========================================================================== */

#antarctica-gis-map {
    width: 100%;
    height: 580px;
    background-color: #060D1A;
    border-radius: 8px;
    border: 1px solid var(--treaty-gold-dark);
}

.official-map-tooltip {
    background: #081225 !important;
    border: 1px solid var(--treaty-gold) !important;
    color: #F8FAFC !important;
    border-radius: 6px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8) !important;
}

.official-map-tooltip::before {
    border-top-color: #081225 !important;
}

/* Pulse badge */
.pulse-badge {
    position: relative;
}
.pulse-badge::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    background: currentColor;
    opacity: 0.4;
    animation: pulseGlow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.35); opacity: 0; }
}

/* ==========================================================================
   PRINT STYLESHEET (High-Res 300 DPI A4 Export)
   ========================================================================== */

@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    *, *::before, *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        background: #FFF !important;
        color: #0A1120 !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: 100% !important;
        overflow: visible !important;
    }

    /* Hide everything except certificate area */
    header, footer, nav, .no-print, #plot-warning-toast, #tab-panel-landing, #tab-panel-map, #tab-panel-owner, #tab-panel-title, #tab-panel-registry, #checkout-modal, #heraldry-studio-modal {
        display: none !important;
    }

    /* Strict hiding of inactive certificate subtabs during print */
    .hidden,
    [hidden],
    .cert-deed-sheet.hidden,
    #cert-schedule-container.hidden,
    #cert-main-container.hidden,
    #cert-title-container.hidden,
    #cert-grand-container.hidden,
    #cert-schedule-container.hidden .cert-deed-sheet {
        display: none !important;
    }

    #tab-panel-certificate {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    #tab-panel-certificate > .grid {
        display: block !important;
        width: 100% !important;
    }

    .lg\:col-span-8 {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .lg\:col-span-4 {
        display: none !important;
    }

    #certificate-printable-area {
        display: block !important;
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 !important;
        background: transparent !important;
    }

    .diplomatic-treaty-container {
        box-shadow: none !important;
        border: 2.5px double #0C1E3C !important;
        outline: 1.5px solid #C5A880 !important;
        outline-offset: -5px !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        background-color: #FDFBF7 !important;
        box-sizing: border-box !important;
    }

    .cert-deed-sheet:not(.hidden) {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        margin: 0 !important;
        page-break-after: auto !important;
        break-after: auto !important;
    }

    #cert-schedule-container:not(.hidden) {
        display: block !important;
        gap: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* All deeds mode: break between all deeds in order */
    body[data-cert-print-mode="both"] #cert-main-container:not(.hidden),
    body[data-cert-print-mode="both"] #cert-title-container:not(.hidden),
    body[data-cert-print-mode="both"] #cert-schedule-container:not(.hidden) .cert-deed-sheet,
    body[data-cert-print-mode="all"] #cert-main-container:not(.hidden),
    body[data-cert-print-mode="all"] #cert-title-container:not(.hidden),
    body[data-cert-print-mode="all"] #cert-schedule-container:not(.hidden) .cert-deed-sheet {
        page-break-after: always !important;
        break-after: page !important;
    }

    body[data-cert-print-mode="both"] #cert-grand-container:not(.hidden),
    body[data-cert-print-mode="all"] #cert-grand-container:not(.hidden) {
        page-break-after: auto !important;
        break-after: auto !important;
    }

    /* Schedule only mode: break between schedule sheets, but not after the last sheet */
    body[data-cert-print-mode="schedule"] #cert-schedule-container:not(.hidden) .cert-deed-sheet:not(:last-child) {
        page-break-after: always !important;
        break-after: page !important;
    }

    body[data-cert-print-mode="schedule"] #cert-schedule-container:not(.hidden) .cert-deed-sheet:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }

    .cert-deed-portrait-sheet:not(.hidden) {
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm !important;
        height: 297mm !important;
        max-height: 297mm !important;
        padding: 9mm 12mm 9mm 12mm !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        position: relative !important;
        overflow: hidden !important;
    }

    .cert-deed-portrait-sheet > .cert-content-body,
    .cert-deed-portrait-sheet > .space-y-3,
    .cert-deed-portrait-sheet > .space-y-4,
    .cert-deed-portrait-sheet > .relative:not(.text-center):not(.border-b) {
        flex: 1 1 auto !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-evenly !important;
        margin: 0 !important;
        padding-top: 1mm !important;
        padding-bottom: 1mm !important;
    }

    .cert-deed-landscape-sheet:not(.hidden) {
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm !important;
        height: 297mm !important;
        max-height: 297mm !important;
        padding: 0 !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
        position: relative !important;
        overflow: hidden !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        border: none !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    .cert-deed-landscape-sheet > .cert-rotated-inner {
        width: 297mm !important;
        max-width: 297mm !important;
        height: 210mm !important;
        min-height: 210mm !important;
        max-height: 210mm !important;
        padding: 8mm 10mm !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) rotate(90deg) !important;
        transform-origin: center center !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        background-color: #FDFBF7 !important;
        border: 2.5px double #0C1E3C !important;
        outline: 1.5px solid #C5A880 !important;
        outline-offset: -5px !important;
    }

    .cert-deed-landscape-sheet .cert-content-body,
    .cert-deed-landscape-sheet .space-y-2,
    .cert-deed-landscape-sheet .relative:not(.text-center):not(.border-b) {
        flex: 1 1 auto !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-evenly !important;
        margin: 0 !important;
        padding-top: 0.5mm !important;
        padding-bottom: 0.5mm !important;
    }

    .treaty-guilloche-watermark {
        opacity: 0.22 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .treaty-watermark-text-subtle {
        opacity: 1 !important;
        color: rgba(140, 109, 63, 0.16) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .cert-bg-silhouette {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        opacity: 0.22 !important;
    }

    .diplomatic-corner-seal,
    .diplomatic-grand-corner {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

.cert-deed-landscape {
    max-width: 100%;
    width: 100%;
}

.heraldic-crest-svg {
    overflow: visible !important;
}

#cert-heraldic-crest-slot,
#heraldry-canvas-preview,
#modal-heraldry-canvas {
    overflow: visible !important;
}
