/* Lecciones de teoría (htmlFiles/leccion.html + contenido de Lecciones/) */

.lesson {
    --tone-text: color-mix(in srgb, var(--tone) 72%, var(--text));
}

/* Barra de progreso de lectura (solo en navegadores con animaciones ligadas al scroll) */
.reading-progress {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    z-index: 99;
    height: 3px;
    background: var(--tone);
    transform: scaleX(0);
    transform-origin: 0 50%;
}

@supports (animation-timeline: scroll()) {
    .reading-progress {
        animation: reading-progress linear both;
        animation-timeline: scroll(root);
    }
}

@keyframes reading-progress {
    to { transform: scaleX(1); }
}

/* ---------- Cabecera ---------- */

.lesson-header {
    max-width: 760px;
    margin: 16px 0 32px;
}

.lesson-header h1 {
    margin: 12px 0 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.3rem, 5.5vw, 3.4rem);
    line-height: 1.05;
    letter-spacing: -0.025em;
}

.lesson-intro {
    max-width: 60ch;
    margin: 0;
    color: var(--text-muted);
    font-size: 1.15rem;
}

.lesson-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.lesson-meta-tip::before {
    content: "🔊 ";
}

/* ---------- Disposición: contenido + índice ---------- */

.lesson-layout {
    display: grid;
    grid-template-columns: minmax(0, 760px) 230px;
    grid-template-areas: "contenido indice";
    justify-content: space-between;
    align-items: start;
    gap: 48px;
}

.lesson-content {
    grid-area: contenido;
    min-width: 0;
}

.lesson-toc {
    grid-area: indice;
    position: sticky;
    top: calc(var(--nav-h) + 24px);
}

.lesson-toc summary {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    list-style: none;
    pointer-events: none;
}

.lesson-toc summary::-webkit-details-marker {
    display: none;
}

#toc {
    margin: 0;
    padding: 0;
    list-style: none;
    border-left: 2px solid var(--border);
}

#toc a {
    display: block;
    margin-left: -2px;
    padding: 6px 12px;
    border-left: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    transition: color 0.2s, border-color 0.2s;
}

#toc a:hover {
    color: var(--text);
}

#toc a.is-active {
    border-left-color: var(--tone);
    color: var(--tone-text);
    font-weight: 800;
}

@media (max-width: 1000px) {
    .lesson-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "indice" "contenido";
        gap: 20px;
    }

    .lesson-toc {
        position: static;
        border-radius: var(--radius);
        border: 1px solid var(--border);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }

    .lesson-toc summary {
        display: flex;
        justify-content: space-between;
        margin: 0;
        padding: 14px 16px;
        cursor: pointer;
        pointer-events: auto;
    }

    .lesson-toc summary::after {
        content: "▾";
        transition: transform 0.2s;
    }

    .lesson-toc[open] summary::after {
        transform: rotate(180deg);
    }

    #toc {
        margin: 0 16px 14px;
    }
}

/* ---------- Texto ---------- */

.lesson-content {
    font-size: 1.05rem;
    line-height: 1.7;
}

.lesson-content section + section {
    margin-top: 48px;
}

.lesson-content h2 {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.75rem;
    line-height: 1.2;
    scroll-margin-top: calc(var(--nav-h) + 20px);
}

.lesson-content h2::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    margin-bottom: 12px;
    border-radius: 2px;
    background: var(--tone);
}

.lesson-content h3 {
    margin: 28px 0 10px;
    font-size: 1.12rem;
    font-weight: 800;
}

.lesson-content p {
    margin: 0 0 14px;
}

.lesson-content ul,
.lesson-content ol {
    margin: 0 0 16px;
    padding-left: 1.3em;
}

.lesson-content li {
    margin: 6px 0;
}

.lesson-content li::marker {
    color: var(--tone);
}

/* Palabras en francés dentro del texto */
.lesson-content i[lang="fr"],
.lesson-content b[lang="fr"] {
    color: var(--tone-text);
    font-weight: 700;
}

.lesson-content b {
    color: var(--tone-text);
}

/* ---------- Ejemplos ---------- */

