/* longitude.quest - Styles
   Colors: #0F2922, #F2EDE4, #6B8F7E, #C75C3A, #3D6B5E, #B8943E, #4A5568, #2A3B34, #D4DDD8, #8BA89B
   Fonts: Commissioner, Fira Code
*/

:root {
    --deep-meridian: #0F2922;
    --vellum: #F2EDE4;
    --botanical: #6B8F7E;
    --coral: #C75C3A;
    --meridian-line: #3D6B5E;
    --gold: #B8943E;
    --section-divide: #4A5568;
    --text-dark: #2A3B34;
    --text-light: #D4DDD8;
    --sage: #8BA89B;
    --reveal-duration: 0.8s;
    --reveal-easing: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Commissioner', sans-serif;
    font-weight: 375;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: var(--text-dark);
    background-color: var(--vellum);
    overflow-x: hidden;
    position: relative;
}

/* Grain overlay */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* Canvas layers */
#meridian-canvas,
#botanical-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

#botanical-canvas {
    z-index: 1;
}

/* Root networks */
#root-networks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* ========== COMPASS NAVIGATION ========== */
#compass-nav {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 500;
    width: 48px;
    height: 48px;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

#compass-nav:hover,
#compass-nav.expanded {
    width: 200px;
    height: 200px;
}

#compass-rose {
    width: 100%;
    height: 100%;
    transition: transform 60s linear;
}

#compass-nav:hover #compass-rose,
#compass-nav.expanded #compass-rose {
    animation: compass-slow-rotate 60s linear infinite;
}

@keyframes compass-slow-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.compass-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.4s var(--reveal-easing);
    pointer-events: none;
}

#compass-nav:hover .compass-labels,
#compass-nav.expanded .compass-labels {
    opacity: 1;
    pointer-events: auto;
}

.compass-label {
    position: absolute;
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    color: var(--botanical);
    background: rgba(242, 237, 228, 0.9);
    border: 1px solid var(--meridian-line);
    padding: 2px 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.3s, background 0.3s;
}

.compass-label:hover {
    color: var(--coral);
    background: rgba(242, 237, 228, 1);
}

.label-n { top: 0; left: 50%; transform: translateX(-50%); }
.label-e { top: 50%; right: 0; transform: translateY(-50%); }
.label-s { bottom: 0; left: 50%; transform: translateX(-50%); }
.label-w { top: 50%; left: 0; transform: translateY(-50%); }
.label-ne { top: 15%; right: 5%; }

/* ========== SECTIONS ========== */
.section {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    padding: 8vh 0;
}

.section--light {
    background: transparent;
    color: var(--text-dark);
}

.section--dark {
    background: var(--deep-meridian);
    color: var(--text-light);
}

.section--dark .section-header {
    color: var(--text-light);
}

.section--dark .content-block p {
    color: var(--text-light);
}

.section--dark .coordinate-label {
    color: var(--botanical);
}

.section--final {
    padding-bottom: 20vh;
}

/* ========== HERO ========== */
#hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hero-meridian-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 100%;
    z-index: 1;
}

#hero-line {
    width: 100%;
    height: 100%;
}

#hero-meridian-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: draw-meridian 2s var(--reveal-easing) forwards;
}

@keyframes draw-meridian {
    to { stroke-dashoffset: 0; }
}

.hero-content {
    position: relative;
    z-index: 5;
    text-align: center;
    opacity: 0;
    animation: fade-in 1s var(--reveal-easing) 1.8s forwards;
}

.hero-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: clamp(2.2rem, 6vw, 4rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dark);
    margin-bottom: 1rem;
    display: inline-flex;
    gap: 0.05em;
}

.letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: letter-appear 0.6s var(--reveal-easing) forwards;
}

.letter[data-index="0"] { animation-delay: 2.0s; }
.letter[data-index="1"] { animation-delay: 2.12s; }
.letter[data-index="2"] { animation-delay: 2.24s; }
.letter[data-index="3"] { animation-delay: 2.36s; }
.letter[data-index="4"] { animation-delay: 2.48s; }
.letter[data-index="5"] { animation-delay: 2.60s; }
.letter[data-index="6"] { animation-delay: 2.72s; }
.letter[data-index="7"] { animation-delay: 2.84s; }
.letter[data-index="8"] { animation-delay: 2.96s; }

@keyframes letter-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-coordinates {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--botanical);
    opacity: 0;
    animation: fade-in 1.2s var(--reveal-easing) 3.2s forwards;
}

@keyframes fade-in {
    to { opacity: 1; }
}

.hero-bloom {
    position: absolute;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 100px;
    z-index: 4;
}

/* ========== SECTION BANDS ========== */
.section-band {
    max-width: 520px;
    min-width: 180px;
    padding: 4vh 2rem;
    position: relative;
}

.band--west {
    margin-left: 12%;
    margin-right: auto;
}

.band--east {
    margin-left: auto;
    margin-right: 12%;
}

.band--center {
    margin-left: auto;
    margin-right: auto;
}

