/* ============================================
   layer2.report - Fairycore Research Gazette
   Horizontal-Scroll Report Tapestry
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --warm-parchment: #FDF3E7;
    --deeper-parchment: #FBE8D3;
    --burnt-sienna: #8B4513;
    --copper-accent: #D4873E;
    --amber-glow: #E8A84C;
    --forest-thorn: #2D3B2D;
    --crystal-violet: #7B5EA7;
    --rose-blush: #D4869C;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Nunito', sans-serif;
    --font-code: 'Fira Code', monospace;

    --spring-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--forest-thorn);
    font-family: var(--font-body);
    color: var(--burnt-sienna);
}

/* --- Scroll Container --- */
.scroll-container {
    display: flex;
    width: fit-content;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    position: relative;
}

.scroll-container::-webkit-scrollbar {
    height: 4px;
}

.scroll-container::-webkit-scrollbar-track {
    background: var(--deeper-parchment);
}

.scroll-container::-webkit-scrollbar-thumb {
    background: var(--copper-accent);
    border-radius: 2px;
}

/* --- Golden Thread --- */
.golden-thread {
    position: fixed;
    bottom: 10vh;
    left: 0;
    height: 1px;
    background: var(--amber-glow);
    z-index: 100;
    pointer-events: none;
    width: 0;
    transition: width 0.3s ease-out;
}

.golden-thread::before {
    content: '';
    position: absolute;
    right: -2px;
    top: -1.5px;
    width: 6px;
    height: 4px;
    background: var(--amber-glow);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--amber-glow);
}

/* --- Panel Base --- */
.panel {
    flex: 0 0 100vw;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    background: var(--warm-parchment);
}

.panel-bg-alt {
    background: var(--deeper-parchment);
}

/* --- Panel Dividers (Sharp Angles) --- */
.panel-divider {
    flex: 0 0 0;
    width: 0;
    height: 100vh;
    position: relative;
    z-index: 10;
    pointer-events: none;
}

.panel-report {
    clip-path: polygon(3% 0, 100% 0, 97% 100%, 0 100%);
}

.panel-report::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(105deg, transparent 0%, transparent 2%, currentColor 2%, currentColor 2.3%, transparent 2.3%);
    opacity: 0.05;
    pointer-events: none;
}

/* --- Title Folio (Panel 1) --- */
.panel-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.title-content {
    text-align: center;
    z-index: 2;
}

.site-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 6rem);
    color: var(--burnt-sienna);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    animation: titleReveal 1.2s ease-out 0.3s forwards;
}

@keyframes titleReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.vine-border {
    width: 60vw;
    max-width: 800px;
    margin: 0 auto 1.5rem;
    opacity: 0;
    animation: fadeIn 0.5s ease-out 1s forwards;
}

.vine-border svg {
    width: 100%;
    height: 40px;
}

.vine-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: vineGrow 1.5s ease-out 1.2s forwards;
}

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

.vine-leaf {
    opacity: 0;
    animation: leafAppear 0.3s ease-out forwards;
}

.vine-leaf:nth-child(2) { animation-delay: 1.8s; }
.vine-leaf:nth-child(3) { animation-delay: 2.0s; }
.vine-leaf:nth-child(4) { animation-delay: 2.2s; }
.vine-leaf:nth-child(5) { animation-delay: 2.4s; }
.vine-leaf:nth-child(6) { animation-delay: 2.6s; }

@keyframes leafAppear {
    to { opacity: 1; }
}

.subtitle {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--copper-accent);
    opacity: 0;
    animation: fadeIn 0.8s ease-out 2s forwards;
}

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

/* --- Floating Crystal --- */
.floating-crystal {
    position: absolute;
    top: 12%;
    right: 15%;
    z-index: 1;
    opacity: 0;
    animation: crystalFadeIn 1.5s ease-out 0.5s forwards;
}

@keyframes crystalFadeIn {
    to { opacity: 1; }
}

.crystal-shape {
    width: 80px;
    height: 120px;
    background: linear-gradient(135deg, var(--crystal-violet) 0%, var(--amber-glow) 50%, var(--rose-blush) 100%);
    clip-path: polygon(50% 0%, 85% 20%, 100% 55%, 80% 90%, 50% 100%, 20% 90%, 0% 55%, 15% 20%);
    animation: crystalFloat 6s ease-in-out infinite, crystalRotate 3s ease-in-out 0.5s forwards;
    filter: saturate(0.8);
}

@keyframes crystalFloat {
    0%, 100% { transform: translateY(0) rotateY(15deg); }
    50% { transform: translateY(-15px) rotateY(-5deg); }
}

@keyframes crystalRotate {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(15deg); }
}

.crystal-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(212, 135, 62, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
}

/* --- Scroll Indicator --- */
.scroll-indicator {
    position: absolute;
    bottom: 15vh;
    right: 4vw;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: indicatorPulse 2s ease-in-out infinite;
    opacity: 0;
    animation: fadeIn 0.5s ease-out 2.5s forwards, indicatorPulse 2s ease-in-out 3s infinite;
}

