/* sustaining.quest - Emakimono horizontal scroll */

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100vh;
    overflow-x: scroll;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #B8C4B8 transparent;
}

body {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    color: #3A3A3A;
    background: #F0F5EC;
}

::-webkit-scrollbar {
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #B8C4B8;
    border-radius: 2px;
}

/* ===== OPENING OVERLAY ===== */
#opening-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #F0F5EC;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#opening-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#opening-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 4rem;
    color: #2D4A3E;
    letter-spacing: 0.15em;
    opacity: 0;
    animation: fadeInTitle 0.8s ease 0.4s forwards;
}

#opening-subtitle {
    font-family: 'Quicksand', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    color: #3A3A3A;
    margin-top: 1rem;
    opacity: 0;
    animation: fadeInTitle 0.8s ease 0.8s forwards;
}

#scroll-arrow {
    margin-top: 3rem;
    opacity: 0;
    animation: fadeInTitle 0.6s ease 1.5s forwards, pulseArrow 2s ease-in-out 2s infinite;
}

#scroll-arrow svg {
    width: 48px;
    height: 48px;
}

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

@keyframes pulseArrow {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50% { transform: translateX(12px); opacity: 0.5; }
}

/* ===== FIXED LEFT STRIP ===== */
#left-strip {
    position: fixed;
    top: 0;
    left: 0;
    width: 48px;
    height: 100vh;
    background: rgba(240, 245, 236, 0.92);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
    opacity: 0;
    transition: opacity 0.6s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#left-strip.visible {
    opacity: 1;
}

#left-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 11px;
    color: #2D4A3E;
    letter-spacing: 0.12em;
    white-space: nowrap;
}

#progress-bar {
    width: 3px;
    height: 60%;
    background: rgba(184, 196, 184, 0.3);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

#progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to bottom, #7A9E7A, #C4A265);
    border-radius: 2px;
    transition: height 0.1s linear;
}

/* ===== HORIZON LINE ===== */
#horizon-line {
    position: fixed;
    top: 62vh;
    left: 48px;
    right: 0;
    height: 1px;
    background: #B8C4B8;
    opacity: 0.3;
    z-index: 50;
    pointer-events: none;
}

/* ===== SCROLL CANVAS ===== */
#scroll-canvas {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    height: 100vh;
    width: max-content;
    padding-left: 48px;
    background: linear-gradient(
        to right,
        #F0F5EC 0%,
        #F0F5EC 8%,
        #E8EFE0 20%,
        #E8EFE0 32%,
        #F5EDE0 45%,
        #F5EDE0 55%,
        #1A2A22 60%,
        #1A2A22 72%,
        #F5EDE0 76%,
        #E8ECF0 85%,
        #E8ECF0 95%,
        #E8ECF0 100%
    );
}

/* ===== KAN SECTIONS ===== */
.kan {
    width: clamp(200vw, 250vw, 300vw);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.kan-content {
    display: flex;
    flex-direction: column;
    width: 80%;
    max-width: 1400px;
    height: 85vh;
    position: relative;
}

.kan-upper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 1rem;
    max-height: 55vh;
}

.kan-lower {
    flex: 0 0 auto;
    padding-top: 1.5rem;
    max-height: 38vh;
    overflow: hidden;
}

/* ===== PLATE LABELS ===== */
.plate-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    color: #2D4A3E;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.kan.revealed .plate-label {
    opacity: 1;
    transform: translateX(0);
}

/* ===== KAN TITLES ===== */
.kan-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: #2D4A3E;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease 0.4s, transform 0.6s ease 0.4s;
    position: relative;
}

.kan-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 1px;
    background: #B8C4B8;
    margin-top: 0.5rem;
}

.kan.revealed .kan-title {
    opacity: 1;
    transform: translateX(0);
}

/* ===== KAN TEXT ===== */
.kan-text {
    max-width: 38ch;
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    line-height: 1.85;
    color: #3A3A3A;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease 0.6s, transform 0.6s ease 0.6s;
}

.kan-text p {
    margin-bottom: 1em;
}

.kan.revealed .kan-text {
    opacity: 1;
    transform: translateX(0);
}

/* ===== ANNOTATIONS ===== */
.annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1.05rem);
    color: #7A9E7A;
    transform: rotate(-3deg) translateX(30px);
    max-width: 32ch;
    margin-top: 1rem;
    padding-left: 1rem;
    border-left: 2px solid rgba(122, 158, 122, 0.3);
    opacity: 0;
    transition: opacity 0.6s ease 0.8s, transform 0.6s ease 0.8s;
}

.kan.revealed .annotation {
    opacity: 1;
    transform: rotate(-3deg) translateX(0);
}

/* ===== ILLUSTRATIONS ===== */
.kan-illustration {
    width: 100%;
    max-width: 800px;
    position: relative;
}

.vector-panel {
    width: 100%;
    height: auto;
    opacity: 0;
    transition: opacity 0.8s ease 0.2s;
}

.kan.revealed .vector-panel {
    opacity: 1;
}

/* SVG text styles */
.seed-label,
.zone-label,
.tool-label,
.layer-label,
.infra-label {
    font-family: 'Quicksand', sans-serif;
    font-size: 10px;
    fill: #7A9E7A;
}

