/* =================================================================== */
/* ===== FEATURE 3: PREAMBLE EXPLORER STYLES (HISTORIC & REFINED) ===== */
/* =================================================================== */

/* Variables inheriting from global style tokens with premium extensions */
:root {
    --preamble-saffron: #FF9933;
    --preamble-green: #138808;
    --preamble-navy: #000080;
    --preamble-gold-primary: #b5893d;
    --preamble-gold-bright: #d4af37;
    --preamble-gold-dark: #8a6d3b;
    --preamble-maroon-historic: #4a1805; /* Deep, rich calligraphic maroon from original image */
    --preamble-parchment: #f4f6e4; /* Authentic light-sage/warm cream aged parchment */
    --preamble-parchment-border: #8c734b;
    --preamble-glass-bg: rgba(255, 255, 255, 0.45);
    --preamble-glass-border: rgba(255, 255, 255, 0.6);
    --preamble-shadow: 0 25px 55px rgba(12, 16, 25, 0.2), 0 8px 30px rgba(0, 0, 0, 0.06);
    --preamble-transition: all 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Background Flow & Particle Effects */
body {
    min-height: 100vh;
    background-color: #f3f5ee;
    background-image: 
        radial-gradient(rgba(74, 24, 5, 0.03) 1.5px, transparent 1.5px),
        linear-gradient(135deg, #FFEFE2 0%, #FFFFFF 50%, #E8FDF0 100%);
    background-size: 30px 30px, 100% 100%;
}

/* DECREASED CONTAINER WIDTH FOR HISTORIC SCROLL RATIO */
.preamble-container {
    position: relative;
    width: 100%;
    max-width: 820px;
    margin: 100px auto 50px;
    padding: 0 var(--space-lg);
    box-sizing: border-box;
    z-index: 2;
}

/* Background Orbs */
.preamble-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}

.preamble-bg .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    mix-blend-mode: multiply;
    animation: orbFloat 15s ease-in-out infinite alternate;
}

.orb--saffron {
    top: -10%;
    left: 5%;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, var(--preamble-saffron) 0%, transparent 70%);
}

.orb--green {
    bottom: -10%;
    right: 5%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--preamble-green) 0%, transparent 70%);
    animation-delay: -3s;
}

.orb--navy {
    top: 40%;
    left: 45%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--preamble-navy) 0%, transparent 70%);
    animation-delay: -6s;
}

@keyframes orbFloat {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -40px) scale(1.1); }
    100% { transform: translate(-20px, 20px) scale(0.95); }
}

/* Introduction Headers */
.preamble-header {
    text-align: center;
    max-width: 750px;
    margin: 0 auto var(--space-xl);
    z-index: 10;
    position: relative;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    background: rgba(74, 24, 5, 0.06);
    border: 1px solid rgba(74, 24, 5, 0.15);
    color: var(--preamble-maroon-historic);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-md);
    box-shadow: 0 4px 10px rgba(74, 24, 5, 0.05);
}

