/* haskell.quest - Creamy Pastel Functional Programming Quest */

:root {
    --bg-primary: #fdf6ec;
    --bg-secondary: #f7ede0;
    --text-primary: #3d2b1f;
    --text-secondary: #7a6552;
    --accent-warm: #e07a5f;
    --accent-cool: #81b29a;
    --accent-soft: #f2cc8f;
    --timeline-spine: #c9a87c;
    --highlight: #f4a261;
    --timeline-faint: #e8d5b7;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
}

/* Timeline Spine */
.timeline-spine {
    position: fixed;
    left: 8%;
    top: 0;
    width: 2px;
    height: 100vh;
    background-color: var(--timeline-faint);
    z-index: 10;
}

.timeline-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background-color: var(--timeline-spine);
    transition: height 0.1s linear;
}

/* Timeline Milestone Markers */
.chapter-milestone {
    position: absolute;
    left: 8%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--timeline-spine);
    background-color: transparent;
    z-index: 15;
    top: 10vh;
}

.chapter-milestone.filled {
    animation: bounceFill 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Progress dots along spine */
.timeline-spine::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 100%;
    background-image: radial-gradient(circle, var(--timeline-faint) 2px, transparent 2px);
    background-size: 6px 80px;
    background-repeat: repeat-y;
    opacity: 0.6;
}

/* Scatter Shapes */
.scatter-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.scatter-shape {
    position: absolute;
}

.scatter-s1 { top: 15%; left: 3%; transform: rotate(12deg); }
.scatter-s2 { top: 30%; right: 5%; transform: rotate(-8deg); }
.scatter-s3 { top: 50%; left: 2%; transform: rotate(25deg); }
.scatter-s4 { top: 65%; right: 8%; transform: rotate(15deg); }
.scatter-s5 { top: 80%; left: 4%; transform: rotate(-5deg); }
.scatter-s6 { top: 10%; right: 3%; transform: rotate(20deg); }
.scatter-s7 { top: 45%; right: 2%; transform: rotate(-15deg); }
.scatter-s8 { top: 90%; right: 6%; transform: rotate(10deg); }

/* Chapters - Common */
.chapter {
    position: relative;
    min-height: 100vh;
    padding: 80px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chapter-content {
    position: relative;
    max-width: 680px;
    margin-left: 20%;
    padding: 0 24px;
    z-index: 5;
}

.chapter-number {
    position: absolute;
    left: 14%;
    top: 10%;
    font-family: 'Nunito', sans-serif;
    font-weight: 200;
    font-size: clamp(4rem, 10vw, 8rem);
    color: var(--timeline-faint);
    z-index: 2;
    pointer-events: none;
    user-select: none;
}

/* Chapter 1 - Lambda Gate */
.chapter-1 {
    min-height: 100vh;
    background-color: var(--bg-primary);
}

.lambda-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    opacity: 0.6;
}

.quest-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 200;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 24px;
    font-variation-settings: 'wght' 200;
    z-index: 5;
    position: relative;
}

.quest-subtitle {
    font-weight: 400;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: var(--text-secondary);
    max-width: 520px;
    line-height: 1.8;
}

/* Floating shapes in chapter 1 */
.float-shape {
    position: absolute;
    z-index: 3;
}

.float-circle {
    top: 20%;
    right: 15%;
    animation: floatSlow 6s ease-in-out infinite;
}

.float-rect {
    bottom: 25%;
    right: 22%;
    animation: floatSlow 8s ease-in-out infinite reverse;
}

.float-diamond {
    top: 60%;
    right: 10%;
    animation: floatSlow 7s ease-in-out infinite 1s;
}

@keyframes floatSlow {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-12px); }
}

/* Chapter 2 - Types as Colors */
.chapter-2 {
    min-height: 120vh;
    background-color: var(--bg-primary);
}

.type-shapes-display {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin: 32px 0;
    padding: 24px;
    background-color: var(--bg-secondary);
    border-radius: 24px;
    border: 1px solid var(--timeline-faint);
}

.type-shape-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.type-shape-item code {
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    background-color: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--text-primary);
}

.type-arrow {
    font-size: 1.6rem;
    color: var(--timeline-spine);
    font-weight: 300;
}

