/* Base Styles - Mobile First */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #16a34a;
    --error-color: #dc2626;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --max-width: 720px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-height: 100vh;
}

/* Container */
.quiz-container, .page-container {
    max-width: var(--max-width);
    margin: 0 auto;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 0; /* Ensure no top padding */
}

/* Navigation */
.main-nav {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 48px; /* Fixed height to prevent jumping */
    margin: 0;
    order: -1; /* Ensure nav is always first in flex container */
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
    position: relative;
    height: 100%;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 0;
    margin: 0;
    padding: 0;
    height: 100%;
}

.nav-menu li {
    flex: 1;
    display: flex;
}

.nav-menu a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease, background 0.3s ease;
    position: relative;
}

.nav-menu a:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

/* Desktop only - underline effect */
@media (min-width: 768px) {
    .nav-menu a::after {
        content: '';
        position: absolute;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 2px;
        background: var(--primary-color);
        transition: width 0.3s ease;
    }
    
    .nav-menu a.active::after {
        width: 50%;
    }
}

.nav-menu a.active {
    color: var(--primary-color);
    background: var(--bg-secondary);
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 16px 0;
    width: 30px;
    height: 48px;
    position: relative;
}

.nav-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    margin: 5px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation */
@media (max-width: 767px) {
    /* Hamburger toggle button */
    .nav-toggle {
        display: block;
        z-index: 1001;
    }
    
    /* Mobile menu container */
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgb(255, 255, 255) !important;
        background-color: white !important;
        flex-direction: column;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-bottom: 2px solid var(--border-color);
        z-index: 999;
        height: auto !important;
        max-height: calc(100vh - 48px);
        overflow-y: auto;
    }
    
    .nav-menu.active {
        display: flex !important;
    }
    
    .nav-menu li {
        border-bottom: 1px solid var(--border-color);
        display: block !important;
        flex: none !important;
        background: white;
    }
    
    .nav-menu li:last-child {
        border-bottom: none;
    }
    
    .nav-menu a {
        text-align: left !important;
        padding: 16px 20px !important;
        height: auto !important;
        display: block !important;
        border: none !important;
        border-left: 4px solid transparent !important;
        background: white !important;
        position: relative !important;
    }
    
    .nav-menu a.active {
        border-left-color: var(--primary-color) !important;
        background: #f8f9fa !important;
        color: var(--primary-color) !important;
    }
    
    .nav-menu a:hover {
        background: #f8f9fa !important;
    }
}

/* Header */
.quiz-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    text-align: center;
    margin-top: 8px; /* Add same space below nav as other pages */
}

.quiz-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

/* Progress Section */
.progress-section {
    padding: 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: none;
    position: relative;
}

