/* ============================================================
   Mandarun — speedrun components ("Ink & Paper")
   Loaded after minimal.css; shares its tokens.
   ============================================================ */

/* ---------- Buttons: map legacy speedrun variants ---------- */
.btn .btn-b { display: none; }

.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { background: var(--red); border-color: var(--red); color: var(--paper); }

.btn-outline:hover { background: var(--ink); color: var(--paper); }

.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: var(--paper); }

.btn-success { background: transparent; color: var(--jade); border-color: var(--jade); }
.btn-success:hover { background: var(--jade); color: var(--paper); }

.btn-large { padding: 1.15rem 2rem; }

/* Legacy HUD dot is replaced by the .eyebrow::before dot */
.eyebrow .hud-dot { display: none; }

/* ---------- Page headings used by speedrun views ---------- */
.page-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(2.4rem, 6vw, 4rem);
    line-height: 1;
    letter-spacing: -.02em;
}

.page-sub { color: var(--muted); margin-top: 1rem; max-width: 62ch; }

/* ---------- Persistent run header ---------- */
.run-header {
    border-bottom: 1px solid var(--line);
    margin-bottom: clamp(2rem, 5vw, 3.5rem);
}

.run-header__top {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 1.1rem var(--gut);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}

.run-header__brand {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    text-decoration: none;
    color: var(--ink);
}

.run-header__seal {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--zh);
    font-size: 17px;
    line-height: 1;
    transition: background .25s var(--ease);
}
.run-header__brand:hover .run-header__seal { background: var(--red); }

.run-header__title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .24em;
    text-transform: uppercase;
}
.run-header__zh { color: var(--faint); }

.run-header__stats { display: flex; gap: clamp(1.25rem, 4vw, 2.75rem); }

.run-header__stat {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    text-align: right;
}

.run-header__k {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--faint);
}

