/* ============================================
   political.wiki - Parliamentary Library Design
   ============================================ */

/* CSS Custom Properties */
:root {
    --aged-vellum: #F4ECD8;
    --bookcloth-linen: #E8DCC8;
    --tooling-gold: #C4A35A;
    --ink-vermillion: #A0522D;
    --carbon-ink: #2C1810;
    --faded-sepia: #5B4636;
    --library-mahogany: #3E1F0D;
    --pressed-fern: #4A6741;
    --dried-petal: #C17858;
    --binding-shadow: #1A0E08;
    --brass-dark: #8B7332;
    --brass-highlight: #DAC47A;
    --brass-border: #6B5422;
    --linen-line: #D4C8B0;
    --deep-mahogany: #4A2A16;

    --spring-easing: cubic-bezier(0.34, 1.56, 0.64, 1);
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Crimson Pro', 'Times New Roman', serif;
    --font-annotation: 'Caveat', cursive;
    --font-technical: 'Literata', 'Georgia', serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--aged-vellum);
    color: var(--carbon-ink);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.4vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* Linen Weave Texture on body */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(212, 200, 176, 0.3) 2px, rgba(212, 200, 176, 0.3) 3px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(212, 200, 176, 0.3) 2px, rgba(212, 200, 176, 0.3) 3px);
}

/* ============================================
   Book Cover - Opening Sequence
   ============================================ */
#book-cover {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    perspective: 1500px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--binding-shadow);
    transition: opacity 0.6s ease;
}

#book-cover.hidden {
    opacity: 0;
    pointer-events: none;
}

#cover-front {
    width: 80vw;
    max-width: 600px;
    height: 80vh;
    max-height: 800px;
    background: radial-gradient(ellipse at 30% 40%, #4A2A16 0%, #3E1F0D 60%, #2C1810 100%);
    border-radius: 4px 12px 12px 4px;
    position: relative;
    transform-origin: left center;
    transition: transform 1.8s var(--spring-easing);
    box-shadow:
        inset 0 0 60px rgba(26, 14, 8, 0.5),
        4px 4px 20px rgba(0, 0, 0, 0.6),
        -2px 0 8px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

#book-cover.opening #cover-front {
    transform: rotateY(-160deg);
}

.cover-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    opacity: 0.15;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(196, 163, 90, 0.1) 2px,
            rgba(196, 163, 90, 0.1) 3px
        );
}

.cover-border {
    position: absolute;
    top: 30px;
    left: 30px;
    right: 30px;
    bottom: 30px;
    border: 2px solid var(--tooling-gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.gilt-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border-color: var(--tooling-gold);
    border-style: solid;
}
.gilt-corner-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; }
.gilt-corner-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; }
.gilt-corner-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; }
.gilt-corner-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; }

.cover-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    color: var(--tooling-gold);
    letter-spacing: 0.15em;
    font-variant: small-caps;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.cover-subtitle {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--tooling-gold);
    letter-spacing: 0.08em;
    opacity: 0.8;
    text-align: center;
}

.wax-seal {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle, #A0522D 0%, #6B3020 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    margin-top: 12px;
}

.wax-seal span {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.8rem;
    color: rgba(244, 236, 216, 0.7);
    transform: rotate(-5deg);
}

#endpaper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background:
        conic-gradient(from 30deg at 25% 35%, #C17858 0deg, #4A6741 60deg, #C4A35A 120deg, #F4ECD8 180deg, #C17858 240deg, #4A6741 300deg, #C17858 360deg),
        conic-gradient(from 150deg at 75% 65%, #F4ECD8 0deg, #C4A35A 90deg, #C17858 180deg, #4A6741 270deg, #F4ECD8 360deg);
    background-blend-mode: overlay;
    opacity: 0;
    transition: opacity 0.8s ease 1.0s;
}

#book-cover.opening #endpaper {
    opacity: 1;
}

/* ============================================
   Spine Navigation
   ============================================ */
#spine {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, #4A2A16 0%, #3E1F0D 60%, #2C1810 100%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 3px 0 12px rgba(26, 14, 8, 0.5);
    opacity: 0;
    transition: opacity 0.6s ease;
}

#spine.visible {
    opacity: 1;
}

.spine-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.08;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1px,
            rgba(196, 163, 90, 0.3) 1px,
            rgba(196, 163, 90, 0.3) 2px
        );
    pointer-events: none;
}

.spine-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.65rem;
    color: var(--tooling-gold);
    letter-spacing: 0.1em;
    font-variant: small-caps;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px 4px;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    position: relative;
    z-index: 1;
}

.spine-label:hover {
    color: var(--brass-highlight);
    text-shadow: 0 0 8px rgba(218, 196, 122, 0.4);
}

/* ============================================
   Mobile Bookmark Ribbons
   ============================================ */
#bookmark-ribbons {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#bookmark-ribbons.visible {
    opacity: 1;
}