.preamble-header h2 {
    font-size: clamp(2rem, 5vw, 2.8rem);
    font-weight: 800;
    color: var(--preamble-maroon-historic);
    margin: 0;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.intro-lead {
    font-size: clamp(0.95rem, 2vw, 1.05rem);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-top: var(--space-sm);
}

/* DECREASED WIDTH: Parchment Paper Constitution Container */
.parchment-frame {
    position: relative;
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
    background: var(--preamble-parchment);
    box-shadow: var(--preamble-shadow), inset 0 0 100px rgba(216, 185, 147, 0.25);
    border-radius: 14px;
    padding: 10px;
    box-sizing: border-box;
    z-index: 5;
    margin-bottom: 24px;
}

/* AUTHENTIC DEEP PADDING: Text pushed inside the 110px border strips on all 4 sides */
.parchment-inner {
    position: relative;
    background: var(--preamble-parchment);
    /* top/bottom: 110px border + generous breathing room */
    /* left/right: 90px side border + breathing room */
    padding: clamp(8rem, 12vw, 10rem) clamp(7rem, 10vw, 8.5rem);
    border-radius: 8px;
    overflow: hidden;
}



/* ══════════════════════════════════════════════════════════
   FOUR-SIDED AUTHENTIC BORDER
   Each side uses a dedicated pre-rotated SVG (border-top/bottom/left/right.svg)
   No CSS rotation tricks — just simple absolute positioning.
   ══════════════════════════════════════════════════════════ */

.preamble-golden-border {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: visible;
}

/* ── TOP: full width strip anchored to the top edge ── */
.border-top {
    position: absolute;
    display: block;
    top: -11px;
    left: -6px;
    width: calc(100% + 12px);
    height: 115px;          /* matches the 310px viewBox height at appropriate scale */
    object-fit: fill;
}

/* ── BOTTOM: same SVG as top, flipped vertically with CSS scaleY(-1) ── */
/* scaleY(-1) is 100% reliable in browsers — no SVG transform hacks needed */
.border-bottom {
    position: absolute;
    display: block;
    bottom: -6px;
    left: -6px;
    width: calc(100% + 12px);
    height: 110px;
    object-fit: fill;
    transform: scaleY(-1);          /* flip: flowers now face UP (inward toward content) */
    transform-origin: center center;
}

/* ── LEFT: narrow full-height strip on the left edge ── */
.border-left {
    position: absolute;
    display: block;
    left: -6px;
    top: -6px;
    width: 90px;           /* visual width of the decorative band */
    height: calc(100% + 12px);
    object-fit: fill;
}

/* ── RIGHT: narrow full-height strip on the right edge ── */
.border-right {
    position: absolute;
    display: block;
    right: -6px;
    top: -6px;
    width: 90px;
    height: calc(100% + 12px);
    object-fit: fill;
}

/* ── Responsive: slightly thinner strips on mobile ── */
@media (max-width: 600px) {
    .border-top,
    .border-bottom {
        height: 68px;
        top: -3px;
        left: -3px;
        width: calc(100% + 6px);
    }
    .border-bottom {
        bottom: -3px;
        top: unset;
    }
    .border-left,
    .border-right {
        width: 58px;
        top: -3px;
        height: calc(100% + 6px);
    }
    .border-right {
        right: -3px;
        left: unset;
    }
}




/* Watermark: Extremely subtle background details */
.chakra-watermark {
    position: absolute;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(300px, 60vw, 420px);
    height: clamp(300px, 60vw, 420px);
    opacity: 0.05;
    pointer-events: none;
    user-select: none;
    z-index: 1;
}

.chakra-watermark svg {
    width: 100%;
    height: 100%;
    color: var(--preamble-maroon-historic);
}

/* AUTHENTIC BLACKLETTER TITLES: Exact match of original document */
.preamble-title {
    font-family: 'Grenze Gotisch', 'EB Garamond', serif;
    font-size: clamp(2.2rem, 5vw, 3.4rem); /* Enlarged, majestic Gothic title */
    font-weight: 800;
    text-align: center;
    color: var(--preamble-maroon-historic);
    letter-spacing: 0.02em;
    margin-top: 1.2rem;
    margin-bottom: 0.4rem;
    position: relative;
    z-index: 10;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
}

/* Calligraphic Traditional Divider Under Title */
.traditional-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 240px;
    height: 24px;
    margin: 0.8rem auto 1.4rem;
    position: relative;
    z-index: 10;
    opacity: 0.9;
}

.traditional-divider svg {
    width: 100%;
    height: 100%;
}

.preamble-subtitle {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: clamp(1.15rem, 2vw, 1.35rem);
    font-weight: 800;
    text-align: center;
    color: var(--preamble-maroon-historic);
    letter-spacing: 0.28em;
    margin-bottom: clamp(1.8rem, 4vw, 2.6rem);
    position: relative;
    z-index: 10;
}

/* CENTERED PREAMBLE BODY TEXT (Authentic layout) */
.preamble-text {
    position: relative;
    z-index: 10;
    text-align: center;
    line-height: 2.15;
    font-family: 'EB Garamond', 'Georgia', serif;
    font-size: clamp(1.1rem, 2vw, 1.32rem); /* Enhanced calligraphic readability */
    color: #2e1d13;
    padding: 0 15px;
}

.solemn-resolve {
    margin-bottom: 1.8rem;
    text-align: center;
}

.sovereign-block {
    display: block;
    font-family: 'Cinzel', serif;
    font-weight: 800;
    font-size: clamp(1.2rem, 2.2vw, 1.42rem);
    color: var(--preamble-maroon-historic);
    letter-spacing: 0.05em;
    margin-top: 0.6rem;
    line-height: 1.6;
}

