/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    /* Public build: the primary colour is a clinical teal rather than the heart-red used in
       the private build, so the header does not read as AHA trade dress (heart + that red +
       resuscitation training). Property names are kept as --red* so nothing else changes. */
    --red: #0f6f6a;
    --red-dark: #0a534f;
    --red-light: #e4f2f1;
    --blue: #1a5276;
    --blue-light: #eaf2f8;
    --green: #1e8449;
    --green-light: #e8f8f0;
    --orange: #e67e22;
    --orange-light: #fef5e7;
    --purple: #6c3483;
    --purple-light: #f4ecf7;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-500: #9e9e9e;
    --gray-700: #616161;
    --gray-900: #212121;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    color: var(--gray-900);
    background: var(--gray-100);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === HEADER === */
header {
    background: var(--red);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.logo-icon {
    display: flex;
    align-items: center;
    color: white;
}
.logo-icon svg { display: block; }
.logo h1 { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.logo .subtitle { font-size: 0.75rem; opacity: 0.9; }
.logo .subtitle a, footer .colophon a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
#main-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav-btn {
    background: rgba(255,255,255,0.15);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}
.nav-btn:hover { background: rgba(255,255,255,0.3); }
.nav-btn.active { background: white; color: var(--red); font-weight: 600; }

/* === MAIN === */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}
.view { display: none; }
.view.active { display: block; }

/* === HOME === */
.hero { text-align: center; padding: 2rem 0; }
.hero h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.hero > p { color: var(--gray-700); font-size: 1.1rem; margin-bottom: 2rem; }
.hero-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}
.hero-card {
    background: white;
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}
.hero-card:hover { border-color: var(--red); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.hero-card-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.hero-card h3 { color: var(--red); margin-bottom: 0.5rem; font-size: 1.2rem; }
.hero-card p { color: var(--gray-700); font-size: 0.9rem; }

.updates-banner {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: var(--shadow);
}
.updates-banner h3 { color: var(--red); margin-bottom: 1rem; font-size: 1.3rem; }
.updates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}
.update-item {
    padding: 1rem;
    background: var(--red-light);
    border-radius: var(--radius);
    border-left: 4px solid var(--red);
}
.update-item strong { display: block; margin-bottom: 0.25rem; color: var(--red-dark); }
.update-item p { font-size: 0.85rem; color: var(--gray-700); }

/* === SUMMARIES === */
.view-header { margin-bottom: 1.5rem; }
.view-header h2 { margin-bottom: 1rem; }
.filter-bar { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.filter-btn {
    background: var(--gray-200);
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}
.filter-btn:hover { background: var(--gray-300); }
.filter-btn.active { background: var(--red); color: white; }
.summaries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.summary-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    border-left: 4px solid var(--red);
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.summary-card .card-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.summary-card h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.summary-card .card-cat { font-size: 0.75rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.05em; }
.summary-card[data-cat="bls"] { border-left-color: var(--blue); }
.summary-card[data-cat="acls"] { border-left-color: var(--red); }
.summary-card[data-cat="pals"] { border-left-color: var(--green); }
.summary-card[data-cat="neonatal"] { border-left-color: var(--purple); }
.summary-card[data-cat="post-arrest"] { border-left-color: var(--orange); }
.summary-card[data-cat="special"] { border-left-color: var(--gray-700); }

.summary-detail { animation: fadeIn 0.3s; }
.back-btn {
    background: none;
    border: 1px solid var(--gray-300);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    transition: var(--transition);
}
.back-btn:hover { background: var(--gray-200); }
#summary-content {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
#summary-content h2 { color: var(--red); margin-bottom: 1.5rem; font-size: 1.5rem; border-bottom: 2px solid var(--red); padding-bottom: 0.5rem; }
#summary-content h3 { color: var(--blue); margin: 1.5rem 0 0.75rem; font-size: 1.15rem; }
#summary-content ul { margin-left: 1.5rem; margin-bottom: 1rem; }
#summary-content li { margin-bottom: 0.4rem; line-height: 1.5; }
#summary-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
#summary-content th, #summary-content td { border: 1px solid var(--gray-300); padding: 0.5rem 0.75rem; text-align: left; }
#summary-content th { background: var(--red); color: white; font-weight: 600; }
#summary-content tr:nth-child(even) { background: var(--gray-50); }
#summary-content .alert-box {
    background: var(--orange-light);
    border: 1px solid var(--orange);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
}
#summary-content .new-2025 {
    background: var(--red-light);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
}
#summary-content .new-2025::before { content: "2025 UPDATE: "; font-weight: 700; color: var(--red); }

