/* ============================================
   diplomatic.boo - Celestial Diplomatic Almanac
   Styles
   ============================================ */

/* --- CSS Variables --- */
:root {
    --parchment: #F5F0E6;
    --ink: #2B2B3A;
    --ink-secondary: #3D3D4A;
    --stellar-rose: #FF6B9D;
    --treaty-teal: #00D4AA;
    --signal-yellow: #FFD93D;
    --astral-violet: #C084FC;
    --deep-void: #0F0F1A;
    --foxing: #D4A574;
    --dispatch-gray: #6B7280;
    --white: #FFFFFF;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.75;
    color: var(--ink-secondary);
    background-color: var(--parchment);
    overflow-x: hidden;
}

/* --- Paper Texture Background (4-layer CSS-only texture) --- */
.parchment-mode {
    background-color: var(--parchment);
    background-image:
        /* Layer 2: Vertical fiber pattern */
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(212, 165, 116, 0.03) 3px,
            rgba(212, 165, 116, 0.03) 4px
        ),
        /* Layer 3: Foxing spots - 14 scattered radial gradients */
        radial-gradient(circle at 15% 25%, rgba(212, 165, 116, 0.04) 0%, transparent 50px),
        radial-gradient(circle at 72% 18%, rgba(212, 165, 116, 0.03) 0%, transparent 40px),
        radial-gradient(circle at 35% 65%, rgba(212, 165, 116, 0.04) 0%, transparent 60px),
        radial-gradient(circle at 85% 50%, rgba(212, 165, 116, 0.02) 0%, transparent 45px),
        radial-gradient(circle at 50% 80%, rgba(212, 165, 116, 0.03) 0%, transparent 55px),
        radial-gradient(circle at 8% 70%, rgba(212, 165, 116, 0.04) 0%, transparent 35px),
        radial-gradient(circle at 60% 35%, rgba(212, 165, 116, 0.02) 0%, transparent 70px),
        radial-gradient(circle at 92% 85%, rgba(212, 165, 116, 0.03) 0%, transparent 50px),
        radial-gradient(circle at 25% 92%, rgba(212, 165, 116, 0.04) 0%, transparent 40px),
        radial-gradient(circle at 78% 72%, rgba(212, 165, 116, 0.03) 0%, transparent 55px),
        radial-gradient(circle at 45% 10%, rgba(212, 165, 116, 0.02) 0%, transparent 30px),
        radial-gradient(circle at 5% 45%, rgba(212, 165, 116, 0.035) 0%, transparent 65px),
        radial-gradient(circle at 40% 42%, rgba(212, 165, 116, 0.025) 0%, transparent 80px),
        radial-gradient(circle at 68% 88%, rgba(212, 165, 116, 0.03) 0%, transparent 45px);
    /* Layer 4: Edge vignette */
    box-shadow: inset 0 0 80px rgba(212, 165, 116, 0.08);
}

.void-mode {
    background-color: var(--deep-void);
    color: var(--parchment);
}

/* --- Navigation - Telegram Header Strip --- */
.telegram-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 30px;
    background-color: rgba(15, 15, 26, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(212, 165, 116, 0.15);
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.05em;
    transition: transform 0.3s ease;
}

.nav-label {
    color: var(--dispatch-gray);
    text-transform: uppercase;
    font-weight: 400;
}

.nav-dispatches {
    display: flex;
    gap: 4px;
}

.nav-dispatch-link {
    color: var(--dispatch-gray);
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid rgba(107, 114, 128, 0.3);
    transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
    font-weight: 700;
}

.nav-dispatch-link:hover {
    color: var(--signal-yellow);
    border-color: var(--signal-yellow);
    background-color: rgba(255, 217, 61, 0.06);
}

.nav-dispatch-link.active {
    color: var(--signal-yellow);
    border-color: var(--signal-yellow);
}

/* --- Hero Section --- */
.hero {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.hero-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 8vw;
    line-height: 1.05;
    color: var(--parchment);
    letter-spacing: 0.08em;
    opacity: 0;
    animation: fadeIn 1.2s ease-out forwards;
}

.hero-subtitle {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    color: var(--dispatch-gray);
    margin-top: 20px;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 600ms ease-out 400ms forwards;
}

.hero-constellation {
    display: block;
    margin: 30px auto 0;
    opacity: 0;
    animation: fadeIn 800ms ease-out 800ms forwards;
}

.constellation-line {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawLine 1200ms ease-in-out 1000ms forwards;
}

.constellation-node {
    opacity: 0;
    animation: fadeIn 400ms ease-out 1800ms forwards;
}

