/* haskell.day -- terminal-meets-editorial design language */

:root {
    --void: #0d1117;
    --evaluated: #161b22;
    --constraint: #21262d;
    --constraint-hover: #1c2128;
    --pure: #e6edf3;
    --partial: #8b949e;
    --lambda: #3fb950;
    --lambda-bright: #4ae060;
    --monad-blue: #58a6ff;
    --type-purple: #bc8cff;
    --thunk-amber: #d29922;
    --functor-coral: #f47067;
    --hackage-teal: #39d353;

    --col-max: 52rem;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--void);
    color: var(--pure);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: clamp(1rem, 1.15vw, 1.1rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

code, pre, .mono {
    font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
    font-feature-settings: "liga" on, "calt" on;
}

/* ---------- Page rail (mini section indicator) ---------- */
.page-rail {
    position: fixed;
    top: 50%;
    left: 1.5rem;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    z-index: 10;
    opacity: 0;
    transition: opacity 600ms var(--ease-out);
}
.page-rail.visible { opacity: 1; }

.rail-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--constraint);
    transition: all 300ms var(--ease-out);
    cursor: pointer;
}
.rail-dot[data-target="purity"]      { --c: var(--monad-blue); }
.rail-dot[data-target="types"]       { --c: var(--type-purple); }
.rail-dot[data-target="laziness"]    { --c: var(--thunk-amber); }
.rail-dot[data-target="abstraction"] { --c: var(--functor-coral); }
.rail-dot[data-target="community"]   { --c: var(--hackage-teal); }
.rail-dot.active {
    background: var(--c);
    transform: scale(1.6);
    box-shadow: 0 0 12px color-mix(in srgb, var(--c) 60%, transparent);
}

@media (max-width: 720px) {
    .page-rail { display: none; }
}

/* ---------- Layout column ---------- */
.column {
    width: 100%;
    max-width: var(--col-max);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section {
    position: relative;
    min-height: 100vh;
    padding: 7rem 0 5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.section + .section {
    border-top: 1px solid var(--constraint);
}

.section-eyebrow {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--partial);
    margin-bottom: 1.5rem;
}

/* ---------- Lambda watermark ---------- */
.lambda-watermark {
    position: absolute;
    top: 50%;
    right: -8%;
    transform: translateY(-50%) rotate(15deg);
    font-family: "Source Serif 4", serif;
    font-size: clamp(30rem, 50vw, 60rem);
    line-height: 1;
    color: var(--pure);
    opacity: 0.02;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}

/* ---------- Operator constellations ---------- */
.operator-cloud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}
.op {
    position: absolute;
    left: var(--x);
    top: var(--y);
    font-family: "JetBrains Mono", monospace;
    font-size: var(--s);
    color: var(--pure);
    opacity: 0.10;
    transform: translate3d(0, 0, 0);
    transition: transform 400ms linear;
}

/* ---------- Hero / The Prompt ---------- */
.section-prompt {
    text-align: left;
}
.prompt-stage {
    position: relative;
    z-index: 1;
}
.repl-line {
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(0.95rem, 1.3vw, 1.15rem);
    line-height: 1.7;
    color: var(--pure);
}
.hero-line {
    font-size: clamp(1.05rem, 1.5vw, 1.3rem);
    margin-bottom: 2.5rem;
    min-height: 2em;
}
.prompt-label {
    color: var(--lambda);
    font-weight: 500;
    margin-right: 0.6rem;
}
.hero-expr, .quit-expr {
    color: var(--pure);
    white-space: pre;
}
.cursor {
    display: inline-block;
    color: var(--lambda);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9em;
    line-height: 1;
    transform: translateY(-0.05em);
    animation: cursor-blink 530ms step-end infinite;
    margin-left: 0.05em;
}
.cursor.hidden { visibility: hidden; }

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

.hero-output {
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
}
.hero-output.shown {
    opacity: 1;
    transform: scale(1);
}
.hero-title {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 9vw, 7rem);
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--pure);
    margin-bottom: 1.2rem;
}
.hero-type {
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    color: var(--partial);
    opacity: 0;
    transition: opacity 500ms var(--ease-out) 200ms;
}
.hero-output.shown .hero-type { opacity: 1; }

