/* =====================================================================
   SterileGenius — CRCST Training Website
   Stylesheet: responsive, mobile-first, accessible
   ===================================================================== */

:root {
    --teal:       #0d7c66;
    --teal-dark:  #095c4b;
    --teal-light: #14a085;
    --mint:       #e6f6f1;
    --amber:      #f5a524;
    --coral:      #ef4444;
    --green:      #16a34a;
    --ink:        #16302b;
    --slate:      #5b6b66;
    --bg:         #f7faf9;
    --card:       #ffffff;
    --border:     #d9e6e1;
    --shadow:     0 4px 18px rgba(13, 124, 102, 0.08);
    --shadow-lg:  0 12px 38px rgba(13, 124, 102, 0.14);
    --radius:     16px;
    --radius-sm:  10px;
    --maxw:       1140px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.6;
    font-size: 17px;
}

h1, h2, h3, h4, .brand-text {
    font-family: 'Poppins', 'Nunito', sans-serif;
    line-height: 1.2;
    color: var(--ink);
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 820px; }

.skip-link {
    position: absolute; left: -9999px; top: 0; background: var(--teal); color: #fff;
    padding: 10px 16px; z-index: 999; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ----------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px;
    padding: 12px 22px; border-radius: 999px; border: 2px solid transparent;
    cursor: pointer; transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
    text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--teal); border-color: var(--teal); }
