/* kge.css — KGE Stories. Reading first: generous line height, restrained
   colour, and the three scripts clearly distinguished without shouting. */

.kge-host { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.kge-root { position: relative; padding: var(--s4) var(--s4) var(--s8); max-width: 780px; margin: 0 auto; }
.kge-dim { color: var(--text-dim); font-size: 0.86rem; }

.kge-head { margin-bottom: var(--s4); }
.kge-head h2 { margin: 0 0 var(--s1); font-size: 1.5rem; }
.kge-head p { margin: 0 0 var(--s3); color: var(--text-dim); font-size: 0.92rem; line-height: 1.5; }

.kge-progress { display: flex; align-items: center; gap: var(--s2); font-size: 0.82rem; color: var(--text-dim); }
.kge-bar { flex: 1 1 auto; max-width: 220px; height: 7px; border-radius: 4px; background: rgba(0,0,0,0.09); overflow: hidden; }
.kge-bar i { display: block; height: 100%; background: var(--accent); }

.kge-focusbar { display: flex; align-items: center; gap: var(--s1); margin-top: var(--s3); flex-wrap: wrap; }
.kge-focus {
    border: 1px solid var(--border); background: var(--card); color: inherit;
    font: inherit; font-size: 0.82rem; padding: var(--s1) var(--s3); border-radius: 50px; cursor: pointer;
    min-height: 36px;  /* comfortable thumb target */
}
.kge-focus.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.kge-tier { margin-bottom: var(--s5); }
.kge-tier h3 {
    margin: 0 0 var(--s2); font-size: 0.72rem; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text-dim);
}
.kge-cards { display: grid; gap: var(--s2); }
@media (min-width: 640px) { .kge-cards { grid-template-columns: 1fr 1fr; } }

.kge-card {
    display: flex; flex-direction: column; gap: var(--s1); text-align: left;
    padding: var(--s3) var(--s4); border-radius: 14px; cursor: pointer;
    border: 1px solid var(--border); background: var(--card); color: inherit; font: inherit;
}
.kge-card:hover { border-color: var(--accent); }
.kge-card.done { border-color: rgb(var(--completed-rgb)); }
.kge-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.kge-card-top strong { font-size: 1rem; }
.kge-card-top em { font-style: normal; font-size: 0.76rem; color: var(--text-dim); white-space: nowrap; }
.kge-card-blurb { color: var(--text-dim); font-size: 0.85rem; line-height: 1.45; }
.kge-card-bar { height: 4px; border-radius: 3px; background: rgba(0,0,0,0.08); overflow: hidden; margin-top: 3px; }
.kge-card-bar i { display: block; height: 100%; background: rgb(var(--completed-rgb)); }

.kge-crumb { margin-bottom: var(--s2); }
.kge-back { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: var(--s1) 0; }
.kge-back:hover { text-decoration: underline; }