.hero-type .hl-name { color: var(--pure); }
.hero-type .hl-op { color: var(--lambda); }
.hero-type .hl-type { color: var(--type-purple); }
.hero-type .hl-paren { color: var(--partial); }

/* ---------- Type-signature navigation ---------- */
.section-nav { padding-top: 6rem; }

.ghci-dots {
    display: flex;
    gap: 0.45rem;
    margin-bottom: 1.5rem;
}
.ghci-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.dot-green  { background: var(--lambda); }
.dot-blue   { background: var(--monad-blue); }
.dot-purple { background: var(--type-purple); }

.type-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.type-nav-item {
    --accent: var(--lambda);
    background: var(--evaluated);
    border: 1px solid var(--constraint);
    border-left: 0 solid var(--accent);
    padding: 1.2rem 1.5rem;
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: var(--pure);
    cursor: pointer;
    opacity: 0;
    transform: translateX(20px);
    transition:
        background 250ms var(--ease-out),
        border-color 250ms var(--ease-out),
        border-left-width 250ms var(--ease-out),
        opacity 400ms var(--ease-out),
        transform 400ms var(--ease-out);
}
.type-nav-item.in-view {
    opacity: 1;
    transform: translateX(0);
}
.type-nav-item:hover {
    background: var(--constraint-hover);
    border-left-width: 3px;
}
.type-nav-item:hover .hl-op,
.type-nav-item:hover .hl-arrow {
    color: var(--lambda-bright);
}
.type-nav-item .hl-name {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 500;
    color: var(--pure);
    letter-spacing: -0.02em;
    margin-right: 0.75rem;
    font-size: 1.05em;
}
.type-nav-item .hl-op,
.type-nav-item .hl-arrow {
    color: var(--lambda);
    transition: color 250ms var(--ease-out);
    margin: 0 0.4rem;
}
.type-nav-item .hl-type {
    color: var(--partial);
}

/* ---------- Concept sections ---------- */
.concept {
    --accent: var(--lambda);
    border-left: 0 solid var(--accent);
    padding-left: 1.5rem;
    transition: border-left-width 300ms var(--ease-out);
}
.concept.in-view {
    border-left-width: 4px;
}
.concept[data-accent="#58a6ff"] { --accent: var(--monad-blue); }
.concept[data-accent="#bc8cff"] { --accent: var(--type-purple); }
.concept[data-accent="#d29922"] { --accent: var(--thunk-amber); }
.concept[data-accent="#f47067"] { --accent: var(--functor-coral); }
.concept[data-accent="#39d353"] { --accent: var(--hackage-teal); }

.concept-header { margin-bottom: 2.75rem; position: relative; z-index: 1; }
.concept-sig {
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(1.05rem, 1.5vw, 1.35rem);
    font-weight: 500;
    line-height: 1.55;
    letter-spacing: -0.005em;
    color: var(--pure);
}
.concept-sig .hl-name {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
    font-size: 1.1em;
    margin-right: 0.5rem;
}
.concept-sig .hl-op,
.concept-sig .hl-arrow {
    color: var(--lambda);
    margin: 0 0.4rem;
}
.concept-sig .hl-type { color: var(--partial); }

.concept-grid {
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 2rem;
    align-items: start;
    position: relative;
    z-index: 1;
}