.btn-outline:hover { background: var(--mint); color: var(--teal-dark); }
.btn-light { background: #fff; color: var(--teal-dark); }
.btn-light:hover { background: #f0fdf9; color: var(--teal-dark); }
.btn-lg { font-size: 18px; padding: 15px 30px; }
.btn-sm { font-size: 14px; padding: 8px 16px; }
.btn-block { width: 100%; }

/* ----------------------------------------------------------------- Header */
.site-header {
    background: #fff; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100; box-shadow: 0 1px 8px rgba(0,0,0,.03);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 66px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 26px; }
.brand-text { font-size: 22px; color: var(--teal); }
.site-nav { display: flex; align-items: center; gap: 22px; }
.site-nav a { font-weight: 600; color: var(--ink); }
.site-nav a.active { color: var(--teal); }
.nav-user { color: var(--slate); font-size: 14px; }
.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { width: 26px; height: 3px; background: var(--teal); border-radius: 3px; transition: .25s; }
.nav-toggle.open span:nth-child(1){ transform: translateY(8px) rotate(45deg); }
.nav-toggle.open span:nth-child(2){ opacity: 0; }
.nav-toggle.open span:nth-child(3){ transform: translateY(-8px) rotate(-45deg); }

/* ----------------------------------------------------------------- Hero */
.hero { background: linear-gradient(160deg, var(--mint) 0%, #fff 70%); padding: 64px 0 72px; overflow: hidden; }
.hero-inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
.badge {
    display: inline-block; background: #fff; color: var(--teal-dark);
    border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px;
    font-size: 13px; font-weight: 700; margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); margin: 0 0 16px; }
.hero h1 .hl { color: var(--teal); }
.lead { font-size: 1.18rem; color: var(--slate); margin: 0 0 26px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 26px; list-style: none; padding: 0; margin: 34px 0 0; flex-wrap: wrap; }
.hero-stats li { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 1.8rem; color: var(--teal); font-family: 'Poppins'; }
.hero-stats span { font-size: 13px; color: var(--slate); text-transform: uppercase; letter-spacing: .5px; }

.hero-art { position: relative; min-height: 320px; }
.art-card {
    position: absolute; background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px; font-weight: 700;
    box-shadow: var(--shadow-lg); font-size: 15px;
}
.art-1 { top: 10px; left: 0; }
.art-2 { top: 90px; right: 10px; }
.art-3 { top: 180px; left: 30px; }
.art-4 { top: 250px; right: 0; background: var(--teal); color: #fff; border-color: var(--teal); }

/* ----------------------------------------------------------------- Sections */
.section { padding: 60px 0; }
.section-alt { background: var(--mint); }
.section-title { font-size: clamp(1.6rem, 3vw, 2.2rem); text-align: center; margin: 0 0 8px; }
.section-sub { text-align: center; color: var(--slate); max-width: 640px; margin: 0 auto 36px; }

/* Topic cards */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 20px; }
.topic-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 26px 22px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
    display: flex; flex-direction: column; color: var(--ink);
}
.topic-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); text-decoration: none; }
.topic-icon { font-size: 34px; }
.topic-card h3 { margin: 12px 0 8px; font-size: 1.2rem; }
.topic-card p { color: var(--slate); font-size: 15px; margin: 0 0 16px; flex: 1; }
.topic-meta { font-size: 13px; font-weight: 700; color: var(--teal); }

/* Features */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 22px; }
.feature { background: #fff; border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.feature span { font-size: 34px; }
.feature h3 { margin: 12px 0 8px; font-size: 1.15rem; }
.feature p { color: var(--slate); margin: 0; font-size: 15px; }

/* CTA band */
.cta-band { background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%); color: #fff; text-align: center; }
.cta-band h2 { color: #fff; font-size: 2rem; margin: 0 0 10px; }
.cta-band p { font-size: 1.1rem; opacity: .95; margin: 0 0 24px; }

/* ----------------------------------------------------------------- Auth */
.auth-wrap { padding: 60px 0; min-height: 60vh; display: flex; align-items: center; }
.auth-card {
    max-width: 460px; margin: 0 auto; background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 38px 32px; box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 1.7rem; margin: 0 0 6px; }
.auth-sub { color: var(--slate); margin: 0 0 22px; }
.auth-card label { display: block; font-weight: 700; margin: 14px 0 6px; font-size: 14px; }
.auth-card input {
    width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 16px; font-family: inherit; transition: border .15s;
}
.auth-card input:focus { outline: none; border-color: var(--teal); }
.auth-card .btn { margin-top: 22px; }
.auth-alt { text-align: center; margin: 18px 0 0; color: var(--slate); }
.req { color: var(--coral); }
.muted { color: var(--slate); }

/* Alerts */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 15px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ----------------------------------------------------------------- Quizzes list */
.topic-block { margin-bottom: 46px; }
.topic-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.topic-icon-lg { font-size: 42px; }
.topic-head h2 { margin: 0; }
.topic-head p { margin: 2px 0 0; }
.quiz-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 20px; }
.quiz-card {
    background: #fff; border: 1px solid var(--border); border-top: 5px solid var(--slate);
    border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
    display: flex; flex-direction: column;
}
.quiz-card.diff-beginner { border-top-color: var(--green); }
.quiz-card.diff-intermediate { border-top-color: var(--amber); }
.quiz-card.diff-advanced { border-top-color: var(--coral); }
.quiz-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.quiz-card h3 { margin: 0 0 8px; font-size: 1.15rem; }
.quiz-card p { flex: 1; margin: 0 0 14px; font-size: 14px; }
.quiz-meta { font-size: 13px; color: var(--slate); margin-bottom: 14px; font-weight: 700; }
.diff-pill { font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; color: #fff; }
.diff-pill.diff-beginner { background: var(--green); }
.diff-pill.diff-intermediate { background: var(--amber); }
.diff-pill.diff-advanced { background: var(--coral); }
.best-badge { font-size: 13px; font-weight: 800; color: var(--amber); }

/* ----------------------------------------------------------------- Quiz runner */
.back-link { display: inline-block; margin-bottom: 18px; font-weight: 700; }
.quiz-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.quiz-header h1 { margin: 0; font-size: 1.6rem; }
.quiz-progress-bar { height: 10px; background: var(--mint); border-radius: 999px; overflow: hidden; }
.quiz-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal-light), var(--teal)); transition: width .35s ease; }
.quiz-meta-row { display: flex; justify-content: space-between; margin: 12px 0 22px; font-weight: 700; color: var(--slate); }
.timer { font-variant-numeric: tabular-nums; }

