/* 试炼 THE TRIAL — fight UI for watching a lesson.
 *
 * Built to the mockup: forge-metal frame with FORGE pillars, glitch-signal
 * enemy, boss HP bar, diamond beat track, segmented FOCUS cell meter, COMBO
 * plate. Everything is CSS and SVG over one static enemy PNG — no sprite
 * sheets, no canvas, no engine, no new dependency.
 *
 * Dark scope on purpose: the site is light, the Foundry is not. Everything is
 * namespaced under .trial-root so nothing can leak into the community shell.
 *
 * Every effect is a class toggle, and every one is neutralised by the
 * prefers-reduced-motion block at the bottom.
 */

.trial-root {
    --t-ink: #e9edf5;
    --t-ink-2: #93a0b8;
    --t-ink-3: #64718c;
    --t-bg: #05070e;
    --t-panel: #0b1120;
    --t-line: #1b2740;
    --t-cyan: #35e0f5;
    --t-magenta: #e879f9;
    --t-amber: #f5a623;
    --t-amber-2: #ffcf6b;
    --t-red: #f43f5e;
    --t-ok: #34d399;
    --t-forge: linear-gradient(160deg, #2a1b0c 0%, #16110c 45%, #0c0a08 100%);

    min-height: 100vh;
    background:
        radial-gradient(1200px 620px at 50% -12%, #17223d 0%, transparent 68%),
        radial-gradient(700px 400px at 8% 40%, #2a1040 0%, transparent 65%),
        var(--t-bg);
    color: var(--t-ink);
    font-family: var(--font);
    padding: 18px 14px 60px;
}

.trial-wrap { max-width: 1080px; margin: 0 auto; }

/* ---------- act header ---------- */

.t-acthead {
    text-align: center; position: relative; margin-bottom: 20px;
    padding: 9px 0;
    border-top: 1px solid rgba(53, 224, 245, .18);
    border-bottom: 1px solid rgba(53, 224, 245, .18);
}
.t-acthead span {
    font-size: 14px; letter-spacing: .30em; text-transform: uppercase;
    color: var(--t-cyan); text-shadow: 0 0 16px rgba(53, 224, 245, .55);
}
/* bracket ornaments at either end of the rule */
.t-acthead::before, .t-acthead::after {
    content: ''; position: absolute; top: -1px; bottom: -1px; width: 22px;
    border: 1px solid rgba(53, 224, 245, .4);
}
.t-acthead::before { left: 0; border-right: none; }
.t-acthead::after { right: 0; border-left: none; }

.t-back {
    background: none; border: 1px solid var(--t-line); color: var(--t-ink-2);
    border-radius: var(--r-pill); padding: 6px 14px; font-size: 12.5px;
    cursor: pointer; font-family: inherit; white-space: nowrap;
    position: absolute; left: 0; top: 50%; transform: translateY(-50%); z-index: 2;
}
.t-back:hover { color: var(--t-ink); border-color: var(--t-cyan); }

/* ---------- briefing ---------- */

.t-brief { animation: t-fadein .3s ease-out; }
.t-brief-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }

.t-card {
    background: linear-gradient(170deg, rgba(20, 29, 50, .92), rgba(9, 13, 24, .95));
    border: 1px solid var(--t-line); border-radius: 14px; padding: 20px 22px;
    position: relative;
}
/* clipped corner notch — reads as panel plating, costs nothing */
.t-card::after {
    content: ''; position: absolute; right: 0; top: 0;
    border-width: 0 14px 14px 0; border-style: solid;
    border-color: transparent var(--t-bg) transparent transparent;
}

.t-kicker {
    font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
    color: var(--t-amber); margin-bottom: 12px;
}
.t-brief p { color: var(--t-ink-2); font-size: 14.5px; line-height: 1.65; margin-bottom: 12px; }
.t-brief p:last-child { margin-bottom: 0; }
.t-brief p.lead { color: var(--t-ink); font-size: 16.5px; font-weight: 600; }

.t-threat {
    margin-top: 16px; padding: 13px 15px; border-radius: 11px;
    background: rgba(244, 63, 94, .07); border-left: 2px solid var(--t-red);
    font-size: 13.5px; line-height: 1.55; color: #ffc6cf;
}
.t-threat b { color: #fff; }

.t-lesson-title { font-size: 20px; font-weight: 720; line-height: 1.3; margin-bottom: 6px; }
.t-lesson-sub { color: var(--t-cyan); font-size: 13.5px; margin-bottom: 14px; }
.t-takeaways { list-style: none; display: grid; gap: 9px; margin: 14px 0 0; }
.t-takeaways li {
    font-size: 13.5px; line-height: 1.5; color: var(--t-ink-2);
    padding-left: 22px; position: relative;
}
.t-takeaways li::before {
    content: '◈'; position: absolute; left: 0; top: 0; color: var(--t-amber);
}

.t-objective {
    margin-top: 18px; padding: 14px 16px; border-radius: 12px;
    background: rgba(53, 224, 245, .06); border: 1px solid rgba(53, 224, 245, .22);
}
.t-objective .t-kicker { color: var(--t-cyan); margin-bottom: 7px; }
.t-objective p { color: var(--t-ink); font-size: 14px; margin: 0; }

.t-loot-preview { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 16px; }
.t-lp {
    flex: 1; min-width: 82px; text-align: center; padding: 11px 8px;
    border-radius: 11px; background: rgba(245, 166, 35, .07);
    border: 1px solid rgba(245, 166, 35, .25);
}
.t-lp-val { font-size: 19px; font-weight: 800; color: var(--t-amber-2); }
.t-lp-key { font-size: 10.5px; color: var(--t-ink-3); letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; }

.t-begin-row { text-align: center; margin-top: 24px; }

/* Prior-run notice. Sits above the begin button so "you were here before" is
   read before the decision to start, not after it. */
.t-resume {
    margin-top: 22px; text-align: center;
    border-top: 1px solid var(--t-line); padding-top: 18px;
}

.t-resume-line {
    color: var(--t-ink-2); font-size: 13.5px; line-height: 1.6;
    max-width: 560px; margin: 0 auto 12px;
}

/* ---------- enemy ---------- */

.t-enemy { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }

.t-sprite {
    width: 132px; height: 132px; flex: 0 0 132px; position: relative;
    animation: t-float 3.4s ease-in-out infinite;
}
.t-sprite img {
    width: 100%; height: 100%; object-fit: contain;
    filter: drop-shadow(0 0 22px rgba(232, 121, 249, .45));
}
/* fallback glyph when the art hasn't loaded */
.t-sprite .t-glyph {
    position: absolute; inset: 0; display: grid; place-items: center;
    font-size: 52px; color: var(--t-magenta);
}
@keyframes t-float { 0%, 100% { transform: translateY(-6px); } 50% { transform: translateY(6px); } }

.t-sprite.hit { animation: t-shake .26s steps(4); filter: brightness(2.6) saturate(.5); }
@keyframes t-shake {
    0% { transform: translateX(-10px); } 33% { transform: translateX(9px); }
    66% { transform: translateX(-6px); } 100% { transform: translateX(0); }
}
.t-sprite.dead { animation: t-dissolve 1s ease-in forwards; }
@keyframes t-dissolve {
    to { opacity: 0; transform: scale(.7) translateY(-18px); filter: blur(9px); }
}

.t-emeta { flex: 1; min-width: 0; }
.t-ename {
    font-size: 17px; font-weight: 700; margin-bottom: 9px; letter-spacing: .04em;
    text-shadow: 0 0 18px rgba(244, 63, 94, .4);
}
.t-ename small { color: var(--t-ink-2); font-weight: 500; font-size: 13px; letter-spacing: .1em; }

/* boss bar: forge plate, notched ends, numeric readout */
.t-hpbar {
    position: relative; height: 26px; border-radius: 5px;
    background: var(--t-forge);
    border: 1px solid #4a2f14;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6), 0 3px 14px rgba(0, 0, 0, .5);
    padding: 4px; overflow: hidden;
}
.t-hpfill {
    height: 100%; width: 100%; border-radius: 3px;
    background: linear-gradient(90deg, #b3121f 0%, #f43f5e 45%, #ff8a3d 100%);
    box-shadow: 0 0 18px rgba(244, 63, 94, .6), inset 0 1px 0 rgba(255, 255, 255, .25);
    transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.t-hpnum {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    font-size: 13px; font-weight: 700; color: #ffd9a0;
    text-shadow: 0 1px 3px #000; font-variant-numeric: tabular-nums;
}
.t-hpsub { font-size: 12px; color: var(--t-ink-3); margin-top: 7px; letter-spacing: .04em; }

/* floating damage numbers */
.t-dmg {
    position: absolute; left: 60%; top: 12%;
    font-weight: 900; font-size: 40px; font-style: italic; color: #eaffff;
    text-shadow: 0 0 18px var(--t-cyan), 0 0 40px rgba(53, 224, 245, .8);
    pointer-events: none; white-space: nowrap;
    animation: t-rise .8s cubic-bezier(.2, .8, .2, 1) forwards;
}
@keyframes t-rise { to { transform: translate(18px, -54px); opacity: 0; } }

/* ---------- forge frame ---------- */

.t-forge {
    position: relative; padding: 14px 46px;
    background: var(--t-forge);
    border: 1px solid #4a2f14; border-radius: 16px;
    box-shadow:
        inset 0 0 0 1px rgba(255, 176, 60, .16),
        inset 0 0 60px rgba(255, 140, 40, .09),
        0 26px 70px rgba(0, 0, 0, .6);
}
/* the two FORGE pillars */
.t-pillar {
    position: absolute; top: 16px; bottom: 16px; width: 34px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; color: #ffb347; opacity: .85;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 160, 60, .10), rgba(255, 120, 30, .03));
    border: 1px solid rgba(255, 160, 60, .18);
}
.t-pillar.left { left: 7px; }
.t-pillar.right { right: 7px; }
.t-pillar i { font-size: 15px; filter: drop-shadow(0 0 8px rgba(255, 160, 60, .8)); }
.t-pillar span {
    writing-mode: vertical-rl; font-size: 10px; letter-spacing: .34em;
    text-transform: uppercase; color: #c98a3c;
}
/* corner rivets */
.t-forge::before, .t-forge::after {
    content: ''; position: absolute; width: 9px; height: 9px; border-radius: 50%;
    background: radial-gradient(circle, #ffd08a 0%, #b3651a 60%, #3a2410 100%);
    box-shadow: 0 0 10px rgba(255, 176, 60, .6);
}
.t-forge::before { left: 14px; top: 12px; }
.t-forge::after { right: 14px; top: 12px; }

.t-frame {
    position: relative; border-radius: 8px; overflow: hidden;
    border: 1px solid #23304d; background: #000;
}
.t-frame video { display: block; width: 100%; height: auto; background: #000; }

/* the Static's attack: a red pulse on the FRAME, never over playing video */
.t-frame.struck { animation: t-attack .42s ease-out; }
@keyframes t-attack {
    0% { box-shadow: inset 0 0 0 0 rgba(244, 63, 94, 0); }
    40% { box-shadow: inset 0 0 100px 12px rgba(244, 63, 94, .55); transform: translateX(-7px); }
    70% { transform: translateX(6px); }
    100% { box-shadow: inset 0 0 0 0 rgba(244, 63, 94, 0); transform: translateX(0); }
}

/* strike slash — drawn across the whole stage, enemy to frame */
.t-slash { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.t-slash line {
    stroke: var(--t-cyan); stroke-width: 3; stroke-linecap: round;
    filter: drop-shadow(0 0 12px rgba(53, 224, 245, 1));
    stroke-dasharray: 1000; stroke-dashoffset: 1000;
}
.t-slash.go line { animation: t-draw .18s linear forwards; }
@keyframes t-draw {
    0% { stroke-dashoffset: 1000; opacity: 1; }
    70% { stroke-dashoffset: 0; opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: 0; }
}

/* ---------- lesson context strip (under the act header, above the fight) ---------- */

.t-context {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 12px 16px; margin-bottom: 16px;
    background: rgba(11, 17, 32, .8); border: 1px solid var(--t-line);
    border-left: 3px solid var(--t-cyan); border-radius: 12px;
}
.t-context .t-cx-no {
    font-size: 11px; letter-spacing: .16em; color: var(--t-cyan);
    text-transform: uppercase; white-space: nowrap;
}
.t-context .t-cx-title { font-size: 14.5px; font-weight: 620; flex: 1; min-width: 200px; }
.t-context .t-cx-sub { font-size: 12.5px; color: var(--t-ink-3); }

/* ---------- transport ---------- */

.t-transport { display: flex; align-items: center; gap: 13px; padding: 14px 6px 2px; }
.t-play {
    width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%;
    border: 1px solid rgba(53, 224, 245, .35); background: rgba(53, 224, 245, .08);
    color: var(--t-cyan); font-size: 15px; cursor: pointer;
}
.t-play:hover { background: rgba(53, 224, 245, .18); }

.t-scrub { flex: 1; min-width: 0; height: 30px; position: relative; cursor: pointer; }
.t-scrub-rail {
    position: absolute; left: 0; right: 0; top: 13px; height: 4px;
    border-radius: 999px; background: #16203a;
}
.t-scrub-fill {
    position: absolute; left: 0; top: 13px; height: 4px; border-radius: 999px;
    background: var(--t-cyan); width: 0; box-shadow: 0 0 12px rgba(53, 224, 245, .8);
}
.t-scrub-dot {
    position: absolute; top: 8px; width: 14px; height: 14px; border-radius: 50%;
    background: #eafeff; border: 2px solid var(--t-cyan);
    box-shadow: 0 0 16px rgba(53, 224, 245, 1); margin-left: -7px; left: 0;
}
/* beat markers: you can SEE the next hit coming. cheapest attention win here. */
.t-beat {
    position: absolute; top: 7px; width: 17px; height: 17px; margin-left: -8.5px;
    border: 1.5px solid #3a4a68;
    transform: rotate(45deg); border-radius: 3px; background: #0a1020;
    display: grid; place-items: center;
}
.t-beat i {
    transform: rotate(-45deg); font-size: 8px; color: transparent;
}
.t-beat.done { border-color: var(--t-cyan); background: rgba(53, 224, 245, .16); }
.t-beat.done i { color: var(--t-cyan); }
.t-beat.next {
    border-color: var(--t-amber); background: rgba(245, 166, 35, .2);
    animation: t-pulse 1.5s ease-in-out infinite;
}
@keyframes t-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, .6); }
    50% { box-shadow: 0 0 0 9px rgba(245, 166, 35, 0); }
}
.t-time { font-size: 13px; color: var(--t-ink-2); font-variant-numeric: tabular-nums; }

/* ---------- meters ---------- */

.t-meters { display: grid; grid-template-columns: 1.4fr .9fr; gap: 14px; margin-top: 16px; }

.t-plate {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 18px; border-radius: 12px;
    background: linear-gradient(150deg, rgba(12, 22, 40, .95), rgba(7, 12, 22, .95));
    border: 1px solid var(--t-line);
}
.t-plate.cyan { border-color: rgba(53, 224, 245, .3); box-shadow: inset 0 0 34px rgba(53, 224, 245, .07); }
.t-plate.amber { border-color: rgba(245, 166, 35, .34); box-shadow: inset 0 0 34px rgba(245, 166, 35, .09); }

.t-plate-label { font-size: 13px; letter-spacing: .08em; white-space: nowrap; }
.t-plate.cyan .t-plate-label { color: var(--t-cyan); }
.t-plate.amber .t-plate-label { color: var(--t-amber); }
.t-plate-label em { font-style: normal; font-size: 11px; opacity: .72; letter-spacing: .16em; }

/* segmented cell meter — 20 cells, filled left to right */
.t-cells { display: flex; gap: 3px; flex: 1; min-width: 0; }
.t-cell {
    flex: 1; height: 15px; border-radius: 2px; background: #131d33;
    transition: background .3s ease, box-shadow .3s ease;
}
.t-cell.on { background: var(--t-cyan); box-shadow: 0 0 9px rgba(53, 224, 245, .75); }
.t-cell.warn { background: var(--t-amber); box-shadow: 0 0 9px rgba(245, 166, 35, .75); }
.t-cell.crit { background: var(--t-red); box-shadow: 0 0 9px rgba(244, 63, 94, .75); }

.t-focus-num { font-size: 15px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t-focus-num small { color: var(--t-ink-3); font-weight: 500; }

.t-combo-val {
    font-size: 30px; font-weight: 900; font-style: italic; color: var(--t-amber-2);
    text-shadow: 0 0 20px rgba(245, 166, 35, .8); margin-left: auto;
    line-height: 1; font-variant-numeric: tabular-nums;
}
.t-flame { font-size: 22px; filter: grayscale(1) opacity(.3); transition: filter .3s ease; }
.t-flame.lit { filter: none; animation: t-flicker 1.1s ease-in-out infinite; }
@keyframes t-flicker { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.16); } }
.t-plate.flare { animation: t-flare .32s ease-out; }
@keyframes t-flare { 50% { transform: scale(1.035); } }

/* ---------- question card ---------- */

.t-overlay {
    position: absolute; inset: 0; display: none; z-index: 6;
    background: linear-gradient(180deg, rgba(5, 8, 16, .88), rgba(5, 8, 16, .97));
    padding: 20px 22px; overflow-y: auto;
}
.t-overlay.show { display: block; animation: t-fadein .22s ease-out; }
@keyframes t-fadein { from { opacity: 0; } to { opacity: 1; } }

.t-q-kicker {
    font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
    color: var(--t-amber); margin-bottom: 9px;
}
.t-q-text { font-size: 17.5px; font-weight: 640; line-height: 1.45; margin-bottom: 15px; }
.t-choices { display: grid; gap: 8px; }
.t-choice {
    text-align: left; padding: 11px 15px; border-radius: 10px; cursor: pointer;
    background: rgba(255, 255, 255, .04); border: 1px solid var(--t-line);
    color: var(--t-ink); font-size: 14px; font-family: inherit; line-height: 1.42;
}
.t-choice:hover:not(:disabled) { border-color: var(--t-cyan); background: rgba(53, 224, 245, .09); }
.t-choice:disabled { cursor: default; opacity: .6; }
.t-choice.right { border-color: var(--t-ok); background: rgba(52, 211, 153, .15); opacity: 1; }
.t-choice.wrong { border-color: var(--t-red); background: rgba(244, 63, 94, .13); opacity: 1; }

.t-why {
    margin-top: 13px; padding: 12px 15px; border-radius: 10px; font-size: 13.5px;
    line-height: 1.55; color: var(--t-ink-2);
    background: rgba(255, 255, 255, .03); border-left: 2px solid var(--t-cyan);
}
.t-actions { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; }
.t-btn {
    padding: 11px 22px; border-radius: var(--r-pill); cursor: pointer;
    font-size: 14px; font-weight: 650; font-family: inherit;
    background: linear-gradient(100deg, var(--t-cyan), #6ee7f7);
    color: #04121a; border: none; text-decoration: none; display: inline-block;
}
.t-btn:hover { filter: brightness(1.1); }
.t-btn.big { padding: 14px 40px; font-size: 15.5px; letter-spacing: .04em; }
.t-btn.ghost { background: transparent; color: var(--t-ink); border: 1px solid var(--t-line); }
.t-btn.ghost:hover { border-color: var(--t-cyan); }

/* ---------- end cards ---------- */

.t-end { text-align: center; padding: 26px 16px; }
.t-end-title { font-size: 25px; font-weight: 780; margin-bottom: 11px; }
.t-end-sub { color: var(--t-ink-2); font-size: 14.5px; line-height: 1.6; margin-bottom: 20px; }
.t-loot {
    display: inline-flex; gap: 22px; flex-wrap: wrap; justify-content: center;
    padding: 16px 28px; border-radius: 14px; margin-bottom: 20px;
    background: linear-gradient(160deg, rgba(245, 166, 35, .17), rgba(232, 121, 249, .1));
    border: 1px solid rgba(245, 166, 35, .38);
    animation: t-loot-in .5s cubic-bezier(.2, .8, .2, 1);
}
@keyframes t-loot-in { from { transform: rotateY(90deg); opacity: 0; } }
.t-loot-item { text-align: center; }
.t-loot-val { font-size: 22px; font-weight: 800; color: var(--t-amber-2); }
.t-loot-key { font-size: 10.5px; color: var(--t-ink-3); letter-spacing: .1em; text-transform: uppercase; }

.t-note { margin-top: 22px; font-size: 12.5px; color: var(--t-ink-3); text-align: center; line-height: 1.65; }
.t-note a { color: var(--t-cyan); }

/* ---------- gate ---------- */

.t-gate { text-align: center; padding: 84px 20px; }
.t-gate h2 { font-size: 22px; margin-bottom: 11px; }
.t-gate p { color: var(--t-ink-2); margin-bottom: 20px; font-size: 14.5px; line-height: 1.6; }

/* ---------- mobile ----------
 * 390px is the target. Vertical flow only; nothing here is position:fixed,
 * which is the trap that broke the July mobile pass. */

@media (max-width: 860px) {
    .t-brief-grid { grid-template-columns: 1fr; }
    .t-meters { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .trial-root { padding: 12px 9px 44px; }
    /* stack, don't overlap: the absolute back button collides with the act
       title once the title wraps to two lines */
    .t-acthead { margin-bottom: 16px; padding: 10px 0; }
    .t-acthead span { font-size: 11.5px; letter-spacing: .2em; }
    .t-back {
        position: static; transform: none;
        display: block; width: max-content; margin: 0 auto 10px;
    }
    /* pillars eat too much width on a phone — the frame keeps the glow */
    .t-forge { padding: 10px; }
    .t-pillar { display: none; }
    .t-sprite { width: 88px; height: 88px; flex-basis: 88px; }
    .t-ename { font-size: 14.5px; }
    .t-hpbar { height: 22px; }
    .t-dmg { font-size: 30px; }
    .t-card { padding: 16px 15px; }
    .t-q-text { font-size: 15.5px; }
    .t-overlay { padding: 13px; }
    .t-choice { padding: 10px 12px; font-size: 13.5px; }
    .t-cell { height: 12px; }
    .t-combo-val { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    .trial-root *,
    .trial-root *::before,
    .trial-root *::after {
        animation: none !important;
        transition: none !important;
    }
}
