/* ============================================
   diplomatic.quest - Medieval Cartographic Style
   ============================================ */

/* --- CSS Variables (from DESIGN.md palette) --- */
:root {
    --parchment-gold: #f4e8c1;
    --ink-sepia: #3e2723;
    --royal-crimson: #8b0000;
    --forest-mantle: #2e5339;
    --wax-seal: #cc5500;
    --vellum: #e8e4d4;
    --gilded: #b8860b;

    --font-heading: 'Cormorant Garamond', serif;
    --font-body: 'EB Garamond', serif;
    --font-accent: 'MedievalSharp', cursive;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--ink-sepia);
    background-color: var(--parchment-gold);
    overflow-x: hidden;
}

/* --- Parchment Noise Texture --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#noise);
    opacity: 0.06;
    pointer-events: none;
    z-index: 9999;
}

/* --- Quest Log Sidebar --- */
#quest-log {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 220px;
    background: linear-gradient(135deg, #5c3a1e 0%, #3e2518 100%);
    border: 3px solid var(--gilded);
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 4px 4px 20px rgba(0,0,0,0.4), inset 0 0 30px rgba(0,0,0,0.3);
    color: var(--parchment-gold);
    padding: 0;
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32"><path d="M8 28 L6 30 L5 29 L7 27 Z" fill="%233e2723"/><path d="M8 28 L24 4 L26 6 L10 30 Z" fill="%23b8860b" stroke="%233e2723" stroke-width="0.5"/><path d="M24 4 L25 2 L28 5 L26 6 Z" fill="%23e8e4d4"/></svg>') 4 28, auto;
    transition: opacity 0.3s ease;
}

.quest-log-header {
    background: var(--royal-crimson);
    padding: 12px 16px;
    border-radius: 5px 5px 0 0;
    border-bottom: 2px solid var(--gilded);
    text-align: center;
}

.quest-log-title {
    font-family: var(--font-accent);
    font-size: 1.2rem;
    color: var(--parchment-gold);
    letter-spacing: 0.05em;
}

.quest-log-body {
    padding: 20px 16px;
    position: relative;
}

.quest-path {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.quest-path-line {
    position: absolute;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 0;
    border-left: 2px dashed var(--gilded);
    opacity: 0.5;
}

.envoy-marker {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 14px;
    height: 14px;
    background: var(--wax-seal);
    border: 2px solid var(--parchment-gold);
    border-radius: 50%;
    z-index: 2;
    transition: top 0.4s ease-out;
    box-shadow: 0 0 8px rgba(204, 85, 0, 0.6);
}

.quest-stop {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.stop-dot {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    border: 2px solid var(--gilded);
    background: transparent;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.quest-stop.visited .stop-dot {
    background: var(--gilded);
    border-color: var(--parchment-gold);
}

.quest-stop.active .stop-dot {
    background: var(--wax-seal);
    border-color: var(--parchment-gold);
    box-shadow: 0 0 6px rgba(204, 85, 0, 0.5);
}

.stop-label {
    font-family: var(--font-accent);
    font-size: 0.85rem;
    color: var(--vellum);
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.quest-stop.visited .stop-label,
.quest-stop.active .stop-label {
    opacity: 1;
    color: var(--parchment-gold);
}

/* --- Main Content --- */
#main-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 40px;
    padding-right: 280px;
}

/* --- Sections --- */
.section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px 0;
    position: relative;
}

/* --- Hero Section --- */
.hero-section {
    text-align: center;
    padding-top: 60px;
}

.parchment-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(62,39,35,0.08) 100%);
    pointer-events: none;
}

/* --- Compass Rose --- */
.compass-rose {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 50px;
}

.compass-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--parchment-gold);
    border: 3px solid var(--ink-sepia);
    z-index: 4;
    box-shadow: 0 0 0 4px var(--gilded), 0 0 0 6px var(--ink-sepia);
}

.compass-square {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    border: 2px solid var(--ink-sepia);
    background: var(--gilded);
    opacity: 0.7;
    z-index: 2;
}

.compass-square.sq1 {
    transform: translate(-50%, -50%) rotate(45deg);
}

.compass-square.sq2 {
    transform: translate(-50%, -50%) rotate(22.5deg);
}

