/* ===== longitude.quest - Weathered Navigator's Meditation ===== */

:root {
    --parchment: #F5EDE0;
    --aged-gold: #E8C874;
    --brass: #C4A265;
    --dark-brass: #8B6F3A;
    --leather: #8B7355;
    --desk-wood: #3D2B1F;
    --teal-shadow: #2C4A5A;
    --warm-parchment: #D4C5A9;
    --deep-brown: #5C4A3A;
}

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

body {
    background: var(--desk-wood);
    color: var(--desk-wood);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    line-height: 1.8;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ===== Desk Surface ===== */
#desk-surface {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--desk-wood);
    z-index: 0;
}

/* ===== Candle Glow ===== */
#candle-glow {
    position: fixed;
    top: -10%;
    right: -5%;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 200, 116, 0.12) 0%, transparent 70%);
    z-index: 1;
    pointer-events: none;
    animation: candleFlicker 3s ease-in-out infinite alternate;
}

@keyframes candleFlicker {
    0% { opacity: 0.7; transform: scale(1); }
    25% { opacity: 0.85; transform: scale(1.02); }
    50% { opacity: 0.65; transform: scale(0.98); }
    75% { opacity: 0.9; transform: scale(1.01); }
    100% { opacity: 0.75; transform: scale(1); }
}

/* ===== Compass Rose ===== */
#compass-rose {
    position: fixed;
    bottom: 5vh;
    right: 5vw;
    width: 150px;
    height: 150px;
    z-index: 2;
    pointer-events: none;
    opacity: 0.4;
    animation: compassSpin 120s linear infinite;
}

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

/* ===== Parchment Pages ===== */
.parchment-page {
    position: relative;
    z-index: 3;
    max-width: 700px;
    margin: 0 auto;
    margin-bottom: 4vh;
    background: var(--parchment);
    padding: 3rem 2.5rem;
    box-shadow:
        0 2px 8px rgba(61, 43, 31, 0.3),
        0 8px 24px rgba(61, 43, 31, 0.15),
        inset 0 0 60px rgba(196, 162, 101, 0.08);
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.parchment-page.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Paper grain via SVG filter */
.parchment-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='grain'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='3' stitchTiles='stitch' type='fractalNoise'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23grain)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.page-content {
    position: relative;
    z-index: 1;
}

/* Page worn edge */
.page-edge {
    position: absolute;
    bottom: -2px;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--warm-parchment), transparent);
    opacity: 0.5;
}

/* First page extra spacing */
#page-title {
    margin-top: 15vh;
}

/* ===== Typography ===== */
h1 {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.04em;
    color: var(--desk-wood);
    margin-bottom: 1rem;
    min-height: 2.5rem;
}

h2 {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: clamp(1.25rem, 2.5vw, 2rem);
    letter-spacing: 0.04em;
    color: var(--desk-wood);
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--brass);
    padding-bottom: 0.5rem;
}

p {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 0.95rem);
    line-height: 1.9;
    color: var(--deep-brown);
    margin-bottom: 1.2rem;
}

.logbook-entry {
    font-style: italic;
    color: var(--leather);
    font-size: clamp(0.8rem, 1.1vw, 0.9rem);
}

.annotation {
    color: var(--teal-shadow);
    font-size: 0.8rem;
    padding-left: 1rem;
    border-left: 2px solid var(--brass);
    margin-top: 1rem;
    opacity: 0.8;
}

/* ===== Formula Block ===== */
.formula-block {
    text-align: center;
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(196, 162, 101, 0.1);
    border: 1px solid var(--brass);
}

.formula {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    color: var(--dark-brass);
    letter-spacing: 0.08em;
}

/* ===== Closing Mark ===== */
.closing-mark {
    text-align: center;
    font-size: 1.5rem;
    color: var(--brass);
    margin-top: 2rem;
}

/* ===== Typewriter cursor ===== */
.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--desk-wood);
    animation: cursorBlink 0.8s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .parchment-page {
        margin-left: 1rem;
        margin-right: 1rem;
        padding: 2rem 1.5rem;
    }

    #compass-rose {
        width: 100px;
        height: 100px;
        right: 2vw;
        bottom: 2vh;
    }

    #page-title {
        margin-top: 8vh;
    }
}

@media (max-width: 480px) {
    .parchment-page {
        padding: 1.5rem 1rem;
    }
}
