/* Global styles and utility classes */
html {
    box-sizing: border-box;
    scroll-behavior: smooth;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #343a40;
    font-size: 16px; /* Base font size for easier rem/em scaling if needed */
}

header {
    background: #343a40;
    color: #fff;
    padding: 1rem 1rem; /* Adjusted padding for responsiveness */
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    margin: 0;
    font-size: 2rem; /* Adjusted for mobile */
    font-weight: bold;
}

nav {
    margin-top: 0.75rem;
    display: flex; /* Added flex for better nav layout */
    flex-wrap: wrap; /* Allow nav items to wrap on small screens */
    justify-content: center; /* Center nav items when they wrap */
    align-items: center;
}

nav a {
    color: #fff;
    margin: 0.25rem 0.5rem; /* Adjusted margin for wrapping */
    text-decoration: none;
    padding: 0.6rem 1rem; /* Adjusted padding */
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

nav a:hover, nav a.active {
    background-color: #495057;
}

main {
    padding: 1rem; /* Base padding */
    max-width: 960px;
    margin: 1.5rem auto; /* Adjusted margin */
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
}

footer {
    text-align: center;
    padding: 1.5rem 1rem; /* Adjusted padding */
    background: #343a40;
    color: #fff;
    width: 100%;
    margin-top: 2rem;
}

h1, h2, h3, h4, h5, h6 { /* Basic responsive typography for headings */
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

h1 { font-size: 2.2rem; } /* Example, could use clamp() or vw for more fluid */
h2 { font-size: 1.8rem; color: #007bff; }
h3 { font-size: 1.4rem; color: #007bff; }

main h2 {
    text-align: center;
    font-size: 1.8rem; /* Adjusted */
}

main h3 {
    font-size: 1.5rem; /* Adjusted */
    border-bottom: 2px solid #007bff30;
    padding-bottom: 0.5rem;
}


ul {
    list-style: none;
    padding: 0;
}

ul li {
    padding: 0.3rem 0;
}

.course-for-section ul li, .course-covers-section ul li {
    padding-left: 1.5rem;
    position: relative;
    margin-bottom: 0.5rem;
}

.course-for-section ul li::before, .course-covers-section ul li::before {
    content: '✔';
    color: #28a745;
    position: absolute;
    left: 0;
    font-weight: bold;
}


ul li a {
    text-decoration: none;
    color: #007bff;
}

ul li a:hover {
    color: #0056b3;
}

button, .cta-button {
    display: inline-block;
    background: #007bff;
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem; /* Adjusted padding */
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem; /* Adjusted font size */
    margin-top: 1rem;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.3s ease;
    line-height: 1.5; /* Ensure text is vertically centered if button wraps */
}
button:focus, .cta-button:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}


button:hover, .cta-button:hover {
    background: #0056b3;
}

.hidden {
    display: none !important; /* Added !important for robustness */
}

/* Home Page Specific Styles */
.hero-section {
    text-align: center;
    padding: 1.5rem 1rem; /* Adjusted padding */
    background-color: #e9ecef;
    border-radius: 8px;
    margin-bottom: 1.5rem; /* Adjusted margin */
}
.hero-section h2 {
    color: #343a40;
    font-size: 2rem; /* Adjusted */
}
.hero-section p {
    font-size: 1.05rem; /* Adjusted */
    color: #495057;
    max-width: 700px;
    margin: 0 auto 1rem auto;
}

.course-for-section, .course-covers-section {
    margin-bottom: 1.5rem; /* Adjusted */
    padding: 1rem; /* Adjusted */
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

.cta-section {
    text-align: center;
    margin-top: 1.5rem; /* Adjusted */
    padding: 1.5rem 0;
    border-top: 1px solid #eee;
}


/* Feedback Form Styles */
#feedback-form div {
    margin-bottom: 1rem;
}

#feedback-form label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: bold;
}

#feedback-form input[type="text"],
#feedback-form input[type="email"],
#feedback-form select,
#feedback-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
}

#feedback-form textarea {
    resize: vertical;
    min-height: 100px; /* Ensure textarea is reasonably tall */
}

/* Chapter Content Styles */
#chapter-content-article {
    padding: 0.5rem; /* Reduced padding if main already has enough */
}
#chapter-content-article h1,
#chapter-content-article h2,
#chapter-content-article h3 {
    color: #343a40;
}
#chapter-content-article p {
    margin-bottom: 1.2rem;
    font-size: 1.05rem;
}
#chapter-content-article ul,
#chapter-content-article ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem; /* Adjusted for smaller screens */
}
#chapter-content-article li {
    margin-bottom: 0.5rem;
    border-bottom: none;
    padding: 0;
    list-style-type: disc;
}
#chapter-content-article strong {
    color: #0056b3;
}


