/* =========================================================================
   SETTABLE LEVEL BADGE

   The badge itself is still app-layout.css's `.level-badge` + `.level-1/2/3` —
   the colours, the pill shape and the pop-in animation all stay. This file only
   turns it from a label into a control, and adds the picker it opens.

   `.level-badge` sets `cursor: default` and is written for a <span>; the
   `.is-settable` rules below undo exactly that much and no more, so an
   unratable badge (a question with no resolvable key) looks identical to how
   it always did.
   ========================================================================= */

.level-badge.is-settable {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    line-height: 1.35;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.level-badge.is-settable:hover {
    transform: translateY(-1px);
    filter: brightness(1.12);
}

.level-badge.is-settable:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* The one thing the badge has to say that it never had to before: whether this
   is the student's own rating or the value the question shipped with. Without
   the mark, a tap that saved and a tap that did nothing look the same. */
.level-badge .ql-mark {
    font-size: 0.62rem;
    opacity: 0.85;
}

.level-badge.is-mine {
    box-shadow: inset 0 0 0 1px currentColor, 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ── picker ─────────────────────────────────────────────────────────────── */

.ql-pop,
.ql-pop * {
    box-sizing: border-box;
}

.ql-pop {
    position: fixed;
    z-index: 2147483000;
    width: 258px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--line, #262e3a);
    background: var(--surface-solid, #151a22);
    color: var(--text-main, #eef2f8);
    box-shadow: var(--shadow-md, 0 16px 44px rgba(0, 0, 0, 0.4));
    animation: qlRise 0.16s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ql-pop[hidden] {
    display: none;
}

@keyframes qlRise {
    from { opacity: 0; transform: translateY(-5px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ql-pop { animation: none; }
    .level-badge.is-settable { transition: none; }
}

.ql-pop-title {
    margin: 0 0 10px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted, #939eaf);
}

/* "for you" is the whole point of the feature, so it is the emphasis rather
   than a footnote. */
.ql-pop-title em {
    font-style: normal;
    color: var(--text-main, #eef2f8);
}

.ql-pop-rows {
    display: grid;
    gap: 6px;
}

/* Each row carries the tone of the level it sets, so the choice reads as a
   choice about difficulty and not as three identical buttons.

   The tone comes from the semantic tokens, NOT from `.level-1/2/3`. Those three
   are tuned for a dark question card — #81c784, #ffcc80, #ef9a9a — and on the
   light theme's #f3f6fb row they are close to invisible. --success/--warning/
   --danger already switch with the theme in premium-ui.css and are legible on
   both grounds. */
.ql-opt[data-level="1"] { --ql-tone: var(--success, #4cc38a); }
.ql-opt[data-level="2"] { --ql-tone: var(--warning, #f0b429); }
.ql-opt[data-level="3"] { --ql-tone: var(--danger, #f2776b); }

.ql-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 11px;
    border: 1px solid var(--line, #262e3a);
    background: var(--surface-raised, #1c222c);
    color: var(--text-main, #eef2f8);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.14s ease, background 0.14s ease;
}

/* An outlined chip rather than a filled one, because a fill would have to be
   `background: currentColor` — and setting `color` on the same element to get a
   readable digit redefines what currentColor means, so the chip paints itself
   white on white. The ring needs no second colour. */
.ql-opt .ql-opt-n {
    flex: none;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--ql-tone);
    background: none;
    color: var(--ql-tone);
    font-size: 0.72rem;
    font-weight: 800;
}

.ql-opt-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ql-opt-copy b {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--ql-tone);
}

.ql-opt-copy small {
    font-size: 0.72rem;
    color: var(--text-muted, #939eaf);
}

.ql-opt:hover {
    border-color: var(--ql-tone);
}

.ql-opt.is-on {
    border-color: var(--ql-tone);
    background: color-mix(in srgb, var(--ql-tone) 13%, transparent);
}

.ql-reset {
    width: 100%;
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid var(--line, #262e3a);
    background: none;
    color: var(--text-muted, #939eaf);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.ql-reset:hover {
    color: var(--text-main, #eef2f8);
}

.ql-reset[hidden] {
    display: none;
}

.ql-pop-foot {
    margin: 10px 0 0;
    font-size: 0.71rem;
    line-height: 1.45;
    color: var(--text-muted, #939eaf);
}

/* ── the badge in review and on the result page ─────────────────────────── */

/* Those rows are rebuilt on every Next/Previous, and re-running the badge's
   pop-in each time reads as a glitch rather than as an entrance. */
.ql-inline {
    animation: none;
    opacity: 1;
}

.ql-push {
    margin-left: auto;
}

/* The solution block's self-note button is position:absolute at top/right 12px
   (responsive.css), so it is NOT part of the row above it — a badge pushed to
   the right edge lands underneath it. Leave its corner clear: 34px of button
   plus its 12px offset. */
.tm-solution .tm-sol-toprow {
    padding-right: 54px;
}