.lesson-content .ejemplos {
    display: grid;
    gap: 8px;
    margin: 12px 0 18px;
    padding: 0;
    list-style: none;
}

.ejemplos li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    line-height: 1.45;
}

.ejemplos li > :not(.speak-btn) {
    grid-column: 2;
}

.ejemplos .speak-btn {
    grid-row: 1 / span 2;
    width: 34px;
    height: 34px;
}

.ejemplos [lang="fr"] {
    font-family: var(--font-display);
    font-size: 1.12rem;
    font-weight: 600;
}

.ejemplos .es {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.lesson-content .usos {
    padding: 0;
    list-style: none;
}

.usos > li {
    margin: 18px 0;
}

/* ---------- Tablas de conjugación ---------- */

.conj-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
    gap: 14px;
    margin: 16px 0 22px;
}

.conj {
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.conj figcaption {
    padding: 10px 14px;
    background: color-mix(in srgb, var(--tone) 10%, var(--surface));
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.conj figcaption span[lang] {
    color: var(--text);
    font-family: var(--font-display);
    font-size: 1.12rem;
    font-weight: 600;
}

.conj table {
    width: 100%;
    border-collapse: collapse;
}

.conj tr + tr {
    border-top: 1px solid var(--border);
}

.conj th {
    width: 36%;
    padding: 7px 8px 7px 14px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 700;
    text-align: left;
}

.conj td {
    padding: 7px 14px 7px 0;
    font-size: 1.05rem;
    font-weight: 700;
}

/* ---------- Tablas generales ---------- */

.tabla-scroll {
    margin: 14px 0 20px;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.97rem;
    line-height: 1.5;
}

.tabla th {
    padding: 10px 14px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.tabla td {
    padding: 10px 14px;
    vertical-align: top;
}

.tabla tr + tr td,
.tabla thead + tbody tr:first-child td {
    border-top: 1px solid var(--border);
}

.tabla td[lang="fr"] {
    font-weight: 600;
}

/* ---------- Elementos que se escuchan al pulsarlos ---------- */

.is-speakable {
    cursor: pointer;
    transition: background-color 0.15s;
}

.is-speakable:hover,
.is-speakable:focus-visible {
    background: color-mix(in srgb, var(--tone) 8%, var(--surface));
}

.is-speakable.is-speaking {
    background: color-mix(in srgb, var(--tone) 16%, var(--surface));
}

.conj tr.is-speakable td {
    position: relative;
}

.conj tr.is-speakable td::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 12px;
    width: 16px;
    height: 16px;
    background: var(--tone);
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 0.15s;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5Z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5Z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7'/%3E%3C/svg%3E") center / contain no-repeat;
}

.conj tr.is-speakable:hover td::after,
.conj tr.is-speakable:focus-visible td::after,
.conj tr.is-speaking td::after {
    opacity: 1;
}

/* ---------- Notas ---------- */

.nota {
    --c: var(--primary);
    position: relative;
    margin: 20px 0;
    padding: 14px 18px 14px 52px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--c) 30%, var(--border));
    background: color-mix(in srgb, var(--c) 8%, var(--surface));
}

.nota::before {
    content: "i";
    position: absolute;
    top: 15px;
    left: 16px;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--c);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1;
}

.nota--ojo {
    --c: #e0901f;
}

.nota--ojo::before {
    content: "!";
}

.nota--truco {
    --c: var(--success);
}

.nota--truco::before {
    content: "✦";
}

.nota .ejemplos {
    margin-bottom: 4px;
}

/* ---------- Bloques especiales ---------- */

.formula {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.formula span {
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--border));
    background: color-mix(in srgb, var(--tone) 10%, var(--surface));
}

.grupos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin: 16px 0 20px;
}

.grupo {
    padding: 16px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    line-height: 1.5;
}

.lesson-content .grupo p {
    margin: 0 0 8px;
}

.lesson-content .grupo p:last-child {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.grupo-num {
    color: var(--tone-text);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.grupo-regla {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
}

.grupo-ej {
    color: var(--tone-text);
    font-weight: 700;
    font-style: italic;
}

.parejas {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 16px;
}

.parejas span {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--border));
    background: color-mix(in srgb, var(--tone) 8%, var(--surface));
    font-weight: 700;
}

