/* ============================================================
   PlumbMate — Global Stylesheet v2.0
   Font: Inter (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Accessibility helpers ── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: #1e293b;
    color: white;
    padding: 10px 20px;
    font-weight: 700;
    font-size: 0.9em;
    z-index: 9999;
    border-radius: 0 0 8px 0;
    text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ── Focus styles (WCAG 2.1 SC 2.4.7 / WCAG 2.2 SC 2.4.13) ── */
*:focus { outline: none; }
*:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
    border-radius: 4px;
}

/* ── Scroll padding — prevents focused elements hiding behind
      sticky header (70px) or fixed footer buttons (~60px)  ── */
html {
    scroll-padding-top: 90px;
    scroll-padding-bottom: 80px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.7;
    color: #1e293b;
    background-color: #f8f9fa;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

/* ── Container ── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
    background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
    color: white;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

header h1 {
    font-size: 2.4em;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 1.05em;
    opacity: 0.85;
    font-style: italic;
    font-weight: 400;
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
    background: #1e293b;
    color: #64748b;
    text-align: center;
    padding: 24px;
    margin-top: 60px;
    font-size: 0.9em;
}

/* ============================================================
   CARDS (generic)
   ============================================================ */
.card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
    padding: 28px;
    border: 1px solid #e8ecf0;
}

/* ============================================================
   INTRO SECTION
   ============================================================ */
.intro {
    background: #ffffff;
    padding: 32px;
    margin: 32px 0;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
    text-align: center;
    border: 1px solid #e8ecf0;
}

.intro h2 {
    color: #1e293b;
    margin-bottom: 12px;
    font-size: 1.6em;
    font-weight: 700;
}