.run-header__stat b {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.run-header__stat b em { font-style: normal; color: var(--muted); font-size: .72em; }

.run-progress {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 1.1rem var(--gut) 0;
}
.run-progress--mastery { padding-top: 1rem; padding-bottom: 1.15rem; }

.run-progress__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .5rem;
}
.run-progress__k {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--muted);
}
.run-progress__v {
    font-size: 11px;
    letter-spacing: .04em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.run-progress__v b { color: var(--ink); font-weight: 600; }
.run-progress__v em { font-style: normal; color: var(--faint); }

.run-progress--mastery .run-progress__k,
.run-progress--mastery .run-progress__v { color: var(--faint); }
.run-progress--mastery .run-progress__v b { color: var(--gold); }

.run-bar { position: relative; background: var(--line); }
.run-bar--run { height: 6px; }
.run-bar--mastery { height: 2px; }
.run-bar__fill {
    position: absolute;
    inset: 0 auto 0 0;
    max-width: 100%;
    transition: width .7s var(--ease);
}
.run-bar--run .run-bar__fill { background: var(--ink); }
.run-bar--mastery .run-bar__fill { background: var(--gold); }

/* ---------- Speedrun page header ---------- */
.speedrun-page {
    max-width: var(--maxw);
    margin: 0 auto;
    padding-inline: var(--gut);
}

.path-resume { margin: 1.75rem 0 .5rem; }

.path-note { margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.path-note a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- The climb (path nodes) ---------- */
.path {
    list-style: none;
    max-width: var(--maxw);
    margin: clamp(1.5rem, 4vw, 2.5rem) auto clamp(3rem, 6vw, 4rem);
    padding-inline: var(--gut);
    border-top: 1px solid var(--line);
}

.path-node { border-bottom: 1px solid var(--line); }

.path-node__link {
    display: flex;
    align-items: center;
    gap: clamp(1rem, 2.5vw, 1.75rem);
    padding: 1.1rem 0;
    text-decoration: none;
    color: inherit;
    transition: padding-left .25s var(--ease);
}
a.path-node__link:hover { padding-left: .75rem; }

.path-node__face {
    flex: none;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border: 1px solid var(--ink);
    font-family: var(--zh);
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1;
    transition: background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
}

.path-node__meta { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }

.path-node__label { font-family: var(--serif); font-size: 1.25rem; line-height: 1.1; }

.path-node__status {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: var(--faint);
}

.path-node--locked .path-node__link { opacity: .4; cursor: not-allowed; }
.path-node--locked .path-node__face { border-style: dashed; border-color: var(--line-2); }

.path-node--unlocked .path-node__face { border-color: var(--red); color: var(--red); }
.path-node--unlocked .path-node__status { color: var(--red); }

.path-node--cleared .path-node__face { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.path-node--cleared .path-node__status { color: var(--jade); }

.path-node--boss .path-node__face { font-size: 1.55rem; }
.path-node--boss.path-node--unlocked .path-node__face { border-color: var(--gold); color: var(--gold); }
.path-node--boss.path-node--unlocked .path-node__status { color: var(--gold); }
.path-node--boss.path-node--cleared .path-node__face { background: var(--gold); border-color: var(--gold); color: #fff; }
.path-node--boss.path-node--cleared .path-node__status { color: var(--gold); }

/* ---------- Level shell ---------- */
.level-shell {
    max-width: 860px;
    margin: 0 auto clamp(3rem, 6vw, 4rem);
    padding-inline: var(--gut);
}

.level-topline {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--ink);
    margin-bottom: 1.5rem;
}

.level-topline__title { display: flex; align-items: baseline; gap: .85rem; flex-wrap: wrap; }

.level-topline__kind {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--red);
}

.level-topline__badge { font-family: var(--serif); font-size: 1.5rem; }

.level-round { display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; }
.level-round__p {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: var(--faint);
}
.level-round__name { font-family: var(--zh); font-size: 1.05rem; color: var(--muted); }

.level-rail { display: flex; gap: .4rem; margin-bottom: 1.5rem; }
.level-rail__dot { width: 32px; height: 2px; background: var(--line-2); transition: background .3s var(--ease); }
.level-rail__dot.is-done { background: var(--ink); }

.level-actions { display: flex; justify-content: center; margin-top: 2rem; }

/* ---------- Learn intro cards ---------- */
.learn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    border-top: 1px solid var(--line-2);
    border-left: 1px solid var(--line-2);
}

.learn-card {
    position: relative;
    padding: 1.5rem 1.35rem 1.35rem;
    border-right: 1px solid var(--line-2);
    border-bottom: 1px solid var(--line-2);
}

.learn-card__rank {
    position: absolute;
    top: 1rem;
    right: 1.1rem;
    font-size: 10px;
    letter-spacing: .14em;
    color: var(--faint);
}

.learn-card .speak-btn { position: absolute; top: .85rem; left: 1rem; }

.learn-card__hanzi {
    font-family: var(--zh);
    font-size: 2.75rem;
    font-weight: 500;
    line-height: 1;
    margin-top: 1.75rem;
}

.learn-card__pinyin { color: var(--muted); font-size: .95rem; letter-spacing: .06em; margin: .6rem 0 .7rem; }

.learn-card__meaning { font-size: .9rem; line-height: 1.5; }

.learn-card__example {
    margin-top: .9rem;
    padding-top: .9rem;
    border-top: 1px solid var(--line);
    font-family: var(--zh);
    font-size: 1.05rem;
}

.learn-card__example--soon {
    font-family: var(--sans);
    font-style: italic;
    font-size: .78rem;
    color: var(--faint);
}

/* ---------- Quiz ---------- */
.quiz { margin-top: .5rem; }

.quiz-card {
    text-align: center;
    padding: clamp(2rem, 5vw, 3rem) clamp(1.25rem, 4vw, 2.5rem);
    border: 1px solid var(--line-2);
}

.quiz-card__rank {
    display: block;
    font-size: 10px;
    letter-spacing: .2em;
    color: var(--faint);
    margin-bottom: .5rem;
}

.quiz-card__hanzi {
    font-family: var(--zh);
    font-weight: 500;
    font-size: clamp(3.5rem, 13vw, 6rem);
    line-height: 1.05;
}

.quiz-card__pinyin { color: var(--muted); font-size: 1.15rem; letter-spacing: .1em; margin-top: .6rem; }

.quiz-card__meaning { margin-top: 1.1rem; font-family: var(--serif); font-size: 1.6rem; }
.quiz-card--reveal .quiz-card__meaning { font-size: 1.95rem; }

.quiz-card__example { margin-top: 1rem; font-family: var(--zh); font-size: 1.15rem; color: var(--ink-2); }

.quiz-prompt { margin: 1rem 0 .5rem; text-align: center; color: var(--muted); font-size: .95rem; }

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border-top: 1px solid var(--line-2);
    border-left: 1px solid var(--line-2);
    margin-top: 1.5rem;
}

