/* =========================================
   1. GLOBAL THEME & VARIABLES
   ========================================= */
:root {
    /* DEFAULT THEME: BLUE MOON */
    /* Layer 1: Subtle center glow */
    --bg-layer-1: radial-gradient(circle at 50% 50%, rgba(0, 200, 255, 0.1), transparent 60%);
    /* Layer 2: Deep Blue/Black Base */
    --bg-layer-2: linear-gradient(135deg, #000814 0%, #001f4d 50%, #000814 100%);
    
    --glass-bg: rgba(5, 20, 30, 0.75);
    --glass-border: rgba(100, 200, 255, 0.2);
    
    --accent-color: #00d2ff;       /* Cyan */
    --accent-secondary: #0077ff;   /* Deep Blue */
    --accent-glow: rgba(0, 210, 255, 0.6);
    
    --text-color: #ffffff;
    --text-dim: #d5efff;
    --error-color: #ff0055;
}

/* THEME: FIERY RED */
[data-theme="fire"] {
    --bg-layer-1: radial-gradient(circle at 50% 50%, rgba(255, 200, 0, 0.1), transparent 60%);
    --bg-layer-2: linear-gradient(135deg, #1a0505 0%, #4a0000 50%, #1a0505 100%);
    --glass-bg: rgba(20, 5, 5, 0.75);
    --glass-border: rgba(255, 100, 100, 0.15);
    --accent-color: #ff9f43;
    --accent-secondary: #ff6b6b;
    --accent-glow: rgba(255, 159, 67, 0.6);
    --text-dim: #ffd5d5;
    --error-color: #ff4757;
}

/* THEME: VENOM */
[data-theme="venom"] {
    --bg-layer-1: radial-gradient(circle at 50% 50%, rgba(50, 255, 50, 0.08), transparent 60%);
    --bg-layer-2: linear-gradient(135deg, #051405 0%, #0a2e0a 50%, #051405 100%);
    --glass-bg: rgba(5, 20, 5, 0.75);
    --glass-border: rgba(50, 255, 50, 0.15);
    --accent-color: #00ff88;       /* Neon Green */
    --accent-secondary: #00b860;   /* Forest Green */
    --accent-glow: rgba(0, 255, 136, 0.5);
    --text-dim: #dfffe5;
    --error-color: #ff5555;
}

/* THEME: NEBULA */
[data-theme="nebula"] {
    --bg-layer-1: radial-gradient(circle at 50% 50%, rgba(200, 0, 255, 0.08), transparent 60%);
    --bg-layer-2: linear-gradient(135deg, #12001f 0%, #2d004d 50%, #12001f 100%);
    --glass-bg: rgba(20, 5, 30, 0.75);
    --glass-border: rgba(200, 100, 255, 0.15);
    --accent-color: #e056fd;       /* Bright Violet */
    --accent-secondary: #be2edd;   /* Deep Purple */
    --accent-glow: rgba(224, 86, 253, 0.5);
    --text-dim: #f3d0ff;
    --error-color: #ff4757;
}

/* THEME: PHANTOM */
[data-theme="phantom"] {
    --bg-layer-1: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05), transparent 60%);
    --bg-layer-2: linear-gradient(135deg, #000000 0%, #1a1a1a 50%, #000000 100%);
    --glass-bg: rgba(20, 20, 20, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-color: #ffffff;       /* Pure White */
    --accent-secondary: #7f8fa6;   /* Cool Grey */
    --accent-glow: rgba(255, 255, 255, 0.3);
    --text-dim: #b2bec3;
    --error-color: #ff6b6b;
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background: var(--bg-layer-1), var(--bg-layer-2);
    background-size: 200% 200%;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    transition: background 0.5s ease;
}

/* Drifting Smoke Animation */
body::before {
    content: "";
    position: fixed;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 40%, transparent 70%);
    animation: driftFumes 25s infinite linear;
    z-index: -1;
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes driftFumes {
    0% { transform: rotate(0deg) translate(0, 0); }
    50% { transform: rotate(180deg) translate(50px, 50px); }
    100% { transform: rotate(360deg) translate(0, 0); }
}

/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
header {
    width: 100%;
    padding: 20px 20px 40px 20px;
    text-align: center;
    position: relative;
    z-index: 10;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Dashboard Button */
.home-btn, a.home-btn {
    position: absolute;
    top: 30px;
    left: 40px;
    color: #ffffff !important;
    text-decoration: none !important;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    z-index: 100;
    cursor: pointer;
}

.home-btn:hover {
    background: var(--accent-secondary);
    border-color: transparent;
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-2px);
    color: white !important;
}

/* Theme Button */
.theme-btn {
    position: absolute;
    top: 30px;
    right: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 10px 14px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    z-index: 100;
}
.theme-btn:hover {
    background: var(--accent-secondary);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: rotate(90deg);
}

/* Theme Modal Circles */
.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 25px;
    margin-bottom: 25px;
}

.theme-circle {
    width: 50px; 
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid rgba(255,255,255,0.2);
    transition: 0.3s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
.theme-circle:hover { 
    transform: scale(1.15); 
    border-color: #fff; 
}

/* Header Text */
header h1 {
    font-size: 3rem; 
    margin: 0;
    font-weight: 800;
    background: linear-gradient(to right, var(--accent-color), var(--accent-secondary), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px var(--accent-glow);
    line-height: 1.2;
    padding: 0 10px;
    max-width: 100%;
}

header h2 {
    font-size: 1.1rem;
    color: var(--text-dim);
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 10px;
}

/* =========================================
   3. PANELS & TYPING AREAS
   ========================================= */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
    padding: 40px; margin: 20px;
    width: 90%; max-width: 1000px;
    text-align: center; position: relative;
    height: auto; display: flex; flex-direction: column;
}

#drill-container[style*="display: none"],
#results-panel[style*="display: none"] {
    display: none !important;
}

.typing-area {
    font-family: 'Roboto Mono', monospace; font-size: 1.8rem; line-height: 1.7;
    max-height: 300px; overflow-y: auto; margin: 30px 0; text-align: left;
    white-space: pre-wrap; outline: none; position: relative; padding-right: 15px;
}
.typing-area::-webkit-scrollbar { width: 8px; }
.typing-area::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 4px; }
.typing-area::-webkit-scrollbar-thumb { background: var(--accent-secondary); border-radius: 4px; }

/* Beginner/Touch Spans */
.typing-area span { color: #555; padding: 2px 1px; border-radius: 3px; transition: background-color 0.1s; }
.typing-area span.current { 
    background-color: var(--accent-color); color: #000 !important;
    box-shadow: 0 0 20px var(--accent-glow); font-weight: 900; animation: pulseBlock 1s infinite;
}
.typing-area span.correct { color: #fff; text-shadow: 0 0 8px rgba(255,255,255,0.4); }
.typing-area span.incorrect { color: var(--error-color); background: rgba(255, 71, 87, 0.15); text-decoration: underline; }

/* Pro Mode Elements */
.word { display: inline-flex; margin-right: 15px; margin-bottom: 15px; color: #444; position: relative; line-height: 1.5; }
.word.active { color: #bbb; }
letter { position: relative; padding: 2px 1px; border-radius: 3px; transition: all 0.1s; }
letter.current { 
    background-color: var(--accent-color); color: #000 !important;
    box-shadow: 0 0 20px var(--accent-glow); font-weight: 900; animation: pulseBlock 1s infinite;
}
letter.space-char { width: 10px; display: inline-block; height: 1em; }
letter.correct { color: #fff; text-shadow: 0 0 8px rgba(255,255,255,0.4); }
letter.incorrect { color: var(--error-color); text-decoration: underline; background: rgba(255, 71, 87, 0.1); }
letter.extra { color: #8a2be2; opacity: 0.8; margin-left: 1px; }

@keyframes pulseBlock { 
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px var(--accent-glow); }
    50% { transform: scale(1.1); box-shadow: 0 0 25px var(--accent-glow); }
}

/* =========================================
   4. COMPONENTS
   ========================================= */
.start-btn, .action-btn {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    color: white; border: none; padding: 15px 40px; border-radius: 50px;
    font-size: 1.1rem; font-weight: 700; text-transform: uppercase; cursor: pointer;
    transition: 0.3s; box-shadow: 0 10px 20px -10px var(--accent-secondary); margin: 10px;
}
.start-btn:hover { transform: translateY(-3px); box-shadow: 0 15px 30px -10px var(--accent-glow); }

/* User Badge */
.user-badge {
    position: absolute; top: 30px; 
    right: 120px; 
    background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255,255,255,0.15);
    padding: 8px 20px; border-radius: 50px;
    display: flex; align-items: center; gap: 10px; z-index: 20;
}
.user-badge .avatar {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    border-radius: 50%; display: flex; justify-content: center; align-items: center;
    font-weight: bold; font-size: 0.8rem;
}

/* Stats */
.stats-grid { display: flex; justify-content: center; gap: 30px; margin: 30px 0; }
.stat-card {
    background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1);
    padding: 20px 30px; border-radius: 15px; min-width: 120px;
    display: flex; flex-direction: column; gap: 8px;
}
.stat-label { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; font-weight: 600; }
.stat-value { font-size: 2.2rem; font-weight: 800; color: var(--accent-color); text-shadow: 0 0 15px var(--accent-glow); line-height: 1; }

/* Keyboard */
.keyboard-container {
    margin-top: 30px; background: rgba(0,0,0,0.4); padding: 25px;
    border-radius: 20px; display: inline-block; border: 1px solid rgba(255,255,255,0.1);
    transition: opacity 0.5s;
}
.key-row { display: flex; justify-content: center; gap: 6px; margin-bottom: 6px; }
.key {
    width: 45px; height: 45px;
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px; display: flex; justify-content: center; align-items: center;
    font-weight: bold; color: #777; transition: 0.1s; font-size: 1rem;
}
.key.active { background: var(--accent-color); color: #000; box-shadow: 0 0 15px var(--accent-glow); transform: scale(0.95); }
.key.space { width: 250px; }

/* =========================================
   5. HOMEPAGE LAYOUT
   ========================================= */
.modes { 
    display: flex; flex-direction: row; gap: 30px; 
    justify-content: center; flex-wrap: wrap; 
    margin-top: 40px; width: 100%; max-width: 1200px; 
}
.mode-card {
    background: rgba(10, 5, 5, 0.6); backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 20px;
    padding: 30px 20px; width: 280px; text-align: center;
    transition: all 0.4s; position: relative; overflow: hidden;
}
.mode-card:hover { transform: translateY(-10px); border-color: var(--accent-color); box-shadow: 0 10px 40px rgba(0,0,0,0.4); }
.mode-card h2 { color: var(--accent-color); margin-bottom: 10px; font-size: 1.6rem; }
.mode-card p { color: var(--text-dim); line-height: 1.5; margin-bottom: 25px; font-size: 0.95rem; }

/* =========================================
   6. EPIC FOOTER (Smooth Cycling Glow)
   ========================================= */
footer {
    width: 100%;
    text-align: center;
    padding: 100px 0 120px 0;
    margin-top: auto;
    position: relative;
    z-index: 5;
}

.sekiro-container {
    display: inline-block;
    position: relative;
    padding: 20px;
}

.sekiro-box {
    /* The Box Itself - Stationary */
    border: 3px solid #fff; 
    padding: 15px 60px;
    background: #000; 
    position: relative;
    z-index: 2;
    
    /* DEFAULT STATE */
    box-shadow: 
        0 0 10px var(--accent-color),
        0 0 20px var(--accent-secondary);
    
    /* Smooth, slow breathing animation (3 seconds) */
    animation: smoothGlow 3s infinite alternate ease-in-out;
}

/* The Text */
.sekiro-text {
    font-family: 'Cinzel', serif;
    font-size: 2.8rem;
    letter-spacing: 10px;
    text-transform: uppercase;
    font-weight: 800;
    color: #fff;
    margin: 0;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
    position: relative;
    z-index: 3;
}

/* SMOOTH CYCLE ANIMATION 
   No shaking (transform), just a gentle pulse of light intensity.
*/
@keyframes smoothGlow {
    0% {
        /* Dimmer State */
        box-shadow: 
            0 0 5px #fff,
            0 0 15px var(--accent-color),
            0 0 30px var(--accent-secondary),
            0 0 50px transparent; /* Fade out edge */
    }
    100% {
        /* Bright State */
        box-shadow: 
            0 0 10px #fff,
            0 0 25px var(--accent-color),
            0 0 50px var(--accent-secondary),
            0 0 80px var(--accent-glow); /* Extended glow */
    }
}

/* =========================================
   7. CURRICULUM MODULE STYLES
   ========================================= */
.module-list {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Space between cards */
    padding: 10px;
    max-height: 500px; /* Scrollable if too many modules */
    overflow-y: auto;
}

/* Scrollbar for the list */
.module-list::-webkit-scrollbar { width: 6px; }
.module-list::-webkit-scrollbar-thumb { background: var(--accent-color); border-radius: 10px; }

.module-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 20px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    text-align: left; /* Ensure text aligns left */
}

.module-item:hover {
    transform: translateX(10px); /* Slide effect */
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
    box-shadow: -5px 0 15px rgba(0,0,0,0.3);
}

/* Left side: Number + Text */
.mod-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.mod-number {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--text-dim);
    opacity: 0.3;
    min-width: 40px;
}

.mod-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mod-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

/* Badges (Remedial vs Normal) */
.mod-badge {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.badge-remedial {
    color: var(--error-color);
    border: 1px solid var(--error-color);
    background: rgba(255, 71, 87, 0.1);
}

.badge-core {
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    background: rgba(255, 159, 67, 0.1); /* Slightly Orange for Core */
}

/* Start Button inside the card */
.mod-btn {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.8rem;
    font-weight: 600;
}

.module-item:hover .mod-btn {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #000;
}

/* Modals */
.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); backdrop-filter: blur(10px);
    justify-content: center; align-items: center; z-index: 2000;
}
.modal-content {
    background: #1a0a0a; border: 1px solid var(--accent-secondary);
    padding: 40px; border-radius: 24px; text-align: center; width: 90%; max-width: 500px;
    box-shadow: 0 0 50px var(--accent-glow);
}
.modal-content input {
    width: 100%; padding: 15px; margin: 20px 0;
    background: rgba(255,255,255,0.05); border: 2px solid #551a1a;
    border-radius: 10px; color: #fff; text-align: center;
    box-sizing: border-box;
}

/* =========================================
   8. PORTFOLIO & HEATMAP
   ========================================= */
.heatmap-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 15px;
    justify-content: center;
}
.heatmap-box {
    width: 15px;
    height: 15px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05); /* Level 0 */
    transition: 0.2s;
}
.heatmap-box:hover { transform: scale(1.3); z-index: 10; border: 1px solid #fff; }
.heat-1 { background: rgba(0, 210, 255, 0.3); } /* Level 1 */
.heat-2 { background: rgba(0, 210, 255, 0.6); } /* Level 2 */
.heat-3 { background: rgba(0, 210, 255, 0.9); } /* Level 3 */
.heat-4 { background: #fff; box-shadow: 0 0 10px #fff; } /* Level 4+ */

/* Match theme colors dynamically */
[data-theme="fire"] .heat-1 { background: rgba(255, 159, 67, 0.3); }
[data-theme="fire"] .heat-2 { background: rgba(255, 159, 67, 0.6); }
[data-theme="fire"] .heat-3 { background: rgba(255, 159, 67, 0.9); }

[data-theme="venom"] .heat-1 { background: rgba(0, 255, 136, 0.3); }
[data-theme="venom"] .heat-2 { background: rgba(0, 255, 136, 0.6); }
[data-theme="venom"] .heat-3 { background: rgba(0, 255, 136, 0.9); }

/* =========================================
   9. RESPONSIVE COMPRESSION (NO SCROLLBAR)
   ========================================= */
@media (max-height: 950px) {
    /* Tighten the header to save space */
    header { padding: 15px 20px 5px 20px !important; }
    header h1 { font-size: 2.2rem !important; }
    header h2 { font-size: 0.9rem !important; margin-top: 5px !important; }
    
    /* This forces PERFECT vertical and horizontal centering for Beginner/Touch */
    .glass-panel {
        padding: 25px !important;
        margin: auto !important; 
        max-height: 85vh; 
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 90% !important;
    }

    /* FIX: Pull Professional Mode back up right below the timer */
    #prof-panel {
        margin-top: 20px !important;
        margin-bottom: auto !important;
        justify-content: flex-start !important;
    }
    #prof-panel .typing-area {
        max-height: 35vh !important; /* Gives the text block more room to breathe */
    }

    #ai-box { padding: 10px 15px !important; margin-bottom: 10px !important; min-height: auto !important; }
    #ai-box div[style*="font-size: 2rem"] { font-size: 1.5rem !important; }
    
    .typing-area {
        font-size: 1.5rem !important;
        margin: 10px 0 !important;
        max-height: 20vh !important; 
        min-height: 60px !important;
    }

    .keyboard-container {
        margin-top: 10px !important;
        padding: 15px !important;
        transform: scale(0.85);
        transform-origin: top center;
        margin-bottom: -30px !important; 
    }

    .hand-guide {
        margin-top: 40px !important;
        margin-bottom: -20px !important;
        transform: scale(0.75);
        transform-origin: top center;
    }
}

/* Extreme compression for very tight screens */
@media (max-height: 750px) {
    .glass-panel { margin: auto !important; }
    #prof-panel { margin-top: 10px !important; }
    .keyboard-container { transform: scale(0.75); margin-bottom: -50px !important; }
    .hand-guide { transform: scale(0.6); margin-top: 25px !important; margin-bottom: -40px !important; }
    .typing-area { font-size: 1.3rem !important; max-height: 15vh !important; }
    header h1 { font-size: 1.8rem !important; }
}