/* ========================================
   Choosing Classlings at the board (js/classlings-chooser.js)
   A screen over the Today screen: who's choosing, then the Classlings that pupil owns, then a cheer.
   Every pupil owns Kit, Ribbit, Cub and Hop; anyone can change their champion any time.
   ======================================== */

.clc-open {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: 600 14px / 1 var(--cla-display, 'Fredoka', system-ui, sans-serif);
    color: var(--cla-ink, #1e1b3a);
    background: var(--cla-page, #fff);
    border: 2px solid var(--cla-ink, #1e1b3a);
    border-radius: 999px;
    box-shadow: 0 3px 0 var(--cla-ink, #1e1b3a);
    padding: 7px 11px;
    margin-bottom: 3px;
    white-space: nowrap;
    cursor: pointer;
}

.clc-open[hidden],
.clc-menu-item[hidden],
.clc[hidden],
.clc-count[hidden] {
    display: none;
}

.clc-menu-item > span:not(.clc-count) {
    white-space: nowrap;
}

/* Beside Battle on wider screens until everyone has picked a favourite, then in the More menu. On a
   phone, where the header has no room, it is always in the menu. */
@media (max-width: 760px) {
    .clc-open {
        display: none !important;
    }
}

@media (min-width: 761px) {
    .clc-menu-item:not([data-everyone-chosen]) {
        display: none !important;
    }
}

/* The one-off tip once everyone has picked: a small panel on the mix's ink edge and lift, with the
   standard small gold OK. */
.clc-tip {
    position: fixed;
    z-index: 1100;
    width: min(320px, calc(100vw - 16px));
    display: grid;
    gap: 12px;
    padding: 14px 16px;
    color: var(--cla-ink, #1e1b3a);
    background: var(--cla-page, #ffffff);
    border: 3px solid var(--cla-ink, #1e1b3a);
    border-radius: 20px;
    box-shadow: 0 6px 0 var(--cla-ink, #1e1b3a);
    font: 400 16px / 1.45 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
}

.clc-tip::before {
    content: '';
    position: absolute;
    top: -10px;
    right: 18px;
    width: 14px;
    height: 14px;
    background: var(--cla-page, #ffffff);
    border-left: 3px solid var(--cla-ink, #1e1b3a);
    border-top: 3px solid var(--cla-ink, #1e1b3a);
    transform: rotate(45deg);
}

/* Above Menu, its point at the bottom. */
.clc-tip.is-above::before {
    top: auto;
    bottom: -10px;
    transform: rotate(225deg);
}

.clc-tip p {
    margin: 0;
}

.clc-tip strong {
    font-family: var(--cla-display, 'Fredoka', system-ui, sans-serif);
    font-weight: 600;
}

.clc-tip-ok {
    justify-self: end;
    min-height: var(--ctl-small-h, 48px);
    margin: 0 0 var(--ctl-small-lift, 4px);
    padding: 0 16px;
    font: var(--ctl-small-font, 600 18px / 1.1 'Fredoka', system-ui, sans-serif);
    color: var(--cla-ink, #1e1b3a);
    background: var(--cla-gold, #f7c230);
    border: 3px solid var(--cla-gold-deep, #c98a12);
    border-radius: var(--ctl-small-r, 14px);
    box-shadow: 0 var(--ctl-small-lift, 4px) 0 var(--cla-gold-deep, #c98a12);
    cursor: pointer;
    transition: transform 460ms cubic-bezier(0.28, 1.9, 0.5, 1), box-shadow 460ms cubic-bezier(0.28, 1.9, 0.5, 1);
}

.clc-tip-ok:active {
    transform: translateY(var(--ctl-small-lift, 4px));
    box-shadow: 0 0 0 var(--cla-gold-deep, #c98a12);
    transition-duration: 70ms;
}

.clc-tip-ok:focus-visible {
    outline: 4px solid var(--cla-ink, #1e1b3a);
    outline-offset: 4px;
}

.clc-open:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 var(--cla-ink, #1e1b3a);
}

.clc-open:focus-visible {
    outline: 4px solid var(--cla-ink, #1e1b3a);
    outline-offset: 4px;
}

.clc-count {
    font: 700 12px / 1 var(--cla-display, 'Fredoka', system-ui, sans-serif);
    color: var(--cla-ink, #1e1b3a);
    background: var(--cla-gold, #f7c230);
    border: 2px solid var(--cla-ink, #1e1b3a);
    border-radius: 999px;
    padding: 2px 6px;
    font-variant-numeric: tabular-nums;
}

.clc {
    /* The mix's colours (shared/css/classlings.css), and reading words in Atkinson Hyperlegible (the
       teacher's decision E, 9 October); headings, labels and buttons in Fredoka. */
    --clc-ink: var(--cla-ink, #1e1b3a);
    --clc-ink-2: var(--cla-ink-2, #4a4766);
    --clc-page: var(--cla-page, #ffffff);
    --clc-wash: var(--cla-wash, #f3f2f9);
    --clc-wash-2: var(--cla-wash-2, #e4e1f1);
    --clc-grape: var(--cla-grape, #a07cff);
    --clc-grape-deep: var(--cla-grape-deep, #6a45dc);
    --clc-grape-tint: var(--cla-grape-tint, #eee8ff);
    --clc-lime: var(--cla-lime, #7ed957);
    --clc-lime-deep: var(--cla-lime-deep, #3e9a2a);
    --clc-display: var(--cla-display, 'Fredoka', 'Trebuchet MS', system-ui, sans-serif);
    --clc-read: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
    /* Back is a square like the bar's Home and Menu, at the bar's own size. */
    --clc-square: var(--cla-square, 78px);
    --clc-square-r: var(--cla-square-r, 28px);
    --clc-square-icon: var(--cla-square-icon, 32px);
    --clc-lift: var(--ctl-lift, 6px);
    --clc-gutter: var(--cla-gutter, 32px);
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    color: var(--clc-ink);
    background: var(--clc-page);
    font: 400 18px / 1.45 var(--clc-read);
}

/* ---------------------------------------------------------------- the page */

.clc-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: calc(16px + env(safe-area-inset-top, 0px)) var(--clc-gutter) 16px;
}

.clc-plate {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 20px 24px 24px;
    overflow-y: auto;
    background: var(--clc-page);
    border: 3px solid var(--clc-wash-2);
    border-radius: 28px;
}

.clc-q {
    margin: 0;
    font: 700 28px / 1.1 var(--clc-display);
    text-wrap: balance;
}

.clc-q strong {
    font-weight: 700;
}

.clc-line {
    max-width: 52em;
    margin: -4px 0 4px;
    font: 400 18px / 1.45 var(--clc-read);
    color: var(--clc-ink-2);
}

.clc-group {
    margin: 4px 0 0;
    font: 600 20px / 1.2 var(--clc-display);
    color: var(--clc-ink-2);
}

/* ---------------------------------------------------------------- the tiles */

/* Who's choosing: a picking tile for each pupil, those who haven't picked first. */
.clc-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 12px;
}

/* The pupils' picking tile (shared/css/classlings-pupil.css .pick): white, corners 28, a pale edge;
   purple with a ring when chosen. */
.clc-pupil,
.clc-choice {
    appearance: none;
    position: relative;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 4px;
    min-width: 0;
    margin: 0;
    padding: 8px 8px 12px;
    color: var(--clc-ink);
    font: 600 20px / 1.2 var(--clc-display);
    text-align: center;
    background: var(--clc-page);
    border: 3px solid var(--clc-wash-2);
    border-radius: 28px;
    cursor: pointer;
    transition: transform 460ms cubic-bezier(0.28, 1.9, 0.5, 1);
    -webkit-tap-highlight-color: transparent;
}

.clc-pupil:hover,
.clc-choice:hover {
    border-color: var(--clc-grape);
}

.clc-pupil:active,
.clc-choice:active {
    transform: scale(0.94);
    transition-duration: 70ms;
}

.clc-pupil canvas,
.clc-choice canvas {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
}

.clc-pupil > span {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.clc-pupil small {
    display: block;
    font: 400 16px / 1.25 var(--clc-read);
    color: var(--clc-ink-2);
}

/* One pupil's Classlings: the four starters and any they've hatched, big enough to see from the back. */
.clc-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 260px));
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
}

.clc-choice canvas {
    aspect-ratio: 1 / 1;
}

.clc-choice .clc-label {
    display: grid;
    justify-items: center;
    gap: 4px;
}

.clc-choice .clc-label strong {
    font: 600 24px / 1.1 var(--clc-display);
}

.clc-choice .clc-label span {
    font: 400 16px / 1.3 var(--clc-read);
    color: var(--clc-ink-2);
}

.clc-choice[aria-pressed="true"] {
    background: var(--clc-grape-tint);
    border-color: var(--clc-grape-deep);
    box-shadow: inset 0 0 0 3px var(--clc-grape-deep);
}

/* The champion now: the pupils' "On" marker in the tile's corner. */
.clc-choice .clc-label .clc-now {
    position: absolute;
    top: -10px;
    right: -8px;
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font: 600 16px / 1 var(--clc-display);
    color: var(--clc-ink);
    background: var(--clc-lime);
    border: 2px solid var(--clc-lime-deep);
    border-radius: 14px;
}

.clc-pupil:focus-visible,
.clc-choice:focus-visible,
.clc-back:focus-visible,
.clc-go:focus-visible {
    outline: 4px solid var(--clc-ink);
    outline-offset: 4px;
}

.clc-error {
    align-self: center;
    margin: 4px 0 0;
    padding: 10px 16px;
    font: 600 18px / 1.4 var(--clc-display);
    color: var(--clc-ink);
    text-align: center;
    background: var(--cla-tangerine-tint, #ffeddf);
    border: 3px solid var(--cla-tangerine-deep, #cf5a12);
    border-radius: 20px;
}

/* The cheer. */
.clc-done {
    display: grid;
    gap: 12px;
    justify-items: center;
    margin: auto 0;
    text-align: center;
}

.clc-done canvas {
    display: block;
    width: min(440px, 100%);
    aspect-ratio: 2 / 1;
    border: 3px solid var(--clc-wash-2);
    border-radius: 28px;
}

.clc-done h3 {
    margin: 0;
    font: 700 36px / 1.1 var(--clc-display);
    text-wrap: balance;
}

.clc-done .clc-line {
    margin: 0;
}

/* ---------------------------------------------------------------- the bar */

/* Back, the title in Classlings' lettering with the class and where you are, and the page's own button
   at the end: the Settings and Points history pattern. */
.clc-dock {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    padding: 4px var(--clc-gutter) calc(16px + env(safe-area-inset-bottom, 0px));
}

.clc-back {
    appearance: none;
    display: inline-grid;
    flex: none;
    place-items: center;
    align-content: center;
    gap: 2px;
    width: var(--clc-square);
    height: var(--clc-square);
    margin: 0 0 var(--clc-lift);
    padding: 0;
    font: 600 18px / 1 var(--clc-display);
    color: var(--clc-ink);
    background: var(--clc-page);
    border: 3px solid var(--clc-ink);
    border-radius: var(--clc-square-r);
    box-shadow: 0 var(--clc-lift) 0 var(--clc-ink);
    cursor: pointer;
    transition: transform 460ms cubic-bezier(0.28, 1.9, 0.5, 1), box-shadow 460ms cubic-bezier(0.28, 1.9, 0.5, 1);
}

.clc-back:hover {
    background: var(--clc-wash);
}

.clc-back:active {
    transform: translateY(var(--clc-lift));
    box-shadow: 0 0 0 var(--clc-ink);
    transition-duration: 70ms;
}

.clc-back-ic {
    display: block;
    width: var(--clc-square-icon);
    height: var(--clc-square-icon);
}

.clc-name {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: 12px;
    min-width: 0;
    height: var(--clc-square);
    margin: 0 0 var(--clc-lift);
    overflow: hidden;
}

/* The lettering at scale 2 (40 px tall), as the bar's page titles. */
.clc-title {
    --title-scale: 2;
    flex: none;
    margin: 0 0 calc(var(--title-scale) * -4px);
    line-height: 0;
    white-space: nowrap;
}

.clc-title svg {
    display: block;
    width: calc(var(--title-scale) * var(--w) * 1px);
    height: calc(var(--title-scale) * var(--h) * 1px);
}

.clc-title.is-text {
    margin: 0;
    font: 600 26px / 1.2 var(--clc-display);
}

.clc-when {
    display: grid;
    flex: 0 1 auto;
    gap: 2px;
    min-width: 0;
    margin: 0;
    font: 600 20px / 1.1 var(--clc-display);
    white-space: nowrap;
}

.clc-when > * {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clc-when b {
    font-weight: 600;
}

.clc-when span {
    font: 400 16px / 1.2 var(--clc-read);
    color: var(--clc-ink-2);
}

/* The page's own button: the standard's gold (shared/css/classlings-controls.css .cla-btn.is-gold),
   centred on the bar's middle line. */
.clc-bar {
    display: flex;
    flex: none;
    gap: 12px;
}

.clc-bar:empty {
    display: none;
}

.clc-bar .clc-go {
    margin-bottom: calc(var(--clc-lift) + (var(--clc-square) - var(--ctl-h, 56px)) / 2);
}

.clc-bar .clc-go:disabled {
    cursor: default;
}

@media (max-width: 640px) {
    .clc {
        --clc-gutter: 16px;
    }

    .clc-body {
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
        padding-bottom: 12px;
    }

    .clc-plate {
        padding: 16px;
    }

    .clc-q {
        font-size: 24px;
    }

    .clc-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .clc-choices {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .clc-choice .clc-label strong {
        font-size: 20px;
    }

    .clc-done h3 {
        font-size: 28px;
    }

    /* The page's button takes a row of its own above Back and the title. */
    .clc-bar {
        flex: 1 1 100%;
        order: -1;
    }

    .clc-bar .clc-go {
        flex: 1;
        min-width: 0;
        margin-bottom: var(--clc-lift);
        white-space: normal;
    }

    /* A phone's bar has room for Back and the title only. */
    .clc-when {
        display: none;
    }
}

/* Short screens (a school laptop's 540 to 600 px of page): smaller pictures, so a pupil's four fit. */
@media (max-height: 700px) and (min-width: 641px) {
    .clc-plate {
        padding: 14px 20px 18px;
        gap: 8px;
    }

    .clc-choices {
        grid-template-columns: repeat(auto-fit, minmax(160px, 220px));
    }

    .clc-choice canvas {
        aspect-ratio: 4 / 3;
    }
}

@media (prefers-reduced-motion: reduce) {
    .clc-pupil,
    .clc-choice,
    .clc-back {
        transition: none;
    }
}
