/* Scalars: a balance scale. Colours come from /css/theme.css, so light and
   dark follow the device like the rest of the site. */

/* hidden must win over any display rule below (.review is a grid). */
[hidden] { display: none !important; }

/* Read by screen readers, never seen: the maths in words, misses left,
   what just happened. */
.sr {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* The page itself, or dark mode puts light ink on the browser's white. */
body {
    margin: 0;
    background: var(--bg, #f6f3ec);
    color: var(--ink, #2b2a33);
    font: 17px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.scalars {
    --bad: var(--short);
    max-width: 40rem;
    margin: 0 auto;
    padding: 1rem;
    color: var(--ink);
    text-align: center;
}

.masthead h1 { margin: .5rem 0 0; font-size: 2.2rem; letter-spacing: .02em; }
.tagline { margin: .25rem 0 1rem; color: var(--muted); font-style: italic; }
.lede { max-width: 30rem; margin: 0 auto 1rem; }
h2 { font-size: 1.1rem; margin: 1rem 0 .5rem; }

button {
    font: inherit;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: .6rem;
    cursor: pointer;
}
button:focus-visible, .level:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.go { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); padding: .7rem 2rem; font-size: 1.1rem; }

/* ---------- levels ---------- */

.levels {
    display: grid;
    grid-template-columns: minmax(0, 22rem) auto;
    justify-content: center;
    align-items: center;
    gap: .5rem 1rem;
    margin-bottom: 1rem;
}
.levels .head { font-weight: bold; text-align: left; }
.levels .mine-head { max-width: 6rem; text-align: center; font-size: .85rem; line-height: 1.2; }
.level {
    /* A link that looks like the other buttons. */
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: .6rem;
    text-decoration: none;
    display: grid;
    grid-template-columns: 1.5rem 1fr;
    align-items: center;
    gap: .75rem;
    padding: .6rem .8rem;
    text-align: left;
}
.level:hover { background: var(--card-hover); }
.level.last { border-color: var(--accent); }
.level .n { font-size: 1.4rem; font-weight: bold; color: var(--accent); }
.level .sample { font-size: 1.05rem; }
.level .vs { color: var(--muted); padding: 0 .3rem; }
.level .side { white-space: nowrap; }   /* a narrow screen breaks at the ?, never inside a side */
.levels .mine { font-size: 1.2rem; font-weight: bold; text-align: center; }

/* ---------- status ---------- */

.status { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.weights { display: flex; gap: .3rem; }
.weight {
    width: 1rem; height: .9rem;
    background: var(--ink);
    clip-path: polygon(25% 0, 75% 0, 100% 100%, 0 100%);   /* a little weight */
}
.weight.gone { opacity: .15; }
.score { font-size: 1.6rem; font-weight: bold; }
.level-tag { color: var(--muted); }
.level-tag.up { animation: up 1.2s ease-out; }
@keyframes up {
    0% { color: var(--good); transform: scale(1.6); }
    100% { color: var(--muted); transform: scale(1); }
}

/* ---------- the scale ---------- */

.scale { position: relative; padding-bottom: 4.5rem; margin: 1rem 0 .5rem; }
.pans { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pan {
    min-height: 5.5rem;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    padding: .4rem .3rem .6rem;
    border-bottom: 4px solid var(--ink);
    border-radius: 0 0 50% 50% / 0 0 1.2rem 1.2rem;   /* a shallow dish */
    transition: transform .35s ease;
}
.expr { font-size: clamp(1.1rem, 5.5vw, 2.3rem); line-height: 1.3; white-space: nowrap; }
.val { min-height: 1.4rem; color: var(--muted); font-size: 1rem; }

.beam {
    position: absolute; left: 22%; right: 22%; bottom: 3.6rem;
    height: .35rem; background: var(--ink); border-radius: .2rem;
    transition: transform .35s ease;
}
.post {
    position: absolute; left: 50%; bottom: 0; width: 2.4rem; height: 3.8rem;
    transform: translateX(-50%);
    background: var(--ink);
    clip-path: polygon(50% 0, 62% 85%, 100% 100%, 0 100%, 38% 85%);
}

/* The heavier side sinks. */
.scale[data-tilt="left"] .beam { transform: rotate(-6deg); }
.scale[data-tilt="left"] #pan-left { transform: translateY(.9rem); }
.scale[data-tilt="left"] #pan-right { transform: translateY(-.9rem); }
.scale[data-tilt="right"] .beam { transform: rotate(6deg); }
.scale[data-tilt="right"] #pan-left { transform: translateY(-.9rem); }
.scale[data-tilt="right"] #pan-right { transform: translateY(.9rem); }

/* Asked for less motion: the scale jumps to its tilt, and a level up only
   turns green for a moment. */
@media (prefers-reduced-motion: reduce) {
    .pan, .beam { transition: none; }
    .level-tag.up { animation: up-still 1.2s step-end; }
}
@keyframes up-still {
    0% { color: var(--good); }
    100% { color: var(--muted); }
}

/* ---------- maths ---------- */

.op { padding: 0 .1em; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; font-size: .85em; line-height: 1.1; }
.frac .top { border-bottom: .08em solid currentColor; padding: 0 .15em; }
.sqrt .rad { border-top: .08em solid currentColor; padding: 0 .1em; }
.int { display: inline-flex; align-items: center; font-size: 1.25em; }
.int .lims { display: inline-flex; flex-direction: column; font-size: .5em; line-height: 1.1; margin-left: .05em; }
sup, sub { font-size: .6em; }

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

.buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .6rem; }
.choice { min-height: 4.5rem; font-size: 1.8rem; touch-action: manipulation; }
.choice[data-choice="balance"] { font-size: 1.1rem; font-weight: bold; }
.choice.is-right { background: var(--good); color: var(--accent-ink); border-color: var(--good); }
.choice.is-wrong { background: var(--bad); color: var(--accent-ink); border-color: var(--bad); }
.choice.is-answer { box-shadow: 0 0 0 3px var(--good); }
.keys { color: var(--muted); font-size: .8rem; }
@media (pointer: coarse) { .keys { display: none; } }

/* ---------- over ---------- */

.big { font-size: 1.6rem; font-weight: bold; }
.best { color: var(--muted); }
.again { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin: 1rem 0; }
.again button:not(.go) { padding: .7rem 1.2rem; }
.seed { color: var(--muted); font-size: .8rem; }

/* ---------- review ---------- */

.review { counter-reset: q; list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .4rem; text-align: left; }
.review li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .1rem .8rem;
    padding: .5rem .8rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--good);
    border-radius: .5rem;
    counter-increment: q;
}
.review li.miss { border-left-color: var(--bad); }
.review .sides { grid-column: 1 / -1; font-size: 1.15rem; white-space: nowrap; }
.review .sides::before { content: counter(q) ". "; color: var(--muted); font-size: .85rem; }
.review .vs { color: var(--muted); padding: 0 .2rem; }
.review .why { grid-row: 2; grid-column: 2; color: var(--muted); font-size: .85rem; text-align: right; }
.review .pick { grid-row: 2; grid-column: 1; color: var(--muted); font-size: .85rem; }
/* Your pick in red when it was wrong; the right answer always in green. */
.review .got { color: var(--good); }
.review .lost { color: var(--bad); }

/* ---------- saved results ---------- */

/* A link dressed as one of the buttons beside it. */
.button {
    display: inline-block;
    padding: .7rem 1.2rem;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: .6rem;
    text-decoration: none;
}
.button.go { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.save-hint, .save-msg { color: var(--muted); font-size: .9rem; }
.save-hint a { color: var(--accent); }
.save-panel {
    max-width: 28rem;
    margin: 0 auto 1rem;
    padding: .6rem 1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: .6rem;
}
.save-panel p { margin: .4rem 0; }
.save-panel a { color: var(--accent); overflow-wrap: anywhere; }
.missing { color: var(--bad); }
.who { color: var(--muted); }

/* A player's name chip (partials/player_name.tpl.php), as the site's styles.css draws it. */
.Handle {
    display: inline-flex;
    align-items: center;
    gap: .25em;
    margin-left: .4em;
    padding: .05em .45em;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: .8em;
    color: var(--accent);
    background: var(--card-hover);
    border: 1px solid var(--line);
    border-radius: 999px;
    vertical-align: .1em;
    white-space: nowrap;
}
.HandleBadge { font-size: .85em; }

/* ---------- your results ---------- */

.saved-results li.quiet { border-left-color: var(--line); }
.saved-results a, .results-page .tagline a { color: var(--accent); }
.saved-results .actions form { display: flex; gap: .4rem; justify-content: flex-end; }
.saved-results .actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.saved-results .actions button { padding: .3rem .6rem; font-size: .85rem; }

/* ---------- challenges ---------- */

.versus { margin: -.2rem 0 0; color: var(--muted); font-size: .9rem; }
.cheer { margin: .2rem 0 0; font-weight: 600; color: var(--accent); }
