/* ============================
   haskell.day — styles.css
   ============================ */

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: #0D1117;
    color: #B8B0A8;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* --- Chalk Texture Overlay --- */
.chalk-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

.purity-module .chalk-texture-boost {
    opacity: 0.05;
}

/* --- Lambda Particle Canvas --- */
#lambda-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* --- Cursor Trail --- */
#cursor-trail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.trail-arrow {
    position: absolute;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #7EE787;
    opacity: 0.15;
    pointer-events: none;
    transition: opacity 0.8s ease-out;
    user-select: none;
}

.trail-arrow.fading {
    opacity: 0;
}

/* --- Lambda Fold Navigation --- */
#lambda-nav {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#lambda-nav.visible {
    opacity: 1;
}

.lambda-item {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.lambda-symbol {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    color: #4A5568;
    transition: color 0.3s ease;
    user-select: none;
}

.lambda-item.active .lambda-symbol {
    color: #F0A500;
}

.lambda-item:hover .lambda-symbol {
    color: #F0A500;
}

.lambda-tooltip {
    position: absolute;
    left: 48px;
    white-space: nowrap;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    color: #6B7280;
    background: #161B22;
    padding: 4px 12px;
    border: 1px solid #21262D;
    border-radius: 4px;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.lambda-item:hover .lambda-tooltip {
    opacity: 1;
    transform: translateX(0);
}

/* --- Commutative Diagrams --- */
.diagram-container {
    position: fixed;
    pointer-events: none;
    z-index: 0;
    opacity: 0.08;
}

.diagram-1 {
    width: 300px;
    height: 300px;
    top: 10%;
    right: 5%;
    animation: diagram-rotate 120s linear infinite;
}

.diagram-2 {
    width: 250px;
    height: 250px;
    bottom: 15%;
    left: 3%;
    animation: diagram-rotate 120s linear infinite reverse;
}

.diagram-3 {
    width: 280px;
    height: 280px;
    top: 55%;
    right: 10%;
    animation: diagram-rotate 120s linear infinite;
    animation-delay: -40s;
}

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

.commutative-diagram {
    width: 100%;
    height: 100%;
}

.diagram-node {
    font-family: 'Source Serif 4', serif;
    font-size: 20px;
    fill: #A78BFA;
    font-style: italic;
}

.diagram-arrow {
    stroke: #A78BFA;
    stroke-width: 1.5;
    fill: none;
}

.diagram-arrowhead {
    fill: #A78BFA;
}

.diagram-label {
    font-family: 'Source Serif 4', serif;
    font-size: 14px;
    fill: #A78BFA;
    font-style: italic;
    text-anchor: middle;
}

/* --- Module Base --- */
.module {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding: 0;
}

/* --- Opening Module --- */
.opening-module {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.opening-content {
    text-align: center;
    max-width: 800px;
    padding: 0 2rem;
}

.ghci-prompt {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    color: #7EE787;
    margin-bottom: 1.5rem;
    min-height: 1.6em;
}

.cursor-blink {
    animation: blink 1s step-end infinite;
    color: #7EE787;
}

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

.type-response {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1.1rem);
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.type-response.visible {
    opacity: 1;
    transform: translateY(0);
}

.response-name {
    color: #E8E0D4;
}

.response-separator {
    color: #6B7280;
}

.response-type {
    color: #F0A500;
}

.response-arrow {
    color: #E8E0D4;
}

.site-title {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.site-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.site-title h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(3rem, 6vw, 5rem);
    font-weight: 700;
    color: #E8E0D4;
    letter-spacing: -0.02em;
    line-height: 1.15;
    text-shadow: 0 0 40px rgba(126, 231, 135, 0.19);
    margin-bottom: 0.5rem;
}

.site-subtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    color: #B8B0A8;
}

/* --- Type Signature Bands --- */
.type-signature-band {
    width: 100%;
    background: #161B22;
    border-top: 1px solid #21262D;
    padding: 1rem 8%;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1.1rem);
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.type-signature-band.animate-in {
    opacity: 1;
    transform: translateX(0);
}

.sig-name {
    color: #7EE787;
}

.sig-separator {
    color: #6B7280;
}

.sig-type {
    color: #F0A500;
}

.sig-arrow {
    color: #E8E0D4;
}

.sig-constraint {
    color: #F97583;
}

.sig-typevar {
    color: #A78BFA;
}

/* --- Module Grid --- */
.module-grid {
    display: grid;
    grid-template-columns: 55% 25%;
    gap: 0;
    padding: 3rem 0;
    margin-left: 8%;
    margin-right: 12%;
}

/* --- Module Content --- */
.module-content {
    padding-right: 3rem;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.module-content.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.module-content h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(2rem, 4vw, 3.2rem);
    font-weight: 700;
    color: #E8E0D4;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 1.5rem;
}

.module-content p {
    margin-bottom: 1.5rem;
    color: #B8B0A8;
}

.module-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: #7EE787;
    background: rgba(126, 231, 135, 0.08);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

/* --- Code Cards --- */
.code-card {
    background: #161B22;
    border: 1px solid #21262D;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
}

.code-card pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    line-height: 1.65;
}

.code-card code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: #B8B0A8;
    font-size: inherit;
}

