/* Bio-Lab Research Quiz Styles */
:root {
    --primary-blue: #0077be;
    --secondary-blue: #4a9eff;
    --accent-green: #00d084;
    --success-green: #10b981;
    --warning-yellow: #f59e0b;
    --error-red: #ef4444;
    --dark-blue: #1e293b;
    --light-blue: #e0f2fe;
    --lab-white: #ffffff;
    --lab-gray: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --glow-color: #4a9eff;
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 20px rgba(0,0,0,0.15);
    --shadow-heavy: 0 10px 40px rgba(0,0,0,0.2);
}

/* Dark Theme Variables */
body.dark {
    --primary-blue: #3b82f6;
    --secondary-blue: #60a5fa;
    --accent-green: #34d399;
    --success-green: #10b981;
    --warning-yellow: #fbbf24;
    --error-red: #f87171;
    --dark-blue: #0f172a;
    --light-blue: #1e3a8a;
    /* Keep lab-white light for header text visibility */
    --lab-white: #f1f5f9;
    --lab-gray: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --glow-color: #60a5fa;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 70%, #334155 100%);
    color-scheme: dark;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    transition: background 0.6s ease, color 0.3s ease; /* Smooth theme transition */
}



/* Laboratory Background */
.laboratory-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

.grid-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(74, 158, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 158, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: gridPulse 4s ease-in-out infinite;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Floating Molecules Animation */
.floating-molecules {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.molecule {
    position: absolute;
    font-size: 2rem;
    opacity: 0.4;
    animation: float 20s infinite linear;
}

.molecule-1 { left: 10%; animation-delay: 0s; }
.molecule-2 { left: 20%; animation-delay: -4s; }
.molecule-3 { left: 70%; animation-delay: -8s; }
.molecule-4 { left: 80%; animation-delay: -12s; }
.molecule-5 { left: 50%; animation-delay: -16s; }

@keyframes float {
    0% { transform: translateY(100vh) rotate(0deg); }
    100% { transform: translateY(-100px) rotate(360deg); }
}

/* Header Styles */
.lab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 2rem;
}

.header-right { display: flex; align-items: center; gap: 1.5rem; }

.control-bar { display: flex; gap: .75rem; }

.music-wrapper { display:flex; align-items:center; gap:.4rem; }

#music-volume { width:70px; accent-color: var(--secondary-blue); cursor:pointer; }
@media (max-width:768px){ #music-volume{ width:60px; } }
@media (max-width:520px){ #music-volume{ width:55px; } }
body.dark #music-volume { filter: brightness(1.1); }

.icon-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background .3s, transform .25s, box-shadow .3s;
    position: relative;
}

.icon-btn:hover { background: rgba(255,255,255,0.25); transform: translateY(-2px); }
.icon-btn:active { transform: translateY(0); }
.icon-btn[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--secondary-blue) inset; }
.icon-btn:focus-visible { outline: 2px solid var(--secondary-blue); outline-offset: 2px; }

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lab-logo {
    font-size: 2.5rem;
    animation: pulse 2s infinite;
}

.lab-title {
    color: var(--lab-white);
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.lab-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
}

.status-indicators {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--lab-white);
    font-size: 0.9rem;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.lab-time {
    color: rgba(255, 255, 255, 0.7);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

/* Main Container */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
    position: relative;
}

.quiz-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow-heavy);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

