/* layer2.report — Coastal Blend + Y2K Futurism */
/* Fonts: Playfair Display, Lora, Inconsolata */

:root {
    --fog-linen: #f0ebe3;
    --wet-sand: #d5c7b5;
    --abalone-teal: #3d8b7a;
    --kelp-bronze: #8b6f47;
    --deep-tide: #2a3040;
    --ink-stone: #1a1e28;
    --pearl-shift: #a8d4c8;
    --coral-whisper: #c4846a;
    --left-width: 45fr;
    --right-width: 55fr;
}

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

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

body {
    font-family: 'Lora', Georgia, serif;
    background-color: var(--fog-linen);
    color: var(--deep-tide);
    line-height: 1.72;
    overflow-x: hidden;
}

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

/* Progress Indicator */
#progress-track {
    position: fixed;
    left: 0;
    top: 0;
    width: 16px;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#progress-fill {
    position: absolute;
    left: 7px;
    top: 0;
    width: 2px;
    height: 0%;
    background-color: var(--abalone-teal);
    transition: height 0.6s ease-in-out;
}

.progress-marker {
    position: absolute;
    left: 2px;
    cursor: pointer;
    transition: transform 0.6s ease-in-out;
    z-index: 2;
}

.progress-marker:hover {
    transform: scale(1.4);
}

.marker-leaf {
    display: block;
}

/* Split Container */
#split-container {
    display: grid;
    grid-template-columns: var(--left-width) var(--right-width);
    min-height: 100vh;
    position: relative;
    transition: grid-template-columns 1.5s ease-in-out;
}

/* Left Panel */
#left-panel {
    background-color: var(--wet-sand);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.iridescent-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(168,212,200,0.15), rgba(196,132,106,0.1), rgba(61,139,122,0.12));
    mix-blend-mode: overlay;
    opacity: 0.4;
    z-index: 2;
    pointer-events: none;
    transition: background 3s ease-in-out;
}

#left-panel:hover .iridescent-overlay {
    background: linear-gradient(150deg, rgba(168,212,200,0.18), rgba(196,132,106,0.12), rgba(61,139,122,0.15));
}

.illustration-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transition: opacity 1.2s ease-in-out;
    z-index: 1;
}

.illustration-layer.active {
    opacity: 1;
}

.chapter-svg {
    width: 100%;
    height: 100%;
    max-height: 90vh;
}

/* Draw-on animation for SVG paths */
.draw-on {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s ease-in-out;
}

.illustration-layer.active .draw-on {
    stroke-dashoffset: 0;
}

/* Vine Divider */
#vine-divider {
    position: fixed;
    left: calc(45% - 10px);
    top: 0;
    width: 20px;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
    transition: left 1.5s ease-in-out, opacity 1.2s ease-in-out;
}

#vine-svg {
    width: 100%;
    height: 100%;
    animation: vineSway 8s ease-in-out infinite;
}

@keyframes vineSway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(3px); }
}

/* Right Panel */
#right-panel {
    background-color: var(--fog-linen);
    position: relative;
    z-index: 1;
}

.chapter {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 6rem 3rem 6rem 2.5rem;
}

.chapter-content {
    max-width: 540px;
}

/* Typography */
.domain-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 6rem);
    color: var(--ink-stone);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
    color: var(--kelp-bronze);
    margin-bottom: 2rem;
    letter-spacing: -0.02em;
}

.chapter-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    color: var(--ink-stone);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    position: relative;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--kelp-bronze);
}

.chapter-label {
    display: block;
    font-family: 'Inconsolata', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--kelp-bronze);
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}

.body-text {
    font-family: 'Lora', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: var(--deep-tide);
    max-width: 38ch;
    margin-bottom: 1.5rem;
}

.annotation {
    font-family: 'Inconsolata', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--kelp-bronze);
    margin-top: 2rem;
}

/* Leaf Divider */
.leaf-divider {
    display: flex;
    gap: 24px;
    align-items: center;
    margin: 1.5rem 0;
}

.leaf-divider svg {
    transform: rotate(30deg);
    flex-shrink: 0;
}

/* Data Visualizations */
.data-viz {
    margin: 2rem 0;
    width: 100%;
    max-width: 480px;
}

.vine-data-svg,
.tide-data-svg {
    width: 100%;
    height: auto;
}

/* Vine grow animation */
.vine-grow {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 2s ease-in-out;
}

.vine-grow.animated {
    stroke-dashoffset: 0;
}

/* Tide wave animation */
.tide-wave {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease-in-out;
}

.tide-wave.animated {
    stroke-dashoffset: 0;
}

/* Metrics Prose */
.metrics-prose {
    margin: 1.5rem 0;
}

.metric-line {
    font-family: 'Lora', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.6vw, 1.05rem);
    line-height: 1.72;
    color: var(--deep-tide);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.leaf-bullet {
    flex-shrink: 0;
    margin-top: 0.35rem;
}

.protocol-name {
    font-family: 'Inconsolata', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--abalone-teal);
    font-weight: 600;
}

.data-value {
    font-family: 'Inconsolata', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--kelp-bronze);
}

.inline-sparkline {
    display: inline-block;
    width: 48px;
    height: 14px;
    vertical-align: middle;
    margin: 0 2px;
}

.inline-sparkline svg {
    width: 100%;
    height: 100%;
}

/* Epilogue */
.chapter-epilogue {
    min-height: 100vh;
}

.epilogue-attribution {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(139, 111, 71, 0.3);
}

.attribution-line {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    color: var(--ink-stone);
    letter-spacing: -0.02em;
    margin-bottom: 0.8rem;
}

.attribution-detail {
    font-family: 'Inconsolata', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--kelp-bronze);
    margin-bottom: 0.3rem;
    opacity: 0.8;
}

/* Reveal Animation */
.reveal-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-in-out, transform 0.8s ease-in-out;
}

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

/* Mobile Progress Bar */
#mobile-progress {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(213, 199, 181, 0.5);
    z-index: 50;
}

#mobile-progress-fill {
    height: 100%;
    width: 0%;
    background-color: var(--abalone-teal);
    transition: width 0.6s ease-in-out;
}

/* Epilogue full-width merge */
.chapter-epilogue-merged #split-container {
    grid-template-columns: 1fr;
}

/* Responsive / Mobile */
@media (max-width: 768px) {
    #split-container {
        grid-template-columns: 1fr;
    }

    #left-panel {
        position: relative;
        height: 40vh;
        top: auto;
    }

    #vine-divider {
        display: none;
    }

    #progress-track {
        display: none;
    }

    #mobile-progress {
        display: block;
    }

    .chapter {
        min-height: auto;
        padding: 3rem 1.5rem;
    }

    .chapter-content {
        max-width: 100%;
    }

    .body-text {
        max-width: 100%;
    }

    .illustration-layer {
        position: relative;
        height: 40vh;
        padding: 1rem;
    }

    .illustration-layer.active ~ .illustration-layer {
        display: none;
    }

    .data-viz {
        max-width: 100%;
    }

    .metric-line {
        flex-direction: row;
    }
}

@media (max-width: 480px) {
    .domain-title {
        font-size: 2.4rem;
    }

    .chapter-title {
        font-size: 1.6rem;
    }

    .leaf-divider {
        gap: 16px;
    }
}

/* Leaf sway animation */
@keyframes leafSway {
    0%, 100% { transform: rotate(28deg); }
    50% { transform: rotate(34deg); }
}

/* Animation for sparklines */
@keyframes sparkDraw {
    from { stroke-dashoffset: 60; }
    to { stroke-dashoffset: 0; }
}
