/* haskell.quest // cyberpunk data-viz dashboard */

:root {
    --bg-void: #0a0a12;
    --rain-green: #00ff88;
    --hud-cyan: #00e5ff;
    --hud-purple: #b44eff;
    --hud-locked: #3a3a48;
    --hud-warn: #ff2d55;
    --hud-gold: #ffd700;
    --body: #b8c0d0;
    --panel: rgba(10, 10, 18, 0.85);
    --panel-edge: rgba(0, 229, 255, 0.3);
    --panel-soft: rgba(0, 229, 255, 0.15);
    --font-display: "Orbitron", "Space Grotesk", system-ui, sans-serif;
    --font-code: "Source Code Pro", "Space Mono", ui-monospace, monospace;
    --font-body: "Exo 2", "Inter", system-ui, sans-serif;
}

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

html, body {
    background: var(--bg-void);
    color: var(--body);
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.7;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    position: relative;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(180, 78, 255, 0.18), transparent 60%),
        radial-gradient(ellipse at 80% 90%, rgba(0, 229, 255, 0.15), transparent 55%),
        linear-gradient(180deg, #05050b 0%, #0a0a12 50%, #06060d 100%);
}

a { color: var(--hud-cyan); text-decoration: none; }
a:hover { color: var(--hud-purple); }

/* ============ Code Rain ============ */
.code-rain {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    mask-image: linear-gradient(180deg, transparent 0%, black 15%, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, black 15%, black 85%, transparent 100%);
    opacity: 0.45;
}

.rain-col {
    position: absolute;
    top: 0;
    width: 1.2em;
    font-family: var(--font-code);
    font-size: 14px;
    line-height: 1.5;
    color: var(--rain-green);
    text-shadow: 0 0 6px rgba(0, 255, 136, 0.6);
    white-space: pre;
    animation: fall linear infinite;
    will-change: transform;
}

.rain-col span { display: block; opacity: 0.85; }
.rain-col span:first-child {
    color: #d8ffe8;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.95);
    opacity: 1;
}

@keyframes fall {
    from { transform: translateY(-110vh); }
    to   { transform: translateY(110vh); }
}

/* ============ Grid overlay ============ */
.grid-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(rgba(0, 229, 255, 0.05) 1px, transparent 1px) 0 0 / 80px 80px,
        linear-gradient(90deg, rgba(0, 229, 255, 0.05) 1px, transparent 1px) 0 0 / 80px 80px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* ============ Top HUD ============ */
.top-hud {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.85rem 1.5rem;
    background: linear-gradient(180deg, rgba(10,10,18,0.95), rgba(10,10,18,0.6));
    border-bottom: 1px solid var(--panel-edge);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-family: var(--font-code);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hud-id { display: flex; align-items: center; gap: 0.6rem; color: var(--hud-cyan); }
.hud-id .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--rain-green);
    box-shadow: 0 0 10px var(--rain-green);
    animation: blink 2s infinite;
}
.hud-id .hud-label { color: var(--body); opacity: 0.6; }
.hud-id .hud-value { color: var(--hud-cyan); }

@keyframes blink {
    0%, 60%, 100% { opacity: 1; }
    65%, 80% { opacity: 0.2; }
}

.hud-nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.hud-nav a {
    color: var(--body);
    opacity: 0.65;
    padding: 0.2rem 0.5rem;
    border: 1px solid transparent;
    transition: opacity .15s, border-color .15s, color .15s;
}
.hud-nav a:hover, .hud-nav a.active {
    opacity: 1;
    color: var(--hud-cyan);
    border-color: var(--panel-edge);
}

.hud-clock { display: flex; align-items: center; gap: 0.75rem; color: var(--hud-cyan); }
.hud-clock .hud-online {
    padding: 0.2rem 0.45rem;
    border: 1px solid var(--rain-green);
    color: var(--rain-green);
    font-size: 0.7rem;
}

/* ============ Layout / Sections ============ */
main {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 6rem;
    padding: 4rem 1.5rem 6rem;
    max-width: 1280px;
    margin: 0 auto;
}

.section-head { max-width: 720px; margin-bottom: 2rem; }
.kicker {
    font-family: var(--font-code);
    color: var(--hud-cyan);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}
.lead { color: var(--body); opacity: 0.8; margin-top: 0.5rem; max-width: 56ch; }