.scroll-text {
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--copper-accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.scroll-arrow {
    animation: arrowSlide 1.5s ease-in-out infinite;
}

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

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

/* --- Report Panels --- */
.panel-inner {
    display: flex;
    height: 100%;
    padding: 6vh 5vw;
    gap: 4vw;
    align-items: center;
}

.report-content {
    flex: 0 0 60%;
    max-width: 60%;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.panel-report.is-visible .report-content {
    opacity: 1;
    transform: translateX(0);
}

.report-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--burnt-sienna);
    letter-spacing: -0.01em;
    margin-bottom: 1.5rem;
    line-height: 1.25;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.5s ease-out 0.3s, transform 0.5s ease-out 0.3s;
}

.panel-report.is-visible .report-title {
    opacity: 1;
    transform: translateX(0);
}

.report-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.05rem);
    line-height: 1.8;
    color: var(--burnt-sienna);
    margin-bottom: 1.2rem;
    opacity: 0;
    transition: opacity 0.5s ease-out 0.5s;
}

.panel-report.is-visible .report-body {
    opacity: 1;
}

.report-annotation {
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--copper-accent);
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(139, 69, 19, 0.15);
    opacity: 0;
    transition: opacity 0.5s ease-out 0.7s;
}

.panel-report.is-visible .report-annotation {
    opacity: 1;
}

.code-label {
    color: var(--crystal-violet);
    font-weight: 500;
}

/* --- Report Charts (Crystal Visualizations) --- */
.report-chart {
    flex: 0 0 32%;
    max-width: 32%;
    height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s ease-out 0.4s, transform 0.6s ease-out 0.4s;
}

.panel-report.is-visible .report-chart {
    opacity: 1;
    transform: translateX(0);
}

.chart-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--burnt-sienna);
    margin-bottom: 2rem;
    text-align: center;
}

.crystal-chart {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1.2vw;
    height: 45vh;
    padding-bottom: 2rem;
    position: relative;
}

.crystal-chart::after {
    content: '';
    position: absolute;
    bottom: 1.8rem;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(139, 69, 19, 0.2);
}

.crystal-bar {
    width: clamp(40px, 4vw, 60px);
    height: 0;
    background: linear-gradient(
        180deg,
        var(--bar-color) 0%,
        color-mix(in srgb, var(--bar-color) 70%, transparent) 100%
    );
    clip-path: polygon(15% 0%, 85% 0%, 100% 8%, 95% 50%, 100% 92%, 85% 100%, 15% 100%, 0% 92%, 5% 50%, 0% 8%);
    position: relative;
    transition: height 0.8s var(--spring-bounce);
    transform-origin: bottom center;
    box-shadow: 0 0 0px transparent;
}

.crystal-bar.grown {
    height: var(--bar-height);
    box-shadow: 0 0 15px color-mix(in srgb, var(--bar-color) 40%, transparent);
}

.bar-label {
    position: absolute;
    bottom: -1.8rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-code);
    font-size: 0.7rem;
    color: var(--burnt-sienna);
    white-space: nowrap;
    opacity: 0.7;
}

/* --- Epilogue Panel --- */
.panel-epilogue {
    flex: 0 0 60vw;
    width: 60vw;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--warm-parchment);
    position: relative;
    padding: 8vh 4vw;
}

.epilogue-content {
    text-align: center;
    max-width: 700px;
    z-index: 2;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.panel-epilogue.is-visible .epilogue-content {
    opacity: 1;
    transform: translateY(0);
}

.epilogue-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.8rem, 3.5vw, 3rem);
    color: var(--burnt-sienna);
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin-bottom: 2rem;
}

.epilogue-text {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    color: var(--copper-accent);
    line-height: 1.8;
    margin-bottom: 2rem;
}

.epilogue-vine {
    width: 60%;
    margin: 0 auto;
    opacity: 0.5;
}

.epilogue-vine svg {
    width: 100%;
    height: 30px;
}

/* --- Epilogue Thorns --- */
.epilogue-thorns {
    position: absolute;
    top: 0;
    left: 3vw;
    height: 100%;
    width: 80px;
    opacity: 0.4;
    z-index: 1;
}

.epilogue-thorns-right {
    left: auto;
    right: 3vw;
}

.thorn-left, .thorn-right {
    width: 100%;
    height: 100%;
}

/* --- Panel Visibility Animations --- */
.panel-report .report-content,
.panel-report .report-chart {
    will-change: opacity, transform;
}

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
    .panel-inner {
        flex-direction: column;
        padding: 4vh 6vw;
        gap: 3vh;
        overflow-y: auto;
    }

    .report-content {
        flex: none;
        max-width: 100%;
    }

    .report-chart {
        flex: none;
        max-width: 100%;
        height: 35vh;
    }

    .crystal-chart {
        height: 25vh;
    }

    .panel-report {
        clip-path: none;
    }

    .floating-crystal {
        top: 8%;
        right: 8%;
    }

    .crystal-shape {
        width: 50px;
        height: 75px;
    }

    .epilogue-thorns {
        display: none;
    }

    .panel-epilogue {
        flex: 0 0 100vw;
        width: 100vw;
    }
}

@media (max-width: 600px) {
    .vine-border {
        width: 80vw;
    }

    .scroll-indicator {
        right: 6vw;
        bottom: 12vh;
    }

    .panel-inner {
        padding: 3vh 5vw;
    }

    .crystal-bar {
        width: 32px;
    }
}

/* --- Subtle background texture --- */
.panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%238B4513' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.panel > * {
    position: relative;
    z-index: 1;
}
