/* ===================================================
   concurrent.quest - Styles
   Y2K Futurism + Hand-Drawn Field Journal
   Immersive-Scroll Narrative
   =================================================== */

/* --- CSS Custom Properties --- */
:root {
    --deep-sienna: #6B3A2A;
    --warm-umber: #7B5B3A;
    --deep-bark: #3E2723;
    --solar-flare: #E8692A;
    --burnt-coral: #CD5C45;
    --desert-sand: #F5E6D0;
    --pale-apricot: #FFDAB9;
    --frosted-amber: rgba(255, 200, 145, 0.12);
    --chrome-silver: #C0C0C0;
    --warm-white: #FFF8F0;
    --terracotta: #A0522D;
    --saddle-brown: #8B4513;
    --chrome-light: #E8E8E8;
    --sand-mid: #E8C9A0;

    --font-display: 'Caveat Brush', cursive;
    --font-secondary: 'Architects Daughter', cursive;
    --font-body: 'Nunito', sans-serif;
    --font-accent: 'Orbitron', sans-serif;

    --scroll-progress: 0;
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--deep-bark);
    background-color: var(--desert-sand);
    overflow-x: hidden;
    letter-spacing: 0.015em;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Hidden SVG defs --- */
svg.defs-only {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Background Plane --- */
#bg-plane {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    will-change: transform;
}

.bg-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 300%;
    background: linear-gradient(165deg, #FFDAB9 0%, #F5E6D0 40%, #E8C9A0 100%);
}

.bg-crosshatch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 300%;
}

/* --- Solar Glow Overlay --- */
#solar-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 30% 20%, rgba(232, 105, 42, 0.15) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* --- Foreground Decorative Elements --- */
#fg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.ink-splat {
    position: absolute;
    border-radius: 50%;
    display: block;
}

/* --- Compass Rose --- */
#compass-rose {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1000;
    background: rgba(245, 230, 208, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 4px;
    box-shadow: 4px 6px 20px rgba(139, 69, 19, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#compass-rose svg {
    animation: compass-spin 30s linear infinite;
}

#compass-rose:hover {
    transform: scale(1.1);
    box-shadow: 4px 6px 28px rgba(139, 69, 19, 0.25);
}

@keyframes compass-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Chapter Overlay --- */
#chapter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.4s ease;
}

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

.overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(62, 39, 35, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.chapter-index {
    position: relative;
    z-index: 1;
    text-align: center;
}

.overlay-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--warm-white);
    margin-bottom: 2rem;
    text-shadow: 2px 3px 0px rgba(139, 69, 19, 0.15);
}

.chapter-index ul {
    list-style: none;
}

.chapter-index li {
    margin: 0.75rem 0;
}

.chapter-link {
    font-family: var(--font-secondary);
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--pale-apricot);
    text-decoration: none;
    transition: color 0.3s ease, transform 0.3s ease;
    display: inline-block;
}

.chapter-link:hover {
    color: var(--solar-flare);
    transform: translateX(8px);
}

.overlay-bubbles {
    margin-top: 2rem;
    opacity: 0.7;
    display: flex;
    justify-content: center;
}

.overlay-bubbles svg {
    display: block;
}

/* --- Chapter Base Styles --- */
.chapter {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 4rem 2rem;
}