.type-composition {
    display: flex;
    gap: 32px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.maybe-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.maybe-wrapper code {
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
    background-color: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 6px;
}

/* Cards */
.card {
    background-color: var(--bg-primary);
    border: 1px solid var(--timeline-faint);
    border-radius: 24px;
    padding: 32px;
    margin: 24px 0;
    transition: border-color 0.3s ease;
}

.card:hover {
    border-color: var(--accent-soft);
}

.card h3 {
    font-weight: 600;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    margin-bottom: 12px;
    color: var(--text-primary);
}

.card p {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.card p:last-child {
    margin-bottom: 0;
}

.code-example {
    margin: 16px 0;
}

.code-example code {
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    background-color: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

code {
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    background-color: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 6px;
}

/* Chapter 3 - Monad Trail */
.chapter-3 {
    min-height: 140vh;
    background-color: var(--bg-primary);
}

.monad-trail {
    position: relative;
    width: 100%;
    min-height: 800px;
    margin: 40px 0;
}

.trail-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.monad-node {
    position: absolute;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    z-index: 3;
    max-width: 320px;
}

.monad-circle {
    flex-shrink: 0;
}

.monad-label h4 {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.monad-label p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Chapter 4 - Pattern Matching */
.chapter-4 {
    min-height: 100vh;
    background-color: var(--bg-primary);
}

.pattern-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 32px;
    justify-content: flex-start;
}

.pattern-tile {
    background-color: var(--bg-primary);
    border: 1px solid var(--timeline-faint);
    border-radius: 16px;
    padding: 20px;
    max-width: 320px;
    min-width: 260px;
    flex: 1 1 260px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.pattern-tile:hover {
    border-color: var(--accent-soft);
    box-shadow: 0 4px 20px rgba(201, 168, 124, 0.15);
}

.pattern-tile-header {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--accent-warm);
    margin-bottom: 10px;
    letter-spacing: 0.02em;
}

.pattern-tile pre {
    background-color: var(--bg-secondary);
    padding: 14px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 0;
}

.pattern-tile code {
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Chapter 5 - Summit */
.chapter-5 {
    min-height: 100vh;
    background-color: var(--bg-primary);
    padding-bottom: 120px;
}

.summit-seal {
    display: flex;
    justify-content: center;
    margin: 48px 0;
}

.seal-svg {
    filter: drop-shadow(0 4px 12px rgba(201, 168, 124, 0.2));
}

.timeline-terminus {
    position: absolute;
    left: 8%;
    bottom: 120px;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--accent-warm);
    border: 3px solid var(--bg-primary);
    box-shadow: 0 0 0 2px var(--timeline-spine);
    z-index: 15;
}

/* Footer */
.quest-footer {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    font-weight: 300;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

/* Headings */
h2 {
    font-weight: 800;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 16px;
}

h3 {
    font-weight: 600;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
}

/* Lambda list markers */
.chapter-content > p {
    margin-bottom: 16px;
}

/* Bounce Enter Animation */
@keyframes bounceEnter {
    0% { opacity: 0; transform: translateY(40px) scale(0.9); }
    50% { opacity: 1; transform: translateY(-8px) scale(1.02); }
    70% { transform: translateY(3px) scale(0.99); }
    100% { transform: translateY(0) scale(1); }
}

.bounce-in {
    animation: bounceEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.bounce-target {
    opacity: 0;
    transform: translateY(40px);
}

.bounce-target.bounce-in {
    opacity: 1;
    transform: translateY(0);
}

/* Bounce Fill for milestones */
@keyframes bounceFill {
    0% { background-color: transparent; transform: translateX(-50%) scale(1); }
    40% { background-color: var(--accent-warm); transform: translateX(-50%) scale(1.3); }
    70% { transform: translateX(-50%) scale(0.9); }
    100% { background-color: var(--accent-warm); transform: translateX(-50%) scale(1); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .timeline-spine {
        left: 4%;
    }

    .chapter-milestone {
        left: 4%;
    }

    .timeline-terminus {
        left: 4%;
    }

    .chapter-content {
        margin-left: 12%;
        padding: 0 16px;
    }

    .chapter-number {
        left: 8%;
        font-size: clamp(3rem, 8vw, 5rem);
    }

    .monad-node {
        max-width: 250px;
    }

    .monad-trail {
        min-height: 600px;
    }

    .pattern-tile {
        min-width: 100%;
    }

    .type-shapes-display {
        justify-content: center;
    }

    .float-shape {
        display: none;
    }
}

@media (max-width: 480px) {
    .chapter-content {
        margin-left: 14%;
    }

    .type-composition {
        gap: 16px;
    }

    .monad-node {
        flex-direction: column;
        max-width: 200px;
    }
}

/* Subtle emphasis styles */
em {
    color: var(--accent-warm);
    font-style: italic;
}

strong {
    font-weight: 700;
}

/* Selection color */
::selection {
    background-color: var(--accent-soft);
    color: var(--text-primary);
}
