/* css/lessons.css */
.course-header { /* Specific to lessons page, if different from global main-header */
    text-align: center;
    margin-bottom: 25px;
    color: #4b0082;
}

.course-header h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 8px;
}

.course-header p {
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: #555;
}

.tabs-container {
    display: flex;
    flex-wrap: nowrap;
    margin-bottom: 20px;
    background-color: #e7e3f3; /* Lighter purple */
    border-radius: 8px;
    padding: 5px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #6a5acd #e0e0e0;
}
.tabs-container::-webkit-scrollbar { height: 6px; }
.tabs-container::-webkit-scrollbar-track { background: #e0e0e0; border-radius: 3px; }
.tabs-container::-webkit-scrollbar-thumb { background-color: #6a5acd; border-radius: 3px; }

.tab-button {
    padding: 10px 15px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: bold;
    color: #4b0082;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
    flex-shrink: 0;
    white-space: nowrap;
    margin-right: 5px;
}
.tab-button:last-child { margin-right: 0; }
.tab-button:hover, .tab-button:focus-visible {
    background-color: #d0c0e0;
    color: #300052;
}
.tab-button.active {
    background-color: #6a5acd;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.lesson-content {
    display: none; /* Initially hidden, JS will make it active */
    padding: 20px; /* Increased padding */
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 2px solid #6a5acd;
    animation: fadeIn 0.4s ease-out;
}

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

.lesson-content.active {
    display: block;
}

.lesson-content h2 {
    color: #ff6347; /* Tomato */
    font-size: clamp(1.5rem, 4vw, 2rem); /* Slightly larger */
    margin-bottom: 18px; /* Increased margin */
    padding-bottom: 8px;
    border-bottom: 2px dashed #ff6347;
}

.lesson-content h3 {
    color: #00796b; /* Teal */
    font-size: clamp(1.3rem, 3.5vw, 1.6rem); /* Slightly larger */
    margin-top: 25px;
    margin-bottom: 12px;
}

.lesson-content p, .lesson-content li {
    font-size: clamp(0.95rem, 2.8vw, 1.1rem);
    margin-bottom: 12px; /* Increased margin */
}

.lesson-content ul {
    list-style-position: outside; /* More standard list appearance */
    list-style-type: '🐌'; /* Custom bullet */
    padding-left: 30px; /* Proper indentation */
}
.lesson-content ul li {
    padding-left: 8px; /* Space after bullet */
}

.lesson-content .why-important {
    background-color: var(--color-callout-tips-bg);
    border-left: 5px solid var(--color-callout-tips-accent);
    padding: 18px; /* Increased padding */
    margin: 25px 0;
    border-radius: 8px;
}
.lesson-content .why-important ul {
    list-style-type: '💡'; /* Custom bullet */
}

.lesson-path-section {
    background: #f8faf9;
    border: 1px solid #d9e8e2;
    border-radius: 10px;
    padding: 18px 20px;
}

.lesson-path-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0;
    color: #00796b;
    font-size: clamp(1.4rem, 3.6vw, 1.8rem);
}

.lesson-path-table {
    width: max(100%, 620px);
    border-collapse: separate;
    margin: 0;
    table-layout: fixed;
    border: none;
    border-radius: 0;
    overflow: visible;
    background: transparent;
}

.lesson-path-table thead th {
    text-align: left;
    color: #1f2937;
    font-size: clamp(1rem, 2.8vw, 1.15rem);
    font-weight: 800;
    padding: 14px 16px;
    background: #eef4f7;
}

.lesson-path-table thead th:nth-child(1) {
    width: 20%;
}

.lesson-path-table thead th:nth-child(2) {
    width: 32%;
}

.lesson-path-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: clamp(1rem, 2.8vw, 1.1rem);
}

.lesson-path-table tbody td:nth-child(2) {
    font-weight: 800;
    font-size: clamp(1.05rem, 3vw, 1.2rem);
    color: #1f2937;
}

.lesson-path-table tbody td:nth-child(3) {
    font-family: 'Fira Mono', 'Consolas', 'Courier New', monospace;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
}

.lesson-path-index {
    display: inline-block;
    min-width: 1ch;
    margin-right: 10px;
    color: #111827;
    font-size: clamp(1rem, 2.8vw, 1.1rem);
}

.lesson-path-dot {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #111827;
    vertical-align: middle;
}

.lesson-path-dot-green {
    background: #32cd32;
}

.lesson-path-dot-yellow {
    background: #ffd400;
}

.lesson-path-dot-red {
    background: #ff3040;
}

