/* DNA Replication Study App — Light/Dark Theme */
:root {
    --bg: #070a0f;
    --surface: #0d1117;
    --surface-2: #151b25;
    --surface-3: #1c2333;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent-1: #3b82f6;
    --accent-2: #8b5cf6;
    --accent-3: #10b981;
    --warning: #f59e0b;
    --bond-phosphodiester: var(--accent-1);
    --bond-hydrogen: var(--warning);
    --canvas-bg: #070a0f;
    --radius: 10px;
    --radius-sm: 6px;
    --trans: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body.light {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --border: rgba(15, 23, 42, 0.1);
    --border-strong: rgba(15, 23, 42, 0.18);
    --text: #0f172a;
    --text-muted: #334155;
    --accent-1: #1d4ed8;
    --accent-2: #6d28d9;
    --accent-3: #047857;
    --warning: #b45309;
    --canvas-bg: #f8fafc;
}

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

html, body {
    width: 100%; height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

body.embedded .header {
    display: none;
}

.app { width: 100%; height: 100%; display: flex; flex-direction: column; }

/* ——— Header ——— */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0; gap: 12px;
}

.header-left { display: flex; align-items: center; gap: 10px; }

.logo-mark {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-3);
    font-size: 16px;
}

.header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
}

.header-right { display: flex; align-items: center; gap: 10px; }

/* Theme Toggle */
.theme-toggle {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text-muted); border-radius: var(--radius-sm);
    cursor: pointer; transition: var(--trans); flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-icon.moon { display: none; }
body.light .theme-icon.sun { display: none; }
body.light .theme-icon.moon { display: block; }

/* Mode Tabs */
.mode-tabs {
    display: flex; gap: 2px;
    background: var(--surface-2); padding: 3px; border-radius: var(--radius-sm);
}
.mode-tab {
    padding: 6px 14px; border: none; background: none;
    color: var(--text-muted); font-size: 12px; font-weight: 500;
    font-family: inherit; border-radius: 4px; cursor: pointer;
    transition: var(--trans); white-space: nowrap;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--accent-1); color: #fff; }

/* ——— Main Content ——— */
.main-content { flex: 1; overflow: hidden; min-height: 0; }

.explore-panel {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) 260px;
    grid-template-rows: minmax(0, 1fr) auto;
    height: 100%;
}
.explore-panel.hidden, .quiz-panel.hidden { display: none; }

/* ——— Enzyme Sidebar ——— */
.enzyme-sidebar {
    grid-column: 1; grid-row: 1 / 3;
    display: flex; flex-direction: column; gap: 3px;
    padding: 10px 8px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
}

.enzyme-sidebar h4 {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-muted);
    padding: 6px 6px 4px;
}

.enzyme-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border: 1px solid transparent;
    background: none; border-radius: var(--radius-sm);
    cursor: pointer; transition: var(--trans);
    color: var(--text); font-family: inherit; font-size: 12px;
    text-align: left;
}
.enzyme-btn:hover { background: var(--surface-2); border-color: var(--border); }
.enzyme-btn.active {
    background: var(--surface-2); border-color: var(--accent-1);
    box-shadow: 0 0 10px rgba(59,130,246,0.1);
}

.enzyme-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.enzyme-label { font-weight: 500; }

/* ——— Canvas Area ——— */
.canvas-area {
    grid-column: 2; grid-row: 1;
    position: relative;
    background: var(--canvas-bg);
    min-height: 0;
    min-width: 0;
}

#fork-canvas {
    width: 100%; height: 100%; display: block;
}

/* ——— Info Panel ——— */
.info-panel-wrap {
    grid-column: 3; grid-row: 1 / 3;
    display: flex; flex-direction: column; gap: 10px;
    padding: 12px 10px;
    border-left: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
}

.info-card {
    padding: 12px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius);
}
.info-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 16px; font-weight: 600; margin-bottom: 6px;
}
.info-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.enzyme-dot-lg { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }

.info-fn {
    font-size: 13px; font-weight: 500; line-height: 1.5;
    margin-bottom: 8px; color: var(--text);
}

.info-bond, .info-loc {
    font-size: 12px; color: var(--text-muted); line-height: 1.6; margin-bottom: 4px;
}
.info-bond strong, .info-loc strong { color: var(--text); }