.ribbon {
    width: 28px;
    height: 40px;
    border: none;
    cursor: pointer;
    clip-path: polygon(0 0, 100% 0, 100% 75%, 50% 100%, 0 75%);
    transition: transform 0.3s var(--spring-easing);
}

.ribbon:hover {
    transform: translateY(-4px);
}

.ribbon-red { background-color: var(--ink-vermillion); }
.ribbon-green { background-color: var(--pressed-fern); }
.ribbon-gold { background-color: var(--tooling-gold); }

/* ============================================
   Main Content Area
   ============================================ */
#content-area {
    margin-left: 48px;
    padding: 40px 32px;
    max-width: 1400px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#content-area.visible {
    opacity: 1;
}

/* ============================================
   Section Headers
   ============================================ */
.section-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px;
    padding-top: 24px;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    color: var(--carbon-ink);
    letter-spacing: 0.02em;
    font-variant: small-caps;
    white-space: nowrap;
}

.gilt-rule {
    flex: 1;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--tooling-gold) 10%,
        var(--brass-dark) 50%,
        var(--tooling-gold) 90%,
        transparent 100%
    );
    position: relative;
}

.gilt-rule::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: var(--tooling-gold);
    border-radius: 50%;
}

/* ============================================
   Block Grid
   ============================================ */
.block-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2px;
    background: linear-gradient(180deg, #C4A35A 0%, #8B7332 40%, #A08840 60%, #C4A35A 100%);
    padding: 2px;
    border-radius: 2px;
    margin-bottom: 60px;
}

.specimens-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.index-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* ============================================
   Content Sections
   ============================================ */
.content-section {
    margin-bottom: 20px;
}

/* ============================================
   Block Base Styles
   ============================================ */
.block {
    background: var(--aged-vellum);
    padding: 24px;
    position: relative;
    opacity: 0;
    transform: translateY(40px) scale(0.96);
    transition: opacity 0.6s var(--spring-easing), transform 0.6s var(--spring-easing);
}

.block.animate-in {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.block h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.4rem, 2.5vw, 1.8rem);
    color: var(--carbon-ink);
    letter-spacing: 0.02em;
    margin-bottom: 12px;
    font-variant: small-caps;
}

.block h4 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--carbon-ink);
    letter-spacing: 0.02em;
    margin-bottom: 8px;
    font-variant: small-caps;
}

.block p {
    margin-bottom: 0;
    text-indent: 1.5em;
}

.block p:first-of-type {
    text-indent: 0;
}

.block p + p {
    text-indent: 1.5em;
}

.annotation {
    font-family: var(--font-annotation);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--faded-sepia);
    transform: rotate(-1.5deg);
    display: inline-block;
    margin-top: 12px;
    text-indent: 0 !important;
}

/* ============================================
   Folio Blocks (2-column spanning)
   ============================================ */
.folio-block {
    grid-column: 1 / -1;
    padding: 32px;
    padding-left: 48px;
    position: relative;
}

.stitching {
    position: absolute;
    left: 16px;
    top: 24px;
    bottom: 24px;
    width: 4px;
    background: repeating-linear-gradient(
        180deg,
        var(--faded-sepia) 0px,
        var(--faded-sepia) 4px,
        transparent 4px,
        transparent 6px,
        var(--faded-sepia) 6px,
        var(--faded-sepia) 10px,
        transparent 10px,
        transparent 12px,
        var(--faded-sepia) 12px,
        var(--faded-sepia) 16px,
        transparent 16px,
        transparent 18px,
        var(--faded-sepia) 18px,
        var(--faded-sepia) 22px,
        transparent 22px,
        transparent 24px,
        var(--faded-sepia) 24px,
        var(--faded-sepia) 32px,
        transparent 32px,
        transparent 34px
    );
    opacity: 0.5;
}

.folio-spread {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.folio-left,
.folio-right {
    flex: 1;
}

.gutter-shadow {
    width: 2px;
    min-height: 100%;
    background: linear-gradient(180deg,
        transparent 0%,
        var(--binding-shadow) 20%,
        rgba(26, 14, 8, 0.6) 50%,
        var(--binding-shadow) 80%,
        transparent 100%
    );
    box-shadow:
        -4px 0 8px rgba(26, 14, 8, 0.15),
        4px 0 8px rgba(26, 14, 8, 0.15);
    flex-shrink: 0;
    align-self: stretch;
}

/* ============================================
   Drawer Blocks
   ============================================ */
.drawer-block {
    cursor: pointer;
    transition: opacity 0.6s var(--spring-easing), transform 0.6s var(--spring-easing),
                box-shadow 0.3s ease;
    background: var(--bookcloth-linen);
    overflow: hidden;
}

.drawer-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(212, 200, 176, 0.2) 2px, rgba(212, 200, 176, 0.2) 3px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(212, 200, 176, 0.2) 2px, rgba(212, 200, 176, 0.2) 3px);
}