.lesson-content .code-example {
    background-color: #f8f9fa;
    border-left: 5px solid #32cd32; /* Green */
    padding: 12px 18px; /* Adjusted padding */
    margin: 20px 0;
    font-family: 'Fira Mono', 'Consolas', 'Courier New', monospace;
    font-size: clamp(0.9rem, 2.5vw, 1.05rem); /* Slightly larger */
    border-radius: 6px; /* Softer radius */
    white-space: pre-wrap;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.task {
    background-color: var(--color-callout-task-bg);
    border: 2px dashed var(--color-callout-task-accent);
    padding: 18px;
    margin-top: 25px;
    border-radius: 8px;
}

.lesson-manual-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 10px;
    padding: 10px 16px;
    font-size: 0.95rem;
    text-decoration: none;
    border-radius: 999px;
}
.lesson-content .lesson-manual-link:hover,
.lesson-content .lesson-manual-link:focus-visible,
.lesson-content .task .btn:hover,
.lesson-content .task .btn:focus-visible {
    color: #fff;
    text-decoration: none;
}
.lesson-manual-link::before {
    content: "";
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    margin-right: 0.55em;
    vertical-align: -0.1em;
    background-color: currentColor;
    mask: url('../assets/icons/book-open.svg') no-repeat center / contain;
    -webkit-mask: url('../assets/icons/book-open.svg') no-repeat center / contain;
}
.lesson-manual-link-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.tip {
    background-color: var(--color-callout-tip-bg);
    border-left: 6px solid var(--color-callout-tip-accent);
    padding: 16px 22px;
    margin-top: 20px;
    border-radius: 8px;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
    line-height: 1.55;
}
.tip > :last-child {
    margin-bottom: 0;
}
.tip strong {
    color: #00796b;
    font-weight: 800;
}
.tip ul {
    margin: 10px 0 0 1.2rem;
    padding: 0;
}
.tip li + li {
    margin-top: 6px;
}

.lesson-content details {
    margin-top: 12px;
    border: 1px solid #d9dfef;
    border-radius: 10px;
    background: #f8fbff;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(63, 81, 181, 0.08);
}
.lesson-content summary {
    position: relative;
    cursor: pointer;
    padding: 12px 16px 12px 42px;
    font-weight: 700;
    color: #3b3f65;
    background: #eef4ff;
    list-style: none;
}
.lesson-content summary::-webkit-details-marker {
    display: none;
}
.lesson-content summary::before {
    content: "▸";
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #5c6bc0;
    font-size: 1rem;
    transition: transform 0.2s ease;
}
.lesson-content details[open] summary {
    background: #e4ecff;
    border-bottom: 1px solid #d9dfef;
}
.lesson-content details[open] summary::before {
    transform: translateY(-50%) rotate(90deg);
}
.lesson-content details > *:not(summary) {
    margin: 0;
    padding: 14px 16px 16px;
}
.lesson-content details > *:not(summary):last-child {
    padding-top: 12px;
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    gap: 15px;
}

.lesson-image {
    display: block;
    max-width: clamp(200px, 50vw, 350px); /* Responsive max-width */
    height: auto;
    margin: 20px auto; /* Centered with more margin */
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border: 1px solid #eee; /* Subtle border */
}
.lesson-image-wide {
    max-width: 100%; /* Allow full width if specified */
    width: 100%;
}

.bottom-nav-buttons { /* For buttons like "To Editor", "To Manual" at the very bottom */
    margin: 30px auto 10px auto;
}


/* Media Queries for smaller screens */
@media (max-width: 768px) {
    .navigation-buttons .btn {
        max-width: 100%; /* Stack buttons on smaller screens */
    }
    .navigation-buttons {
        flex-direction: column;
    }
    .bottom-nav-buttons {
        margin-top: 24px;
    }
}

@media (max-width: 600px) {
    .page-wrapper { padding: 5px; } /* Reduced padding for page wrapper */
    .tabs-container { padding: 5px 0; }
    .tab-button { padding: 8px 10px; font-size: 0.85rem; }
    .lesson-content { padding: 15px; }
    .lesson-content h2 { font-size: 1.6rem; }
    .lesson-content h3 { font-size: 1.3rem; }
    .lesson-content p, .lesson-content li { font-size: 0.9rem; }
    .lesson-content .code-example { font-size: 0.85rem; padding: 10px 12px;}
    .lesson-path-section { padding: 14px 12px; }
    .lesson-path-table { table-layout: auto; }
    .lesson-content .manual-table { width: max(100%, 500px); }
    .lesson-manual-link-group {
        flex-direction: column;
        align-items: flex-start;
    }
    .lesson-path-table thead th:nth-child(1),
    .lesson-path-table thead th:nth-child(2) { width: auto; }
    .lesson-path-dot { width: 18px; height: 18px; }
}

/* --- Accessibility refinements: lessons page --- */
.a11y-high-contrast .tab-button {
    color: #fff !important;
    border: 1px solid #fff !important;
}

.a11y-high-contrast .tab-button:hover,
.a11y-high-contrast .tab-button:focus-visible {
    background: #222 !important;
    color: #fff !important;
}

.a11y-high-contrast .tab-button.active {
    background: #fff !important;
    color: #000 !important;
    border-color: #fff !important;
}

.a11y-high-contrast .lesson-image {
    border: 2px solid #fff !important;
    box-shadow: none !important;
}

.a11y-larger-text .tab-button,
.a11y-larger-text .lesson-content p,
.a11y-larger-text .lesson-content li {
    line-height: 1.5;
}

.a11y-increased-spacing .lesson-content p,
.a11y-increased-spacing .lesson-content li {
    margin-bottom: 0.9em !important;
}
