/* === xbom.wiki — Cinematic Atlas of Supply Chain Provenance === */

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
    overflow-x: hidden;
}

body {
    font-family: 'Libre Baskerville', serif;
    color: #2D1B0E;
    background-color: #F5EDE0;
    /* Grid-line scaffolding overlay */
    background-image:
        linear-gradient(to right, rgba(45,27,14,0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(45,27,14,0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    overflow-x: hidden;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Typography --- */
h1, h2, .chapter-number {
    font-family: 'Poiret One', cursive;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #C9A96E;
}

h2 {
    font-size: clamp(2rem, 5vw, 4rem);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

p {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.8;
    margin-bottom: 1.5em;
    color: #2D1B0E;
}

.mono {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9em;
    opacity: 0.8;
}

.metadata {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    letter-spacing: 0.05em;
    color: #8A9A7B;
    border-top: 1px solid rgba(201,169,110,0.3);
    padding-top: 1em;
    margin-top: 2em;
}

/* --- Spreads --- */
.spread {
    width: 100vw;
    height: 100vh;
    position: relative;
    scroll-snap-align: start;
    overflow: hidden;
}

/* Grid activation on active spread */
.spread.active-spread {
    background-image:
        linear-gradient(to right, rgba(45,27,14,0.12) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(45,27,14,0.12) 1px, transparent 1px);
    background-size: 48px 48px;
    transition: background-image 0.8s ease;
}

/* --- Spread Cover --- */
.spread-cover {
    background-color: #8B5E3C;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leather-texture {
    position: absolute;
    inset: 0;
    background:
        repeating-radial-gradient(circle at 20% 30%, rgba(45,27,14,0.03) 1px, transparent 2px),
        repeating-radial-gradient(circle at 80% 70%, rgba(45,27,14,0.02) 1px, transparent 3px),
        repeating-radial-gradient(circle at 50% 50%, rgba(45,27,14,0.015) 1px, transparent 4px);
    filter: url(#leather-noise);
    opacity: 0.08;
    pointer-events: none;
}

.cover-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 12vh 5vw;
}

.cartouche {
    position: absolute;
    width: min(80vw, 800px);
    height: auto;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.cartouche.visible {
    opacity: 1;
}

.cartouche .cartouche-border,
.cartouche .cartouche-border-inner,
.cartouche .corner-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cartouche.drawn .cartouche-border,
.cartouche.drawn .cartouche-border-inner,
.cartouche.drawn .corner-line {
    stroke-dashoffset: 0;
}

.cover-text {
    text-align: center;
    opacity: 0;
    transition: opacity 0.8s ease;
    z-index: 2;
}

.cover-text.visible {
    opacity: 1;
}

.cover-title {
    font-size: clamp(4rem, 10vw, 9rem);
    color: #C9A96E;
    line-height: 1;
    margin: 0.2em 0;
}

.gold-rule {
    border: none;
    height: 1px;
    background: #C9A96E;
    width: 60%;
    margin: 0.5em auto;
    opacity: 0.6;
}

.cover-subtitle {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #C9A96E;
    opacity: 0.8;
    margin-top: 0.5em;
    line-height: 1.6;
}

.chevron-container {
    position: absolute;
    bottom: 5vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.chevron {
    width: 40px;
    height: 24px;
    opacity: 0;
    animation: chevronPulse 3s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    animation-delay: 3s;
}

@keyframes chevronPulse {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(8px); opacity: 1; }
}

/* --- Content Spreads --- */
.spread-content {
    background-color: #F5EDE0;
}

.spread-grid {
    display: grid;
    height: 100%;
    gap: 0;
}

.spread-grid.left-heavy {
    grid-template-columns: 60% 40%;
}

.spread-grid.right-heavy {
    grid-template-columns: 40% 60%;
}

.plate-side {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4vh 3vw;
    background-color: rgba(139,94,60,0.04);
}

.text-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8vh 5vw 8vh 4vw;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.spread.in-view .text-side {
    opacity: 1;
    transform: translateY(0);
}

.chapter-number {
    position: absolute;
    top: 4vh;
    left: 3vw;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    opacity: 0.3;
}

.diagram {
    width: 100%;
    max-width: 500px;
    height: auto;
}

/* --- Drop Caps --- */
.drop-cap {
    float: left;
    font-family: 'Poiret One', cursive;
    font-size: 3.6em;
    line-height: 0.8;
    padding: 0.08em 0.15em 0 0;
    margin-right: 0.05em;
    color: #C9A96E;
    background: #8B5E3C;
    border: 1px solid #C9A96E;
    text-align: center;
    min-width: 1.2em;
}

/* --- SVG Diagram Styles --- */
.station-label {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 10px;
    font-weight: 600;
    fill: #C9A96E;
    text-anchor: middle;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.station-label-sm {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 8px;
    font-weight: 300;
    fill: #8A9A7B;
    text-anchor: middle;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Path draw animation */
.route-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.spread.in-view .route-path {
    stroke-dashoffset: 0;
}

/* Station scale animation */
.station {
    transform-origin: center;
    transform: scale(0);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.spread.in-view .station {
    transform: scale(1);
}

.station-sm {
    transform-origin: center;
    transform: scale(0);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.3s;
}

.spread.in-view .station-sm {
    transform: scale(1);
}

/* Station hover */
.station:hover {
    transform: scale(1.2);
    cursor: pointer;
}

/* --- Tooltip --- */
.tooltip {
    position: fixed;
    background: #F5EDE0;
    border: 1px solid #C9A96E;
    padding: 0.8em 1.2em;
    font-family: 'Libre Baskerville', serif;
    font-size: 0.85rem;
    color: #2D1B0E;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
    max-width: 200px;
    box-shadow: 0 4px 12px rgba(45,27,14,0.15);
}

.tooltip.visible {
    opacity: 1;
    transform: scale(1);
}

/* --- Diamond Pip Navigation --- */
.pip-nav {
    position: fixed;
    right: 2vw;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 50;
}

.pip {
    width: 12px;
    height: 12px;
    border: 1px solid #C9A96E;
    background: transparent;
    transform: rotate(45deg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    padding: 0;
}

.pip:hover {
    transform: rotate(45deg) scale(1.3);
    box-shadow: 0 0 8px rgba(201,169,110,0.4);
}

.pip.active {
    background: #C9A96E;
}

/* --- Grid Activation for plate side --- */
.spread.in-view .plate-side {
    background-image:
        linear-gradient(to right, rgba(201,169,110,0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(201,169,110,0.08) 1px, transparent 1px);
    background-size: 48px 48px;
    transition: background 0.8s ease;
}

/* --- Sunburst Divider (hidden utility) --- */
.sunburst-divider {
    display: none;
}

/* --- Accent Colors --- */
.station:hover {
    stroke: #C47B5A;
}

.pip.active:hover {
    background: #5B7F6E;
}

/* --- Staggered station delays --- */
.spread.in-view .station:nth-child(3n+1) { transition-delay: 0.1s; }
.spread.in-view .station:nth-child(3n+2) { transition-delay: 0.2s; }
.spread.in-view .station:nth-child(3n) { transition-delay: 0.3s; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .spread-grid.left-heavy,
    .spread-grid.right-heavy {
        grid-template-columns: 1fr;
        grid-template-rows: 50% 50%;
    }

    .spread-grid.right-heavy .text-side {
        order: 1;
    }

    .spread-grid.right-heavy .plate-side {
        order: 2;
    }

    .pip-nav {
        right: 1vw;
    }

    .pip {
        width: 8px;
        height: 8px;
    }

    .text-side {
        padding: 4vh 5vw;
    }
}