/* === QUIZ === */
.quiz-setup { text-align: center; max-width: 600px; margin: 0 auto; }
.quiz-setup h2 { margin-bottom: 0.5rem; }
.quiz-setup > p { color: var(--gray-700); margin-bottom: 2rem; }
.quiz-options {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
    text-align: left;
}
.option-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}
.option-group select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    background: white;
}
.btn-primary {
    background: var(--red);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: var(--radius);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-primary:hover { background: var(--red-dark); }

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    min-width: 100px;
}
.progress-fill {
    height: 100%;
    background: var(--red);
    transition: width 0.3s;
    border-radius: 4px;
}
#quiz-progress-text, #quiz-score-live {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.question-card {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
}
.question-meta { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge.cat-adult-bls, .badge.cat-pediatric-bls { background: var(--blue-light); color: var(--blue); }
.badge.cat-adult-acls-cardiac-arrest, .badge.cat-adult-acls-bradycardia, .badge.cat-adult-acls-tachycardia { background: var(--red-light); color: var(--red); }
.badge.cat-pals-cardiac-arrest, .badge.cat-pals-bradycardia, .badge.cat-pals-tachycardia { background: var(--green-light); color: var(--green); }
.badge.cat-post-cardiac-arrest { background: var(--orange-light); color: var(--orange); }
.badge.cat-neonatal { background: var(--purple-light); color: var(--purple); }
.badge.cat-special-circumstances { background: var(--gray-200); color: var(--gray-700); }
.badge.diff-basic { background: #e8f5e9; color: #2e7d32; }
.badge.diff-intermediate { background: #fff3e0; color: #ef6c00; }
.badge.diff-advanced { background: #fce4ec; color: #c62828; }

.question-card h3 { font-size: 1.1rem; margin-bottom: 1.5rem; line-height: 1.5; }
.options-list { display: grid; gap: 0.5rem; }
.option-btn {
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    transition: var(--transition);
    line-height: 1.4;
}
.option-btn:hover { border-color: var(--blue); background: var(--blue-light); }
.option-btn.correct { border-color: var(--green); background: var(--green-light); font-weight: 600; }
.option-btn.incorrect { border-color: #c62828; background: #fce4ec; }
.option-btn.disabled { pointer-events: none; opacity: 0.7; }
.option-btn.correct.disabled, .option-btn.incorrect.disabled { opacity: 1; }

.explanation {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--blue-light);
    border-radius: var(--radius);
    border-left: 4px solid var(--blue);
    line-height: 1.6;
    font-size: 0.95rem;
    animation: fadeIn 0.3s;
}
.explanation strong { color: var(--blue); }

.quiz-results { text-align: center; max-width: 600px; margin: 0 auto; }
.results-score {
    font-size: 3rem;
    font-weight: 700;
    margin: 1.5rem 0;
}
.results-score.excellent { color: var(--green); }
.results-score.good { color: var(--blue); }
.results-score.needs-work { color: var(--orange); }
.results-score.poor { color: var(--red); }
.results-breakdown {
    text-align: left;
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow);
}
.results-breakdown h3 { margin-bottom: 1rem; }
.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
}

/* === CODE SIMULATOR === */
.mega-scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.scenario-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    border-top: 4px solid var(--red);
}
.scenario-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.scenario-card.pediatric { border-top-color: var(--green); }
.scenario-card.special { border-top-color: var(--purple); }
.scenario-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.scenario-card .scenario-meta { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 0.5rem; }
.scenario-card .scenario-path {
    font-size: 0.8rem;
    background: var(--gray-100);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    display: inline-block;
    font-family: monospace;
}

.mega-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.mega-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gray-900);
    color: #4caf50;
    padding: 0.4rem 1rem;
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
}
.timer-label { font-size: 0.75rem; color: var(--gray-500); }
.timer-value { font-size: 1.2rem; font-weight: 700; }

