/* ============================================================
   layer-2.quest Stylesheet
   Scandinavian-Celestial Design
   ============================================================ */

:root {
    /* Color Palette */
    --forest-void: #0C1F14;
    --birch-panel: #F0EBE0;
    --vellum: #E8DFC8;
    --star-white: #E8E4DA;
    --forest-ink: #1A2E1F;
    --oxidized-copper: #5A8C6A;
    --polaris-gold: #C9A84C;
    --frost-silver: #9EAAA2;

    /* Typography */
    --font-serif: 'Instrument Serif', serif;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'Space Grotesk', monospace;

    /* Sizing */
    --spread-height: 100vh;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--forest-void);
    color: var(--star-white);
    overflow-x: hidden;
}

/* Typography Base */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 400;
}

h1 {
    font-size: clamp(3.2rem, 8vw, 6rem);
    letter-spacing: -0.03em;
    line-height: 1.05;
}

h2 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: -0.02em;
}

h3 {
    font-size: clamp(1.4rem, 3vw, 2rem);
}

p {
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
}

/* Label and accent text */
.label, .metadata {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

/* ============================================================
   Spread System
   ============================================================ */

.spread {
    height: var(--spread-height);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Spread 1: The Observatory Dome */
.spread-1 {
    background: linear-gradient(180deg, #0a1810 0%, #0C1F14 50%, #050f0a 100%);
}

.observatory-dome {
    text-align: center;
    z-index: 10;
    position: relative;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
    animation-delay: 0.2s;
}

.constellation-title {
    font-family: var(--font-serif);
    color: var(--star-white);
    margin-bottom: 2rem;
    text-transform: lowercase;
    letter-spacing: -0.02em;
    text-shadow: 0 0 20px rgba(232, 228, 218, 0.2);
}

.divider-rule {
    width: 60%;
    height: 1px;
    background-color: var(--star-white);
    margin: 0 auto 2rem;
    opacity: 0.6;
    animation: scaleIn 1s ease-out forwards;
    animation-delay: 0.4s;
}

.subtitle {
    font-family: var(--font-serif);
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    color: var(--star-white);
    opacity: 0.7;
    letter-spacing: 0.01em;
    animation: fadeIn 1s ease-out forwards;
    animation-delay: 0.6s;
}

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

.star {
    position: absolute;
    background: radial-gradient(circle, var(--star-white), transparent);
    border-radius: 50%;
    animation: twinkle 4s infinite ease-in-out;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.2; }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scaleX(0);
    }
    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

/* Spread 2: The Protocol Atlas */
.spread-2 {
    background: linear-gradient(180deg, #0C1F14 0%, #051208 100%);
}

.protocol-atlas {
    display: grid;
    grid-template-columns: 35% 1fr;
    gap: 6rem;
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    z-index: 10;
}

.atlas-left {
    display: flex;
    align-items: flex-start;
    padding-top: 2rem;
}

.atlas-heading {
    color: var(--star-white);
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
    animation-delay: 0.3s;
}

.atlas-right {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.protocol-block {
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
    animation-delay: 0.5s;
}

.protocol-block:nth-child(2) {
    animation-delay: 0.7s;
}

.protocol-block:nth-child(3) {
    animation-delay: 0.9s;
}

.starburst-ornament {
    width: 20px;
    height: 20px;
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    vertical-align: middle;
    background-color: var(--polaris-gold);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.protocol-block h3 {
    color: var(--star-white);
    margin-bottom: 1rem;
}

.protocol-block p {
    color: var(--star-white);
    opacity: 0.9;
}

/* Spread 3: The Navigation Chart */
.spread-3 {
    background: linear-gradient(180deg, #0a1810 0%, #0C1F14 50%, #050f0a 100%);
}

.navigation-chart-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.navigation-chart {
    width: 100%;
    max-width: 500px;
    height: auto;
    opacity: 0;
    animation: fadeIn 1s ease-out forwards;
    animation-delay: 0.3s;
}

.navigation-chart rect {
    fill: transparent;
}

.orbit-ring {
    fill: none;
    stroke: var(--oxidized-copper);
    stroke-width: 1;
    opacity: 0.4;
    animation: rotateOrbit calc(120s * (1 + var(--ring-index) * 0.1)) linear infinite;
}

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

.node {
    fill: var(--polaris-gold);
    transition: r 0.3s ease-out;
}

.central-node {
    fill: var(--polaris-gold);
    filter: drop-shadow(0 0 4px var(--polaris-gold));
}

.protocol-node {
    transition: r 0.3s ease-out, filter 0.3s ease-out;
}

.protocol-node:hover {
    r: 7;
    filter: drop-shadow(0 0 6px var(--polaris-gold));
}

.node-label {
    font-family: var(--font-mono);
    font-size: 12px;
    fill: var(--frost-silver);
    text-anchor: middle;
    transition: transform 0.3s ease-out;
    cursor: default;
}

.connection-line {
    stroke: var(--oxidized-copper);
    stroke-width: 1;
    opacity: 0.3;
}

/* Spread 4: The Signal Log */
.spread-4 {
    background: var(--birch-panel);
    color: var(--forest-ink);
}

.signal-log {
    width: 100%;
    max-width: 42ch;
    margin: 0 auto;
    padding: 4rem 2rem;
    background-image:
        linear-gradient(90deg, var(--vellum), var(--vellum)),
        repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg, rgba(139, 119, 80, 0.03) 0.5deg, transparent 1deg),
        radial-gradient(circle at 15% 25%, rgba(120, 90, 50, 0.06) 0%, transparent 8%),
        radial-gradient(circle at 85% 65%, rgba(120, 90, 50, 0.06) 0%, transparent 10%),
        radial-gradient(circle at 20% 80%, rgba(120, 90, 50, 0.06) 0%, transparent 6%);
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.15);
    border-radius: 0;
    position: relative;
    z-index: 10;
}

.log-entry {
    margin-bottom: 3rem;
    padding: 1.5rem;
    background-color: rgba(255, 255, 255, 0.5);
    border-left: 2px solid var(--oxidized-copper);
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
}

.log-entry:nth-child(1) { animation-delay: 0.3s; }
.log-entry:nth-child(2) { animation-delay: 0.5s; }
.log-entry:nth-child(3) { animation-delay: 0.7s; }
.log-entry:nth-child(4) { animation-delay: 0.9s; }
.log-entry:nth-child(5) { animation-delay: 1.1s; }

.log-date {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--forest-ink);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: block;
    margin-bottom: 0.5rem;
}

.log-text {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--forest-ink);
    margin-bottom: 0.75rem;
}

.log-protocol {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--oxidized-copper);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
}

/* Spread 5: The Departure */
.spread-5 {
    background: linear-gradient(180deg, #0a1810 0%, #0C1F14 50%, #051208 100%);
    position: relative;
}

.departure-container {
    text-align: center;
    z-index: 10;
    max-width: 700px;
    padding: 2rem;
}

.departure-heading {
    color: var(--star-white);
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
    animation-delay: 0.3s;
}

.departure-text {
    color: var(--star-white);
    opacity: 0.85;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
    animation-delay: 0.5s;
}

.final-star-field {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 1;
}

/* ============================================================
   Responsive Design
   ============================================================ */

@media (max-width: 768px) {
    .protocol-atlas {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .atlas-left {
        padding-top: 0;
    }

    .observatory-dome {
        padding: 0 1rem;
    }

    .navigation-chart-container {
        padding: 2rem 1rem;
    }

    .signal-log {
        padding: 2rem 1rem;
    }

    .departure-container {
        padding: 1rem;
    }
}

/* ============================================================
   Scroll-Triggered Animations
   ============================================================ */

.spread {
    opacity: 1;
}

/* Intersection Observer will manage visibility animations */
.spread.fade-in h1,
.spread.fade-in h2,
.spread.fade-in h3 {
    animation: fadeInUp 0.8s ease-out forwards;
}

.spread.fade-in p {
    animation: fadeInUp 0.8s ease-out forwards;
    animation-delay: 0.2s;
}

.spread.fade-in .starburst-ornament {
    animation: scaleIn 0.6s ease-out forwards;
    animation-delay: 0.1s;
}