/* CENTERED VALUES LIST (Authentic Symmetrical Flow) */
.values-list {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
    margin: 2rem 0;
    padding-left: 0;
    border-left: none;
    align-items: center;
}

.value-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    width: 100%;
}

.fraternity-lead {
    margin: 0.8rem 0 0.4rem;
    font-style: italic;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.value-subtext {
    color: #3d2f23;
    font-size: clamp(1.05rem, 1.8vw, 1.22rem);
    line-height: 1.55;
    max-width: 92%;
}

.adoption-clause {
    margin-top: clamp(2rem, 6vw, 3.2rem);
    text-align: center;
    font-style: italic;
    line-height: 1.8;
}

/* ── Interactive Highlight Term Buttons ── */
.term-wrapper {
    display: inline-block;
    position: relative;
    z-index: 15;
}

.preamble-term {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 1.5rem;
    font-family: 'Cinzel', serif;
    font-weight: 800;
    font-size: clamp(1.125rem, 2vw, 1.38rem);
    letter-spacing: 0.1em;
    cursor: pointer;
    border-radius: 8px;
    user-select: none;
    transition: var(--preamble-transition);
    outline: none;
}

/* Term Colors matching the actual Preamble's rich dark-red/bronze accent tones */
#term-justice { 
    color: var(--preamble-maroon-historic); 
    background: rgba(74, 24, 5, 0.04); 
}
#term-justice .outline-svg { color: var(--preamble-saffron); }

#term-liberty { 
    color: var(--preamble-maroon-historic); 
    background: rgba(74, 24, 5, 0.04); 
}
#term-liberty .outline-svg { color: var(--preamble-navy); }

#term-equality { 
    color: var(--preamble-maroon-historic); 
    background: rgba(74, 24, 5, 0.04); 
}
#term-equality .outline-svg { color: var(--preamble-green); }

#term-fraternity { 
    color: var(--preamble-maroon-historic); 
    background: rgba(74, 24, 5, 0.04); 
}
#term-fraternity .outline-svg { color: var(--preamble-gold-primary); }

/* Interactive Hover States */
.preamble-term:hover,
.preamble-term:focus-visible {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 4px 15px rgba(74, 24, 5, 0.1);
    background: rgba(74, 24, 5, 0.08);
}

.preamble-term:active {
    transform: translateY(0) scale(1);
}

/* SVG Outline Drawer logic */
.outline-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 8px;
}

.svg-rect {
    stroke-dasharray: 450;
    stroke-dashoffset: 450;
    stroke: currentColor;
    transition: stroke-dashoffset 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* On hover/focus drawing trigger */
.preamble-term:hover .svg-rect,
.preamble-term:focus-visible .svg-rect {
    stroke-dashoffset: 0;
}

/* Dynamic glow values on focus */
.preamble-term:focus-visible {
    box-shadow: 0 0 0 3px rgba(74, 24, 5, 0.25);
}

/* Mobile instruction hint */
.tap-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 15px;
    display: none;
    font-family: 'EB Garamond', serif;
}

/* ── Elegant Glassmorphic Modal overlay ── */
.preamble-modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-fixed);
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
    padding: var(--space-md);
    box-sizing: border-box;
}

.preamble-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.preamble-modal-card {
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--preamble-glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 30px 70px rgba(6, 10, 20, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.94) translateY(20px);
    transition: transform 450ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 300ms ease;
    opacity: 0;
    overflow: hidden;
    font-family: system-ui, -apple-system, sans-serif;
}

.preamble-modal-overlay.active .preamble-modal-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Modal Header styling */
.modal-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid rgba(0, 0, 128, 0.08);
    background: rgba(255, 255, 255, 0.4);
}

.modal-term-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(0, 0, 128, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--preamble-navy);
    font-size: 1.25rem;
    margin-right: var(--space-md);
}

.modal-header h3 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--preamble-navy);
}

.modal-close-btn {
    background: rgba(15, 23, 42, 0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--preamble-transition);
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: rotate(90deg);
}

/* Modal Scroll Body content */
.modal-body-content {
    padding: var(--space-xl);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    max-height: 55vh;
}

.content-section {
    padding: var(--space-lg);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: var(--preamble-transition);
}

