/* Worked examples as class slides (mathcourse/stepped_example.html): a teal
   band, the question, three coloured columns and a conclusion, shown a step
   at a time by mathcourse/stepped.js. The slide's own colours are the ones on
   the class slides it copies; everything else comes from core/theme.css. */

.pe-body {
    --pe-teal: #16707F;
    --pe-teal-panel: #E6F1F3;
    --pe-teal-fill: #C5E0E5;
    --pe-grey: #333333;
    --pe-grey-panel: #F4F5F6;
    --pe-grey-fill: #DCDDE3;
    --pe-orange: #B35C00;
    --pe-orange-panel: #FDF0DD;
    --pe-orange-fill: #F6D9AE;
    --pe-text: #1F1F1F;
    --pe-serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
    font-size: 16px;
}
.pe-body .pe-bar { position: static; }
.pe { padding: 0 0 32px; }

/* The caption of the step and its three buttons stay in reach. */
.pe-stepbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 20px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--cream);
}
.pe-stepbar[hidden] { display: none; }
.pe-caption { flex: 1 1 18rem; margin: 0; font-size: 1.125rem; font-weight: 600; line-height: 1.35; color: var(--ink); }
.pe-count {
    display: inline-block;
    margin-right: 8px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--pe-teal);
    font-size: 0.8125rem;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: 2px;
    color: var(--paper);
}
.pe-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-btn-quiet { background: var(--paper); color: var(--ink); }
.pe-actions .mw-btn:disabled { opacity: 0.35; cursor: default; }

/* The slide keeps the proportions of the class slide: its type follows its
   width, and on a wide screen its width follows the height left for it. */
.pe-stage { container-type: inline-size; box-sizing: border-box; width: 100%; margin: 16px auto 0; padding: 0 16px; }
.pe-slide {
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--paper);
    font-size: 16px;
    line-height: 1.3;
    color: var(--pe-text);
}
.pe-band {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.2em 1.5em;
    padding: 1.05em 1.6em;
    background: var(--pe-teal);
    color: var(--paper);
}
.pe-band h1 { margin: 0; font-size: 1.5em; font-weight: 700; line-height: 1.2; }
.pe-band p { margin: 0; font-size: 1.02em; opacity: 0.72; }
.pe-question { margin: 1em 1.6em; font-size: 1.32em; }
.pe-cols { display: grid; gap: 0.9em; margin: 0 1.6em; }
.pe-panel { box-sizing: border-box; min-width: 0; padding: 0.9em 0.4em 1.1em; scroll-margin-top: 150px; text-align: center; }
.pe-panel h2 { margin: 0 0 0.75em; font-size: 1.28em; font-weight: 700; line-height: 1.2; color: var(--pe-tone); }
.pe-tone-teal { --pe-tone: var(--pe-teal); --pe-fill: var(--pe-teal-fill); background: var(--pe-teal-panel); }
.pe-tone-ink { --pe-tone: var(--pe-grey); --pe-fill: var(--pe-grey-fill); background: var(--pe-grey-panel); }
.pe-tone-orange { --pe-tone: var(--pe-orange); --pe-fill: var(--pe-orange-fill); background: var(--pe-orange-panel); }
.pe-conclusion { margin: 1em 1.6em 1.3em; font-size: 1.32em; scroll-margin-top: 150px; }

/* Figures: a shape with its measurements, or the Finance Solver's boxes. */
.pe-figure { display: flex; align-items: center; justify-content: center; min-height: 11em; }
.pe-shape { display: block; width: 13.2em; max-width: 100%; height: auto; overflow: visible; }
.pe-fill { fill: var(--pe-fill); stroke: var(--pe-text); stroke-width: 1.6; stroke-linejoin: round; }
.pe-fill-light { fill: color-mix(in srgb, var(--pe-fill) 60%, white); }
.pe-fill-dark { fill: color-mix(in srgb, var(--pe-fill) 80%, black); }
.pe-edge { stroke: var(--pe-text); stroke-width: 1.6; }
.pe-dot { fill: var(--pe-text); }
.pe-num { font-family: var(--pe-serif); font-size: 21px; text-anchor: middle; dominant-baseline: central; fill: var(--pe-tone); }
.pe-num-mid { font-size: 23px; }
.pe-num-big { font-size: 28px; }
.pe-num-left { text-anchor: start; }
.pe-pi { font-style: italic; }
.pe-solver {
    border: 0.09em solid var(--pe-text);
    border-radius: 0.3em;
    border-collapse: separate;
    border-spacing: 0;
    padding: 0.45em 0.7em 0.5em;
    background: var(--paper);
    font-size: 0.9em;
    line-height: 1.28;
    text-align: left;
}
.pe-solver thead th { padding: 0 0 0.3em; font-weight: 700; white-space: nowrap; }
.pe-solver tbody tr:first-child > * { padding-top: 0.45em; border-top: 0.07em solid var(--pe-text); }
.pe-solver tbody th { padding: 0 1.4em 0 0; font-weight: 500; }
.pe-solver td { padding: 0; font-family: var(--pe-serif); font-size: 1.06em; text-align: right; white-space: nowrap; }
.pe-solver .is-solved td { font-weight: 700; color: var(--pe-tone); }