.brass-pull {
    width: 48px;
    height: 12px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--tooling-gold) 0%, var(--brass-dark) 50%, var(--brass-highlight) 100%);
    border: 1px solid var(--brass-border);
    border-radius: 6px;
    box-shadow:
        0 2px 4px rgba(26, 14, 8, 0.4),
        inset 0 1px 0 rgba(218, 196, 122, 0.6);
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.drawer-block:hover .brass-pull {
    transform: rotate(15deg);
}

.drawer-face {
    position: relative;
    z-index: 1;
}

.drawer-hidden {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s var(--spring-easing), padding 0.5s ease;
    padding-top: 0;
    border-top: none;
    position: relative;
    z-index: 1;
}

.drawer-block.open .drawer-hidden {
    max-height: 400px;
    padding-top: 16px;
    border-top: 1px solid var(--linen-line);
}

.drawer-block.open {
    box-shadow: inset 0 4px 8px rgba(26, 14, 8, 0.15);
}

/* ============================================
   Specimen Blocks
   ============================================ */
.specimen-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: var(--aged-vellum);
    min-height: 420px;
}

.mounting-pin {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--brass-highlight) 0%, var(--tooling-gold) 40%, var(--brass-dark) 100%);
    box-shadow: 0 1px 3px rgba(26, 14, 8, 0.4);
    margin-bottom: 8px;
}

.botanical-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    filter: brightness(1.05) contrast(0.92) saturate(0.8);
}

.brass-button {
    margin-top: 12px;
    padding: 6px 16px;
    font-family: var(--font-technical);
    font-weight: 500;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--carbon-ink);
    background: linear-gradient(135deg, var(--tooling-gold) 0%, var(--brass-dark) 50%, var(--brass-highlight) 100%);
    border: 1px solid var(--brass-border);
    border-radius: 3px;
    cursor: pointer;
    box-shadow:
        0 2px 4px rgba(26, 14, 8, 0.4),
        inset 0 1px 0 rgba(218, 196, 122, 0.6);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.brass-button:active {
    box-shadow:
        0 1px 2px rgba(26, 14, 8, 0.4),
        inset 0 2px 4px rgba(26, 14, 8, 0.3);
    transform: translateY(1px);
}

.specimen-label {
    font-family: var(--font-annotation);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--faded-sepia);
    margin-top: 12px;
    transform: rotate(-1.5deg);
    text-align: center;
}

/* ============================================
   Index Cards
   ============================================ */
.index-card {
    background: #FBF7ED;
    border-radius: 6px;
    padding: 16px 20px;
    min-height: auto;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent calc(1.5em - 1px),
            rgba(196, 163, 90, 0.2) calc(1.5em - 1px),
            rgba(196, 163, 90, 0.2) 1.5em
        );
    background-position: 0 2.5em;
    box-shadow: 1px 1px 4px rgba(26, 14, 8, 0.1);
}

.index-card h4 {
    border-bottom: 1px solid var(--tooling-gold);
    padding-bottom: 4px;
}

.index-card p {
    font-family: var(--font-technical);
    font-weight: 300;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    line-height: 1.5em;
    color: var(--faded-sepia);
    text-indent: 0;
}

/* ============================================
   Wax Seal (section completion indicator)
   ============================================ */
.content-section .section-header::after {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle, #A0522D 0%, #6B3020 100%);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

/* ============================================
   Ribbon Bookmarks on blocks
   ============================================ */
.folio-block::after {
    content: '';
    position: absolute;
    top: 0;
    right: 24px;
    width: 16px;
    height: 36px;
    background: var(--ink-vermillion);
    clip-path: polygon(0 0, 100% 0, 100% 75%, 50% 100%, 0 75%);
}

.content-section:nth-child(2n) .folio-block::after {
    background: var(--pressed-fern);
}

.content-section:nth-child(3n) .folio-block::after {
    background: var(--tooling-gold);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    #spine {
        display: none;
    }

    #bookmark-ribbons {
        display: flex;
    }

    #content-area {
        margin-left: 0;
        padding: 24px 16px 60px;
    }

    .block-grid {
        grid-template-columns: 1fr;
    }

    .folio-spread {
        flex-direction: column;
    }

    .gutter-shadow {
        width: 100%;
        min-height: 2px;
        height: 2px;
        box-shadow:
            0 -4px 8px rgba(26, 14, 8, 0.1),
            0 4px 8px rgba(26, 14, 8, 0.1);
    }

    .folio-block {
        padding-left: 24px;
    }

    .stitching {
        left: 8px;
    }

    .section-title {
        font-size: clamp(1.6rem, 4vw, 2.5rem);
    }

    .index-grid {
        grid-template-columns: 1fr;
    }

    .specimens-grid {
        grid-template-columns: 1fr;
    }

    #cover-front {
        width: 90vw;
        height: 70vh;
    }
}

@media (max-width: 480px) {
    .cover-title {
        font-size: 1.8rem;
    }

    .cover-border {
        top: 16px;
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .block {
        padding: 16px;
    }
}

/* ============================================
   Paper texture canvas overlay
   ============================================ */
#paper-texture-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.04;
}