.code-keyword { color: #F97583; }
.code-type { color: #F0A500; }
.code-typevar { color: #A78BFA; }
.code-name { color: #7EE787; }
.code-separator { color: #6B7280; }
.code-arrow { color: #E8E0D4; }
.code-string { color: #F0A500; }
.code-comment { color: #4A5568; font-style: italic; }

/* --- Sidebar --- */
.module-sidebar {
    padding-left: 2rem;
    border-left: 1px solid #21262D;
    opacity: 0;
    transition: opacity 0.5s ease-out;
    align-self: start;
    position: sticky;
    top: 100px;
}

.module-sidebar.animate-in {
    opacity: 1;
}

.sidebar-card {
    margin-bottom: 2rem;
}

.sidebar-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 0.85rem;
    color: #F0A500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.sidebar-card p {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 0.85rem;
    color: #6B7280;
    line-height: 1.6;
}

.sidebar-card code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    color: #7EE787;
}

/* --- Composition Demo --- */
.composition-demo {
    margin: 2rem 0;
    padding: 1rem 0;
}

.composition-svg {
    width: 100%;
    max-width: 600px;
    height: auto;
}

.comp-label {
    font-family: 'Source Serif 4', serif;
    font-size: 22px;
    font-style: italic;
    fill: #E8E0D4;
}

.comp-func {
    font-family: 'Source Serif 4', serif;
    font-size: 18px;
    font-style: italic;
    fill: #7EE787;
}

.comp-arrow {
    stroke: #A78BFA;
    stroke-width: 2;
    fill: none;
}

.comp-arrowhead {
    fill: #A78BFA;
}

.comp-composed {
    stroke: #F0A500;
}

.comp-arrowhead.comp-composed {
    fill: #F0A500;
}

.comp-composed-label {
    fill: #F0A500;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-style: normal;
}

/* --- Purity Demo --- */
.purity-module {
    /* slightly warmer chalk texture via ::before overlay */
}

.purity-demo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin: 2.5rem 0;
    padding: 1.5rem;
    flex-wrap: wrap;
}

.purity-expression {
    background: #161B22;
    border: 1px solid #21262D;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    transition: box-shadow 0.6s ease;
}

.purity-expression code {
    background: none;
    padding: 0;
}

.purity-expression.glow {
    box-shadow: 0 0 20px rgba(126, 231, 135, 0.25), inset 0 0 20px rgba(126, 231, 135, 0.05);
}

.purity-equiv {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    color: #7EE787;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.purity-equiv.visible {
    opacity: 1;
}

/* --- Community Module --- */
.community-module .module-content {
    /* amber warmth */
}

.community-links {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
}

.community-link-card {
    background: #161B22;
    border: 1px solid #21262D;
    border-radius: 8px;
    padding: 1.5rem;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out, border-color 0.3s ease;
}

.community-link-card.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.community-link-card:hover {
    border-color: #F0A500;
}

.community-link-card code {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    margin-bottom: 0.75rem;
    background: none;
    padding: 0;
    border-radius: 0;
}

.community-link-card p {
    margin-bottom: 0;
    font-size: 0.95rem;
}

/* --- Closing Module --- */
.closing-module {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.closing-content {
    text-align: center;
    max-width: 600px;
    padding: 0 2rem;
}

#ghci-closing {
    margin-bottom: 1.5rem;
}

.closing-message {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1.1rem);
    color: #6B7280;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.closing-message.visible {
    opacity: 1;
}

/* --- Spacing Between Modules --- */
#types,
#composition,
#purity,
#community {
    padding-top: 120px;
}

#closing {
    padding-top: 60px;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .module-grid {
        grid-template-columns: 1fr;
        margin-left: 5%;
        margin-right: 5%;
    }

    .module-content {
        padding-right: 0;
    }

    .module-sidebar {
        border-left: none;
        border-top: 1px solid #21262D;
        padding-left: 0;
        padding-top: 1.5rem;
        margin-top: 2rem;
        position: static;
    }

    #lambda-nav {
        display: none;
    }

    .type-signature-band {
        padding: 1rem 5%;
        font-size: clamp(0.75rem, 2vw, 0.95rem);
    }

    .purity-demo {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 600px) {
    .site-title h1 {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .ghci-prompt {
        font-size: 1rem;
    }

    .code-card {
        padding: 1rem;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .diagram-container {
        animation: none;
    }

    .type-signature-band {
        transform: none;
    }

    .module-content {
        transform: none;
    }

    .community-link-card {
        transform: none;
    }

    .site-title {
        transform: none;
    }

    .type-response {
        transform: none;
    }

    .cursor-blink {
        animation: none;
        opacity: 1;
    }

    .trail-arrow {
        display: none;
    }
}

/* --- Selection Color --- */
::selection {
    background: rgba(126, 231, 135, 0.2);
    color: #E8E0D4;
}
