/* =============================================
   Activity 4 – HTML5 & CSS3 Quiz
   style.css
   ============================================= */

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

:root {
    --bg:       #0f1624;
    --surface:  #161f30;
    --surface2: #1c2840;
    --border:   #243148;
    --accent:   #6c63ff;
    --accent2:  #a78bfa;
    --green:    #22c55e;
    --red:      #ef4444;
    --yellow:   #f59e0b;
    --text:     #e2e8f0;
    --muted:    #8892b0;
    --white:    #ffffff;
}

html { scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── SCREENS ── */
.screen { display: none; }
.screen.active { display: flex; }

/* ── START SCREEN ── */
#startScreen {
    min-height: 100vh;
    align-items: center; justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at top, #1a1060 0%, var(--bg) 60%);
}

.start-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    max-width: 480px; width: 100%;
    text-align: center;
    box-shadow: 0 24px 80px rgba(108,99,255,0.15);
}

.start-icon { font-size: 4rem; margin-bottom: 16px; }

.start-card h1 {
    font-size: 1.9rem; font-weight: 900;
    color: var(--white); margin-bottom: 12px;
}
.start-card p {
    font-size: 0.92rem; color: var(--muted);
    line-height: 1.7; margin-bottom: 24px;
}
.start-card p strong { color: var(--accent2); }

.start-rules {
    list-style: none;
    background: var(--surface2); border-radius: 12px;
    padding: 16px 20px; margin-bottom: 28px;
    text-align: left; display: flex; flex-direction: column; gap: 10px;
}
.start-rules li { font-size: 0.85rem; color: var(--text); }

.start-rules li.warn {
    color: var(--yellow);
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: 8px;
    padding: 8px 10px;
}

.btn-start {
    width: 100%; padding: 14px;
    background: var(--accent); color: #fff;
    border: none; border-radius: 10px;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 6px 24px rgba(108,99,255,0.35);
    margin-bottom: 16px;
}
.btn-start:hover { background: #5a52e0; transform: translateY(-2px); }

.back-link {
    display: block; font-size: 0.8rem; color: var(--muted);
    text-decoration: none; transition: color 0.2s;
}
.back-link:hover { color: var(--accent2); }

/* ── QUIZ SCREEN ── */
#quizScreen {
    min-height: 100vh;
    flex-direction: column;
    background: var(--bg);
}

.quiz-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}

.q-back {
    font-size: 0.78rem; color: var(--muted);
    text-decoration: none; transition: color 0.2s;
    flex-shrink: 0;
}
.q-back:hover { color: var(--accent2); }

#qCounter {
    font-size: 0.82rem; color: var(--muted); font-weight: 600;
    white-space: nowrap;
}

.q-score-live {
    font-size: 0.82rem; color: var(--muted); font-weight: 600;
    flex-shrink: 0;
}
.q-score-live span { color: var(--accent2); font-weight: 800; }

/* Progress bar */
.progress-bar {
    height: 4px; background: var(--border); width: 100%;
}
#progressFill {
    height: 100%; background: var(--accent);
    width: 0; transition: width 0.4s ease;
    border-radius: 0 2px 2px 0;
}

/* Question area */
.quiz-main {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 40px 24px;
}

.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px 40px;
    max-width: 760px; width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: cardIn 0.35s ease;
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.q-category {
    font-size: 0.7rem; color: #a78bfa;
    text-transform: uppercase; letter-spacing: 1.5px;
    font-weight: 700; margin-bottom: 12px;
}

.q-text {
    font-size: 1.15rem; font-weight: 700; color: #ffffff;
    line-height: 1.55; margin-bottom: 28px;
}

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

.option-btn {
    background: var(--surface2); border: 1.5px solid var(--border);
    border-radius: 10px; padding: 14px 18px;
    color: #e2e8f0; font-size: 0.88rem; font-weight: 500;
    text-align: left; cursor: pointer;
    display: flex; align-items: center; gap: 12px;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    line-height: 1.4;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}
.option-btn:hover:not(:disabled) {
    border-color: var(--accent2);
    background: rgba(108,99,255,0.1);
    transform: translateY(-2px);
}

.opt-letter {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--border); color: #8892b0;
    font-size: 0.72rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background 0.2s, color 0.2s;
}

.opt-text {
    color: #e2e8f0;
    font-size: 0.88rem;
    line-height: 1.4;
}

/* States */
.option-btn.correct {
    border-color: var(--green); background: rgba(34,197,94,0.12);
}
.option-btn.correct .opt-letter { background: var(--green); color: #fff; }

.option-btn.wrong {
    border-color: var(--red); background: rgba(239,68,68,0.12);
}
.option-btn.wrong .opt-letter { background: var(--red); color: #fff; }

.option-btn:disabled { cursor: default; transform: none !important; }

/* ── RESULT SCREEN ── */
#resultScreen {
    min-height: 100vh;
    align-items: center; justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at bottom, #1a1060 0%, var(--bg) 60%);
}

.result-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; padding: 48px 40px;
    max-width: 480px; width: 100%; text-align: center;
    box-shadow: 0 24px 80px rgba(108,99,255,0.15);
}

.result-icon { font-size: 3.5rem; margin-bottom: 12px; }

.result-card h2 {
    font-size: 1.6rem; font-weight: 900; color: var(--white);
    margin-bottom: 24px;
}