.hero-chevron {
    font-family: 'Space Mono', monospace;
    color: var(--signal-yellow);
    font-size: 24px;
    margin-top: 40px;
    opacity: 0;
    animation: fadeIn 600ms ease-out 2000ms forwards, bob 2s ease-in-out 2600ms infinite;
    cursor: pointer;
}

/* --- Star Field Container --- */
.star-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
}

/* --- Dispatch Sections (16-column asymmetric grid) --- */
.dispatch {
    position: relative;
    padding: 80px 0;
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 0 20px;
}

/* Odd dispatches: content columns 2-10, annotation columns 12-16 */
.dispatch-odd .dispatch-inner {
    grid-column: 2 / 11;
}

.dispatch-odd .margin-annotation {
    grid-column: 12 / 16;
}

/* Even dispatches: content columns 7-16, annotation columns 2-5 */
.dispatch-even .dispatch-inner {
    grid-column: 7 / 16;
}

.dispatch-even .margin-annotation {
    grid-column: 2 / 5;
    grid-row: 1;
}

.dispatch-inner {
    position: relative;
    border: 1px solid var(--ink);
    padding: 0;
    overflow: visible;
    /* Torn-edge bottom with irregular vertices */
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 94.5%,
        98% 95.8%, 96% 94.2%, 94% 96.1%, 92% 94.8%, 90% 96.5%,
        88% 95%, 86% 96.8%, 84% 94.5%, 82% 96.2%, 80% 95.3%,
        78% 97%, 76% 95.2%, 74% 96.5%, 72% 94.8%, 70% 96%,
        68% 95.5%, 66% 97.2%, 64% 95%, 62% 96.3%, 60% 94.6%,
        58% 96.8%, 56% 95.2%, 54% 97%, 52% 95.5%, 50% 96.2%,
        48% 94.5%, 46% 96.5%, 44% 95.8%, 42% 97%, 40% 95%,
        38% 96.3%, 36% 94.8%, 34% 96.5%, 32% 95.2%, 30% 97%,
        28% 95.5%, 26% 96.2%, 24% 94.5%, 22% 96.8%, 20% 95%,
        18% 97%, 16% 95.3%, 14% 96.5%, 12% 94.8%, 10% 96.2%,
        8% 95%, 6% 96.8%, 4% 94.5%, 2% 96.5%, 0% 95%
    );
}

/* Colored paper beneath torn edge */
.dispatch-inner::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 12px;
    z-index: -1;
}

.dispatch-odd .dispatch-inner::after {
    background-color: currentColor;
}

.dispatch-accent {
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 0;
    z-index: 5;
    transition: height 400ms ease-out;
}

.dispatch-accent.animate {
    height: 100%;
}

/* --- Dispatch Header (telegram-style) --- */
.dispatch-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(43, 43, 58, 0.15);
    background-color: rgba(43, 43, 58, 0.03);
    opacity: 0;
    transform: translateX(-30px);
}

.dispatch-header.animate {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
}

.dispatch-number {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: 16px;
    color: var(--ink);
}

.dispatch-date {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.6;
    color: var(--dispatch-gray);
}

.dispatch-stamp {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    border: 2px dashed;
    transform: rotate(-3deg);
    margin-left: auto;
    white-space: nowrap;
}

.stamp-rose {
    color: var(--stellar-rose);
    border-color: var(--stellar-rose);
}

.stamp-teal {
    color: var(--treaty-teal);
    border-color: var(--treaty-teal);
}

.stamp-gold {
    color: var(--signal-yellow);
    border-color: var(--signal-yellow);
}

.stamp-violet {
    color: var(--astral-violet);
    border-color: var(--astral-violet);
}

/* Decorative star glyph on dispatch headers */
.dispatch-header::before {
    content: '\2726';
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 20px;
    color: var(--stellar-rose);
    flex-shrink: 0;
}

.dispatch-even .dispatch-header::before {
    color: var(--signal-yellow);
}

.dispatch:nth-of-type(5) .dispatch-header::before {
    color: var(--astral-violet);
}

/* --- Dispatch Body --- */
.dispatch-body {
    padding: 30px 28px 40px;
    opacity: 0;
    transform: translateY(12px);
}

.dispatch-body.animate {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.dispatch-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: 42px;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: 24px;
}

.dispatch-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.75;
    color: var(--ink-secondary);
    margin-bottom: 18px;
}

.dispatch-text:last-child {
    margin-bottom: 0;
}

/* Emphasized passages */
.dispatch-text strong {
    font-weight: 600;
    color: var(--ink);
}

/* --- Section Break Stars --- */
.dispatch-section-break {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 20px 0 10px;
}

.section-star {
    font-size: 16px;
}

.section-star:nth-child(2) {
    font-size: 22px;
}