/* ---------- the sentences ---------- */
.kge-lines { display: flex; flex-direction: column; gap: var(--s2); }
.kge-line { border: 1px solid var(--border); border-radius: 14px; background: var(--card); overflow: hidden; }
.kge-line.open { border-color: var(--accent); }
.kge-line.done .kge-num { background: rgb(var(--completed-rgb)); color: #fff; }

.kge-sentence {
    display: flex; align-items: flex-start; gap: var(--s3); width: 100%;
    padding: var(--s3) var(--s4); background: none; border: none; color: inherit;
    font: inherit; text-align: left; cursor: pointer;
}
.kge-num {
    flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
    background: rgba(0,0,0,0.07); color: var(--text-dim);
    font-size: 0.72rem; display: flex; align-items: center; justify-content: center;
    margin-top: 2px;
}
.kge-texts { flex: 1 1 auto; display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.kge-en { font-size: 1rem; line-height: 1.45; }
.kge-kn, .kge-el { font-size: 1.02rem; line-height: 1.6; }
.kge-kn { color: #a8632c; }
.kge-el { color: #2f6f86; }
.kge-chev { flex: 0 0 auto; color: var(--text-dim); font-size: 0.8rem; margin-top: var(--s1); }

/* ---------- the workings ---------- */
.kge-detail { padding: 0 var(--s4) var(--s4) var(--s8); display: flex; flex-direction: column; gap: var(--s3); }
@media (max-width: 520px) { .kge-detail { padding-left: var(--s4); } }

.kge-lang { border-left: 3px solid var(--border); padding-left: var(--s3); }
.kge-lang-kn { border-left-color: #a8632c; }
.kge-lang-el { border-left-color: #2f6f86; }
.kge-lang-head {
    font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: var(--s1);
}
.kge-script { font-size: 1.15rem; line-height: 1.55; }
.kge-tr { font-style: italic; color: var(--text-dim); font-size: 0.9rem; margin-top: 2px; }
.kge-say { font-size: 0.88rem; margin-top: var(--s1); letter-spacing: 0.01em; }
.kge-say span {
    font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.09em;
    color: var(--text-dim); margin-right: var(--s1);
}

.kge-gloss { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 0.84rem; }
.kge-gloss-head, .kge-gloss-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.kge-gloss-head { background: rgba(0,0,0,0.05); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.kge-gloss-head span, .kge-gloss-row span { padding: var(--s2) var(--s2); }
.kge-gloss-row { border-top: 1px solid var(--border); }
.kge-gloss-row span:nth-child(2) { color: #a8632c; }
.kge-gloss-row span:nth-child(3) { color: #2f6f86; }

.kge-note { background: rgba(0,0,0,0.04); border-radius: 10px; padding: var(--s3) var(--s3); }
.kge-note-label {
    display: block; font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--accent); margin-bottom: var(--s1);
}
.kge-note p { margin: 0; font-size: 0.9rem; line-height: 1.6; }

.kge-btn {
    border: 1px solid var(--border); background: var(--card); color: inherit;
    font: inherit; font-size: 0.9rem; padding: var(--s2) var(--s4); border-radius: 50px;
    cursor: pointer; align-self: flex-start; min-height: 44px;
}
.kge-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.kge-ghost { background: none; }
.kge-next { margin-top: var(--s4); width: 100%; text-align: center; }
.kge-end { margin-top: var(--s4); text-align: center; }

.kge-toast {
    position: fixed; left: 50%; bottom: 68px; transform: translateX(-50%);
    background: rgba(20,14,26,0.94); color: #fff; padding: var(--s2) var(--s4);
    border-radius: 50px; font-size: 0.88rem; z-index: 60; pointer-events: none;
}
.kge-toast.hidden { display: none; }

@media (max-width: 520px) {
    .kge-gloss-head, .kge-gloss-row { grid-template-columns: 1fr; }
    .kge-gloss-row span { padding: var(--s1) var(--s2); }
    .kge-gloss-row span:first-child { padding-top: var(--s2); }
    .kge-gloss-row span:last-child { padding-bottom: var(--s2); }
    .kge-gloss-head { display: none; }
}

/* ---------- hearing it ----------
 * The speakers sit in a column down the right of the sentence rather than
 * immediately after each line of text, so they stay in one place as the
 * sentences change length instead of jittering left and right. */
.kge-textrow { display: flex; align-items: flex-start; gap: var(--s2); min-width: 0; }
.kge-textrow > :first-child { flex: 1 1 auto; min-width: 0; }

.kge-speak {
    flex: 0 0 auto; position: relative;
    width: 30px; height: 30px; margin-top: -3px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 50%;
    background: var(--card); color: var(--text-dim); cursor: pointer;
}

/* 30px reads better beside a line of text than 44 does, so the button stays
   small and the *target* grows instead — the finger gets its 44px, the layout
   does not have to give up the room. */
.kge-speak::after {
    content: ""; position: absolute; inset: -7px;
}

.kge-speak svg { width: 15px; height: 15px; fill: currentColor; }
.kge-speak .kge-wave {
    fill: none; stroke: currentColor; stroke-width: 1.9;
    stroke-linecap: round; opacity: 0.85;
}

@media (hover: hover) { .kge-speak:hover { color: var(--accent); border-color: var(--accent); } }

.kge-speak.playing {
    color: #fff; background: var(--accent); border-color: var(--accent);
}
.kge-speak.playing .kge-wave { animation: kge-wave 1.1s ease-in-out infinite; }
@keyframes kge-wave {
    0%, 100% { opacity: 0.25; }
    50%      { opacity: 1; }
}

/* The one in the workings sits on the language's own label. */
.kge-lang-head { display: flex; align-items: center; gap: var(--s2); }
.kge-lang-head .kge-speak { width: 26px; height: 26px; margin: -4px 0; }
.kge-lang-head .kge-speak svg { width: 13px; height: 13px; }

.kge-voicegap {
    margin-top: var(--s2); font-size: 0.8rem; line-height: 1.5;
    color: var(--text-dim); max-width: 60ch;
}

/* ---------- conversations ----------
 * The target language is the only thing on the surface of a line. Everything
 * else — the transliteration, the English, the gloss, the note — lives behind
 * one tap, and the visual weight is arranged to say so: the script is set
 * large and dark, the working underneath is quiet.
 *
 * Their turns and yours are told apart by which side the accent sits on and
 * by a small label, not by chat bubbles. A bubble that has to contain a
 * three-column gloss table stops being a bubble. */

.kge-card-found {
    font-size: 0.76rem; color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.kge-card-talk { border-style: solid; }

.kge-tier-note { margin: calc(var(--s2) * -1) 0 var(--s3); line-height: 1.55; max-width: 62ch; }

.kge-talk { display: flex; flex-direction: column; gap: var(--s3); }

.kge-turn { display: flex; flex-direction: column; gap: 2px; }
.kge-who {
    font-size: 0.66rem; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--text-dim);
}
.kge-turn-me { align-items: stretch; }
.kge-turn-me .kge-who { text-align: right; }

.kge-tline {
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--card); overflow: hidden;
}
/* Whose turn it is, in one stripe down the edge. */
.kge-tline-them { border-left: 3px solid var(--text-dim); }
.kge-tline-me   { border-right: 3px solid var(--accent); }
.kge-tline-opt  { border-left: 3px solid var(--accent); }

.kge-tline-row {
    display: flex; align-items: flex-start; gap: var(--s2);
    padding: var(--s3); cursor: pointer; min-height: 48px;
}
.kge-tline-text {
    flex: 1 1 auto; min-width: 0;
    font-size: 1.06rem; line-height: 1.65;
}
/* A reply you have not read yet is the point of the exercise, so it is set
   at full strength; what the other person said is context and steps back. */
.kge-tline-them .kge-tline-text { color: var(--text-dim); font-size: 1rem; }

.kge-tline.open .kge-tline-row { background: rgba(0,0,0,0.03); }

.kge-tline-detail {
    display: flex; flex-direction: column; gap: var(--s3);
    padding: 0 var(--s3) var(--s3);
    border-top: 1px solid var(--border);
    padding-top: var(--s3);
}
.kge-tline-en { font-size: 0.98rem; line-height: 1.55; }
.kge-tline-detail .kge-btn { align-self: stretch; text-align: center; }

/* The one-tap commit. Small, and only on a reply — their lines have nothing
   to commit to. The 44px target is grown with ::after rather than with size,
   the same trick the speaker button uses. */
.kge-tsay {
    flex: 0 0 auto; position: relative;
    width: 30px; height: 30px; margin-top: -3px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--accent); border-radius: 50%;
    background: var(--accent); color: #fff; cursor: pointer;
}
.kge-tsay::after { content: ""; position: absolute; inset: -7px; }
.kge-tsay svg {
    width: 15px; height: 15px; fill: none; stroke: currentColor;
    stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round;
}

.kge-talk-options { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s2); }
.kge-talk-prompt {
    margin: 0; font-size: 0.72rem; letter-spacing: 0.09em;
    text-transform: uppercase; color: var(--text-dim);
}
.kge-talk-prompt .kge-dim { text-transform: none; letter-spacing: 0; font-size: 0.76rem; }

.kge-talk-score { margin: var(--s2) 0 0; font-variant-numeric: tabular-nums; }

/* Only the second column carries a language here, so the three-column
   colouring of a story's gloss would put Greek in Kannada's orange. */
.kge-gloss-kn .kge-gloss-row span:nth-child(2) { color: #a8632c; }
.kge-gloss-el .kge-gloss-row span:nth-child(2) { color: #2f6f86; }

.kge-talk-end {
    margin-top: var(--s3); padding: var(--s4);
    border: 1px solid var(--accent); border-radius: 14px;
    background: rgba(242, 115, 77, 0.06);
}
.kge-talk-end-label {
    font-size: 0.66rem; letter-spacing: 0.09em;
    text-transform: uppercase; color: var(--accent);
}
.kge-talk-end h3 { margin: var(--s1) 0 var(--s2); font-size: 1.15rem; }
.kge-talk-end p { margin: 0; font-size: 0.92rem; line-height: 1.6; }

/* The endings you have not found are counted but not named — knowing there is
   another way through is the reason to play again. */
.kge-endlist { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: 4px; }
.kge-endlist li {
    font-size: 0.85rem; color: var(--text-dim);
    padding-left: var(--s4); position: relative;
}
.kge-endlist li::before { content: "○"; position: absolute; left: 0; }
.kge-endlist li.got { color: inherit; }
.kge-endlist li.got::before { content: "●"; color: var(--accent); }

.kge-talk-again { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.kge-talk-again .kge-btn { align-self: auto; }

@media (max-width: 520px) {
    .kge-tline-text { font-size: 1.12rem; }
    .kge-talk-again .kge-btn { flex: 1 1 100%; text-align: center; }
}

/* ---------- duels ----------
 * The same lines as a conversation, judged. Colour arrives only after you have
 * answered: before that every option has to look equally plausible, or the
 * screen gives away what the reading was supposed to teach. */

.kge-duel-head { margin-bottom: var(--s3); }

.kge-duel-hud {
    display: flex; gap: var(--s5); align-items: center;
    margin-top: var(--s3); flex-wrap: wrap;
}
.kge-duel-side { display: flex; align-items: center; gap: var(--s2); font-size: 0.82rem; }
.kge-pips { display: inline-flex; gap: 4px; }
.kge-pips i {
    width: 13px; height: 13px; border-radius: 50%;
    background: var(--accent); transition: background 0.2s ease;
}
.kge-pips i.foe { background: #7a4b6b; }
.kge-pips i.gone { background: rgba(0,0,0,0.13); }

.kge-duel-bout { display: flex; flex-direction: column; gap: var(--s2); }
.kge-duel-bout .kge-turn { margin-bottom: var(--s2); }

/* Unanswered: identical to every other option, deliberately. */
.kge-tline-opt { border-left: 3px solid var(--accent); }

/* Answered. The one that was right is always marked, whether or not you
   picked it — being shown the answer is the point of getting it wrong. */
.kge-tline-right { border-left: 3px solid rgb(var(--completed-rgb)); }
.kge-tline-wrong { border-left: 3px solid #b03a3a; }
.kge-tline-spent { border-left: 3px solid var(--border); opacity: 0.62; }

.kge-mark { flex: 0 0 auto; font-size: 1rem; font-weight: 700; width: 18px; text-align: center; }
.kge-mark-right { color: rgb(var(--completed-rgb)); }
.kge-mark-wrong { color: #b03a3a; }

.kge-why { background: rgba(176, 58, 58, 0.07); }
.kge-why .kge-note-label { color: #b03a3a; }

.kge-duel-verdict {
    margin-top: var(--s3); padding: var(--s3) var(--s4);
    border-radius: 12px; border: 1px solid var(--border);
    display: flex; flex-direction: column; gap: var(--s3);
}
.kge-duel-verdict.good { border-color: rgb(var(--completed-rgb)); background: rgba(var(--completed-rgb), 0.07); }
.kge-duel-verdict.bad  { border-color: #b03a3a; background: rgba(176, 58, 58, 0.06); }
.kge-duel-verdict p { margin: 0; font-size: 0.92rem; line-height: 1.55; }
.kge-duel-verdict .kge-btn { align-self: flex-start; }

.kge-duel-end.lost { border-color: #b03a3a; background: rgba(176, 58, 58, 0.06); }
.kge-duel-end.lost .kge-talk-end-label { color: #b03a3a; }

.kge-card-duel .kge-card-top em { letter-spacing: -1px; color: #7a4b6b; }

@media (max-width: 520px) {
    .kge-duel-verdict .kge-btn { align-self: stretch; text-align: center; }
    .kge-duel-hud { gap: var(--s4); }
}

/* ---------- the historical cast ----------
 * A scene and the person standing in it. The portrait is anchored to the
 * bottom-left of the scene rather than centred, so the room is still readable
 * behind them — the background is doing work here, not decoration. */

.kge-scene {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: var(--s3);
    line-height: 0;                 /* no descender gap under the image */
    background: rgba(0,0,0,0.06);
}
.kge-scene > img {
    display: block;
    width: 100%;
    height: auto;
    /* Pixel art: never let the browser smooth it on the way up. */
    image-rendering: pixelated;
}
.kge-face {
    position: absolute;
    left: 4%;
    bottom: 0;
    /* Sized against the scene rather than in pixels, so it holds its place in
       the room at every width. */
    width: 30%;
    max-width: 150px;
    height: auto;
}

/* On the card, a small face beside the name — enough to tell Basavanna from
   Purandara Dasa before committing to a fight. */
.kge-card-duel { position: relative; padding-left: 62px; }
.kge-card-face {
    position: absolute;
    left: 6px; top: 50%;
    transform: translateY(-50%);
    width: 48px; height: 48px;
    image-rendering: pixelated;
}

@media (max-width: 520px) {
    .kge-face { width: 34%; }
}

/* A story's or a conversation's own illustration, above its title. Sits in the
   header rather than floating over it — the words are the app and the picture
   introduces them. */
.kge-banner {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
    margin-bottom: var(--s3);
    image-rendering: pixelated;
}