.content-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.03);
}

/* Colors matching the categories */
.card-saffron {
    background: rgba(255, 153, 51, 0.035);
    border-left: 4px solid var(--preamble-saffron);
}
.card-saffron .section-title { color: var(--preamble-saffron); }

.card-navy {
    background: rgba(0, 0, 128, 0.025);
    border-left: 4px solid var(--preamble-navy);
}
.card-navy .section-title { color: var(--preamble-navy); }

.card-green {
    background: rgba(19, 136, 8, 0.03);
    border-left: 4px solid var(--preamble-green);
}
.card-green .section-title { color: var(--preamble-green); }

.section-title {
    margin: 0 0 10px 0;
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.content-section p {
    margin: 0;
    color: #374151;
    font-size: 0.98rem;
    line-height: 1.6;
}

/* Modal Footer & CTA Button */
.modal-footer {
    padding: var(--space-lg) var(--space-xl);
    border-top: 1px solid rgba(0, 0, 128, 0.08);
    background: rgba(255, 255, 255, 0.4);
    display: flex;
    justify-content: flex-end;
}

.modal-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--preamble-navy);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 8px 20px rgba(0, 0, 128, 0.2);
    transition: var(--preamble-transition);
}

.modal-action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(0, 0, 128, 0.3);
    background: var(--navy-dark);
}

.modal-action-btn:active {
    transform: translateY(0);
}

/* ===== RESPONSIVE MEDIA QUERIES ===== */
@media (max-width: 768px) {
    .preamble-container {
        margin-top: 90px;
        max-width: 100%;
    }

    .parchment-inner {
        padding: clamp(7.5rem, 10vw, 8.5rem) clamp(6.8rem, 8vw, 7.5rem);
    }

    @media (max-width: 600px) {
        .parchment-inner {
            padding: clamp(5.2rem, 9vw, 6.2rem) clamp(4.5rem, 7vw, 5.2rem);
        }
    }

    .values-list {
        margin: 1.5rem 0;
        gap: 1.4rem;
    }

    .value-item {
        gap: 4px;
    }

    .value-subtext {
        font-size: 1.05rem;
        max-width: 95%;
    }

    .modal-body-content {
        padding: var(--space-md);
        gap: var(--space-md);
    }

    .content-section {
        padding: var(--space-md);
    }
}

@media (max-width: 480px) {
    .tap-hint {
        display: block;
    }

    .preamble-header h2 {
        font-size: 2.2rem;
    }

    .parchment-frame {
        border-radius: 8px;
        padding: 5px;
    }

    .parchment-inner {
        padding: 4.8rem 4.2rem;
    }

    .preamble-text {
        font-size: 1.1rem;
        line-height: 1.95;
    }

    .sovereign-block {
        font-size: 1.2rem;
    }

    .preamble-term {
        padding: 0.3rem 1rem;
        font-size: 1.15rem;
    }

    .modal-header {
        padding: var(--space-md);
    }

    .modal-header h3 {
        font-size: 1.25rem;
    }

    .modal-footer {
        padding: var(--space-md);
        justify-content: center;
    }

    .modal-action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ── National Emblem of India Styling ── */
.preamble-emblem {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
    z-index: 10;
}

.preamble-emblem.top {
    margin-bottom: clamp(1rem, 2.5vw, 1.8rem);
    margin-top: calc(-1 * clamp(4.5rem, 8vw, 6.2rem) + 1.5rem); /* Proportional offset based on the inner card padding */
}

.preamble-emblem.bottom {
    margin-top: clamp(2rem, 5vw, 3rem);
    margin-bottom: calc(-1 * clamp(4.5rem, 8vw, 6.2rem) + 2rem);
}

.emblem-img {
    width: clamp(75px, 14vw, 100px); /* Majestic, high-fidelity size */
    height: auto;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.08));
    transition: transform var(--preamble-transition);
}

.emblem-img:hover {
    transform: scale(1.06);
}

/* Responsive adjustment for emblems on very small screens */
@media (max-width: 480px) {
    .preamble-emblem.top {
        margin-top: -2.2rem;
    }
    
    .preamble-emblem.bottom {
        margin-top: 1.5rem;
        margin-bottom: -2.2rem;
    }
    
    .emblem-img {
        width: 65px;
    }
}