/* ============ Display titles ============ */
.display-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 4.5rem);
    letter-spacing: 0.1em;
    line-height: 1;
    color: #f1f6ff;
    text-transform: uppercase;
    text-shadow: 0 0 18px rgba(0, 229, 255, 0.35);
    margin: 0.4rem 0 1rem;
}
.display-title.sm { font-size: clamp(1.4rem, 3.5vw, 2.4rem); }
.display-title .accent {
    background: linear-gradient(90deg, var(--hud-cyan), var(--hud-purple));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ============ HUD Panels w/ corner brackets ============ */
.hud-panel {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.hud-panel .corner {
    position: absolute;
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.hud-panel .corner.tl { top: -1px; left: -1px; border-top: 2px solid var(--hud-cyan); border-left: 2px solid var(--hud-cyan); }
.hud-panel .corner.tr { top: -1px; right: -1px; border-top: 2px solid var(--hud-cyan); border-right: 2px solid var(--hud-cyan); }
.hud-panel .corner.bl { bottom: -1px; left: -1px; border-bottom: 2px solid var(--hud-cyan); border-left: 2px solid var(--hud-cyan); }
.hud-panel .corner.br { bottom: -1px; right: -1px; border-bottom: 2px solid var(--hud-cyan); border-right: 2px solid var(--hud-cyan); }

.panel-tag, .tt-tag {
    font-family: var(--font-code);
    color: var(--hud-cyan);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.85;
}

/* ============ HERO ============ */
.hero {
    min-height: 78vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 2rem;
}
.hero-panel {
    padding: clamp(1.5rem, 3vw, 2.6rem);
    max-width: 760px;
    width: 100%;
}
.hero-panel .tagline {
    font-family: var(--font-code);
    color: var(--hud-cyan);
    letter-spacing: 0.06em;
    margin-bottom: 1.2rem;
    opacity: 0.9;
}
.hero-panel .brief { font-size: 1.05rem; max-width: 60ch; }
.hero-panel .brief .hl {
    color: var(--hud-purple);
    font-family: var(--font-code);
    background: rgba(180, 78, 255, 0.12);
    padding: 0 0.3rem;
    border: 1px solid rgba(180, 78, 255, 0.3);
}
.hero-panel .op-id {
    color: var(--hud-cyan);
    font-family: var(--font-code);
    font-weight: 500;
    border-bottom: 1px dashed var(--hud-cyan);
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    margin: 1.6rem 0 1.8rem;
    flex-wrap: wrap;
}

.btn {
    font-family: var(--font-code);
    font-size: 0.86rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.75rem 1.2rem;
    background: transparent;
    color: var(--hud-cyan);
    border: 1px solid var(--hud-cyan);
    cursor: pointer;
    position: relative;
    transition: background .15s, color .15s, transform .15s, box-shadow .2s;
}
.btn.sm { padding: 0.5rem 0.9rem; font-size: 0.78rem; }
.btn:hover { background: rgba(0, 229, 255, 0.12); box-shadow: 0 0 14px rgba(0, 229, 255, 0.4); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(90deg, rgba(0,229,255,0.18), rgba(180,78,255,0.18));
    color: #e9faff;
    border-color: var(--hud-cyan);
}
.btn-primary:hover {
    background: linear-gradient(90deg, rgba(0,229,255,0.32), rgba(180,78,255,0.32));
    color: #fff;
}
.btn-ghost { color: var(--body); border-color: var(--panel-edge); }
.btn-ghost:hover { color: var(--hud-cyan); border-color: var(--hud-cyan); }

.hero-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    border-top: 1px solid var(--panel-soft);
    padding-top: 1.2rem;
}
.stat { display: flex; flex-direction: column; gap: 0.2rem; }
.stat-num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.4rem, 2.6vw, 2rem);
    color: var(--hud-cyan);
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
    letter-spacing: 0.04em;
}
.stat-label {
    font-family: var(--font-code);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--body);
    opacity: 0.65;
}

/* ============ Quest grid ============ */
.quests { position: relative; }
.quest-stage {
    position: relative;
    border: 1px solid var(--panel-soft);
    background: rgba(10, 10, 18, 0.55);
    padding: 1rem;
    min-height: 540px;
}
.quest-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.hex { transition: filter .2s, transform .2s; cursor: pointer; transform-origin: center; transform-box: fill-box; }
.hex polygon { transition: fill .2s, stroke .2s, filter .2s; }