/* Score donut */
.score-circle {
    position: relative; width: 140px; height: 140px;
    margin: 0 auto 24px;
}
.score-circle svg { width: 140px; height: 140px; transform: rotate(-90deg); }
.sc-bg  { fill: none; stroke: var(--border); stroke-width: 10; }
.sc-fill {
    fill: none; stroke: var(--accent); stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 1.2s ease 0.3s, stroke 0.5s;
}
.score-text {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
}
#scoreFraction {
    font-size: 1.6rem; font-weight: 900; color: var(--white);
}
.score-text small { font-size: 0.7rem; color: var(--muted); }

#resultMsg {
    font-size: 0.9rem; color: var(--muted); line-height: 1.7;
    margin-bottom: 28px;
}

.result-stats {
    display: flex; justify-content: center; gap: 16px;
    margin-bottom: 32px;
}
.rs-item {
    background: var(--surface2); border-radius: 12px;
    padding: 14px 20px; min-width: 80px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    border: 1px solid var(--border);
}
.rs-item span { font-size: 1.5rem; font-weight: 900; }
.rs-item small { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; }
.rs-item.correct span { color: var(--green); }
.rs-item.wrong   span { color: var(--red); }
.rs-item.skipped span { color: var(--yellow); }

.result-actions { display: flex; gap: 12px; }

.btn-review, .btn-retry {
    flex: 1; padding: 13px;
    border: none; border-radius: 10px;
    font-size: 0.88rem; font-weight: 700; cursor: pointer;
    transition: transform 0.15s, opacity 0.2s;
}
.btn-review {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border);
}
.btn-review:hover { opacity: 0.8; transform: translateY(-1px); }
.btn-retry {
    background: var(--accent); color: #fff;
    box-shadow: 0 4px 18px rgba(108,99,255,0.3);
}
.btn-retry:hover { background: #5a52e0; transform: translateY(-1px); }

/* ── REVIEW SCREEN ── */
#reviewScreen {
    min-height: 100vh;
    flex-direction: column;
    background: var(--bg);
    padding: 40px 24px;
}

.review-wrap { max-width: 760px; width: 100%; margin: 0 auto; }

.review-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px;
}
.review-header h2 { font-size: 1.4rem; font-weight: 900; color: var(--white); }

.btn-back-result {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 16px; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; transition: border-color 0.2s;
}
.btn-back-result:hover { border-color: var(--accent2); color: var(--accent2); }

.review-item {
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: 14px; padding: 22px 24px; margin-bottom: 16px;
}
.review-item.ri-correct { border-color: rgba(34,197,94,0.4); }
.review-item.ri-wrong   { border-color: rgba(239,68,68,0.4); }
.review-item.ri-skipped { border-color: rgba(245,158,11,0.4); }

.ri-top {
    display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px;
}
.ri-num {
    font-size: 0.7rem; font-weight: 800; color: var(--muted);
    background: var(--surface2); padding: 3px 9px;
    border-radius: 20px; flex-shrink: 0; margin-top: 2px;
}
.ri-question { font-size: 0.92rem; color: var(--white); font-weight: 600; line-height: 1.5; }

.ri-answers { display: flex; flex-direction: column; gap: 8px; }
.ri-answer {
    font-size: 0.82rem; padding: 9px 14px; border-radius: 8px;
    border: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.ri-answer.correct { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.4); color: var(--green); }
.ri-answer.wrong   { background: rgba(239,68,68,0.1);  border-color: rgba(239,68,68,0.4);  color: var(--red); }
.ri-answer.skipped-info { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: var(--yellow); }

/* ── NEXT BUTTON ── */
.next-wrap {
    display: flex; justify-content: flex-end;
    margin-top: 16px;
    animation: fadeIn 0.3s ease;
}

.btn-next {
    background: var(--accent); color: #fff;
    border: none; border-radius: 8px;
    padding: 11px 26px; font-size: 0.88rem; font-weight: 700;
    cursor: pointer; letter-spacing: 0.4px;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 18px rgba(108,99,255,0.35);
}
.btn-next:hover { background: #5a52e0; transform: translateY(-2px); }

/* ── EXPLANATION BOX ── */
.explanation-box {
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: 10px;
    background: var(--surface2);
    border-left: 4px solid var(--accent);
    display: flex; align-items: flex-start; gap: 12px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

.explanation-box.exp-correct { border-left-color: var(--green); }
.explanation-box.exp-wrong   { border-left-color: var(--red); }

.exp-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 1px; }
.exp-label {
    font-size: 0.72rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: 4px;
}
.explanation-box.exp-correct .exp-label { color: var(--green); }
.explanation-box.exp-wrong   .exp-label { color: var(--red); }
.exp-text { font-size: 0.84rem; color: var(--muted); line-height: 1.65; }

.ri-explain {
    margin-top: 10px; padding: 10px 14px;
    background: rgba(108,99,255,0.08);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    font-size: 0.8rem; color: var(--muted); line-height: 1.6;
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
    .options-grid { grid-template-columns: 1fr; }
    .question-card { padding: 24px 20px; }
    .quiz-header { padding: 12px 16px; }
    .result-card { padding: 32px 20px; }
    .start-card { padding: 32px 24px; }
    .result-stats { gap: 10px; }
    .rs-item { padding: 12px 14px; min-width: 70px; }
}