.pe-maths { overflow-x: auto; overflow-y: hidden; font-size: 1.04em; }
.pe-maths mjx-container[display="true"] { margin: 0.5em 0 0; }
.pe-maths .mjx-pe-key { color: var(--pe-tone); }

/* What a step has not reached yet is held back; without the script the whole
   slide shows. Side by side, a part keeps its place while it waits. */
.pe.is-live [data-pe-step],
.pe.is-live [class*="mjx-pe-s"] { transition: opacity 0.6s ease; }
.pe.is-live:not(.pe-on-2) [data-pe-step="2"],
.pe.is-live:not(.pe-on-3) [data-pe-step="3"],
.pe.is-live:not(.pe-on-4) [data-pe-step="4"],
.pe.is-live:not(.pe-on-8) [data-pe-step="8"] { visibility: hidden; opacity: 0; }
.pe.is-live:not(.pe-on-5) .mjx-pe-s5,
.pe.is-live:not(.pe-on-6) .mjx-pe-s6,
.pe.is-live:not(.pe-on-7) .mjx-pe-s7 { visibility: hidden; opacity: 0; }

.pe-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin: 18px 16px 0; }
.pe-pager .mw-link { display: inline-flex; align-items: center; gap: 0.35em; min-height: 44px; }

/* The list of a deck's examples. */
.pe-list { display: grid; gap: 0.6em; margin: 0 1.6em 1.6em; padding: 0; list-style: none; }
.pe-item {
    display: flex;
    align-items: center;
    gap: 0.9em;
    min-height: 44px;
    padding: 0.7em 0.9em;
    border: 1px solid var(--line);
    background: var(--pe-grey-panel);
    text-decoration: none;
    color: var(--pe-text);
}
.pe-item:hover { border-color: var(--pe-teal); background: var(--pe-teal-panel); }
.pe-item:focus-visible { outline: 3px solid var(--tangerine); outline-offset: 2px; }
.pe-item-n {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 2.2em;
    height: 2.2em;
    border-radius: 50%;
    background: var(--pe-teal);
    font-weight: 700;
    color: var(--paper);
}
.pe-item-text { display: flex; flex: 1 1 auto; flex-direction: column; gap: 0.15em; min-width: 0; }
.pe-item-text b { font-size: 1.1em; color: var(--pe-teal); }
.pe-item-go { flex: 0 0 auto; font-size: 1.3em; color: var(--pe-orange); }

@media (min-width: 860px) {
    .pe-stage { max-width: max(860px, calc((100vh - 150px) * 1.62)); }
    .pe-index .pe-stage { max-width: 1100px; }
    .pe-slide { font-size: clamp(13px, 1.36cqw, 34px); }
    .pe-index .pe-slide { font-size: 17px; }
    .pe-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .pe-caption { font-size: clamp(1.125rem, 1.5vw, 1.75rem); }
}

/* On a phone the columns stack in the same order, and a part that is still
   waiting takes no room, so the next step is never a screen away. */
@media (max-width: 859.98px) {
    .pe.is-live:not(.pe-on-2) [data-pe-step="2"],
    .pe.is-live:not(.pe-on-3) [data-pe-step="3"],
    .pe.is-live:not(.pe-on-4) [data-pe-step="4"],
    .pe.is-live:not(.pe-on-8) [data-pe-step="8"] { display: none; }
    .pe-stage { padding: 0 10px; }
    .pe-band { padding: 0.8em 1em; }
    .pe-band h1 { font-size: 1.2em; }
    .pe-band p { font-size: 0.9em; }
    .pe-question, .pe-conclusion { margin-right: 1em; margin-left: 1em; font-size: 1.1em; }
    .pe-cols, .pe-list { margin-right: 1em; margin-left: 1em; }
    .pe-figure { min-height: 0; }
    .pe-actions { flex: 1 1 100%; }
    .pe-actions .mw-btn { flex: 1 1 auto; padding: 0 12px; }
    .pe-caption { font-size: 1rem; }
}

@media (max-width: 400px) {
    .pe-maths { font-size: 0.94em; }
}

@media (prefers-reduced-motion: reduce) {
    .pe.is-live [data-pe-step],
    .pe.is-live [class*="mjx-pe-s"] { transition: none; }
}

/* On paper the finished slide is printed. */
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    .pe-bar, .pe-stepbar, .pe-pager { display: none; }
    .pe-stage { max-width: none; padding: 0; }
    .pe-slide { border: 0; }
    .pe.is-live [data-pe-step],
    .pe.is-live [class*="mjx-pe-s"] { display: revert; visibility: visible; opacity: 1; }
    .pe-band, .pe-panel, .pe-fill, .pe-count { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