.chapter-content {
    max-width: 1200px;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* --- Section Dividers --- */
.section-divider {
    width: 100%;
    padding: 0 5%;
    position: relative;
    z-index: 2;
}

.divider-line {
    width: 100%;
    height: auto;
    display: block;
}

/* --- Typography --- */
.hero-headline {
    font-family: var(--font-display);
    font-size: clamp(2.8rem, 8vw + 0.5rem, 7rem);
    color: var(--deep-sienna);
    letter-spacing: 0.01em;
    line-height: 1.1;
    text-shadow: 2px 3px 0px rgba(139, 69, 19, 0.15);
    text-align: center;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-family: var(--font-secondary);
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    color: var(--warm-umber);
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.section-title {
    font-family: var(--font-secondary);
    font-size: clamp(1.4rem, 3vw + 0.3rem, 2.8rem);
    color: var(--warm-umber);
    font-weight: 400;
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.2vw + 0.4rem, 1.25rem);
    line-height: 1.75;
    color: var(--deep-bark);
    letter-spacing: 0.015em;
    margin-bottom: 1.25rem;
}

.body-text:last-of-type {
    margin-bottom: 0;
}

.tech-label {
    font-family: var(--font-accent);
    font-size: clamp(0.75rem, 1vw, 1rem);
    color: var(--chrome-silver);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 1.5rem;
}

.hero-tech-label {
    opacity: 0.7;
}

.gallery-tech-label {
    text-align: center;
    margin-top: 2rem;
    opacity: 0.6;
}

/* --- Chapter Type A: Hero --- */
.chapter-hero {
    text-align: center;
}

.chapter-hero .chapter-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-sketch {
    margin-bottom: 2rem;
}

.hero-sketch svg {
    max-width: 300px;
    width: 100%;
    height: auto;
}

/* --- Chapter Type B: Split Sketch --- */
.split-layout {
    display: flex;
    gap: 4rem;
    align-items: center;
}

.split-text {
    flex: 0 0 55%;
}

.split-sketch {
    flex: 0 0 40%;
}

.split-layout-reverse {
    flex-direction: row-reverse;
}

/* Hand-drawn panel styling */
.panel-hand-drawn {
    background: var(--frosted-amber);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 2.5rem;
    box-shadow: 8px 12px 32px rgba(139, 69, 19, 0.10);
    border-radius: 12px;
    position: relative;
}

.panel-hand-drawn::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    border: 2px solid var(--warm-umber);
    opacity: 0.25;
    filter: url(#hand-drawn-filter);
    pointer-events: none;
}

/* Stagger offset for panels: organic asymmetric rhythm */
.chapter-split:nth-child(even) .split-layout {
    margin-left: 5%;
}

.chapter-split:nth-child(odd) .split-layout {
    margin-right: 5%;
}

/* --- Chapter Type C: Gallery Drift --- */
.chapter-gallery .chapter-content {
    overflow: visible;
}

.gallery-title {
    text-align: center;
    margin-bottom: 1rem;
}

.gallery-intro {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 2.5rem auto;
}

.gallery-drift {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    cursor: grab;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 1rem;
}

.gallery-drift::-webkit-scrollbar {
    display: none;
}

.gallery-drift:active {
    cursor: grabbing;
}

.gallery-track {
    display: flex;
    gap: 2rem;
    padding: 1rem 2rem;
    width: max-content;
}

.sketch-card {
    flex: 0 0 280px;
    transition: transform 0.3s ease;
}

.sketch-card:hover {
    transform: translateY(-8px) rotate(-1deg);
}

.card-frame {
    background: var(--warm-white);
    padding: 1.5rem;
    box-shadow: 6px 8px 24px rgba(139, 69, 19, 0.12);
    position: relative;
    border-radius: 4px;
}

/* Torn-edge effect via clip-path */
.card-frame::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 8px;
    background: var(--warm-white);
    clip-path: polygon(
        0% 0%, 5% 80%, 10% 20%, 15% 60%, 20% 10%, 25% 70%,
        30% 30%, 35% 80%, 40% 0%, 45% 60%, 50% 20%, 55% 70%,
        60% 10%, 65% 80%, 70% 30%, 75% 60%, 80% 0%, 85% 70%,
        90% 20%, 95% 80%, 100% 0%, 100% 100%, 0% 100%
    );
}

.card-illustration {
    width: 100%;
    height: auto;
    display: block;
    margin-bottom: 1rem;
}

.card-label {
    font-family: var(--font-secondary);
    font-size: 1.1rem;
    color: var(--warm-umber);
    text-align: center;
}

/* --- Chapter Type D: Counter Reveal --- */
.chapter-counter {
    text-align: center;
}