/* --- Rubber Stamp Overlay --- */
.rubber-stamp {
    position: absolute;
    top: 60px;
    right: 40px;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 36px;
    text-transform: uppercase;
    color: var(--stellar-rose);
    opacity: 0.12;
    transform: rotate(2deg);
    letter-spacing: 0.1em;
    pointer-events: none;
    z-index: 3;
}

.stamp-overlay-gold {
    color: var(--signal-yellow);
    transform: rotate(-2deg);
}

/* --- Wax Seal --- */
.wax-seal {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, var(--stellar-rose), var(--astral-violet));
    margin: 10px auto 30px;
    position: relative;
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.3);
}

.wax-seal::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.seal-glyph {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 24px;
    color: var(--parchment);
}

/* --- Margin Annotations (sticky side panels) --- */
.margin-annotation {
    position: sticky;
    top: 20vh;
    align-self: start;
    padding: 15px;
    width: 140px;
    opacity: 0;
    transform: translateX(10px);
}

.margin-annotation.animate {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.margin-annotation.margin-left {
    transform: translateX(-10px);
}

.margin-annotation.margin-left.animate {
    transform: translateX(0);
}

.constellation-diagram {
    display: block;
    margin-bottom: 10px;
}

.annotation-label {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--astral-violet);
    margin-bottom: 4px;
}

.annotation-note {
    display: block;
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 12px;
    line-height: 1.6;
    color: var(--dispatch-gray);
}

/* --- Star-field Interludes (full-bleed void sections) --- */
.interlude {
    position: relative;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.interlude-quote {
    position: relative;
    z-index: 2;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: 6vw;
    line-height: 1.2;
    color: var(--treaty-teal);
    text-align: center;
    max-width: 80%;
    padding: 0 40px;
}

/* --- Star Glyphs (magnetic interaction targets) --- */
.star-glyph {
    display: inline-block;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: default;
    will-change: transform;
}

/* --- Footer --- */
.site-footer {
    position: relative;
    padding: 80px 30px;
    text-align: center;
    overflow: hidden;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
}

.footer-content {
    position: relative;
    z-index: 2;
}

.footer-seal {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, var(--stellar-rose), var(--astral-violet));
    margin: 0 auto 24px;
    box-shadow: 0 4px 20px rgba(255, 107, 157, 0.25);
}

.footer-seal::before {
    content: '';
    position: absolute;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.footer-seal .seal-glyph {
    font-size: 32px;
}

.footer-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 28px;
    line-height: 1.25;
    color: var(--parchment);
    margin-bottom: 12px;
}

.footer-text {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.6;
    color: var(--dispatch-gray);
    margin-bottom: 6px;
}

.footer-stars {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 30px;
}

.footer-star {
    font-size: 20px;
}

.footer-classification {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: rgba(107, 114, 128, 0.5);
    margin-top: 24px;
    text-transform: uppercase;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

@keyframes starFadeIn {
    from { opacity: 0; }
    to { opacity: var(--star-opacity, 0.6); }
}

@keyframes twinkle {
    0%, 100% { opacity: var(--star-opacity, 0.6); }
    50% { opacity: calc(var(--star-opacity, 0.6) * 0.3); }
}

@keyframes starPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .dispatch {
        padding: 60px 20px;
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .dispatch-odd .dispatch-inner,
    .dispatch-even .dispatch-inner {
        grid-column: 1 / -1;
    }

    .dispatch-odd .margin-annotation,
    .dispatch-even .margin-annotation {
        grid-column: 1 / -1;
        position: relative;
        top: auto;
        width: auto;
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 10px 20px;
    }

    .margin-annotation .constellation-diagram {
        width: 60px;
        height: 60px;
        margin-bottom: 0;
        flex-shrink: 0;
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 12vw;
    }

    .hero-subtitle {
        font-size: 12px;
        padding: 0 20px;
    }

    .dispatch-title {
        font-size: 28px;
    }

    .dispatch-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 14px 18px;
    }

    .dispatch-body {
        padding: 20px 18px 30px;
    }

    .dispatch-text {
        font-size: 16px;
    }

    .interlude-quote {
        font-size: 8vw;
    }

    .telegram-nav {
        padding: 8px 15px;
    }

    .nav-label {
        display: none;
    }

    .nav-dispatch-link {
        padding: 3px 8px;
        font-size: 11px;
    }

    .footer-title {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .dispatch-stamp {
        font-size: 9px;
        padding: 2px 6px;
    }

    .rubber-stamp {
        font-size: 24px;
        top: 40px;
        right: 20px;
    }

    .hero-title {
        font-size: 14vw;
    }

    .interlude-quote {
        font-size: 10vw;
        padding: 0 20px;
    }
}