.compass-point {
    position: absolute;
    z-index: 3;
    font-family: var(--font-accent);
    font-size: 1rem;
    color: var(--ink-sepia);
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-point.north {
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-point.north::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid var(--gilded);
}

.compass-point.south {
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-point.south::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 20px solid var(--gilded);
}

.compass-point.east {
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-point.east::before {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 20px solid var(--gilded);
}

.compass-point.west {
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-point.west::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 20px solid var(--gilded);
}

/* --- Banner Ribbon --- */
.banner-ribbon {
    position: relative;
    display: inline-block;
    padding: 16px 60px;
    background: var(--royal-crimson);
    color: var(--parchment-gold);
    clip-path: polygon(0% 20%, 5% 0%, 95% 0%, 100% 20%, 100% 80%, 95% 100%, 5% 100%, 0% 80%);
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.site-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(2rem, 4vw, 3.5rem);
    letter-spacing: 0.08em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.2rem;
    font-style: italic;
    color: var(--ink-sepia);
    opacity: 0.8;
    margin-bottom: 60px;
    max-width: 500px;
}

/* --- Scroll Indicator --- */
.scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: bobDown 2s ease-in-out infinite;
}

.scroll-indicator span {
    font-family: var(--font-accent);
    font-size: 0.9rem;
    color: var(--gilded);
    letter-spacing: 0.1em;
}

.scroll-arrow {
    width: 20px;
    height: 20px;
    border-right: 2px solid var(--gilded);
    border-bottom: 2px solid var(--gilded);
    transform: rotate(45deg);
}

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

/* --- Path Connector --- */
.path-connector {
    width: 2px;
    height: 80px;
    margin: 0 auto;
    border-left: 2px dashed var(--gilded);
    position: relative;
}

.path-connector::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gilded);
}

.path-connector::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: -5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gilded);
}

/* --- Kingdom Sections --- */
.kingdom-section {
    padding: 60px 0;
    min-height: auto;
}

.kingdom-warm {
    background-color: var(--parchment-gold);
}

.kingdom-cool {
    background-color: var(--vellum);
}

/* --- Manuscript Border --- */
.manuscript-border {
    position: relative;
    border: 2px solid var(--ink-sepia);
    padding: 50px 40px;
    max-width: 700px;
    width: 100%;
    background: rgba(244, 232, 193, 0.4);
    box-shadow: inset 0 0 0 6px transparent, inset 0 0 0 7px var(--gilded);
}

/* --- Corner Flourishes --- */
.corner-flourish {
    position: absolute;
    width: 20px;
    height: 20px;
}

.corner-flourish::before,
.corner-flourish::after {
    content: '';
    position: absolute;
    background: var(--gilded);
}

.corner-flourish::before {
    width: 14px;
    height: 14px;
    border: 2px solid var(--ink-sepia);
    transform: rotate(45deg);
}

.corner-flourish::after {
    width: 30px;
    height: 2px;
    background: var(--gilded);
    top: 50%;
}

.corner-flourish.top-left {
    top: -10px;
    left: -10px;
}
.corner-flourish.top-left::after {
    left: 8px;
    transform: translateY(-50%);
}

.corner-flourish.top-right {
    top: -10px;
    right: -10px;
}
.corner-flourish.top-right::after {
    right: 8px;
    transform: translateY(-50%);
}

.corner-flourish.bottom-left {
    bottom: -10px;
    left: -10px;
}
.corner-flourish.bottom-left::after {
    left: 8px;
    transform: translateY(-50%);
}

.corner-flourish.bottom-right {
    bottom: -10px;
    right: -10px;
}
.corner-flourish.bottom-right::after {
    right: 8px;
    transform: translateY(-50%);
}

/* --- Section Anchor / Wax Seal --- */
.section-anchor {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.wax-seal {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #e07020, var(--wax-seal) 50%, #a04000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 3px 8px rgba(0,0,0,0.35), inset 0 -2px 4px rgba(0,0,0,0.2), inset 0 2px 4px rgba(255,200,100,0.2);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.wax-seal::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 60%, rgba(160, 64, 0, 0.3) 100%);
    /* Bumpy seal edge */
    clip-path: polygon(
        50% 0%, 58% 2%, 65% 0%, 72% 3%, 78% 1%, 84% 5%, 90% 4%, 95% 10%,
        97% 16%, 100% 22%, 98% 28%, 100% 35%, 98% 42%, 100% 50%,
        98% 58%, 100% 65%, 97% 72%, 100% 78%, 95% 84%, 90% 90%,
        84% 95%, 78% 97%, 72% 100%, 65% 98%, 58% 100%, 50% 98%,
        42% 100%, 35% 98%, 28% 100%, 22% 97%, 16% 100%, 10% 95%,
        5% 90%, 2% 84%, 0% 78%, 3% 72%, 0% 65%, 2% 58%,
        0% 50%, 2% 42%, 0% 35%, 3% 28%, 0% 22%, 5% 16%,
        10% 10%, 16% 5%, 22% 2%, 28% 0%, 35% 2%, 42% 0%
    );
}

.wax-seal span {
    font-family: var(--font-accent);
    font-size: 1.5rem;
    color: var(--parchment-gold);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    z-index: 1;
}

.wax-seal:hover {
    transform: scale(1.1);
    box-shadow: 3px 4px 12px rgba(0,0,0,0.4), inset 0 -2px 4px rgba(0,0,0,0.2), inset 0 2px 4px rgba(255,200,100,0.3);
}

.grand-seal {
    width: 80px;
    height: 80px;
}

.grand-seal span {
    font-size: 2rem;
}

/* --- Kingdom Typography --- */
.kingdom-name {
    font-family: var(--font-accent);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--ink-sepia);
    text-align: center;
    margin-bottom: 6px;
}