.lesson-content .pasos {
    padding: 0;
    list-style: none;
    counter-reset: paso;
}

.pasos li {
    position: relative;
    padding-left: 40px;
    counter-increment: paso;
}

.pasos li::before {
    content: counter(paso);
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--tone);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 800;
}

.comparar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 14px 0 18px;
}

.comparar > div {
    padding: 14px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
}

.lesson-content .comparar h3 {
    margin: 0 0 8px;
}

.lesson-content .comparar ul {
    margin: 0;
}

.lesson-content .mal,
.lesson-content .bien {
    margin: 6px 0;
    padding: 4px 8px;
    border-radius: 8px;
    font-weight: 700;
}

.mal {
    color: color-mix(in srgb, var(--danger) 80%, var(--text));
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}

.mal small {
    display: inline-block;
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
}

.bien {
    color: color-mix(in srgb, var(--success) 75%, var(--text));
}

.mal::before { content: "✕ "; }
.bien::before { content: "✓ "; }

@media (max-width: 600px) {
    .comparar {
        grid-template-columns: 1fr;
    }
}

/* Línea del tiempo (plus-que-parfait, futur antérieur) */
.linea-tiempo {
    position: relative;
    display: flex;
    justify-content: space-between;
    margin: 20px 0 26px;
    padding: 22px 4px 0;
}

.linea-tiempo::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--border), var(--tone));
}

.lt-punto {
    position: relative;
    flex: 1;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}

.lt-punto::before {
    content: "";
    position: absolute;
    top: -22px;
    left: 50%;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 3px solid var(--surface);
    background: var(--text-muted);
    transform: translateX(-50%);
    box-shadow: 0 0 0 1px var(--border);
}

.lt-pqp { color: var(--tone-text); }
.lt-pqp::before { background: var(--tone); }
.lt-pc::before { background: var(--primary); }

/* Resumen */
.lesson-content .resumen {
    padding: 22px 24px;
    border-radius: var(--radius-lg);
    border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--border));
    background: color-mix(in srgb, var(--tone) 7%, var(--surface));
}

.resumen ul {
    margin-bottom: 0;
}

/* Autoevaluación */
.quiz details {
    margin: 10px 0;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: border-color 0.2s;
}

.quiz details[open] {
    border-color: color-mix(in srgb, var(--tone) 45%, var(--border));
}

.quiz summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
}

.quiz summary::-webkit-details-marker {
    display: none;
}

.quiz summary::after {
    content: "Ver respuesta";
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tone) 12%, transparent);
    color: var(--tone-text);
    font-size: 0.78rem;
    font-weight: 800;
}

.quiz details[open] summary::after {
    content: "Ocultar";
}

.lesson-content .quiz details p {
    margin: 0;
    padding: 0 16px 14px;
    animation: rise 0.3s var(--ease) both;
}

/* ---------- Final de la lección ---------- */

.lesson-end {
    max-width: 760px;
    margin-top: 56px;
}

.cta-card {
    padding: 28px;
    border-radius: var(--radius-lg);
    background: linear-gradient(140deg, var(--tone), color-mix(in srgb, var(--tone) 65%, #0b1630));
    color: #ffffff;
    box-shadow: var(--shadow-lg);
}

.cta-card h2 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.7rem;
}

.cta-card p {
    margin: 0 0 18px;
    opacity: 0.9;
}

.cta-card .btn {
    background: #ffffff;
    color: color-mix(in srgb, var(--tone) 80%, #000000);
}

.cta-card .btn:hover {
    background: #f1f4fb;
}

.lesson-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.pager-link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    transition: border-color 0.2s, transform 0.2s var(--ease);
}

.pager-link span {
    color: var(--text);
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
}

.pager-link:hover {
    border-color: color-mix(in srgb, var(--tone) 45%, var(--border));
    transform: translateY(-2px);
}

.pager-link--next {
    grid-column: 2;
    text-align: right;
}

.cta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.cta-card .btn-cta-alt {
    background: transparent;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.6);
}

.cta-card .btn-cta-alt:hover {
    background: rgba(255, 255, 255, 0.12);
}