.hex.locked polygon { fill: rgba(58, 58, 72, 0.35); stroke: var(--hud-locked); stroke-width: 2; }
.hex.complete polygon { fill: rgba(0, 229, 255, 0.18); stroke: var(--hud-cyan); stroke-width: 2; filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.6)); }
.hex.active polygon { fill: rgba(180, 78, 255, 0.25); stroke: var(--hud-purple); stroke-width: 2.5; filter: drop-shadow(0 0 10px rgba(180, 78, 255, 0.85)); animation: questPulse 2.4s ease-in-out infinite; }
.hex.warn polygon { stroke: var(--hud-warn); fill: rgba(255, 45, 85, 0.12); }

.hex text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    fill: #f1f6ff;
    text-anchor: middle;
    dominant-baseline: central;
    letter-spacing: 0.08em;
    pointer-events: none;
}
.hex.locked text { fill: #6b6f80; }
.hex:hover polygon { filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.95)); }
.hex:hover { transform: scale(1.06); }

@keyframes questPulse {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(180, 78, 255, 0.6)); }
    50% { filter: drop-shadow(0 0 16px rgba(180, 78, 255, 1)); }
}

.path-line {
    fill: none;
    stroke: var(--hud-cyan);
    stroke-width: 1.4;
    stroke-dasharray: 8 4;
    opacity: 0.6;
    animation: dashflow 2s linear infinite;
}
.path-line.dim { stroke: var(--hud-locked); opacity: 0.3; animation: none; }
@keyframes dashflow {
    from { stroke-dashoffset: 0; }
    to   { stroke-dashoffset: -24; }
}

.quest-tooltip {
    position: absolute;
    pointer-events: none;
    padding: 0.85rem 1rem;
    min-width: 240px;
    max-width: 280px;
    transform: translate(-50%, -110%);
    transition: opacity .12s ease;
}
.quest-tooltip[hidden] { display: none; }
.tt-title {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--hud-cyan);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0.3rem 0 0.4rem;
}
.tt-desc { font-size: 0.85rem; color: var(--body); opacity: 0.85; }
.tt-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.6rem;
    font-family: var(--font-code);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--hud-cyan);
}

.quest-legend {
    display: flex;
    gap: 1.2rem;
    margin-top: 1rem;
    font-family: var(--font-code);
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.lg { display: inline-flex; align-items: center; gap: 0.4rem; }
.lg::before {
    content: '';
    width: 14px; height: 14px;
    display: inline-block;
    transform: rotate(30deg);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.lg-complete { color: var(--hud-cyan); }
.lg-complete::before { background: var(--hud-cyan); box-shadow: 0 0 6px var(--hud-cyan); }
.lg-active { color: var(--hud-purple); }
.lg-active::before { background: var(--hud-purple); box-shadow: 0 0 6px var(--hud-purple); }
.lg-locked { color: var(--hud-locked); }
.lg-locked::before { background: var(--hud-locked); }

/* ============ Terminal ============ */
.terminal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 0;
    overflow: hidden;
}
.term-pane {
    border-right: 1px solid var(--panel-soft);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.term-pane:last-child { border-right: 0; }
.term-bar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 0.9rem;
    background: rgba(0, 229, 255, 0.06);
    border-bottom: 1px solid var(--panel-soft);
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--hud-cyan);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.term-dot { width: 9px; height: 9px; border-radius: 50%; }
.d1 { background: var(--hud-warn); }
.d2 { background: var(--hud-gold); }
.d3 { background: var(--rain-green); }
.term-title { margin-left: 0.4rem; opacity: 0.8; }
.term-status {
    margin-left: auto;
    border: 1px solid var(--panel-soft);
    padding: 0.1rem 0.45rem;
    color: var(--rain-green);
    font-size: 0.7rem;
}
.term-status.run { color: var(--hud-gold); border-color: var(--hud-gold); }
.term-status.ok { color: var(--rain-green); border-color: var(--rain-green); }
.term-status.err { color: var(--hud-warn); border-color: var(--hud-warn); }

.term-body {
    padding: 1rem 1.1rem;
    flex: 1;
    font-size: 0.92rem;
    color: var(--body);
}
.term-line { margin: 0.4rem 0; }
.term-line .prompt { color: var(--rain-green); margin-right: 0.4rem; }
.term-line.muted { color: var(--hud-cyan); opacity: 0.55; font-family: var(--font-code); font-size: 0.78rem; letter-spacing: 0.08em; }
.term-list { padding-left: 1.3rem; margin: 0.4rem 0 0.6rem; }
.term-list li { margin: 0.2rem 0; font-family: var(--font-code); font-size: 0.85rem; color: var(--body); }

code {
    font-family: var(--font-code);
    color: var(--rain-green);
    background: rgba(0, 255, 136, 0.08);
    padding: 0 0.3rem;
    border-radius: 2px;
    font-size: 0.85em;
}

.editor-body { padding: 0; display: flex; flex-direction: column; }
.editor {
    margin: 0;
    padding: 1rem 1.1rem;
    font-family: var(--font-code);
    font-size: 0.88rem;
    color: #d0f7e6;
    background:
        repeating-linear-gradient(180deg, transparent 0 24px, rgba(0,229,255,0.04) 24px 25px);
    line-height: 1.5;
    min-height: 280px;
    white-space: pre;
    overflow: auto;
    position: relative;
}
.editor code { background: none; color: inherit; padding: 0; }
.caret {
    display: inline-block;
    width: 8px; height: 1.1em;
    background: var(--hud-cyan);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: caret 1s steps(2) infinite;
    box-shadow: 0 0 6px var(--hud-cyan);
}
@keyframes caret { 50% { opacity: 0; } }

.term-actions {
    display: flex;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--panel-soft);
    background: rgba(0, 229, 255, 0.04);
}
.term-output {
    border-top: 1px solid var(--panel-soft);
    padding: 0.8rem 1.1rem;
    min-height: 100px;
    font-family: var(--font-code);
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.35);
}
.term-output .ok { color: var(--rain-green); }
.term-output .err { color: var(--hud-warn); }
.term-output .info { color: var(--hud-cyan); }

