.lesson-slide--math {
    --pair-outer: #195b78;
    --pair-outer-wash: #e9f4f8;
    --pair-inner: #984313;
    --pair-inner-wash: #fff0df;
    padding: clamp(18px, 3vh, 42px) clamp(16px, 6vw, 100px);
}
.math-slide { width: min(100%, 77rem); margin: auto; min-width: 0; }
.math-slide h2 { margin-bottom: .4em; font-size: clamp(1.9rem, min(4.2vw, 6.9vh), 4.6rem); }
.math-slide__problem {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: center;
    gap: 14px clamp(18px, 4vw, 64px);
}
.math-slide__given { display: grid; min-width: 0; place-items: center; background: #fff; border: 1px solid #e7d6c1; border-radius: 16px; }
.math-slide__prompt { margin: 0; max-width: 45ch; font-size: clamp(1.1rem, 1.8vw, 1.85rem); line-height: 1.38; }
.math-slide__problem--illustrated { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.math-slide__problem--illustrated .math-slide__prompt { grid-column: 1; max-width: 62ch; }
.math-slide__picture { grid-area: 1 / 2 / 3 / 3; width: 100%; height: clamp(125px, 26vh, 250px); object-fit: cover; border-radius: 16px; }
.math-table { width: 100%; border-collapse: collapse; font-variant-numeric: lining-nums tabular-nums; }
.math-table th, .math-table td { padding: .35em .65em; text-align: left; }
.math-table thead th { color: #795332; font-size: clamp(.9rem, 1.2vw, 1.25rem); }
.math-table tbody :is(th, td) { border-top: 1px solid #ebdfcf; font-size: clamp(1.15rem, 1.9vw, 2rem); }

.math-ratio {
    display: inline-grid;
    grid-template-columns: 1.42em .46em 1.42em .82em 1.42em .46em 1.42em;
    grid-template-rows: auto auto auto;
    padding: .4em 0;
    align-items: center;
    text-align: center;
    font: 600 clamp(1.8rem, min(4vw, 6.2vh), 3.7rem)/1.2 Georgia, serif;
    font-variant-numeric: lining-nums tabular-nums;
}
.math-ratio__value, .math-ratio__operator { grid-row: 2; }
.math-ratio__value { border-radius: .2em; }
.math-ratio__operator { color: #715e50; font-weight: normal; }
.math-ratio__brace { position: relative; visibility: hidden; margin-inline: .71em; padding-block: .23em; line-height: 1; }
.math-ratio__brace span { display: flex; justify-content: center; white-space: nowrap; font: 650 clamp(.78rem, 1.1vw, 1.15rem)/1.15 'Segoe UI', sans-serif; }
.math-ratio__brace::before { position: absolute; left: 0; right: 0; height: .13em; content: ''; border: 2px solid currentColor; }
.math-ratio__brace--outer { grid-area: 1 / 1 / 2 / 8; color: var(--pair-outer); }
.math-ratio__brace--inner { grid-area: 3 / 3 / 4 / 6; color: var(--pair-inner); }
.math-ratio__brace--outer::before { bottom: 0; border-bottom: 0; border-radius: .1em .1em 0 0; }
.math-ratio__brace--inner::before { top: 0; border-top: 0; border-radius: 0 0 .1em .1em; }
.math-slide:has(details[open]) .math-ratio__brace { visibility: visible; }
.math-slide:has(details[open]) .math-ratio--pairs .math-ratio__value { color: var(--pair-inner); background: var(--pair-inner-wash); }
.math-slide:has(details[open]) .math-ratio--pairs .math-ratio__value:is(:first-child, :nth-child(7)) { color: var(--pair-outer); background: var(--pair-outer-wash); }

.math-slide__answer { margin-top: .65em; font-size: clamp(1.1rem, 1.8vw, 1.8rem); }
.math-slide__answer summary:focus-visible { outline: 2px solid var(--section-deep); outline-offset: 4px; }
.math-solution { margin-top: .45em; }
.math-solution__paths { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.math-solution__path {
    --ink: var(--pair-outer);
    --wash: var(--pair-outer-wash);
    padding: .5em .85em;
    border-inline-start: 4px solid var(--ink);
    border-radius: 0 12px 12px 0;
    background: var(--wash);
}
.math-solution__path:nth-child(2) { --ink: var(--pair-inner); --wash: var(--pair-inner-wash); }
.math-solution__path dt { color: var(--ink); font-size: clamp(1rem, 1.4vw, 1.5rem); font-weight: 650; }
.math-solution__path dd { display: grid; gap: .08em; margin: .18em 0 0; font: 500 clamp(1.25rem, 2.15vw, 2.3rem)/1.22 Georgia, serif; font-variant-numeric: lining-nums tabular-nums; }
.math-solution__path mark { font-weight: bold; color: var(--ink); }
.math-solution__path mark::before { display: none; }
.math-solution__conclusion { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2em 1em; margin-top: .5em; padding: .5em 0 0; border-top: 1px solid #ddcbb7; font-size: clamp(1rem, 1.5vw, 1.5rem); }
.math-solution__conclusion strong { color: #54381f; font: bold 1.35em/1.25 Georgia, serif; font-variant-numeric: lining-nums; }
.math-solution__conclusion span { flex: 1 1 18em; }

@media screen and (prefers-reduced-motion: no-preference) {
    .is-current .math-slide__given, .is-current .math-slide__picture, .is-current .math-slide__prompt { animation: lesson-arrive .25s ease-out backwards; }
    .is-current .math-slide__prompt { animation-delay: 80ms; }
    .math-slide__answer[open] .math-solution__path, .math-slide__answer[open] .math-solution__conclusion,
    .math-slide:has(details[open]) .math-ratio__brace { animation: lesson-reveal .24s ease-out backwards; }
    .math-slide__answer[open] .math-solution__path:nth-child(2) { animation-delay: 70ms; }
    .math-slide__answer[open] .math-solution__conclusion { animation-delay: 140ms; }
}
@media (max-width: 700px) {
    .math-slide__problem { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .math-slide__picture { grid-area: auto; height: clamp(115px, 32vw, 170px); }
}
@media (max-width: 520px) {
    .math-solution__paths { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .math-slide:has(.math-ratio--pairs) .math-solution__paths { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (max-width: 520px) and (max-height: 740px) {
    .lesson-slide--math { padding: 8px 12px; }
    .math-slide__problem--illustrated { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
    .math-slide__problem--illustrated .math-slide__given { grid-column: 1 / -1; }
    .math-slide__picture { grid-area: 2 / 2; height: auto; }
    .math-table th, .math-table td { padding-block: .18em; }
    .math-solution__path { padding-block: .32em; }
    .math-solution__conclusion { margin-top: .3em; padding-top: .3em; }
}
@media screen and (min-width: 701px) and (max-height: 800px) {
    .lesson-slide--math { padding-block: 12px; }
    .math-table th, .math-table td { padding-block: .22em; }
}
@media screen and (orientation: landscape) and (max-height: 540px) {
    .lesson-slide--math { padding: 5px 14px; }
    .math-slide h2 { margin-bottom: .18em; }
    .math-slide__problem { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 6px 12px; }
    .math-slide__problem--illustrated { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, .55fr); }
    .math-slide__problem--illustrated .math-slide__prompt { grid-column: 2; }
    .math-slide__picture { grid-area: 1 / 3; height: auto; max-height: 23vh; }
    .math-slide__prompt { font-size: 1rem; line-height: 1.25; }
    .math-table th, .math-table td { padding: .15em .4em; }
    .math-slide__answer, .math-solution, .math-solution__conclusion { margin-top: .18em; }
    .math-solution__path { padding: .25em .65em; }
    .math-solution__conclusion { padding-top: .18em; }
}
@media print {
    .math-slide__given { border-color: #999; }
    .math-slide .math-ratio__brace { display: none; }
    .math-slide .math-ratio .math-ratio__value { background: white !important; color: black !important; }
}
