/* ============================================
   haskell.monster - Abstract Glitch Art Tech
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #120820;
    color: #e2e8f0;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    line-height: 1.6;
    overflow-x: hidden;
}

/* --- Keyframes --- */
@keyframes glitch {
    0%, 100% {
        text-shadow: 2px 0 #22d3ee, -2px 0 #ef4444;
    }
    20% {
        text-shadow: -3px 0 #22d3ee, 3px 0 #ef4444;
    }
    40% {
        text-shadow: 3px 0 #22d3ee, -1px 0 #ef4444;
    }
    60% {
        text-shadow: -1px 0 #22d3ee, 2px 0 #ef4444;
    }
    80% {
        text-shadow: 1px 0 #22d3ee, -3px 0 #ef4444;
    }
}

@keyframes glitch-intense {
    0%, 100% {
        text-shadow: 3px 0 #22d3ee, -3px 0 #ef4444;
        transform: translateX(0);
    }
    10% {
        text-shadow: -5px 0 #22d3ee, 5px 0 #ef4444;
        transform: translateX(-2px);
    }
    30% {
        text-shadow: 4px 1px #22d3ee, -4px -1px #ef4444;
        transform: translateX(3px);
    }
    50% {
        text-shadow: -2px 0 #22d3ee, 2px 0 #ef4444;
        transform: translateX(-1px);
    }
    70% {
        text-shadow: 5px -1px #22d3ee, -5px 1px #ef4444;
        transform: translateX(2px);
    }
    90% {
        text-shadow: -3px 0 #22d3ee, 3px 0 #ef4444;
        transform: translateX(-3px);
    }
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    3% { opacity: 0.4; }
    6% { opacity: 1; }
    7% { opacity: 0.6; }
    9% { opacity: 1; }
    50% { opacity: 1; }
    52% { opacity: 0.3; }
    53% { opacity: 1; }
    77% { opacity: 1; }
    78% { opacity: 0.7; }
    80% { opacity: 1; }
}

@keyframes scanline-move {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

@keyframes progress-fill {
    0% { width: 0; }
    70% { width: 72%; }
    72% { width: 72%; }
    74% { width: 68%; }
    76% { width: 75%; }
    100% { width: 100%; }
}

@keyframes progress-glitch-flash {
    0%, 69% { opacity: 0; }
    70% { opacity: 1; }
    76% { opacity: 1; }
    77% { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes trace-appear {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* --- Scanline Overlay --- */
.scanline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent,
        transparent 3px,
        rgba(168, 85, 247, 0.1) 3px,
        rgba(168, 85, 247, 0.1) 4px
    );
    pointer-events: none;
    z-index: 2;
    animation: scanline-move 0.5s linear infinite alternate;
}

/* --- Comment Markers --- */
.comment-marker {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    color: #a855f7;
    font-size: 14px;
    opacity: 0.5;
    margin-bottom: 24px;
    letter-spacing: 1px;
}

/* --- Glitch Title --- */
.glitch-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(48px, 8vw, 80px);
    color: #e2e8f0;
    animation: glitch 3s infinite, flicker 8s infinite;
    position: relative;
    display: inline-block;
}

.glitch-title-sm {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 28px;
    color: #e2e8f0;
    animation: glitch 3s infinite;
    display: inline-block;
}

/* --- Glitch Headings --- */
.glitch-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(28px, 4vw, 44px);
    color: #e2e8f0;
    text-shadow: 2px 0 #22d3ee, -2px 0 #ef4444;
    margin-bottom: 16px;
}

/* =============================================
   SECTION 1: UNLEASH (Hero)
   ============================================= */
.section-unleash {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #120820;
    padding: 40px 20px;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 3;
    text-align: center;
    max-width: 900px;
}

.error-message {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: clamp(18px, 3vw, 28px);
    color: #e2e8f0;
    margin-top: 32px;
    animation: fade-in-up 1s ease 0.5s both;
}

.error-prefix {
    color: #ef4444;
    font-weight: 400;
}

.error-trace {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 14px;
    color: #6b7280;
    margin-top: 20px;
    text-align: left;
    display: inline-block;
    animation: fade-in-up 1s ease 1s both;
}

.trace-line {
    display: block;
    line-height: 1.8;
}

.trace-line.indent {
    padding-left: 24px;
}

.flicker-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #22d3ee, #a855f7, #ef4444, transparent);
    animation: flicker 4s infinite;
    z-index: 3;
}

/* =============================================
   SECTION 2: ENCOUNTER (Glitch Panels)
   ============================================= */
.section-encounter {
    position: relative;
    padding: 100px 20px;
    background-color: #120820;
    overflow: hidden;
}

.section-encounter > .comment-marker {
    text-align: center;
}

.glitch-panel {
    position: relative;
    background-color: #1e1030;
    border-left: 3px solid #a855f7;
    padding: 40px;
    margin: 40px auto;
    max-width: 760px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glitch-panel:hover {
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.2), inset 0 0 20px rgba(34, 211, 238, 0.05);
}