.info-detail { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.info-detail strong { color: var(--text); }

.info-detail-long {
    font-size: 12px; color: var(--text-muted); line-height: 1.7;
    margin-top: 8px; padding-top: 8px;
    border-top: 1px solid var(--border);
}

.repair-badge {
    display: inline-block;
    font-size: 10px; font-weight: 600;
    padding: 2px 8px; border-radius: 4px;
    background: rgba(245, 158, 11, 0.14);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
    margin-bottom: 8px;
}

.dual-box {
    margin-top: 8px; padding: 10px;
    background: var(--surface-3); border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.dual-box h4 {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px;
}
.dual-item {
    font-size: 12px; color: var(--text); line-height: 1.6;
}

.legend-card {
    padding: 12px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius);
}
.legend-card h4 {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 8px;
}
.legend-item {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; color: var(--text-muted); padding: 2px 0;
}
.legend-dot {
    width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}

/* ——— Concept Cards Grid ——— */
.concept-area {
    grid-column: 2; grid-row: 2;
    border-top: 1px solid var(--border);
    background: var(--surface);
    overflow-x: auto;
    padding: 10px 12px;
}

.concept-grid {
    display: flex; gap: 8px;
    min-width: max-content;
}

.concept-card {
    display: flex; gap: 8px; align-items: flex-start;
    min-width: 210px; max-width: 260px;
    flex-shrink: 0;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--trans);
}
.concept-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
}

.concept-icon {
    font-size: 18px; flex-shrink: 0; line-height: 1;
}
.concept-title {
    font-size: 12px; font-weight: 600; margin-bottom: 3px; color: var(--text);
}
.concept-text {
    font-size: 11px; color: var(--text-muted); line-height: 1.55;
}

/* ——— Quiz Panel ——— */
.quiz-panel {
    display: flex; flex-direction: column; height: 100%;
}
.quiz-header {
    display: flex; align-items: center; gap: 24px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.quiz-score, .quiz-streak { display: flex; flex-direction: column; gap: 1px; }
.score-label, .streak-label {
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
}
.score-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px; font-weight: 600; color: var(--accent-3);
}
.streak-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px; font-weight: 600; color: var(--warning);
}
.reset-btn {
    margin-left: auto; padding: 5px 14px;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text-muted); font-size: 12px; font-family: inherit;
    border-radius: var(--radius-sm); cursor: pointer; transition: var(--trans);
}
.reset-btn:hover { background: var(--surface-3); color: var(--text); }

.quiz-body {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 24px;
    background: var(--canvas-bg);
}

.quiz-prompt {
    font-size: 18px; font-weight: 500; text-align: center;
    max-width: 600px; line-height: 1.6; margin-bottom: 28px;
    color: var(--text);
}

.quiz-options {
    display: flex; gap: 10px; flex-wrap: wrap;
    justify-content: center; max-width: 650px;
}

.quiz-option {
    padding: 12px 22px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text);
    font-size: 14px; font-family: inherit; font-weight: 500;
    border-radius: var(--radius); cursor: pointer;
    transition: var(--trans); min-width: 180px; text-align: center;
}
.quiz-option:hover { border-color: var(--accent-1); background: rgba(59,130,246,0.08); }
.quiz-option.correct { border-color: var(--accent-3); background: rgba(16,185,129,0.12); color: var(--accent-3); }
.quiz-option.wrong { border-color: #ef4444; background: rgba(239,68,68,0.12); color: #f87171; }
body.light .quiz-option.correct { color: var(--accent-3); }
body.light .quiz-option.wrong { color: #dc2626; }
.quiz-option.highlight-correct { border-color: var(--accent-3); background: rgba(16,185,129,0.08); }

.quiz-feedback {
    margin-top: 18px; padding: 10px 24px;
    text-align: center; font-size: 13px; font-weight: 500;
    max-width: 600px; border-radius: var(--radius-sm);
}
.quiz-feedback.hidden { display: none; }
.quiz-feedback.correct-feedback { color: var(--accent-3); background: rgba(16,185,129,0.08); }
.quiz-feedback.wrong-feedback { color: #f87171; background: rgba(239,68,68,0.08); }
body.light .quiz-feedback.correct-feedback { color: var(--accent-3); }
body.light .quiz-feedback.wrong-feedback { color: #dc2626; }

.info-bond-term--phosphodiester { color: var(--bond-phosphodiester); }
.info-bond-term--hydrogen { color: var(--bond-hydrogen); }

/* ——— Responsive ——— */
@media (max-width: 900px) {
    .explore-panel {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto auto;
    }
    .enzyme-sidebar {
        flex-direction: row; border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-x: auto; padding: 8px; grid-row: auto;
    }
    .enzyme-sidebar h4 { display: none; }
    .enzyme-btn { min-width: 80px; }
    .info-panel-wrap {
        border-left: none; border-top: 1px solid var(--border);
        max-height: 220px; grid-row: auto;
    }
    .concept-area { grid-column: auto; }
    .header { flex-wrap: wrap; gap: 8px; }
    .mode-tabs { overflow-x: auto; }
}

@media (max-width: 600px) {
    .header h1 { font-size: 13px; }
    .mode-tab { font-size: 11px; padding: 5px 9px; }
    .quiz-option { min-width: 130px; padding: 10px 14px; font-size: 13px; }
    .quiz-prompt { font-size: 15px; }
}