.kingdom-epithet {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--gilded);
    text-align: center;
    margin-bottom: 30px;
    letter-spacing: 0.1em;
}

.kingdom-content p {
    margin-bottom: 18px;
    text-align: justify;
    text-indent: 2em;
}

.kingdom-content p:first-child::first-letter {
    font-family: var(--font-accent);
    font-size: 3em;
    float: left;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 6px;
    color: var(--royal-crimson);
}

/* --- Royal Decree / Blockquote --- */
.royal-decree {
    position: relative;
    margin: 30px 0 10px;
    padding: 24px 30px 24px 30px;
    border-left: 4px solid var(--royal-crimson);
    background: rgba(139, 0, 0, 0.05);
    font-style: italic;
    font-size: 1rem;
    line-height: 1.8;
}

.decree-label {
    display: block;
    font-family: var(--font-accent);
    font-style: normal;
    font-size: 0.8rem;
    color: var(--royal-crimson);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* --- Treaty Scroll --- */
.treaty-scroll {
    margin-top: 30px;
    padding: 30px;
    background: var(--parchment-gold);
    border: 2px solid var(--gilded);
    position: relative;
    text-align: center;
}

.treaty-scroll::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 14px;
    height: 14px;
    background: var(--parchment-gold);
    border-top: 2px solid var(--gilded);
    border-left: 2px solid var(--gilded);
}

.treaty-scroll h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--royal-crimson);
    margin-bottom: 20px;
}

.treaty-terms {
    list-style: none;
    text-align: left;
    max-width: 500px;
    margin: 0 auto 24px;
}

.treaty-terms li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.treaty-terms li::before {
    content: '\2726';
    position: absolute;
    left: 0;
    color: var(--gilded);
    font-size: 1rem;
}

.treaty-seals {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.treaty-seal {
    width: 50px;
    height: 50px;
    opacity: 0.4;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.treaty-seal.stamped {
    opacity: 1;
    transform: scale(1.05);
}

.treaty-seal span {
    font-size: 1.2rem;
}

/* --- Conclusion Section --- */
.conclusion-section .kingdom-content p:first-child::first-letter {
    color: var(--gilded);
}

/* --- Forest Mantle accent (used in nature-themed kingdom) --- */
#kingdom-verdantia .kingdom-content p:first-child::first-letter {
    color: var(--forest-mantle);
}

#kingdom-verdantia .royal-decree {
    border-left-color: var(--forest-mantle);
    background: rgba(46, 83, 57, 0.06);
}

#kingdom-verdantia .decree-label {
    color: var(--forest-mantle);
}

/* --- Footer --- */
.footer-section {
    padding: 60px 0;
    text-align: center;
}

.footer-flourish {
    width: 200px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gilded), transparent);
    margin: 0 auto 24px;
}

.footer-text {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink-sepia);
    margin-bottom: 8px;
    font-style: italic;
}

.footer-domain {
    font-family: var(--font-accent);
    font-size: 0.9rem;
    color: var(--gilded);
    letter-spacing: 0.2em;
}

/* --- Animations --- */
.kingdom-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.kingdom-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.compass-rose {
    animation: compassSpin 30s linear infinite;
}

@keyframes compassSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.compass-point {
    animation: compassCounterSpin 30s linear infinite;
}

@keyframes compassCounterSpin {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(-360deg); }
}

.compass-point.east,
.compass-point.west {
    animation-name: compassCounterSpinY;
}

@keyframes compassCounterSpinY {
    from { transform: translateY(-50%) rotate(0deg); }
    to { transform: translateY(-50%) rotate(-360deg); }
}

/* Wax seal press animation */
@keyframes sealPress {
    0% { transform: scale(1.3); opacity: 0.6; }
    50% { transform: scale(0.95); }
    100% { transform: scale(1.05); opacity: 1; }
}

.treaty-seal.stamping {
    animation: sealPress 0.4s ease-out forwards;
}

/* --- Responsive --- */
@media (max-width: 1100px) {
    #quest-log {
        display: none;
    }
    #main-content {
        padding-right: 40px;
    }
}

@media (max-width: 600px) {
    #main-content {
        padding: 0 16px;
    }
    .manuscript-border {
        padding: 30px 20px;
    }
    .banner-ribbon {
        padding: 12px 30px;
    }
    .compass-rose {
        width: 140px;
        height: 140px;
    }
    .compass-square {
        width: 70px;
        height: 70px;
    }
    .compass-circle {
        width: 44px;
        height: 44px;
    }
    .treaty-seals {
        flex-wrap: wrap;
    }
}