.quiz-option {
    padding: 1.1rem 1.25rem;
    border: none;
    border-right: 1px solid var(--line-2);
    border-bottom: 1px solid var(--line-2);
    background: var(--paper);
    color: var(--ink);
    font-size: .98rem;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: background .2s var(--ease), color .2s var(--ease);
}
.quiz-option:hover { background: var(--ink); color: var(--paper); }

.quiz-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* ---------- Speak button ---------- */
.speak-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--line-2);
    background: transparent;
    color: var(--muted);
    font-size: .7rem;
    cursor: pointer;
    transition: border-color .2s var(--ease), color .2s var(--ease);
}
.speak-btn:hover { border-color: var(--red); color: var(--red); }

.quiz-card .speak-btn { position: relative; }

.quiz-card .speak-btn:not(.speak-btn--big)::before {
    content: "";
    position: absolute;
    inset: -12px;
    border-radius: 50%;
}

.speak-btn--big { width: 64px; height: 64px; font-size: 1.1rem; }

/* ---------- Boss HUD ---------- */
.boss-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1.1rem;
    border: 1px solid var(--red);
    margin-bottom: 1.25rem;
}

.boss-hud__q,
.boss-hud__mode {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .24em;
    text-transform: uppercase;
}
.boss-hud__mode { color: var(--red); }

.boss-hud__time {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
}
.boss-hud__time.is-timeout { color: var(--red); animation: hud-pulse .6s steps(1) infinite; }

@keyframes hud-pulse { 50% { opacity: .25; } }

/* ---------- Summary ---------- */
.summary-shell {
    max-width: 860px;
    margin: 0 auto clamp(3rem, 6vw, 4rem);
    padding-inline: var(--gut);
}

.summary-banner {
    text-align: center;
    padding: clamp(2.5rem, 6vw, 4rem) 1.5rem;
    border: 1px solid var(--line-2);
}
.summary-banner--pass { border-color: var(--ink); }

.summary-banner__seal {
    display: inline-grid;
    place-items: center;
    width: 60px;
    height: 60px;
    border: 1px solid var(--line-2);
    font-family: var(--zh);
    font-size: 1.9rem;
    margin-bottom: 1.1rem;
}
.summary-banner--pass .summary-banner__seal { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.summary-banner--fail .summary-banner__seal { color: var(--red); border-color: var(--red); }

.summary-banner__eyebrow {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: .6rem;
}

.summary-banner h1 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1;
}

.summary-banner p { color: var(--muted); margin-top: .85rem; }

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    border-top: 1px solid var(--line-2);
    border-left: 1px solid var(--line-2);
    margin: 1.75rem 0;
}

.summary-stat {
    padding: 1.25rem 1.4rem;
    border-right: 1px solid var(--line-2);
    border-bottom: 1px solid var(--line-2);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.summary-stat__k {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--faint);
}

.summary-stat b { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; }

.summary-words { margin: 2rem 0; }

.summary-word-list { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--line); }

.summary-word-list li {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: .9rem 0;
    border-bottom: 1px solid var(--line);
}

.summary-word__rank { font-size: 10px; letter-spacing: .1em; color: var(--faint); flex: none; }
.summary-word__hanzi { font-family: var(--zh); font-size: 1.5rem; font-weight: 500; }
.summary-word__pinyin { color: var(--muted); font-size: .85rem; }
.summary-word__meaning { font-size: .9rem; margin-left: auto; text-align: right; color: var(--ink-2); }

.summary-note { color: var(--muted); font-size: .85rem; margin-top: 1rem; }

.summary-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* ---------- Account gate ---------- */
.gate-shell {
    max-width: 620px;
    margin: clamp(2.5rem, 7vw, 5rem) auto;
    padding: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 5vw, 3rem);
    border: 1px solid var(--ink);
    text-align: center;
}

.gate-shell__seal {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--zh);
    font-size: 1.75rem;
    margin-bottom: 1.25rem;
}

.gate-shell .eyebrow { justify-content: center; }

.gate-shell__text {
    color: var(--muted);
    line-height: 1.65;
    max-width: 46ch;
    margin: 1rem auto 1.75rem;
}

.gate-shell__actions { display: flex; gap: .85rem; justify-content: center; flex-wrap: wrap; }

.gate-shell__note { color: var(--faint); font-size: .82rem; margin-top: 1.5rem; }
.gate-shell__note a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
    .quiz-options { grid-template-columns: 1fr; }
    .summary-word-list li { flex-wrap: wrap; }
    .summary-word__meaning { margin-left: 0; text-align: left; flex-basis: 100%; }
    .run-header__stat { text-align: left; }
    .run-header__stats { justify-content: flex-start; }
}