.intro p {
    font-size: 1.05em;
    color: #64748b;
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================================
   HOMEPAGE — STATS BAR
   ============================================================ */
.stats-bar {
    display: flex;
    gap: 16px;
    margin: 24px 0;
    flex-wrap: wrap;
}

.stat-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 20px 24px;
    flex: 1;
    min-width: 160px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card-icon {
    font-size: 2em;
    flex-shrink: 0;
}

.stat-card-content {}

.stat-card-value {
    font-size: 1.8em;
    font-weight: 800;
    color: #1e293b;
    line-height: 1;
}

.stat-card-label {
    font-size: 0.82em;
    color: #64748b;
    font-weight: 500;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================================
   HOMEPAGE — OVERALL PROGRESS BANNER
   ============================================================ */
.overall-progress-banner {
    background: #ffffff;
    border-radius: 14px;
    padding: 24px 28px;
    margin: 0 0 28px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
    border-left: 5px solid #2563eb;
    border: 1px solid #e8ecf0;
    border-left: 5px solid #2563eb;
}

.overall-progress-banner h3 {
    color: #1e293b;
    margin-bottom: 14px;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: #64748b;
}

.overall-stats {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
}

.overall-percentage {
    font-size: 2.8em;
    font-weight: 800;
    color: #1e293b;
    line-height: 1;
    min-width: 90px;
}

.overall-percentage span {
    font-size: 0.38em;
    color: #64748b;
    font-weight: 500;
    display: block;
    margin-top: 4px;
}

.overall-bar-wrap { flex: 1; min-width: 200px; }

.overall-bar-track {
    background: #e8ecf0;
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.overall-bar-fill {
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(90deg, #2563eb, #10b981);
    transition: width 0.8s ease;
    width: 0%;
}

.overall-bar-label {
    font-size: 0.88em;
    color: #64748b;
    font-weight: 500;
}

/* ============================================================
   HOMEPAGE — UNIT CARDS GRID
   ============================================================ */
.modules {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 0 0 40px 0;
}

.module-card {
    background: #ffffff;
    padding: 24px;
    border-radius: 14px;
    text-decoration: none;
    color: #1e293b;
    transition: all 0.25s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf0;
    border-left: 4px solid #2563eb;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    border-color: #2563eb;
}

.module-card img {
    width: 75px;
    height: 75px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}

.module-card-content { flex: 1; }

.module-number {
    font-size: 1.6em;
    font-weight: 800;
    color: #2563eb;
    margin-bottom: 4px;
    line-height: 1;
}

.module-card h3 {
    color: #1e293b;
    margin-bottom: 4px;
    font-size: 1.1em;
    font-weight: 700;
}

.module-card p {
    color: #64748b;
    font-size: 0.88em;
    line-height: 1.5;
    margin-bottom: 0;
}

/* ── Completion state ── */
.module-card.completed {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 1px solid #059669;
    border-left: 4px solid #065f46;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
}

.module-card.completed .module-number {
    background: rgba(255,255,255,0.25);
    color: #fff;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
}

.module-card.completed h3,
.module-card.completed p,
.module-card.completed .unit-progress-label,
.module-card.completed .revision-progress-label {
    color: #fff !important;
}

.completion-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.25);
    color: #fff;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.78em;
    display: none;
}

.module-card.completed .completion-badge { display: block; }

/* ── Progress labels on cards ── */
.unit-progress-label,
.revision-progress-label {
    display: block;
    font-size: 0.82em;
    font-weight: 600;
}

.unit-progress-label { margin-top: 8px; }
.revision-progress-label { margin-top: 3px; }

.unit-progress-label.not-started,
.revision-progress-label.not-started { color: #64748b; }

.unit-progress-label.in-progress,
.revision-progress-label.in-progress { color: #f59e0b; }

.unit-progress-label.all-passed,
.revision-progress-label.all-passed { color: #10b981; }

/* ============================================================
   HOMEPAGE — MODULE GRID (revision hub uses this)
   ============================================================ */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 28px 0;
}

/* ============================================================
   HOMEPAGE — REVISION SECTION
   ============================================================ */
.revision-section {
    background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
    padding: 40px 0;
    margin-top: 40px;
}

.revision-card {
    background: white;
    padding: 28px 32px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: all 0.25s ease;
    text-decoration: none;
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    max-width: 800px;
    margin: 0 auto;
}

.revision-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 32px rgba(0,0,0,0.2);
}

.revision-card-content { flex: 1; text-align: left; }
.revision-card h2 { color: #1e293b; margin-bottom: 8px; font-size: 1.4em; font-weight: 700; }
.revision-card p  { color: #64748b; font-size: 1em; }

.revision-card img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}

/* ============================================================
   BACK LINK
   ============================================================ */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #2563eb;
    text-decoration: none;
    margin: 24px 0 8px 0;
    font-weight: 600;
    font-size: 0.92em;
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(37,99,235,0.07);
    transition: background 0.2s;
}

.back-link:hover {
    background: rgba(37,99,235,0.14);
    text-decoration: none;
}

/* ============================================================
   MODULE HEADER
   ============================================================ */
.module-header {
    background: #ffffff;
    padding: 28px 32px;
    margin: 16px 0 24px 0;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf0;
    border-left: 5px solid #2563eb;
}

.module-header .module-number {
    font-size: 1.4em;
    font-weight: 800;
    color: #2563eb;
    margin-bottom: 4px;
}

.module-header h2 {
    color: #1e293b;
    font-size: 1.5em;
    font-weight: 700;
    margin-bottom: 6px;
}

.module-header p {
    color: #64748b;
    font-size: 0.95em;
}

/* ── Unit page progress tracker ── */
.lesson-progress {
    margin-top: 18px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    font-size: 0.88em;
    border: 1px solid #e8ecf0;
}

.lesson-progress-item {
    display: flex;
    align-items: center;
    padding: 5px 0;
    gap: 10px;
}

.lesson-progress-item .status { font-size: 1.1em; }
.lesson-progress-item.completed .status { color: #10b981; }
.lesson-progress-item.failed .status    { color: #ef4444; }
.lesson-progress-item.incomplete .status{ color: #64748b; }

/* ============================================================
   LESSON SECTIONS (module pages)
   ============================================================ */
.lesson-section {
    background: #ffffff;
    padding: 28px 32px;
    margin: 20px 0;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf0;
}

.lesson-section h3 {
    color: #1e293b;
    margin-bottom: 18px;
    font-size: 1.25em;
    font-weight: 700;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

.lesson-section h4 {
    color: #475569;
    margin: 20px 0 12px 0;
    font-size: 1em;
    font-weight: 600;
}

/* ============================================================
   VIDEO WRAPPER
   ============================================================ */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================================
   TAKE QUIZ BUTTON (module pages)
   ============================================================ */
.take-quiz-btn {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    font-size: 1.1em;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 18px;
    transition: all 0.25s ease;
    text-decoration: none;
    text-align: center;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}

.take-quiz-btn:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.45);
    color: white;
}

/* ============================================================
   STICKY PROGRESS BAR (module pages)
   ============================================================ */
.sticky-progress {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    border-bottom: 1px solid #e8ecf0;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    font-size: 0.88em;
    font-weight: 600;
    color: #475569;
}

.sticky-progress a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.sticky-progress a:hover { text-decoration: underline; }

.sticky-progress-bar-track {
    flex: 1;
    max-width: 200px;
    background: #e8ecf0;
    border-radius: 20px;
    height: 8px;
    margin: 0 16px;
    overflow: hidden;
}

.sticky-progress-bar-fill {
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(90deg, #2563eb, #10b981);
    transition: width 0.5s ease;
}

/* ============================================================
   QUIZ PAGES
   ============================================================ */

/* 70% info box */
.quiz-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #2563eb;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 24px;
    font-size: 0.92em;
    color: #1e40af;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Question progress indicator */
.quiz-progress-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e8ecf0;
    font-size: 0.88em;
    font-weight: 600;
    color: #475569;
}

.quiz-progress-bar-track {
    flex: 1;
    max-width: 180px;
    background: #e8ecf0;
    border-radius: 20px;
    height: 6px;
    overflow: hidden;
    margin: 0 12px;
}

.quiz-progress-bar-fill {
    height: 100%;
    border-radius: 20px;
    background: #2563eb;
    transition: width 0.3s ease;
}

/* Quiz container wrapper */
.quiz-container {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 2px solid #f1f5f9;
}

.quiz-container h4 {
    color: #1e293b;
    margin-bottom: 20px;
    font-size: 1.15em;
    font-weight: 700;
}

/* Individual question cards */
.question {
    margin-bottom: 20px;
    padding: 22px 24px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e8ecf0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s;
}

.question:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.question p {
    font-weight: 600;
    margin-bottom: 16px;
    color: #1e293b;
    font-size: 1em;
    line-height: 1.6;
}

/* Answer options */
.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option {
    padding: 13px 16px;
    background: #f8f9fa;
    border: 2px solid #e8ecf0;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    font-weight: 500;
    color: #374151;
}

.option input[type="radio"] {
    margin-right: 12px;
    accent-color: #2563eb;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.option:hover {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1e40af;
}

.option.selected {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1e40af;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.option.correct {
    border-color: #10b981;
    background: #ecfdf5;
    color: #065f46;
    font-weight: 700;
}

.option.incorrect {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

/* Submit button */
.submit-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 1.05em;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 24px;
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
    letter-spacing: 0.01em;
}

.submit-btn:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.45);
}

.submit-btn:disabled {
    background: #64748b;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Quiz result */
.quiz-result {
    margin-top: 24px;
    padding: 24px;
    border-radius: 12px;
    font-weight: 600;
    text-align: center;
    display: none;
}

.quiz-result.pass {
    background: #ecfdf5;
    color: #065f46;
    border: 2px solid #10b981;
}

.quiz-result.fail {
    background: #fef2f2;
    color: #991b1b;
    border: 2px solid #ef4444;
}

.quiz-result h3 { font-size: 1.3em; margin-bottom: 8px; }

/* ============================================================
   PROGRESS TRACKING (unit pages)
   ============================================================ */
.progress-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82em;
    font-weight: 700;
    margin-top: 8px;
}

.progress-badge.pass { background: #10b981; color: white; }
.progress-badge.fail { background: #ef4444; color: white; }
.progress-badge.incomplete { background: #64748b; color: white; }

/* ============================================================
   REVISION HUB CARDS
   ============================================================ */
.module-card.completed {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 1px solid #059669;
    border-left: 4px solid #065f46;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .modules {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    header h1 { font-size: 1.8em; }

    .container { padding: 0 16px; }

    .lesson-section,
    .module-header {
        padding: 20px;
    }

    .overall-stats { flex-direction: column; gap: 16px; }

    .sticky-progress { display: none; }

    .module-card { flex-direction: column; align-items: flex-start; }
    .module-card img { width: 100%; height: 160px; border-radius: 8px; }
}

/* ============================================================
   FLAG BUTTON
   ============================================================ */
.flag-btn {
    background: none;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    color: #9ca3af;
    font-size: 1em;
    padding: 3px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    flex-shrink: 0;
}

.flag-btn:hover {
    border-color: #f59e0b;
    color: #f59e0b;
}

.flag-btn.flagged {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #d97706;
}

/* Flagged question card */
.question.flagged {
    border-color: #f59e0b;
    background: #fffbeb;
    box-shadow: 0 0 0 2px rgba(245,158,11,0.15);
}

/* ============================================================
   UNANSWERED QUESTION (validation highlight)
   ============================================================ */
.question.unanswered {
    border-color: #f97316;
    background: #fff7ed;
    box-shadow: 0 0 0 2px rgba(249,115,22,0.2);
    animation: shake 0.3s ease;
}

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

/* ============================================================
   QUIZ WARNING MESSAGE
   ============================================================ */
.quiz-warning {
    background: #fff7ed;
    border: 2px solid #f97316;
    border-radius: 10px;
    padding: 14px 18px;
    margin-top: 16px;
    font-size: 0.92em;
    color: #9a3412;
    font-weight: 500;
    display: none;
}

/* Clickable progress items */
a.lesson-progress-item {
    display: flex;
    border-radius: 6px;
    padding: 5px 8px;
    margin: 1px -8px;
    transition: background 0.15s;
}

a.lesson-progress-item:hover {
    background: rgba(37,99,235,0.07);
}