.counter-section-title {
    text-align: center;
    margin-bottom: 1rem;
}

.counter-intro {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 3rem auto;
}

.counter-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3rem 4rem;
}

.counter-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 160px;
}

.counter-chrome-bg {
    position: relative;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.06) 0%, rgba(232, 232, 232, 0.1) 50%, rgba(192, 192, 192, 0.06) 100%);
    border: 1px solid rgba(192, 192, 192, 0.15);
}

.counter-number {
    font-family: var(--font-accent);
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--solar-flare);
    font-weight: 700;
    letter-spacing: 0.12em;
    line-height: 1.2;
    display: block;
}

.counter-infinity {
    font-size: clamp(3rem, 7vw, 6rem);
}

.counter-underline {
    width: 120px;
    height: auto;
    margin: 0.25rem 0;
}

.counter-label {
    font-family: var(--font-secondary);
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--warm-umber);
    margin-top: 0.25rem;
}

.bubble-dots {
    margin-top: 3rem;
    opacity: 0.6;
}

/* --- Finale Chapter --- */
.chapter-finale {
    padding-bottom: 8rem;
}

.finale-sketch svg {
    max-width: 400px;
    width: 100%;
    height: auto;
}

.finale-headline {
    font-size: clamp(2.2rem, 6vw + 0.5rem, 5rem);
}

.finale-subtitle {
    margin-bottom: 1.5rem;
}

.finale-divider-mark {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
    opacity: 0.6;
}

.finale-label {
    margin-top: 2rem;
    opacity: 0.6;
}

/* --- SVG Draw Animation States --- */
.draw-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 2s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.draw-path.drawn {
    stroke-dashoffset: 0;
}

.fill-after-draw {
    opacity: 0;
    transition: opacity 0.6s ease 0.4s;
}

.fill-after-draw.visible {
    opacity: 0.25;
}

/* Specific opacity overrides for certain fills */
.chapter-hero .fill-after-draw.visible {
    opacity: 0.15;
}

.chapter-finale .fill-after-draw.visible {
    opacity: 0.3;
}

.chapter-split .split-sketch .fill-after-draw.visible {
    opacity: 0.2;
}

/* --- Scroll-based reveal animation --- */
.chapter-content {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.chapter-content.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .draw-path {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
        transition: none;
    }
    .fill-after-draw {
        opacity: 0.25;
        transition: none;
    }
    .chapter-content {
        opacity: 1;
        transform: none;
        transition: none;
    }
    #compass-rose svg {
        animation: none;
    }
    #bg-plane {
        transform: none;
    }
    .counter-number {
        transition: none;
    }
    .sketch-card {
        transition: none;
    }
    .chapter-link {
        transition: none;
    }
    #chapter-overlay {
        transition: none;
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .split-layout,
    .split-layout-reverse {
        flex-direction: column;
    }

    .split-text,
    .split-sketch {
        flex: 1 1 100%;
    }

    .chapter-split:nth-child(even) .split-layout,
    .chapter-split:nth-child(odd) .split-layout {
        margin-left: 0;
        margin-right: 0;
    }

    .counter-grid {
        gap: 2rem;
    }

    .counter-item {
        min-width: 120px;
    }

    .chapter {
        padding: 3rem 1.5rem;
    }

    .panel-hand-drawn {
        padding: 1.5rem;
    }

    .gallery-track {
        padding: 1rem;
    }

    .sketch-card {
        flex: 0 0 240px;
    }

    .split-layout {
        gap: 2rem;
    }
}

@media (max-width: 480px) {
    .hero-headline {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .counter-grid {
        flex-direction: column;
        align-items: center;
        gap: 2.5rem;
    }

    .gallery-track {
        gap: 1rem;
    }

    .sketch-card {
        flex: 0 0 200px;
    }

    .chapter {
        padding: 2rem 1rem;
    }

    .panel-hand-drawn {
        padding: 1.25rem;
    }

    #compass-rose {
        width: 48px;
        height: 48px;
        bottom: 16px;
        left: 16px;
    }
}