.layer-label {
    font-size: 11px;
    fill: #2D4A3E;
    font-weight: 500;
}

.infra-label {
    font-size: 9px;
    fill: #7A9E7A;
}

/* Path draw animation */
.draw-in path,
.draw-in line,
.draw-in polyline {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 3s ease;
}

.kan.revealed .draw-in path,
.kan.revealed .draw-in line,
.kan.revealed .draw-in polyline {
    stroke-dashoffset: 0;
}

.draw-in rect,
.draw-in circle,
.draw-in ellipse {
    opacity: 0;
    transition: opacity 1s ease 1s;
}

.kan.revealed .draw-in rect,
.kan.revealed .draw-in circle,
.kan.revealed .draw-in ellipse {
    opacity: 1;
}

/* Water path special animation */
.water-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: none;
}

.kan.revealed .water-path {
    animation: flowWater 4s ease forwards;
}

@keyframes flowWater {
    to { stroke-dashoffset: 0; }
}

/* ===== NETWORK HOVER (KAN III) ===== */
.network-node {
    cursor: pointer;
    transition: r 0.3s ease, opacity 0.3s ease;
}

.network-node:hover {
    r: 12;
}

.hypha {
    transition: opacity 0.4s ease, stroke-width 0.4s ease;
}

.network-caption {
    position: absolute;
    background: rgba(240, 245, 236, 0.95);
    padding: 0.8rem 1rem;
    border-radius: 4px;
    font-family: 'Caveat', cursive;
    font-size: 0.95rem;
    color: #2D4A3E;
    max-width: 260px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    bottom: 10%;
    left: 10%;
    border: 1px solid rgba(184, 196, 184, 0.4);
}

.network-caption.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== DARK SECTION (KAN IV) ===== */
.kan-dark .kan-title {
    color: #D4DDD4;
}

.kan-dark .kan-title::after {
    background: rgba(212, 221, 212, 0.3);
}

.kan-dark .kan-text {
    color: #D4DDD4;
}

.kan-dark .plate-label {
    color: #D4DDD4;
}

.kan-dark .annotation {
    color: #C4A265;
    border-left-color: rgba(196, 162, 101, 0.3);
}

.kan-dark .tool-label {
    fill: #D4DDD4;
    font-size: 9px;
}

.kan-dark .network-caption {
    background: rgba(26, 42, 34, 0.95);
    border-color: rgba(212, 221, 212, 0.2);
}

/* ===== ACCENT COLOR CLASSES ===== */
.accent-coral {
    color: #D4836A;
}

.accent-wheat {
    color: #C8BDA8;
}

/* ===== MA INTERVALS ===== */
.ma-interval {
    width: clamp(30vw, 40vw, 50vw);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.ma-numeral {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 1.5rem;
    color: #B8C4B8;
    opacity: 0.6;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.morph-svg {
    width: 80px;
    height: 80px;
    position: absolute;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);
}

.morph-path {
    transition: d 1.5s ease, fill 1.5s ease;
}

/* ===== END SPACER ===== */
.end-spacer {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.end-text {
    text-align: center;
}

.end-mark {
    display: block;
    font-size: 0.6rem;
    color: #B8C4B8;
    margin-bottom: 1rem;
}

.end-colophon {
    font-family: 'Quicksand', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: #7A9E7A;
    letter-spacing: 0.08em;
}

/* ===== SUPERSCRIPT REFERENCES ===== */
.ref-num {
    font-size: 0.7em;
    vertical-align: super;
    color: #7A9E7A;
    cursor: pointer;
    position: relative;
}

.ref-bubble {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(240, 245, 236, 0.95);
    padding: 0.5rem 0.75rem;
    border-radius: 3px;
    font-family: 'Caveat', cursive;
    font-size: 0.9rem;
    color: #2D4A3E;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    border: 1px solid rgba(184, 196, 184, 0.4);
}

.ref-num:hover .ref-bubble {
    opacity: 1;
}

/* ===== RESPONSIVE: VERTICAL SCROLL ===== */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
    }

    #scroll-canvas {
        flex-direction: column;
        width: 100%;
        height: auto;
        padding-left: 0;
        background: linear-gradient(
            to bottom,
            #F0F5EC 0%,
            #F0F5EC 8%,
            #E8EFE0 20%,
            #E8EFE0 32%,
            #F5EDE0 45%,
            #F5EDE0 55%,
            #1A2A22 60%,
            #1A2A22 72%,
            #F5EDE0 76%,
            #E8ECF0 85%,
            #E8ECF0 95%,
            #E8ECF0 100%
        );
    }

    .kan {
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding: 4rem 1.5rem;
    }

    .kan-content {
        width: 100%;
        height: auto;
    }

    .kan-upper {
        max-height: none;
    }

    .kan-lower {
        max-height: none;
    }

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

    .ma-interval {
        width: 100%;
        height: 30vh;
    }

    #left-strip {
        display: none;
    }

    #horizon-line {
        display: none;
    }

    .end-spacer {
        width: 100%;
        height: 50vh;
    }

    #opening-title {
        font-size: 2.5rem;
    }

    .annotation {
        max-width: 100%;
    }

    .kan-illustration {
        max-width: 100%;
    }
}