/* Quiz Styles */
#chapter-quiz-section {
    margin-top: 2rem;
    padding: 1rem; /* Adjusted padding */
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
}
#chapter-quiz-section h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}


.quiz-question {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 5px;
}

.quiz-question p {
    font-weight: bold;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.quiz-question label {
    display: block; /* Make label take full width for easier tapping */
    margin-bottom: 0.5rem;
    font-weight: normal;
    background-color: #e9ecef;
    padding: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 2px solid transparent;
}
.quiz-question label:hover {
    background-color: #dee2e6;
}

.quiz-question input[type="radio"] {
    margin-right: 0.75rem;
    vertical-align: middle;
}

/* Styles for quiz answer feedback */
.quiz-question label.user-selected {
    /* Might not need specific style if correct/incorrect is primary feedback */
}
.quiz-question label.correct-answer {
    background-color: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724 !important;
    font-weight: bold;
}
.quiz-question label.incorrect-answer {
    background-color: #f8d7da !important;
    border-color: #dc3545 !important;
    color: #721c24 !important;
    font-weight: bold;
}


.quiz-result-div {
    margin-top: 1.5rem;
    font-weight: bold;
    font-size: 1.1rem;
    text-align: center;
    padding: 1rem;
    border-radius: 5px;
}
.quiz-result-div.correct {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.quiz-result-div.incorrect {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}


#navigation-buttons-div {
    margin-top: 2rem;
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap */
    justify-content: space-between;
    gap: 0.5rem; /* Add gap for wrapped buttons */
}
#navigation-buttons-div button {
    flex-grow: 1; /* Allow buttons to grow if space allows */
    min-width: 150px; /* Ensure buttons don't get too small */
}


/* Progress Page Styles */
#progress-tracker-div {
    padding: 1rem 0; /* Removed horizontal padding to use item padding */
}
#progress-tracker-div ul {
    padding-left: 0;
}

#progress-tracker-div li {
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 0.5rem;
    font-size: 1rem; /* Adjusted */
    list-style-type: none;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}
#progress-tracker-div li.completed {
    background-color: #e6ffed;
    color: #28a745;
    padding-left: 1rem;
    position: relative;
}

#progress-tracker-div li.completed::before {
    content: '✔ ';
    color: #28a745;
    font-weight: bold;
    margin-right: 0.5em;
}

#progress-tracker-div li:not(.completed) {
    background-color: #fff9e6;
    color: #856404;
    padding-left: 1rem;
    position: relative;
}
#progress-tracker-div li:not(.completed)::before {
    content: '● ';
    color: #ffc107;
    font-weight: bold;
    margin-right: 0.5em;
}


.completed { /* General completed class for chapter list links on chapters.html */
    text-decoration: line-through;
    color: #6c757d !important;
}


/* Ensure buttons are consistently styled */
#reset-progress-button {
    background-color: #dc3545;
}
#reset-progress-button:hover {
    background-color: #c82333;
}

#mark-complete-button.completed {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    color: #fff !important;
}
#mark-complete-button.completed:hover {
    background-color: #218838 !important;
}

/* Utility class for screen readers only */
.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;
}

/* Media Queries for further responsiveness */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    nav a {
        padding: 0.5rem 0.8rem;
        margin: 0.2rem; /* Tighter margin for wrapped items */
    }
    main {
        margin: 1rem auto;
        padding: 0.75rem;
    }
    main h2 {
        font-size: 1.6rem;
    }
    main h3 {
        font-size: 1.3rem;
    }
    button, .cta-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.95rem;
    }
    #chapter-content-article ul,
    #chapter-content-article ol {
        padding-left: 1.2rem;
    }
    .quiz-question label {
        padding: 0.6rem;
    }
    #navigation-buttons-div button {
        width: 100%; /* Stack nav buttons on small screens */
        margin-bottom: 0.5rem;
    }
    #navigation-buttons-div button:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px; /* Slightly smaller base font for very small screens */
    }
    header h1 {
        font-size: 1.6rem;
    }
    nav a {
        font-size: 0.9rem;
        padding: 0.4rem 0.6rem;
    }
    .hero-section h2 {
        font-size: 1.8rem;
    }
    .hero-section p {
        font-size: 1rem;
    }
    #feedback-form input[type="text"],
    #feedback-form input[type="email"],
    #feedback-form select,
    #feedback-form textarea {
        padding: 0.6rem;
        font-size: 0.95rem;
    }
}
