@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap');

:root {
    /* Main Branding Color (Your Logo Color) */
    --primary: #243551;        
    
    /* A very soft version of your logo color for backgrounds */
    --primary-soft: #f0f4f9;   
    
    /* Backgrounds: Using a cleaner, cooler gray */
    --bg-main: #f8fafc;        
    --bg-card: #ffffff;        
    --glass-bg: rgba(255, 255, 255, 0.92);
    
    /* Typography: Using your logo color for main text for better harmony */
    --text-main: #1e293b;      
    --text-muted: #64748b;    
    
    /* Borders: Subtle slate */
    --border: #e2e8f0;         
    
    /* Functional Colors */
    --success: #059669;        
    --danger: #dc2626;         
    --reference: #243551;      
    
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); 
    --page-padding: 1.25rem; 
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #0f172a;    
        --bg-card: #1e293b;    
        --glass-bg: rgba(30, 41, 59, 0.95);
        --text-main: #f8fafc;  
        --text-muted: #94a3b8; 
        --border: #334155;     
        --primary: #38bdf8; /* This is your sky blue */
        --primary-soft: rgba(56, 189, 248, 0.1); 
        --reference: #94a3b8;  
    }

    /* Target the button by ID to ensure it hits both 'Begin' and 'New Session' */
    #actionBtn {
        background-color: var(--primary);
        color: #0f172a; /* Dark text on light blue looks very sharp */
    }

    /* The "Mirror" Hover: Shifting from sky blue to a deeper ocean blue */
    #actionBtn:hover {
        background-color: #0ea5e9 !important; /* Forces the color change */
        color: #ffffff !important; /* Flips text to white for high contrast */
    }
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 0 var(--page-padding); 
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden; 
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: transform 0.1s ease;
}

button:active {
    transform: scale(0.98);
}

.kbd-hint {
    opacity: 0.6;
    font-size: 0.85em;
    font-weight: 400;
    margin-left: 4px;
    transition: opacity 0.5s ease;
}

/* Dim hints when the user is idle */
body.keyboard-idle .kbd-hint {
    opacity: 0.15;
}

@media (max-width: 600px) {
    .kbd-hint { display: none; }
}

/* --- Navigation & Branding --- */
.top-nav {
    width: 100%;
    max-width: 800px;
    padding: 1.5rem 0 0.5rem 0;
    display: flex;
    justify-content: flex-start;
    background: transparent;
}

.back-link {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.back-link:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
    transform: translateX(-3px);
}

.branding {
    width: 100%;
    padding: 40px 0;
    min-height: 80px; 
    text-align: center; 
}

#site-logo {
    display: block;    
    margin: 0 auto;    
    height: 300px;      
    width: auto;       
}

/* --- Menu Overlay --- */
#menu {
    position: fixed;
    inset: 0;
    top: 0; 
    background: var(--bg-main);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: flex-start; 
    overflow-y: auto;
    padding: 2rem var(--page-padding) 0 var(--page-padding);
}

.menu-content {
    max-width: 760px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    padding-bottom: 120px; 
    min-height: 100%;
}

.settings-group {
    background: var(--bg-card);
    padding: 0.8rem 1.2rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    display: inline-flex;
    align-self: center;
    align-items: center;
    gap: 15px;
    overflow: visible; 
}

.settings-group span {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.toggle-btn {
    background: transparent !important;
    color: var(--text-muted) !important;
    padding: 8px 16px !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    position: relative;
    box-sizing: border-box;
}

.toggle-btn.active {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: var(--shadow-sm) !important;
}

#category-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    width: 100%;
    margin-bottom: 20px;
}

#category-list button {
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    font-weight: 600;
    min-height: 60px;
}

/* --- Quiz Header --- */
header {
    background: var(--glass-bg); 
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky; 
    top: 0; 
    width: 100vw; 
    margin-left: calc(50% - 50vw); 
    z-index: 100;
    display: flex;
    justify-content: center;
}

.header-content {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    padding: 0 4rem; 
    box-sizing: border-box;
}

.progress-bar-bg {
    flex-grow: 1;
    height: 10px;
    background: var(--border);
    border-radius: 100px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.4s ease;
}

#quitBtn {
    background: var(--bg-card);
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* --- Feed --- */
#feed {
    width: 90%;
    max-width: 800px;
    margin-top: 1rem; 
    padding-bottom: 250px;
}

#feed .entry:last-child {
    margin-bottom: 5rem;
}

.entry {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 24px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(15px);
    scroll-margin-top: 100px; 
}

.entry.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.question {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
}

.answer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border);
    color: var(--text-muted);
    text-align: center;
}

.reference {
    margin-top: 0.8rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--reference);
}

/* --- Fixed Footer Controls --- */
.controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 1.5rem 0 calc(40px + env(safe-area-inset-bottom));
    z-index: 150;
    display: flex;
    justify-content: center;
}

.controls-inner {
    width: 100%;
    max-width: 800px;
    display: flex;
    gap: 20px;
    padding: 0 var(--page-padding);
}

#actionBtn {
    width: 100%;
    background: var(--primary);
    color: white;
    padding: 18px;
    border-radius: 16px;
    font-weight: 700;
}

#actionBtn:hover {
    background-color: #1a273c;
    transition: background-color 0.2s ease;
}

.marking-row {
    display: flex;
    gap: 12px;
    margin-top: 1.5rem;
    width: 100%;
}

.marking-row button {
    flex: 1;
    color: white;
    border-radius: 16px;
    padding: 16px;
    font-weight: 700;
}

/* Summary States */
.summary-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.summary-actions div {
    color: var(--primary);
    letter-spacing: -0.02em;
}

.summary-actions button {
    max-width: 300px;
}

/* --- Mobile Breakpoints --- */
@media (max-width: 600px) {
    .header-content {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-areas: 
            "quit quit"
            "label score"
            "progress progress";
        gap: 0.8rem;
    }
    #quitBtn { grid-area: quit; justify-self: flex-end; }
    #step-label { grid-area: label; font-size: 0.85rem; font-weight: 700; }
    #score-display { grid-area: score; font-size: 0.85rem; justify-self: flex-end; font-weight: 700;}
    .progress-bar-bg { grid-area: progress; height: 8px; width: 100%; }
    .entry { padding: 1.5rem; }
    .marking-row { flex-direction: column; }
    .controls { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
}

/* Accessibility & Interaction states */
button:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px; /* Pulls outline inward to prevent overlapping neighbors */
    box-shadow: none;
    z-index: 10;
}

body.using-mouse button:focus {
    outline: none !important;
    box-shadow: none !important;
}

body.using-mouse .kbd-hint {
    display: none;
}