body.dark .quiz-panel, body.dark .results-panel, body.dark .feedback-toast { background: rgba(30,41,59,0.9); }
body.dark .question-panel { background: linear-gradient(135deg, #1e293b, #334155); }
body.dark .option-button { background: #1e293b; }
body.dark .option-button:hover { background: #24324b; }
body.dark .results-stats { background: #1e293b; }
body.dark .lab-header { background: rgba(30,41,59,0.6); }
body.dark .feedback-toast { border-left-color: var(--secondary-blue); }

.quiz-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-blue), var(--secondary-blue), var(--accent-green));
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Experiment Header */
.experiment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.experiment-info h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.specimen-id {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.specimen-code {
    color: var(--primary-blue);
    font-weight: 500;
}

.lab-score {
    text-align: right;
    background: linear-gradient(120deg, var(--primary-blue), var(--secondary-blue));
    color: white;
    padding: .75rem 1rem;
    border-radius: 10px;
    box-shadow: var(--shadow-medium);
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    position: relative;
}

.lab-score .score-meta { font-size: .65rem; opacity: .85; letter-spacing: .5px; margin-top: .25rem; font-family: 'JetBrains Mono', monospace; }

.score-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.score-value {
        font-size: 1.65rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

/* Compact horizontal pill on narrow screens */
@media (max-width: 768px) {
    .lab-score { flex-direction: row; align-items: center; justify-content: space-between; padding: .55rem .75rem; min-width: unset; border-radius: 12px; }
    .score-label { margin-bottom: 0; font-size: .7rem; order: 2; }
    .score-value { font-size: 1.4rem; line-height: 1; }
    .lab-score .score-meta { display: none; }
}

/* Progress Bar */
.progress-container {
    margin-bottom: 2.5rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.progress-track {
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--secondary-blue));
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    min-width: 0;
}

.progress-glow {
    position: absolute;
    top: 0;
    right: -10px;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: progressGlow 2s infinite;
}

@keyframes progressGlow {
    0% { opacity: 0; transform: translateX(-20px); }
    50% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(20px); }
}

/* Question Panel */
.question-panel {
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    position: relative;
}

.question-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.question-icon {
    font-size: 1.5rem;
    width: 48px;
    height: 48px;
    background: var(--primary-blue);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-medium);
}

.question-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.question-number {
    font-weight: 600;
    color: var(--primary-blue);
    font-size: 1rem;
}

.question-category {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.question-text {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--text-primary);
    font-weight: 500;
}

/* Options Grid */
.options-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

.option-button {
    background: var(--lab-white);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-size: 1rem;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.option-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(74, 158, 255, 0.1), transparent);
    transition: left 0.5s;
}

.option-button:hover {
    border-color: var(--secondary-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.option-button:hover::before {
    left: 100%;
}

.option-letter {
    width: 32px;
    height: 32px;
    background: var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.option-button:hover .option-letter {
    background: var(--secondary-blue);
    color: white;
}

.option-text {
    flex: 1;
}

/* Button States */
.option-button.correct {
    border-color: var(--success-green);
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    animation: correctPulse 0.6s ease-out;
}

.option-button.correct .option-letter {
    background: var(--success-green);
    color: white;
}

.option-button.incorrect {
    border-color: var(--error-red);
    background: linear-gradient(135deg, #fef2f2, #fecaca);
    animation: incorrectShake 0.6s ease-out;
}

.option-button.incorrect .option-letter {
    background: var(--error-red);
    color: white;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Results Panel */
.results-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: var(--shadow-heavy);
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
}

.results-animation {
    animation: resultsAppear 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes resultsAppear {
    0% { opacity: 0; transform: translateY(30px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.results-title {
    color: var(--text-primary);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
    padding: 2rem;
    background: var(--lab-gray);
    border-radius: 16px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-blue);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.final-message {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 1.5rem 0;
    line-height: 1.6;
}

/* Lab Button */
.lab-button {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: var(--shadow-medium);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 200px;
    justify-content: center;
}

.lab-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
}

.lab-button:active {
    transform: translateY(0);
}

.button-icon {
    font-size: 1.1rem;
}

/* Feedback Toast */
.feedback-toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-heavy);
    transform: translateX(400px);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1000;
    border-left: 4px solid var(--primary-blue);
}

.feedback-toast.show {
    transform: translateX(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-message {
    font-weight: 500;
    color: var(--text-primary);
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .lab-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .quiz-container {
        padding: 0 1rem 2rem;
    }
    
    .quiz-panel {
        padding: 2rem 1.5rem;
    }
    
    .experiment-header {
        flex-direction: column;
        gap: 1rem;
    }
    /* Center score card on mobile */
    .lab-score { align-self: center; text-align: center; margin: 0 auto; }
    .lab-score .score-label { order: initial; }
    
    .lab-title {
        font-size: 1.5rem;
    }
    
    .results-stats {
        grid-template-columns: 1fr;
    }
    
    .options-grid {
        gap: 0.75rem;
    }
    
    .option-button {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .question-text {
        font-size: 1.1rem;
    }
    
    .results-title {
        font-size: 2rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
}

/* Visually Hidden for a11y */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

/* Theme transition helpers */
* { transition: background-color .4s ease, border-color .4s ease, color .35s ease; }
body.dark .option-button.correct { background: linear-gradient(135deg,#064e3b,#065f46); }
body.dark .option-button.incorrect { background: linear-gradient(135deg,#4c0519,#7f1d1d); }
body.dark .option-letter { background: #334155; color: var(--text-secondary); }
body.dark .option-button:hover .option-letter { background: var(--secondary-blue); color: #fff; }

/* Mobile control bar reposition */
@media (max-width: 768px) {
    .control-bar { order: -1; }
    .header-right { flex-direction: column; align-items: center; }
    .icon-btn { width: 44px; height: 44px; }
}

@media (max-width: 520px) {
    .lab-header { padding: 1.25rem 1rem; }
    .quiz-panel { padding: 1.75rem 1.25rem; }
    .option-button { font-size: .95rem; }
    .icon-btn { font-size: 1.1rem; }
}

/* Ultra-compact adjustments for very small screens */
@media (max-width: 520px) {
    .quiz-panel { padding: 1.25rem 1rem; }
    .experiment-header { margin-bottom: 1rem; padding-bottom: .75rem; }
    .progress-container { margin-bottom: 1.1rem; }
    .question-panel { margin-bottom: 1.1rem; padding: 1.1rem .9rem; }
    .options-grid { gap: .6rem; }
    .option-button { padding: .85rem .9rem; min-height: 52px; }
    .lab-header { margin-bottom: 1rem; }
    .results-panel { padding: 2rem 1.1rem; }
    .results-title { margin-bottom: 1.25rem; }
    .results-stats { margin: 1.25rem 0; padding: 1.25rem; gap: 1rem; }
}

@media (max-width: 400px) {
    .lab-title { font-size: 1.25rem; }
    .lab-subtitle { font-size: .75rem; }
    .question-text { font-size: 1rem; }
    .score-value { font-size: 1.6rem; }
    .option-button { font-size: .9rem; }
}