.progress-section.active {
    display: block;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0;
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-start-over {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    font-size: 12px;
    background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
    color: var(--primary-color);
    border: 1px solid #93c5fd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.1);
}

.btn-start-over:hover {
    background: linear-gradient(180deg, #bfdbfe 0%, #93c5fd 100%);
    color: var(--primary-hover);
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

/* Main Content */
.quiz-content {
    flex: 1;
    padding: 16px;
}

.screen {
    animation: fadeIn 0.3s ease;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Start Screen */
#startScreen {
    text-align: center;
    padding: 32px 16px;
}

#startScreen h2 {
    font-size: 28px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

#startScreen p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.quiz-features {
    list-style: none;
    margin: 24px 0;
    text-align: left;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.quiz-features li {
    padding: 8px 0;
    padding-left: 28px;
    position: relative;
    color: var(--text-secondary);
}

.quiz-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

/* Question Screen */
.question-container {
    margin-bottom: 24px;
}

.question-text {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    line-height: 1.5;
    color: var(--text-primary);
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-button {
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    text-align: left;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    min-height: 48px;
    display: flex;
    align-items: center;
    line-height: 1.3;
}

.option-button:hover:not(.disabled) {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option-button:active:not(.disabled) {
    transform: translateY(0);
}

.option-button.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.option-button.correct {
    background: #dcfce7;
    border-color: var(--success-color);
    color: var(--success-color);
    font-weight: 600;
}

.option-button.incorrect {
    background: #fee2e2;
    border-color: var(--error-color);
    color: var(--error-color);
    font-weight: 600;
}

.option-button.unselected {
    opacity: 0.5;
}

/* True/False Options */
.true-false-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.true-false-container .option-button {
    text-align: center;
    font-weight: 600;
    font-size: 18px;
}

/* Feedback Section */
.feedback-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feedback-header {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
}

.feedback-header.correct {
    color: var(--success-color);
}

.feedback-header.incorrect {
    color: var(--error-color);
}

.feedback-explanation {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.feedback-explanation a,
.review-explanation a {
    color: var(--primary-color);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.feedback-explanation a:hover,
.review-explanation a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

.feedback-explanation sup,
.review-explanation sup {
    font-size: 0.75em;
    vertical-align: super;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    min-height: 44px;
    min-width: 120px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Results Screen */
#resultsScreen {
    text-align: center;
    padding: 32px 16px;
}

#resultsScreen h2 {
    font-size: 32px;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.score-display {
    margin: 32px 0;
}

.final-score {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
}

/* Share Section */
.share-section {
    margin: 32px 0;
    padding: 24px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.share-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 400px;
    margin: 0 auto;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
    justify-content: center;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.share-btn svg {
    fill: currentColor;
}

.share-facebook {
    color: #1877f2;
    border-color: #1877f2;
}

.share-facebook:hover {
    background: #1877f2;
    color: white;
}

.share-twitter {
    color: #1da1f2;
    border-color: #1da1f2;
}

.share-twitter:hover {
    background: #1da1f2;
    color: white;
}

.share-linkedin {
    color: #0077b5;
    border-color: #0077b5;
}

.share-linkedin:hover {
    background: #0077b5;
    color: white;
}

.share-copy {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.share-copy:hover {
    background: var(--primary-color);
    color: white;
}

.copy-feedback {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--success-color);
    color: white;
    border-radius: var(--radius);
    font-size: 14px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    display: none;
}

.copy-feedback.show {
    display: inline-block;
    opacity: 1;
    transform: translateY(0);
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
}

/* Review Screen */
.review-container {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 24px;
    padding: 4px;
}

.review-item {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    border-left: 4px solid transparent;
}

.review-item.correct {
    border-left-color: var(--success-color);
}

.review-item.incorrect {
    border-left-color: var(--error-color);
}

.review-question {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.review-answer {
    margin-bottom: 8px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
}

.review-answer.user-answer {
    border: 2px solid var(--border-color);
}

.review-answer.correct-answer {
    border: 2px solid var(--success-color);
    color: var(--success-color);
    font-weight: 600;
}

.review-explanation {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 8px;
    font-style: italic;
}

.review-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
}

/* Footer */
.quiz-footer {
    padding: 20px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.disclaimer {
    background: rgba(37, 99, 235, 0.05);
    border-radius: var(--radius);
    padding: 12px 24px;
    max-width: var(--max-width);
    margin: 0 auto;
}

.disclaimer p {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

/* Page styles for Resources and Donate */
.page-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    text-align: center;
    margin-top: 8px; /* Add some space below nav */
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.page-header p {
    font-size: 16px;
    opacity: 0.95;
    margin: 0;
}

.page-content {
    flex: 1;
    padding: 32px 16px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

/* Resources Page */
.resource-section {
    margin-bottom: 40px;
}

.resource-section h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.resource-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border-left: 4px solid var(--primary-color);
}

.resource-card h3 {
    margin: 0 0 8px 0;
}

.resource-card h3 a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 20px;
}

.resource-card h3 a:hover {
    text-decoration: underline;
}

.resource-card p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* Donate Page */
.donate-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.donate-container {
    max-width: 600px;
    width: 100%;
}

.story-section, .donate-action, .thank-you {
    margin-bottom: 32px;
    text-align: center;
}

.story-section {
    margin-bottom: 24px;
}

.story-section h2, .donate-action h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.donate-action h2 {
    margin-bottom: 8px; /* Less space before the text */
}

.story-section p, .donate-action p {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.donate-button-container {
    margin: 32px 0;
}

.donate-button {
    display: inline-block;
    padding: 20px 40px;
    background: linear-gradient(135deg, var(--success-color), #14a144);
    color: white;
    text-decoration: none;
    font-size: 20px;
    font-weight: 600;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(22, 163, 74, 0.3);
}

.donate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(22, 163, 74, 0.4);
}

.donate-note {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
}

.thank-you {
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.thank-you p {
    margin: 8px 0;
}

.signature {
    font-weight: 600;
    color: var(--text-primary);
}

/* No JavaScript Message */
.no-js-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
}

/* Tablet and Desktop Styles */
@media (min-width: 768px) {
    .quiz-header h1 {
        font-size: 32px;
    }
    
    .disclaimer p {
        font-size: 15px;
    }
    
    .quiz-content {
        padding: 32px;
    }
    
    .question-text {
        font-size: 24px;
    }
    
    .option-button {
        padding: 20px;
        font-size: 17px;
    }
    
    .true-false-container {
        max-width: 480px;
        margin: 0 auto;
    }
    
    .results-actions,
    .review-actions {
        flex-direction: row;
        justify-content: center;
    }
    
    .btn {
        padding: 14px 32px;
    }
}

/* Large Desktop */
@media (min-width: 1024px) {
    .quiz-container, .page-container {
        margin-top: 20px;
        margin-bottom: 20px;
        border-radius: var(--radius);
        box-shadow: var(--shadow-lg);
        min-height: calc(100vh - 40px);
    }
    
    .quiz-header, .page-header {
        border-radius: var(--radius) var(--radius) 0 0;
    }
    
    .quiz-footer {
        border-radius: 0 0 var(--radius) var(--radius);
    }
    
    /* Override nav border radius when inside container */
    .quiz-container .main-nav,
    .page-container .main-nav {
        border-radius: var(--radius) var(--radius) 0 0;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0040dd;
        --success-color: #008000;
        --error-color: #dd0000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .quiz-header,
    .quiz-footer,
    .btn,
    .progress-section {
        display: none;
    }
    
    .review-item {
        break-inside: avoid;
    }
}