.glitch-panel.offset-right {
    transform: translateX(3px);
}

.glitch-panel.offset-left {
    transform: translateX(-3px);
}

.glitch-panel.offset-right:hover {
    transform: translateX(6px);
}

.glitch-panel.offset-left:hover {
    transform: translateX(-6px);
}

.panel-body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.6;
    color: #e2e8f0;
    margin-bottom: 16px;
}

.code-fragment {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 14px;
    color: #22d3ee;
    background-color: rgba(18, 8, 32, 0.8);
    padding: 8px 16px;
    display: block;
    border-left: 2px solid #22d3ee;
}

/* =============================================
   SECTION 3: BATTLE (Monster Types)
   ============================================= */
.section-battle {
    position: relative;
    padding: 100px 20px;
    background-color: #1e1030;
    overflow: hidden;
}

.section-battle > .comment-marker {
    text-align: center;
}

.section-title {
    text-align: center;
    margin-bottom: 60px;
}

.monster-list {
    max-width: 860px;
    margin: 0 auto;
}

.monster-entry {
    padding: 24px 32px;
    margin-bottom: 8px;
    background-color: rgba(18, 8, 32, 0.6);
    border-left: 3px solid #a855f7;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.monster-entry:hover {
    border-color: #22d3ee;
}

.monster-entry.glitch-intensity-1 {
    text-shadow: 1px 0 #22d3ee, -1px 0 #ef4444;
    transform: translateX(1px);
}

.monster-entry.glitch-intensity-1:hover {
    transform: translateX(4px);
}

.monster-entry.glitch-intensity-2 {
    text-shadow: 2px 0 #22d3ee, -2px 0 #ef4444;
    transform: translateX(-2px);
}

.monster-entry.glitch-intensity-2:hover {
    transform: translateX(-5px);
}

.monster-entry.glitch-intensity-3 {
    text-shadow: 3px 0 #22d3ee, -3px 0 #ef4444;
    transform: translateX(3px);
    animation: glitch-intense 4s infinite;
}

.monster-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(20px, 3vw, 28px);
    color: #e2e8f0;
    display: block;
    margin-bottom: 4px;
}

.monster-desc {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 13px;
    color: #6b7280;
    display: block;
    margin-bottom: 8px;
}

.monster-type {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 13px;
    color: #22d3ee;
    display: block;
    word-break: break-all;
}

/* Progress Bar */
.progress-bar-container {
    max-width: 860px;
    margin: 60px auto 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-label {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 14px;
    color: #6b7280;
    white-space: nowrap;
}

.progress-track {
    flex: 1;
    height: 8px;
    background-color: rgba(18, 8, 32, 0.8);
    border: 1px solid #a855f7;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22d3ee);
    width: 0;
    transition: width 0.1s linear;
}

.progress-fill.animate {
    animation: progress-fill 3s ease forwards;
}

.progress-glitch {
    position: absolute;
    top: -2px;
    left: 68%;
    width: 30px;
    height: 12px;
    background-color: #ef4444;
    opacity: 0;
}

.progress-glitch.animate {
    animation: progress-glitch-flash 3s ease forwards;
}

.progress-value {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 14px;
    color: #4ade80;
    white-space: nowrap;
}

/* =============================================
   SECTION 4: TAME (Footer)
   ============================================= */
.section-tame {
    position: relative;
    padding: 100px 20px 80px;
    background-color: #120820;
    overflow: hidden;
}

.section-tame > .comment-marker {
    text-align: center;
}

.error-trace-footer {
    max-width: 660px;
    margin: 0 auto 60px;
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 14px;
    background-color: #1e1030;
    padding: 32px;
    border-left: 3px solid #ef4444;
}

.trace-header {
    color: #ef4444;
    margin-bottom: 16px;
    font-size: 16px;
}

.trace-entry {
    color: #6b7280;
    line-height: 2;
    opacity: 0;
    animation: trace-appear 0.4s ease forwards;
}

.trace-entry:nth-child(2) { animation-delay: 0.2s; }
.trace-entry:nth-child(3) { animation-delay: 0.4s; }
.trace-entry:nth-child(4) { animation-delay: 0.6s; }
.trace-entry:nth-child(5) { animation-delay: 0.8s; }
.trace-entry:nth-child(6) { animation-delay: 1.0s; }

.trace-entry.resolved {
    color: #4ade80;
}

.tame-message {
    text-align: center;
    margin-bottom: 60px;
}

.success-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(24px, 4vw, 40px);
    color: #4ade80;
    text-shadow: none;
}

.footer-brand {
    text-align: center;
    opacity: 0.4;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .glitch-panel {
        padding: 24px;
        margin: 24px 16px;
    }

    .monster-entry {
        padding: 16px 20px;
    }

    .error-trace-footer {
        padding: 20px;
        margin: 0 16px 40px;
    }

    .progress-bar-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .progress-track {
        width: 100%;
    }
}
