/* Year 9 Science, Unit 1: the lab pages (science/lab_pages.py). Written for
 * the 1.6 "Alkali metals in water" demo, the first of them, which is why the
 * classes say "alk".
 *
 * A reading page in the house tokens, one colour per step so the parts are
 * told apart at a glance: gold for the lab (the 1.6 strand colour on the unit
 * page), teal for the handout, cyan for the videos, tangerine for "Spot the
 * fake", and ink for the teachers' panel. Colour is never the only cue: every
 * step has its number and its heading. */

.alk {
    --alk-step: var(--gold);
    --alk-step-soft: color-mix(in srgb, var(--alk-step) 12%, var(--paper));
    --alk-step-ink: color-mix(in srgb, var(--alk-step) 45%, var(--ink));
    /* The page pictures: the first page's width and the thumbnails', on a
     * wide screen and on a phone; the two-column handout+answers grid sets
     * its own. */
    --alk-first: 9.5rem;
    --alk-thumb: 7.5rem;
    --alk-first-phone: 7.5rem;
    --alk-thumb-phone: 6rem;
    max-width: 60rem;
    margin: 0 auto;
    padding: 1.5rem 16px 3rem;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--ink);
}

.alk-kicker {
    margin: 0 0 0.25rem;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.alk h1 { margin: 0 0 0.75rem; font-size: clamp(1.75rem, 5vw, 2.5rem); line-height: 1.15; font-weight: 800; }

.alk-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.9375rem;
}
.alk-back { color: var(--teal-deep); font-weight: 600; text-decoration: none; }
.alk-back:hover { text-decoration: underline; }
.alk-lang { display: inline-flex; gap: 0.25rem; margin-left: auto; }
.alk-lang a {
    padding: 0.125rem 0.625rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8125rem;
}
.alk-lang a[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.alk :focus-visible { outline: 3px solid var(--teal-deep); outline-offset: 2px; border-radius: 4px; }

.alk-preview {
    margin: 0 0 1.25rem;
    padding: 0.6rem 0.9rem;
    border: 1px dashed var(--ink);
    border-radius: 10px;
    background: var(--cream);
    font-size: 0.9375rem;
    font-weight: 600;
}

/* ------------------------------------------------------------- the steps */

.alk-step {
    margin: 0 0 1.5rem;
    padding: 1.25rem 1.25rem 1.1rem;
    border: 1px solid color-mix(in srgb, var(--alk-step) 40%, var(--line));
    border-top: 6px solid var(--alk-step);
    border-radius: 16px;
    background: var(--paper);
}
.alk-step--sheet { --alk-step: var(--teal); }
.alk-step--videos { --alk-step: var(--cyan); }
.alk-step--fake { --alk-step: var(--tangerine); }

.alk-step h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
}
.alk-num {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 10px;
    background: var(--alk-step);
    color: var(--ink);
    font-size: 1.125rem;
    font-weight: 800;
}
.alk-step h3 { margin: 1.25rem 0 0.4rem; font-size: 1.125rem; font-weight: 800; line-height: 1.3; }
.alk-step p { margin: 0 0 0.85rem; }
.alk-step ul, .alk-step ol { margin: 0 0 0.85rem; padding-left: 1.4rem; }
.alk-step li { margin-bottom: 0.4rem; }

/* The Lesson tab's pointer to the extension: only the phone layout has tabs
   (science-lab-phone.css shows it); on one long page the step is just below. */
.alk-step--pointer { display: none; }

.alk-predict {
    padding: 0.6rem 0.9rem;
    border-left: 5px solid var(--alk-step);
    border-radius: 0 10px 10px 0;
    background: var(--alk-step-soft);
    font-weight: 600;
}
.alk-safety {
    padding: 0.7rem 0.9rem;
    border: 2px solid var(--ink);
    border-radius: 10px;
    background: var(--cream);
}
.alk-safety i { margin-right: 0.25rem; }
.alk-note { margin: 0.5rem 0 0; font-size: 0.9063rem; color: var(--muted); }

/* --------------------------------------------------------------- buttons */