.code-block {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.concept.in-view .code-block { opacity: 1; transform: none; }

.code-block pre {
    background: var(--evaluated);
    border: 1px solid var(--constraint);
    border-radius: 6px;
    padding: 1.5rem;
    overflow-x: auto;
    font-size: clamp(0.78rem, 0.9vw, 0.92rem);
    line-height: 1.7;
}
.code-block code {
    color: var(--pure);
    font-family: "JetBrains Mono", monospace;
    white-space: pre;
}

/* Code syntax highlighting */
.c-com  { color: var(--partial); font-style: italic; }
.c-key  { color: var(--accent, var(--lambda)); font-weight: 500; }
.c-fn   { color: var(--pure); }
.c-typ  { color: var(--type-purple); }
.c-str  { color: var(--thunk-amber); }
.c-num  { color: var(--thunk-amber); }
.c-op   { color: var(--lambda); }
.c-arr  { color: var(--lambda); }
.c-paren { color: var(--partial); }

.prose {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.concept.in-view .prose { opacity: 1; transform: none; }

.prose p {
    margin-bottom: 1.25rem;
    color: var(--pure);
}
.prose p:last-child { margin-bottom: 0; }
.prose code {
    font-size: 0.92em;
    color: var(--pure);
    background: var(--evaluated);
    padding: 0.1em 0.4em;
    border-radius: 3px;
    border: 1px solid var(--constraint);
}
.prose .key {
    font-weight: 400;
    font-style: italic;
}

@media (max-width: 720px) {
    .concept-grid {
        grid-template-columns: 1fr;
    }
    .concept-sig {
        font-size: 1rem;
    }
}

/* ---------- REPL section ---------- */
.section-repl { padding-top: 6rem; }

.repl-title {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    letter-spacing: -0.02em;
    color: var(--pure);
    margin-bottom: 3rem;
}
.repl-stream {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    background: var(--evaluated);
    border: 1px solid var(--constraint);
    border-radius: 6px;
    padding: 2rem 1.75rem;
}
.repl-pair {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 400ms var(--ease-out), transform 400ms var(--ease-out);
}
.repl-pair.in-view {
    opacity: 1;
    transform: none;
}
.repl-input {
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: var(--pure);
    line-height: 1.6;
    word-break: break-word;
}
.repl-input .repl-text { color: var(--pure); }
.repl-output {
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: var(--lambda-bright);
    margin-top: 0.4rem;
    line-height: 1.6;
    opacity: 0;
    transition: opacity 300ms var(--ease-out) 200ms;
    word-break: break-word;
}
.repl-pair.completed .repl-output { opacity: 1; }

/* ---------- The Signature ---------- */
.section-signature {
    text-align: center;
    align-items: center;
    padding-bottom: 8rem;
}

.bind-mark {
    position: relative;
    width: 120px;
    height: 80px;
    margin: 0 auto 3rem;
}
.bind-bar {
    position: absolute;
    left: 0;
    width: 70px;
    height: 6px;
    background: var(--lambda);
    opacity: 0.6;
    border-radius: 1px;
    transform-origin: left center;
}
.bind-bar-1 {
    top: 20px;
    transform: rotate(-30deg);
}
.bind-bar-2 {
    top: 50px;
    transform: rotate(30deg);
}
.bind-eq {
    position: absolute;
    right: 8px;
    top: 26px;
    width: 32px;
    height: 26px;
}
.bind-eq::before,
.bind-eq::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--lambda);
    opacity: 0.6;
    border-radius: 1px;
}
.bind-eq::before { top: 4px; }
.bind-eq::after  { bottom: 4px; }

.closing-quote {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    line-height: 1.5;
    color: var(--pure);
    max-width: 38rem;
    margin: 0 auto 4rem;
}

.quit-block {
    text-align: left;
    max-width: 26rem;
    margin: 0 auto;
    background: var(--evaluated);
    border: 1px solid var(--constraint);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
}
.quit-out {
    font-family: "JetBrains Mono", monospace;
    color: var(--partial);
    margin-top: 0.4rem;
    opacity: 0;
    transition: opacity 400ms var(--ease-out);
    font-size: clamp(0.85rem, 1.1vw, 1rem);
}
.quit-out.shown { opacity: 1; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .hero-output { opacity: 1; transform: none; }
    .hero-output .hero-type { opacity: 1; }
    .type-nav-item { opacity: 1; transform: none; }
    .code-block, .prose { opacity: 1; transform: none; }
    .repl-pair { opacity: 1; transform: none; }
    .repl-pair .repl-output { opacity: 1; }
    .quit-out { opacity: 1; }
    .cursor { animation: none; }
}