.mega-body {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1rem;
}
.mega-monitor {
    background: #1a1a2e;
    color: #00ff88;
    border-radius: var(--radius);
    padding: 1rem;
    font-family: 'Courier New', monospace;
    position: sticky;
    top: 80px;
    align-self: start;
}
.mega-monitor h4 { color: #ffab40; font-size: 0.85rem; margin-bottom: 0.75rem; text-transform: uppercase; }
.vitals-panel { display: grid; gap: 0.5rem; }
.vital {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.vital label { color: #888; font-size: 0.8rem; }
.vital span { font-weight: 700; font-size: 1rem; }
.vital-bp span { color: #ff5252; }
.vital-spo2 span { color: #42a5f5; }
.vital-rhythm span { color: #ffab40; font-size: 0.85rem; }
.vital-etco2 span { color: #ce93d8; }

.mega-scene {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.phase-info { margin-bottom: 1rem; }
.phase-info h3 { color: var(--red); margin-bottom: 0.5rem; }
.phase-info p { color: var(--gray-700); line-height: 1.6; }
.phase-prompt {
    font-weight: 600;
    font-size: 1.05rem;
    margin: 1rem 0;
    color: var(--blue);
}
.phase-options { display: grid; gap: 0.5rem; }
.phase-option-btn {
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    transition: var(--transition);
    line-height: 1.4;
}
.phase-option-btn:hover { border-color: var(--red); background: var(--red-light); }
.phase-option-btn.correct { border-color: var(--green); background: var(--green-light); }
.phase-option-btn.incorrect { border-color: #c62828; background: #fce4ec; }
.phase-option-btn.disabled { pointer-events: none; }

.phase-feedback {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius);
    line-height: 1.6;
    animation: fadeIn 0.3s;
}
.phase-feedback.correct-fb { background: var(--green-light); border-left: 4px solid var(--green); }
.phase-feedback.incorrect-fb { background: #fce4ec; border-left: 4px solid #c62828; }

.phase-actions {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    animation: fadeIn 0.3s;
}
.phase-actions h4 { margin-bottom: 0.5rem; color: var(--gray-700); }
.phase-actions li { margin-left: 1.5rem; padding: 0.2rem 0; font-size: 0.9rem; }

.mega-debrief {
    max-width: 800px;
    margin: 0 auto;
}
.mega-debrief h2 { margin-bottom: 1rem; }
#debrief-content {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    line-height: 1.7;
}
#debrief-content h3 { color: var(--red); margin: 1.5rem 0 0.5rem; }
#debrief-content .debrief-score {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 1rem;
}
#debrief-content .debrief-algorithms {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
#debrief-content .algo-tag {
    background: var(--red-light);
    color: var(--red);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* === FOOTER === */
footer {
    padding: 1.5rem;
    color: var(--gray-700);
    font-size: 0.8rem;
    border-top: 1px solid var(--gray-200);
    margin-top: 2rem;
    background: var(--gray-50);
}
footer .disclaimer {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border: 1px solid var(--gray-300);
    border-left: 4px solid var(--gray-500);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
footer .disclaimer p { line-height: 1.6; }
footer .disclaimer p + p { margin-top: 0.6rem; }
footer .colophon {
    text-align: center;
    color: var(--gray-500);
    margin-top: 1rem;
}

/* === UTILITIES === */
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .header-inner { flex-direction: column; text-align: center; }
    .hero h2 { font-size: 1.5rem; }
    .mega-body { grid-template-columns: 1fr; }
    .mega-monitor { position: static; }
    .question-card { padding: 1.25rem; }
}

/* --- study progress + missed-question review (added for exam prep) --- */
.study-stats { margin: 0.75rem 0 1rem; font-size: 0.92rem; line-height: 1.5; }
.study-stats .st-ok { color: #1e8449; font-weight: 600; }
.study-stats .st-miss { color: #c8102e; font-weight: 600; }
.link-btn { background: none; border: 0; padding: 0; margin-left: 0.4rem; color: #616161; text-decoration: underline; cursor: pointer; font: inherit; font-size: 0.85rem; }
.results-missed { margin: 1.5rem 0; text-align: left; }
.results-missed h3 { margin-bottom: 0.75rem; }
.missed-item { border-left: 4px solid #c8102e; background: rgba(200, 16, 46, 0.05); padding: 0.75rem 1rem; margin-bottom: 0.9rem; border-radius: 4px; }
.missed-q { font-weight: 600; margin: 0 0 0.4rem; }
.missed-yours { color: #c8102e; margin: 0.2rem 0; }
.missed-right { color: #1e8449; font-weight: 600; margin: 0.2rem 0; }
.missed-why { margin: 0.5rem 0 0; font-size: 0.92rem; line-height: 1.5; }