.alk-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.alk-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 2px solid var(--teal-deep);
    border-radius: 10px;
    background: var(--paper);
    color: var(--teal-deep);
    font-size: 0.9688rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
}
.alk-btn:hover { background: var(--mint); }
.alk-btn--main { background: var(--teal-deep); color: var(--paper); }
.alk-btn--main:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------------------------------------------------------------- videos */

.alk-vids {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
    gap: 1rem;
}
.alk-vids--one { grid-template-columns: minmax(0, 26rem); }
.alk-vid {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
}
.alk-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--ink); }
.alk-thumb img, .alk-thumb iframe { display: block; width: 100%; height: 100%; border: 0; object-fit: cover; }
.alk-thumb iframe { position: absolute; inset: 0; }
.alk-play { position: absolute; inset: 0; display: block; }
.alk-play-btn {
    position: absolute;
    inset: 0;
    width: 58px;
    height: 42px;
    margin: auto;
    border-radius: 12px;
    background: var(--tangerine);
}
.alk-play-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-40%, -50%);
    border-style: solid;
    border-width: 9px 0 9px 15px;
    border-color: transparent transparent transparent var(--ink);
}
.alk-play:hover .alk-play-btn { background: color-mix(in srgb, var(--tangerine) 86%, var(--paper)); }
.alk-vmeta { padding: 0.75rem 0.9rem 0.85rem; font-size: 0.9375rem; font-weight: 600; line-height: 1.4; }
.alk-vtitle { display: block; overflow-wrap: anywhere; }
.alk-vmeta small { display: block; margin-top: 0.25rem; font-weight: 400; color: var(--muted); }
.alk-vmeta a { color: var(--teal-deep); }

/* ---------------------------------------------------------- spot the fake */

.alk-fakegrid {
    display: grid;
    grid-template-columns: minmax(0, 26rem) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    margin-bottom: 1rem;
}
.alk-ask {
    padding: 0.9rem 1rem 0.4rem;
    border-radius: 14px;
    background: var(--alk-step-soft);
}
.alk-ask h3 { margin-top: 0; }

.alk-reveal { border: 2px solid var(--ink); border-radius: 14px; background: var(--cream); }
.alk-reveal summary {
    min-height: 44px;
    padding: 0.7rem 1rem;
    font-weight: 800;
    cursor: pointer;
}
.alk-reveal[open] summary { border-bottom: 1px solid var(--line); }
.alk-reveal-body { padding: 0.25rem 1rem 1rem; }
.alk-facts li { margin-bottom: 0.6rem; }
.alk-src {
    display: inline-block;
    padding: 0 0.5rem;
    border: 1px solid var(--alk-step-ink);
    border-radius: 999px;
    color: var(--alk-step-ink);
    font-size: 0.8125rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.alk-src:hover { background: var(--alk-step-soft); text-decoration: underline; }
.alk-think {
    padding: 0.6rem 0.9rem;
    border-left: 5px solid var(--gold);
    border-radius: 0 10px 10px 0;
    background: var(--paper);
    font-weight: 600;
}
.alk-sources a { color: var(--teal-deep); overflow-wrap: anywhere; }

/* ----------------------------------------------------------- for teachers */

.alk-teacher {
    margin-top: 2rem;
    padding: 1.25rem;
    border-radius: 16px;
    background: var(--ink);
    color: var(--paper);
}
.alk-teacher h2 { margin: 0 0 0.5rem; font-size: 1.375rem; font-weight: 800; color: var(--paper); }
.alk-teacher h2 i { margin-right: 0.4rem; color: var(--gold); }
.alk-teacher p { margin: 0 0 0.9rem; color: var(--paper); }
.alk-teacher .alk-note { color: var(--mint2); }
.alk-files { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.6rem; }
.alk-files li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    background: var(--paper);
    color: var(--ink);
}
.alk-file-text { flex: 1 1 16rem; min-width: 0; }
.alk-file-text b { display: block; }
.alk-file-text small { display: block; color: var(--muted); }
.alk-file-go { display: inline-flex; flex-wrap: wrap; gap: 0.5rem; }
.alk-files .alk-note { color: var(--muted); margin: 0; }
.alk-picture { margin: 0 0 1rem; padding: 0.75rem; border-radius: 12px; background: var(--paper); color: var(--ink); }
.alk-picture img { display: block; width: 100%; height: auto; }
.alk-picture figcaption { margin-top: 0.4rem; font-size: 0.875rem; color: var(--muted); }

