/* =========================================================================
   DAILY MIX LADDER

   The screen behind the "Daily Mix Test" card: two tracks, a hundred numbered
   papers each, one of them open.

   The layout says the same thing twice on purpose. The hero card is the paper
   you can sit right now — the only tap that matters on a normal visit, so it
   is the only full-width thing on the screen. The grid under it is the ladder
   itself: where you are, how far it goes, what each rung scored. A student
   opening this screen to "do today's test" never has to read the grid; one
   opening it to see progress never has to read the hero.

   Colour does three jobs and no others: --brand marks the one open paper,
   --success / --warning / --danger report a score, and everything else is
   surface and line. Locked papers are not red — they are simply quiet.

   Tokens only, so both themes come out of premium-ui.css untouched.
   ========================================================================= */

.dmx {
    max-width: 880px;
    margin: 0 auto;
    padding: 4px 0 32px;
}

/* ── header ──────────────────────────────────────────────────────────────── */

.dmx-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3, 12px);
    margin-bottom: var(--sp-3, 12px);
}

.dmx-back {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color .18s ease, background .18s ease;
}

.dmx-back:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.dmx-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.dmx-head-text h3 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.dmx-head-text p {
    margin: 2px 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* The done/total count is the one live number in the header, so it takes the
   full-contrast colour while its label stays muted. */
.dmx-head-count {
    flex: 0 0 auto;
    text-align: right;
    line-height: 1.1;
}

.dmx-head-count b {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.dmx-head-count span {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.dmx-bar {
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
    margin-bottom: var(--sp-4, 16px);
}

.dmx-bar i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--brand);
    transition: width .4s ease;
}

/* ── track tabs ──────────────────────────────────────────────────────────── */

.dmx-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2, 8px);
    margin-bottom: var(--sp-4, 16px);
}

.dmx-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius-sm, 14px);
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: border-color .18s ease, color .18s ease, background .18s ease;
}

.dmx-tab span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dmx-tab em {
    font-style: normal;
    font-size: 0.74rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.8;
}

.dmx-tab:hover {
    border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
}

.dmx-tab.is-on {
    color: var(--text-main);
    border-color: var(--brand);
    background: var(--brand-soft);
}

.dmx-tab.is-on i {
    color: var(--brand);
}

/* ── the open paper ──────────────────────────────────────────────────────── */

.dmx-hero {
    display: flex;
    align-items: center;
    gap: var(--sp-4, 16px);
    padding: 20px;
    margin-bottom: var(--sp-5, 20px);
    border-radius: var(--radius);
    border: 1px solid var(--brand);
    background: var(--surface-raised);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
}

.dmx-hero:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* A paper left mid-test. It takes the second accent rather than --brand,
   because on this screen --brand already means "the open rung" and the paused
   paper is a different claim on the student's attention: not the next thing,
   the unfinished thing. */
.dmx-hero.is-paused {
    border-color: var(--brand-2);
    background: color-mix(in srgb, var(--brand-2) 9%, var(--surface-raised));
}

.dmx-hero.is-paused .dmx-hero-mark {
    background: color-mix(in srgb, var(--brand-2) 16%, transparent);
    color: var(--brand-2);
}

.dmx-hero.is-paused .dmx-hero-go {
    background: var(--brand-2);
}

.dmx-hero.is-done {
    border-color: var(--line);
    cursor: default;
}

.dmx-hero.is-done:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.dmx-hero-mark {
    flex: 0 0 auto;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    background: var(--brand-soft);
    color: var(--brand);
}

.dmx-hero.is-done .dmx-hero-mark {
    background: color-mix(in srgb, var(--success) 14%, transparent);
    color: var(--success);
}

.dmx-hero-text {
    flex: 1 1 auto;
    min-width: 0;
}

.dmx-hero-text strong {
    display: block;
    font-size: 1.05rem;
    color: var(--text-main);
}

.dmx-hero-text span {
    display: block;
    margin-top: 3px;
    font-size: 0.84rem;
    color: var(--text-muted);
}

.dmx-hero-text em {
    display: block;
    margin-top: 6px;
    font-style: normal;
    font-size: 0.76rem;
    color: var(--warning);
}

.dmx-hero-go {
    flex: 0 0 auto;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
}

/* ── the ladder ──────────────────────────────────────────────────────────── */

.dmx-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: var(--sp-2, 8px);
}

.dmx-tile {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: var(--radius-sm, 14px);
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    cursor: pointer;
    transition: transform .14s ease, border-color .14s ease;
}