.q-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.q-text { font-size: 1.25rem; font-weight: 700; font-family: 'Poppins'; margin: 0 0 22px; }
.q-options { display: flex; flex-direction: column; gap: 12px; }
.q-option {
    display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
    background: #fff; border: 2px solid var(--border); border-radius: var(--radius-sm);
    padding: 14px 16px; cursor: pointer; font-size: 16px; font-family: inherit;
    transition: border .15s, background .15s, transform .1s;
}
.q-option:hover:not(:disabled) { border-color: var(--teal); background: var(--mint); transform: translateX(3px); }
.q-option:disabled { cursor: default; }
.q-opt-label {
    flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--mint);
    color: var(--teal-dark); font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.q-option.is-correct { border-color: var(--green); background: #f0fdf4; }
.q-option.is-correct .q-opt-label { background: var(--green); color: #fff; }
.q-option.is-wrong { border-color: var(--coral); background: #fef2f2; }
.q-option.is-wrong .q-opt-label { background: var(--coral); color: #fff; }

.q-feedback { margin-top: 20px; padding: 18px 20px; border-radius: var(--radius-sm); font-size: 15.5px; }
.q-feedback.fb-ok { background: #f0fdf4; border: 1px solid #bbf7d0; }
.q-feedback.fb-no { background: #fffbeb; border: 1px solid #fde68a; }
.q-feedback p { margin: 8px 0 0; }
.fb-correct { font-weight: 800; color: var(--green); font-size: 1.05rem; }
.fb-wrong { font-weight: 800; color: #b45309; font-size: 1.05rem; }
.fb-tool { background: #fff; border-left: 4px solid var(--teal); padding: 10px 14px; border-radius: 8px; }
.q-nav { margin-top: 22px; text-align: right; }

.finish-card { text-align: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 50px 30px; box-shadow: var(--shadow); }
.finish-emoji { font-size: 60px; }
.spinner { width: 38px; height: 38px; border: 4px solid var(--mint); border-top-color: var(--teal); border-radius: 50%; margin: 20px auto 0; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- Result page */
.result-hero { display: flex; align-items: center; gap: 34px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 34px; box-shadow: var(--shadow-lg); margin-bottom: 36px; flex-wrap: wrap; }
.score-ring {
    --pct: 0; flex: none; width: 140px; height: 140px; border-radius: 50%;
    background: conic-gradient(var(--teal) calc(var(--pct) * 1%), var(--mint) 0);
    display: flex; align-items: center; justify-content: center; position: relative;
}
.score-ring::before { content: ''; position: absolute; inset: 12px; background: #fff; border-radius: 50%; }
.score-ring.sm { width: 96px; height: 96px; }
.score-num { position: relative; font-family: 'Poppins'; font-weight: 800; font-size: 1.9rem; color: var(--teal-dark); }
.score-ring.sm .score-num { font-size: 1.3rem; }
.result-hero-copy { flex: 1; min-width: 260px; }
.result-emoji { font-size: 38px; }
.result-hero-copy h1 { font-size: 1.6rem; margin: 6px 0 6px; }
.result-stats { list-style: none; display: flex; gap: 26px; padding: 0; margin: 16px 0 20px; flex-wrap: wrap; }
.result-stats strong { display: block; font-size: 1.4rem; color: var(--teal); font-family: 'Poppins'; }
.result-stats span { font-size: 13px; color: var(--slate); }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.result-actions.center { justify-content: center; margin-top: 36px; }
.review-title { margin: 10px 0 2px; }

.review-card { background: #fff; border: 1px solid var(--border); border-left: 6px solid var(--slate); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow); }
.review-card.rc-correct { border-left-color: var(--green); }
.review-card.rc-wrong { border-left-color: var(--coral); }
.review-q { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.review-num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.review-q p { flex: 1; min-width: 220px; font-weight: 700; margin: 0; }
.review-flag { font-weight: 800; font-size: 14px; }
.rc-correct .review-flag { color: var(--green); }
.rc-wrong .review-flag { color: var(--coral); }
.review-options { list-style: none; padding: 0; margin: 16px 0; }
.review-options li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); margin-bottom: 8px; font-size: 15px; flex-wrap: wrap; }
.review-options .opt-label { font-weight: 800; }
.review-options .opt-correct { background: #f0fdf4; border-color: var(--green); }
.review-options .opt-wrong { background: #fef2f2; border-color: var(--coral); }
.opt-tag { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--green); }
.opt-tag-you { color: var(--slate); }
.opt-skipped { color: var(--slate); }
.review-explain { background: var(--mint); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 15px; }
.review-tool { background: #fff7ed; border-left: 4px solid var(--amber); border-radius: 8px; padding: 12px 16px; font-size: 15px; margin-top: 10px; }

/* ----------------------------------------------------------------- Dashboard */
.dash-head { margin-bottom: 26px; }
.dash-head h1 { font-size: 1.9rem; margin: 0 0 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 18px; margin-bottom: 40px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.stat-card .stat-icon { font-size: 28px; }
.stat-card strong { font-size: 1.7rem; font-family: 'Poppins'; color: var(--teal); }
.stat-primary { grid-column: span 2; flex-direction: row; align-items: center; gap: 18px; background: linear-gradient(135deg,#fff, var(--mint)); }
.stat-primary h3 { margin: 0 0 4px; }
.dash-section-title { margin: 10px 0 18px; font-size: 1.4rem; }
.best-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 18px; margin-bottom: 40px; }
.best-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.best-card-head { display: flex; justify-content: space-between; align-items: center; }
.best-card h3 { margin: 12px 0 2px; font-size: 1.05rem; }
.best-card p { margin: 0 0 12px; font-size: 13px; }
.mini-bar { height: 8px; background: var(--mint); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.mini-fill { height: 100%; background: linear-gradient(90deg,var(--teal-light),var(--teal)); }
.best-card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 14px; }
.best-pct strong { color: var(--teal); }

.empty-state { text-align: center; background: #fff; border: 1px dashed var(--border); border-radius: var(--radius); padding: 46px 20px; }
.empty-state span { font-size: 46px; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.history-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.history-table th, .history-table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 15px; }
.history-table th { background: var(--mint); font-family: 'Poppins'; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--teal-dark); }
.history-table tr:last-child td { border-bottom: none; }
.link-sm { font-weight: 700; font-size: 14px; }

/* check list */
.check-list { list-style: none; padding: 0; }
.check-list li { padding-left: 30px; position: relative; margin-bottom: 10px; }
.check-list li::before { content: '✅'; position: absolute; left: 0; }

/* ----------------------------------------------------------------- Footer */
.site-footer { background: var(--ink); color: #cfe5df; margin-top: 60px; }
.footer-inner { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.4fr; gap: 30px; padding: 50px 0; }
.footer-col h4 { color: #fff; margin: 0 0 14px; font-size: 1rem; }
.footer-col a { display: block; color: #cfe5df; margin-bottom: 8px; font-size: 14px; }
.footer-col a:hover { color: #fff; }
.footer-col .brand-text { color: #fff; }
.footer-col p { font-size: 14px; margin: 8px 0; }
.footer-col .muted { color: #8fb3aa; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding: 18px 0; }
.footer-bottom p { margin: 0; font-size: 13px; text-align: center; color: #8fb3aa; }

/* ----------------------------------------------------------------- Responsive */
@media (max-width: 860px) {
    .hero-inner { grid-template-columns: 1fr; }
    .hero-art { display: none; }
    .footer-inner { grid-template-columns: 1fr 1fr; }
    .stat-primary { grid-column: span 2; }
}
@media (max-width: 720px) {
    .nav-toggle { display: flex; }
    .site-nav {
        position: absolute; top: 66px; left: 0; right: 0; background: #fff;
        flex-direction: column; align-items: flex-start; gap: 0; padding: 0;
        border-bottom: 1px solid var(--border); max-height: 0; overflow: hidden; transition: max-height .25s ease;
    }
    .site-nav.open { max-height: 420px; padding: 8px 0 16px; }
    .site-nav a, .site-nav .btn { width: calc(100% - 40px); margin: 4px 20px; }
    .nav-user { margin: 4px 20px; }
    .result-hero { flex-direction: column; text-align: center; }
    .result-stats { justify-content: center; }
}
@media (max-width: 520px) {
    body { font-size: 16px; }
    .footer-inner { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-primary { grid-column: span 2; }
    .hero-stats { gap: 18px; }
    .q-card { padding: 20px; }
    .q-text { font-size: 1.1rem; }
    .history-table td { font-size: 14px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