.band--convergent {
    margin-left: auto;
    margin-right: auto;
    max-width: 420px;
    text-align: center;
}

/* ========== STATION MARKERS ========== */
.station-marker {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.coordinate-label {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--botanical);
    text-transform: uppercase;
}

.station-bloom {
    width: 24px;
    height: 24px;
    position: relative;
}

/* ========== SECTION HEADERS ========== */
.section-header {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.08em;
    color: var(--text-dark);
    margin-bottom: 2rem;
    text-transform: uppercase;
}

/* ========== MERIDIAN TRACES ========== */
.meridian-trace {
    position: absolute;
    width: 1px;
    background: var(--meridian-line);
    opacity: 0;
    transition: opacity 1.5s var(--reveal-easing), height 2s var(--reveal-easing);
    height: 0;
}

.meridian-trace.visible {
    opacity: 1;
    height: 100%;
}

.trace--west {
    left: -20px;
    top: 0;
}

.trace--east {
    right: -20px;
    top: 0;
}

.trace--center {
    left: -30px;
    top: 0;
}

.trace--convergent {
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

/* ========== CONTENT BLOCKS ========== */
.content-block {
    margin-bottom: 2.5rem;
}

.content-block p {
    font-family: 'Commissioner', sans-serif;
    font-weight: 375;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    max-width: 38em;
    color: var(--text-dark);
}

/* ========== MARGINALIA ========== */
.marginalia {
    margin: 3rem 0;
    padding-left: 1.5rem;
    border-left: 1px solid var(--sage);
    position: relative;
}

.marginalia p {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-style: italic;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    line-height: 1.5;
    color: var(--sage);
}

.section--dark .marginalia {
    border-left-color: var(--botanical);
}

.section--dark .marginalia p {
    color: var(--sage);
}

/* ========== PULL QUOTE ========== */
.pull-quote {
    margin: 6vh 0;
    text-align: center;
}

.pull-quote blockquote p {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-style: italic;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    line-height: 1.6;
    color: var(--sage);
    max-width: 28em;
    margin: 0 auto;
}

/* ========== LATITUDE RINGS ========== */
.latitude-ring {
    position: relative;
    width: 100%;
    height: 2px;
    margin: 4rem 0;
    overflow: visible;
}

.latitude-ring::after {
    content: '';
    position: absolute;
    top: 0;
    left: -20%;
    width: 140%;
    height: 1px;
    background: var(--section-divide);
    opacity: 0.2;
    border-radius: 50%;
    transform: scaleY(0.3);
}

/* ========== GARDEN ========== */
.garden-instruction {
    text-align: center;
    margin: 2rem 0;
}

.instruction-text {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--botanical);
}

#garden-canvas {
    width: 100%;
    height: 400px;
    display: block;
    margin: 2rem 0;
    cursor: crosshair;
    position: relative;
    z-index: 20;
    border: 1px solid rgba(61, 107, 94, 0.15);
    border-radius: 2px;
    background: rgba(242, 237, 228, 0.5);
}

/* ========== DRIFT BLOOM ========== */
.drift-bloom-container {
    display: flex;
    justify-content: center;
    margin: 6vh 0;
}

#final-compass-flower {
    width: 120px;
    height: 120px;
    animation: imperceptible-rotate 120s linear infinite;
}

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

.flower-group {
    transform-origin: center;
}

/* ========== REVEAL ANIMATIONS ========== */
.reveal-element {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--reveal-duration) var(--reveal-easing),
                transform var(--reveal-duration) var(--reveal-easing);
}

.reveal-element.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========== COMPASS ROSE SECTION TRANSITION ========== */
.compass-rose-transition {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    animation: compass-slow-rotate 60s linear infinite;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .section-band {
        max-width: 100%;
        min-width: 0;
        padding: 4vh 1.5rem;
    }

    .band--west,
    .band--east {
        margin-left: 5%;
        margin-right: 5%;
    }

    .band--center,
    .band--convergent {
        margin-left: 5%;
        margin-right: 5%;
    }

    #compass-nav {
        top: 12px;
        right: 12px;
    }

    .hero-title {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

    #garden-canvas {
        height: 300px;
    }
}

@media (max-width: 480px) {
    .section-band {
        padding: 3vh 1rem;
    }

    .marginalia {
        padding-left: 1rem;
    }
}

/* ========== GRADIENT TRANSITIONS BETWEEN SECTIONS ========== */
.section--dark::before {
    content: '';
    position: absolute;
    top: -200px;
    left: 0;
    width: 100%;
    height: 200px;
    background: linear-gradient(to bottom, transparent, var(--deep-meridian));
    pointer-events: none;
    z-index: -1;
}

.section--dark + .section--light::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background: linear-gradient(to bottom, var(--deep-meridian), transparent);
    pointer-events: none;
    z-index: -1;
}

/* Ensure sections stack correctly */
.section {
    position: relative;
    overflow: visible;
}

/* Smooth background transitions via scroll */
.section--dark {
    background: var(--deep-meridian);
}