@media (max-width: 767.98px) {
    .alk-fakegrid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 575.98px) {
    .alk { font-size: 1rem; padding-top: 1rem; }
    .alk-step { padding: 1rem 0.9rem 0.9rem; }
    .alk-step h2 { font-size: 1.3125rem; }
}

@media print {
    .alk-step { break-inside: avoid; border-color: var(--ink); }
    .alk-reveal { display: none; }
}

/* The interactive step. */
.alk-step--try { --alk-step: var(--gold); }
.alk-notes { margin-top: 14px; }

/* Lab pages with a plan of several lessons and one handout per lesson. */
.alk-plan { margin-bottom: 0.85rem; }
.alk-sheet + .alk-sheet { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.alk-sheet-title { margin: 0 0 0.15rem; font-size: 1.125rem; font-weight: 800; line-height: 1.3; }
.alk-sheet > .alk-note { margin: 0 0 0.6rem; }

/* ----------------------------------------- the handout and its answers
 * A lab with an answers file for students shows it BESIDE the handout: two
 * columns on a wide screen, the answers under the handout on a phone. The
 * answers' pictures start behind a "Show the answers" cover (a native
 * <details>, so no script is needed): a blurred first page and the button. */

.alk-sheetgrid--two { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.alk-col { min-width: 0; }
.alk-col-h { margin: 0 0 0.5rem; font-size: 1.125rem; font-weight: 800; line-height: 1.3; }
.alk-col--answers {
    padding: 0.9rem 1rem 0.4rem;
    border: 1px dashed var(--teal-deep);
    border-radius: 12px;
    background: var(--mint);
}
.alk-col--answers > .alk-note { margin: 0 0 0.6rem; }
.alk-answers { margin: 0 0 0.6rem; }
.alk-answers-cover {
    position: relative;
    display: block;
    min-height: 44px;
    overflow: hidden;
    border-radius: 8px;
    list-style: none;
    cursor: pointer;
}
.alk-answers-cover::-webkit-details-marker { display: none; }
.alk-answers-blur {
    display: block;
    width: 100%;
    height: auto;
    max-height: 10rem;
    object-fit: cover;
    object-position: top;
    border-radius: 6px;
    filter: blur(7px);
    opacity: 0.8;
    pointer-events: none;
}
.alk-answers-show, .alk-answers-hide { position: absolute; top: 0.6rem; left: 0.6rem; }
.alk-answers-hide { display: none; }
.alk-answers[open] > .alk-answers-cover { min-height: 0; }
.alk-answers[open] > .alk-answers-cover .alk-answers-blur { display: none; }
.alk-answers[open] > .alk-answers-cover .alk-answers-show { display: none; }
.alk-answers[open] > .alk-answers-cover .alk-answers-hide { position: static; display: inline-flex; }
.alk-answers-body { padding-top: 0.75rem; }
.alk-answers-body .alk-note { margin-bottom: 0; }
.alk-sheetgrid--two { --alk-first: 9.5rem; --alk-thumb: 5.5rem; --alk-first-phone: 7.5rem; --alk-thumb-phone: 5.5rem; }
@media (min-width: 768px) {
    .alk-sheetgrid--two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
@media print {
    .alk-answers-cover { display: none; }
}

/* ------------------------------------------------- pictures of the pages
 * A handout's pages as a row of pictures: the first large enough to read
 * its title, the rest as thumbnails, each labelled "Page n of N". On a
 * phone the row scrolls sideways so the section stays about one screen. */

.alk-gallery { margin: 0 0 0.85rem; }
.alk-pages-hint { margin: 0 0 0.5rem; font-size: 0.9063rem; color: var(--muted); }
.alk-pages {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 0 0 0.85rem;
    padding: 0;
}
.alk-page { flex: 0 0 auto; width: var(--alk-thumb); }
.alk-page:first-child { width: var(--alk-first); }
/* ONLY THE COVER is drawn (the owner, 2026-10-07: a row of every page of the
 * handout and of the answers "is quite a lot of space"). The other pages stay
 * in the list, unseen, so the reader that opens on a tap (lab-gallery.js)
 * still turns through all of them; a picture that is not drawn is not
 * fetched either. */
.alk-page:not(:first-child) { display: none; }
.alk-page-link { display: block; color: var(--ink); text-decoration: none; }
.alk-page-link img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 210 / 297;
    object-fit: cover;
    object-position: top;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.alk-page-link:hover img, .alk-page-link:focus-visible img {
    border-color: var(--teal-deep);
    box-shadow: 0 0 0 3px var(--mint2);
}
.alk-page-label {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    color: var(--muted);
}

/* The teachers-only answers block under the handouts. */
.alk-step--key { --alk-step: var(--ink); background: var(--cream); }
.alk-step--key h2 i { margin-right: 0.2rem; color: var(--gold); }
.alk-step--key > .alk-file-text { margin-bottom: 0.6rem; }

/* A teacher file that is a picture (the particle picture) is shown. */
.alk-files-picture .alk-file-img {
    flex: 1 1 100%;
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

/* ------------------------------------------------------ the page dialog
 * One page at reading size, previous/next through the pages, Download.
 * Native <dialog>: Esc closes and focus stays in. The body scrolls, so a
 * tall page can be read, and nothing blocks the browser's pinch zoom. */

dialog.alk-lv {
    width: min(78rem, calc(100vw - 32px));
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    box-shadow: 0 30px 80px color-mix(in srgb, var(--ink) 35%, transparent);
}
dialog.alk-lv[open] { display: flex; flex-direction: column; overflow: hidden; }
dialog.alk-lv::backdrop { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.alk-lv-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem 0.6rem 1rem;
    border-bottom: 1px solid var(--line);
}
.alk-lv-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.alk-lv-pos { font-size: 0.8125rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.alk-lv-nav, .alk-lv-x {
    flex: none;
    width: 44px;
    height: 44px;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.alk-lv-nav:hover, .alk-lv-x:hover { background: var(--mint); border-color: var(--teal-deep); }
.alk-lv-nav:disabled { opacity: 0.35; cursor: default; }
.alk-lv-nav:disabled:hover { background: var(--paper); border-color: var(--line); }
.alk-lv .alk-lv-download { margin: 0 0.25rem; }
.alk-lv-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 1rem;
    background: var(--cream);
    -webkit-overflow-scrolling: touch;
}
.alk-lv-img {
    display: block;
    width: 100%;
    max-width: 60rem;
    height: auto;
    margin: 0 auto;
    background: var(--paper);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

@media (max-width: 767.98px) {
    dialog.alk-lv {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .alk-lv-head { flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 0.5rem 0.5rem 0.75rem; }
    .alk-lv-title { flex-basis: 100%; white-space: normal; font-size: 0.9375rem; }
    .alk-lv-pos { margin-right: auto; }
    .alk-lv-body { padding: 0; }
    .alk-lv-img { max-width: none; box-shadow: none; }
}
@media (max-width: 575.98px) {
    .alk-pages {
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        padding-bottom: 0.4rem;
        -webkit-overflow-scrolling: touch;
    }
    .alk-page { width: var(--alk-thumb-phone); scroll-snap-align: start; }
    .alk-page:first-child { width: var(--alk-first-phone); }
    .alk-answers-blur { max-height: 6rem; }
    .alk-col--answers { padding: 0.75rem 0.75rem 0.3rem; }
}
@media (prefers-reduced-motion: reduce) {
    .alk-pages { scroll-behavior: auto; }
}
@media print {
    .alk-gallery, .alk-step--key, dialog.alk-lv { display: none !important; }
}
.alk-sheets li { border: 1px solid var(--line); }

/* A lab page sits in the unit's shell, beside the unit's side menu. There is
   no unit header above it, so the menu pins under the site bar. */
.sci-labunit { --sci-head-h: 0px; }
.sci-labmain { padding-bottom: 40px; }
.sci-labunit .sci-sublink.is-on { background: var(--mint); box-shadow: inset 0 0 0 2px var(--tangerine); }

/* A video this reader may not play: the card and its title stay, the frame
 * says how (accounts/templatetags/usage_tags.py, coffee_ask). */
.sci-vlock {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.35rem;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: inherit;
    background: var(--ink);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    color: var(--paper);
}
.sci-vlock-note { margin: 0.5rem 0 0; font-size: 0.9rem; }