/* ============ Leaderboard ============ */
.leaderboard { position: relative; }
.leaderboard .scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.18) 2px,
        rgba(0, 0, 0, 0.18) 4px
    );
    mix-blend-mode: multiply;
    z-index: 1;
}
.leaderboard .section-head, .leaderboard .lb-wrap { position: relative; z-index: 2; }

.lb-wrap { padding: 1.2rem; overflow-x: auto; }
.lb-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    font-family: var(--font-code);
}
.lb-table thead th {
    text-align: left;
    color: var(--hud-cyan);
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 0.4rem 0.9rem;
    border-bottom: 1px solid var(--panel-soft);
}
.lb-table tbody tr {
    background: rgba(10, 10, 18, 0.6);
    transition: background .15s;
}
.lb-table tbody tr:hover { background: rgba(0, 229, 255, 0.08); }
.lb-table tbody td {
    padding: 0.7rem 0.9rem;
    border-top: 1px solid var(--panel-soft);
    border-bottom: 1px solid var(--panel-soft);
    color: var(--body);
    font-size: 0.85rem;
}
.lb-table tbody tr td:first-child {
    border-left: 1px solid var(--panel-soft);
    color: var(--hud-cyan);
    font-family: var(--font-display);
    letter-spacing: 0.08em;
}
.lb-table tbody tr td:last-child {
    border-right: 1px solid var(--panel-soft);
    color: var(--hud-cyan);
    font-family: var(--font-display);
    letter-spacing: 0.04em;
    text-align: right;
}

.rank-1 td:first-child { border-left: 3px solid var(--hud-gold) !important; color: var(--hud-gold) !important; }
.rank-2 td:first-child { border-left: 3px solid #c0c8d8 !important; color: #d8e0ee !important; }
.rank-3 td:first-child { border-left: 3px solid #cd7f32 !important; color: #e6a060 !important; }

/* ============ Footer ============ */
.footer {
    position: relative;
    z-index: 2;
    border-top: 1px solid var(--panel-soft);
    padding: 1.2rem 1.5rem 2rem;
    margin-top: 4rem;
    font-family: var(--font-code);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--body);
    opacity: 0.7;
}
.foot-line {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}

/* ============ Responsive ============ */
@media (max-width: 880px) {
    .top-hud { flex-wrap: wrap; gap: 0.6rem; }
    .hud-nav { order: 3; width: 100%; justify-content: space-between; }
    .terminal-grid { grid-template-columns: 1fr; }
    .term-pane { border-right: 0; border-bottom: 1px solid var(--panel-soft); }
    .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    main { gap: 4rem; padding: 2rem 1rem 4rem; }
}

@media (max-width: 540px) {
    .hud-nav a { font-size: 0.7rem; padding: 0.15rem 0.35rem; }
    .display-title { font-size: clamp(1.6rem, 8vw, 2.4rem); }
}
