/* Chinese IME Trainer (/games/ime-typing). Bootstrap variables throughout, so dark mode follows
   the site theme; every animation is off under prefers-reduced-motion. */

.ime-hero {
    background:
        radial-gradient(circle at 88% 20%, rgba(255, 255, 255, .22), transparent 30%),
        linear-gradient(135deg, #0f172a 0%, #1d4ed8 55%, #0891b2 100%);
}

.ime-hero-demo {
    display: inline-flex;
    flex-direction: column;
    align-self: flex-start;
    gap: .25rem;
    padding: .55rem .8rem;
    border-radius: .7rem;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .4);
    white-space: nowrap;
    font-size: 1rem;
}

.ime-hero-comp { text-decoration: underline dotted; font-family: ui-monospace, Consolas, monospace; }
.ime-hero-cands b { font-size: .7em; opacity: .75; margin: 0 .15em 0 .5em; }
.ime-hero-cands b:first-child { margin-left: 0; }

.ime-game-card { position: relative; overflow: hidden; }

.ime-band-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .6rem;
}

.ime-band {
    border: 1px solid var(--bs-border-color);
    border-radius: .8rem;
    padding: .75rem .45rem;
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.ime-band:hover, .ime-band:focus-visible { transform: translateY(-2px); border-color: var(--bs-primary); }
.ime-band.active {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), .14);
    background: var(--bs-primary-bg-subtle);
}
.ime-band strong, .ime-band span { display: block; }
.ime-band span { margin-top: .2rem; font-size: .76rem; color: var(--bs-secondary-color); }

.ime-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem .9rem; color: var(--bs-secondary-color); }

/* ── Prompt ── */
.ime-prompt { min-height: 7.5rem; }
.ime-target { font-size: clamp(2.6rem, 9vw, 3.6rem); font-weight: 700; line-height: 1.15; letter-spacing: .05em; }
.ime-target-hidden { color: var(--bs-secondary-color); opacity: .45; }
.ime-target-pinyin { font-size: 1.35rem; color: var(--bs-primary); font-weight: 600; min-height: 1.6rem; }
.ime-target-gloss { color: var(--bs-secondary-color); font-style: italic; }
.ime-pop { animation: ime-pop .28s ease-out; }
@keyframes ime-pop { from { transform: scale(.92); opacity: .2; } to { transform: scale(1); opacity: 1; } }

/* ── The simulated input method ── */
.ime-editor {
    position: relative;
    max-width: 34rem;
    margin: 0 auto;
    cursor: text;
}

.ime-doc {
    min-height: 3.4rem;
    padding: .6rem .9rem;
    border: 2px solid var(--bs-primary);
    border-radius: .75rem;
    background: var(--bs-body-bg);
    font-size: 1.8rem;
    line-height: 2rem;
    box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), .12);
    word-break: break-all;
}

.ime-comp {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 1.25rem;
    color: var(--bs-primary);
    text-decoration: underline;
    text-underline-offset: .25em;
}

.ime-caret {
    display: inline-block;
    width: 2px;
    height: 1.6rem;
    margin-left: 2px;
    vertical-align: middle;
    background: var(--bs-body-color);
    animation: ime-blink 1s steps(1) infinite;
}
@keyframes ime-blink { 50% { opacity: 0; } }

.ime-cand-window {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: .15rem;
    margin-top: .35rem;
    padding: .3rem .4rem;
    border-radius: .6rem;
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.ime-cand-window.open { display: flex; animation: ime-drop .12s ease-out; }
@keyframes ime-drop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

.ime-cand {
    border: 0;
    background: transparent;
    color: var(--bs-body-color);
    font-size: 1.35rem;
    padding: .2rem .5rem;
    border-radius: .4rem;
    min-height: 44px;
}
.ime-cand b { font-size: .75rem; color: var(--bs-secondary-color); margin-right: .2rem; font-weight: 600; }
.ime-cand.first { background: rgba(var(--bs-primary-rgb), .15); color: var(--bs-primary); }
.ime-cand:hover, .ime-cand:focus-visible { background: rgba(var(--bs-primary-rgb), .25); }
.ime-cand-none { font-size: .85rem; color: var(--bs-secondary-color); padding: .3rem .5rem; }

.ime-cand-nav { margin-left: auto; display: inline-flex; align-items: center; gap: .2rem; }
.ime-cand-nav button {
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: .35rem;
    min-width: 36px;
    min-height: 36px;
}
.ime-cand-nav small { color: var(--bs-secondary-color); }

/* The real text box sits over the editor, invisible, so taps on a phone raise the keyboard and
   every keystroke lands in one place. */
.ime-input {
    position: absolute;
    inset: 0 0 auto 0;
    height: 3.4rem;
    width: 100%;
    opacity: 0;
    font-size: 16px; /* no iOS zoom-on-focus */
    border: 0;
}

.ime-shake { animation: ime-shake .4s ease; }
@keyframes ime-shake {
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}
.ime-shake .ime-doc { border-color: var(--bs-danger); }

.ime-clock { transition: width .1s linear; background: var(--bs-success); }

/* ── Chat bubbles: each round's words, "sent" when the round ends ── */
.ime-chat { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
.ime-bubble {
    max-width: 90%;
    padding: .4rem .75rem;
    border-radius: 1rem 1rem .25rem 1rem;
    background: #95ec69; /* the familiar green of an outgoing message */
    color: #111;
    font-size: 1.1rem;
    word-break: break-all;
}
.ime-bubble span { margin-right: .3em; }
.ime-bubble span.bad { text-decoration: line-through; color: #a4161a; }
.ime-bubble.open { opacity: .75; border: 1px dashed rgba(0, 0, 0, .25); }
.ime-bubble.sent { animation: ime-send .45s cubic-bezier(.2, .8, .3, 1.3); }
.ime-tick { font-size: .7rem; color: #1b5e20; margin-left: .25rem; }
@keyframes ime-send { from { transform: translateY(12px) scale(.9); } to { transform: none; } }

/* ── Effects: chrome only ── */
.ime-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ime-particle { position: absolute; color: var(--bs-primary); font-size: 1rem; pointer-events: none; }
.ime-particle.gold { color: #f59f00; font-size: 1.2rem; }
.ime-ghost {
    position: fixed;
    z-index: 5;
    pointer-events: none;
    font-size: 1.5rem;
    color: var(--bs-primary);
}

/* ── Results ── */
.ime-result-burst {
    font-size: 2.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, #1d4ed8, #0891b2);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.ime-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.ime-stats div { background: var(--bs-tertiary-bg); border-radius: .6rem; padding: .5rem .25rem; }
.ime-stats strong { display: block; font-size: 1.4rem; }
.ime-stats span { font-size: .75rem; color: var(--bs-secondary-color); }
.ime-review { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.ime-review > div { width: 100%; }
.ime-review-chip {
    display: inline-block;
    padding: .25rem .6rem;
    border-radius: 999px;
    background: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
    text-decoration: none;
    font-size: 1rem;
}

@media (max-width: 575.98px) {
    .ime-band-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ime-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ime-doc { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .ime-pop, .ime-cand-window.open, .ime-shake, .ime-bubble.sent, .ime-caret { animation: none; }
    .ime-band, .ime-clock { transition: none; }
}