.dmx-tile b {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dmx-tile i {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.dmx-tile em {
    font-style: normal;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.dmx-tile:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
}

.dmx-tile.is-done {
    border-color: color-mix(in srgb, var(--success) 40%, var(--line));
}

.dmx-tile.is-done b,
.dmx-tile.is-done em {
    color: var(--success);
}

/* The one open paper, marked the same way the hero is so the eye can join
   them without reading either. */
.dmx-tile.is-next {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.dmx-tile.is-next b,
.dmx-tile.is-next i {
    color: var(--brand);
}

/* Declared after .is-done and .is-next so it wins at equal specificity: a rung
   being sat right now is paused first, and cleared or next only second. */
.dmx-tile.is-paused {
    border-color: var(--brand-2);
    background: color-mix(in srgb, var(--brand-2) 12%, var(--surface-raised));
}

.dmx-tile.is-paused b,
.dmx-tile.is-paused i,
.dmx-tile.is-paused em {
    color: var(--brand-2);
}

.dmx-tile.is-locked {
    background: transparent;
    border-style: dashed;
    cursor: not-allowed;
}

.dmx-tile.is-locked b {
    color: var(--text-muted);
    opacity: 0.65;
}

.dmx-tile.is-locked:hover {
    transform: none;
    border-color: var(--line);
}

/* ── a track the bank cannot pay for ─────────────────────────────────────── */

.dmx-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 24px;
    border-radius: var(--radius);
    border: 1px dashed var(--line);
    text-align: center;
}

.dmx-empty i {
    font-size: 1.6rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.dmx-empty strong {
    color: var(--text-main);
    font-size: 0.98rem;
}

.dmx-empty span {
    color: var(--text-muted);
    font-size: 0.84rem;
    max-width: 42ch;
}

/* ── one paper's attempt history ─────────────────────────────────────────── */

.dmx-sheet {
    position: fixed;
    inset: 0;
    z-index: 100020;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.dmx-sheet-back {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.dmx-sheet-card {
    position: relative;
    width: min(520px, 100%);
    max-height: 78vh;
    overflow-y: auto;
    padding: 20px;
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--line);
    border-bottom: none;
    background: var(--surface-solid);
    box-shadow: var(--shadow-md);
    animation: dmx-rise .22s ease;
}

@keyframes dmx-rise {
    from { transform: translateY(18px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .dmx-sheet-card { animation: none; }
}

@media (min-width: 640px) {
    .dmx-sheet {
        align-items: center;
    }

    .dmx-sheet-card {
        border-radius: var(--radius);
        border-bottom: 1px solid var(--line);
    }
}

.dmx-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: var(--sp-4, 16px);
}

.dmx-sheet-head strong {
    font-size: 1.05rem;
    color: var(--text-main);
}

.dmx-sheet-x {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.dmx-att {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.dmx-att-pct {
    flex: 0 0 auto;
    min-width: 54px;
    text-align: center;
    padding: 8px 0;
    border-radius: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    background: var(--surface-raised);
    color: var(--text-main);
}

.dmx-att-pct.is-good { color: var(--success); }
.dmx-att-pct.is-mid { color: var(--warning); }
.dmx-att-pct.is-low { color: var(--danger); }

.dmx-att-meta {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.35;
}

.dmx-att-meta strong {
    display: block;
    font-size: 0.92rem;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.dmx-att-meta span {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.dmx-att-btn {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.dmx-att-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.dmx-sheet-retake {
    width: 100%;
    margin-top: var(--sp-4, 16px);
    padding: 14px;
    border-radius: var(--radius-sm, 14px);
    border: none;
    background: var(--brand);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
}

/* ── locked-tap notice ───────────────────────────────────────────────────── */

.dmx-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h, 58px) + 20px);
    transform: translate(-50%, 12px);
    z-index: 100030;
    padding: 11px 18px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-solid);
    color: var(--text-main);
    font-size: 0.84rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

.dmx-toast.is-on {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ── narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 520px) {
    .dmx-grid {
        grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    }

    .dmx-hero {
        padding: 16px;
        gap: 12px;
    }

    .dmx-hero-mark {
        width: 48px;
        height: 48px;
        border-radius: 15px;
        font-size: 1.2rem;
    }

    .dmx-hero-go {
        padding: 9px 14px;
        font-size: 0.82rem;
    }

    .dmx-tab {
        padding: 10px 12px;
        font-size: 0.82rem;
    }
}
