/* Motor de idiomas: stories.css. Lista de histórias (capas, filtro por nível, progresso) e leitor em forma de
   conversa (avatares, fala atual, tradução animada, balão do glossário, perguntas em cartão, tela final).
   Carrega depois de profile.css (.stories > h2 sobrescreve .page > h2). Só tokens de tokens.css/lang.css. */
/* ---------- lista ---------- */
.stories .st-hero { display: flex; align-items: flex-start; gap: 16px; margin: 6px 0 14px; }
.stories .st-hero-txt { flex: 1; min-width: 0; }
.stories h2 { margin: 4px 0 6px; font-size: 30px; line-height: 1.1; letter-spacing: -.03em; }
.stories .sub { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.st-total {
  flex: none; display: grid; place-items: center; align-content: center; width: 84px; height: 84px; border-radius: 24px;
  background: var(--tint); box-shadow: inset 0 0 0 1px var(--tint-edge); text-align: center;
}
.st-total b { font-family: var(--font-display); font-size: 30px; line-height: 1; color: var(--primary-ink); font-variant-numeric: tabular-nums; }
.st-total small { margin-top: 3px; font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.st-filter { display: flex; gap: 8px; margin: 0 -16px 6px; padding: 4px 16px 10px; overflow-x: auto; scrollbar-width: none; }
.st-filter::-webkit-scrollbar { display: none; }
.st-f {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--card); color: var(--ink-2); font-weight: 700; font-size: 14.5px;
  transition: background-color .15s, border-color .15s, color .15s;
}
.st-f span { font-size: 12.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-f:hover { border-color: var(--primary); }
.st-f[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: inset 0 -3px 0 var(--primary-edge); }
.st-f[aria-pressed="true"] span { color: rgb(255 255 255 / .85); }
.st-level { margin-top: 18px; }
.st-level[hidden] { display: none; }
.st-lv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.stories h3.lv { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.stories h3.lv .lv-id {
  display: grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 8px;
  background: var(--tint-2); color: var(--primary-ink); font-size: 13px; font-weight: 800; letter-spacing: .02em;
}
.st-lv-n { flex: none; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.st-meter { height: 8px; margin-bottom: 14px; border-radius: 99px; background: var(--line); overflow: hidden; }
.st-meter i { display: block; height: 100%; border-radius: inherit; background: var(--ok-solid); transition: width .3s ease-out; }
.st-grid { display: grid; gap: 10px; }
.story-card {
  display: flex; align-items: stretch; gap: 14px; width: 100%; margin: 0; padding: 10px 12px 10px 10px;
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-1);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.story-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.story-card:active { transform: translateY(1px); }
.story-card .cover {
  position: relative; flex: none; width: 84px; min-height: 104px; overflow: hidden; border-radius: 14px; color: #fff;
  background: linear-gradient(160deg, var(--band) 0%, var(--band-2) 100%);
}
.story-card .cover[data-tone="1"], .sh-cover[data-tone="1"] { background: linear-gradient(160deg, var(--band-2) 0%, var(--band) 100%); }
.story-card .cover[data-tone="2"], .sh-cover[data-tone="2"] { background: linear-gradient(160deg, var(--cover-3a) 0%, var(--cover-3b) 100%); }
.cv-art { position: absolute; inset: 0; display: block; }
.cv-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cv-art.ext svg { position: static; }
.cv-sun { fill: var(--accent); opacity: .9; }
.cv-sun2 { fill: #fff; opacity: .12; }
.cv-hill { fill: #fff; opacity: .16; }
.cv-hill2 { fill: #000; opacity: .14; }
.cv-road { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 2 6; opacity: .55; }
.cv-disc {
  position: absolute; left: 50%; top: 46%; display: grid; place-items: center; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%; background: rgb(255 255 255 / .95); color: var(--brand-ink); box-shadow: 0 6px 14px -6px rgb(0 0 0 / .45);
}
.cv-disc .ico { width: 24px; height: 24px; stroke-width: 2; color: var(--primary-edge); }
.cv-th { position: absolute; left: 50%; top: 44%; width: 64px; height: 64px; margin: -32px 0 0 -32px; filter: drop-shadow(0 6px 8px rgb(0 0 0 / .25)); }
.cv-th > svg { display: block; width: 100%; height: 100%; }
.sh-cover .cv-th { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
.story-card.locked .cv-th { filter: grayscale(1); opacity: .55; }
.story-card .cv-s {
  position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; align-items: center; justify-content: center; gap: 3px;
  padding: 3px 0; border-radius: 7px; font-size: 10.5px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase;
  background: rgb(255 255 255 / .96); color: var(--ink-fixed);
}
.story-card .cv-s .ico { width: 12px; height: 12px; stroke-width: 3; }
.story-card .cv-s.done { background: var(--ok-solid); color: #fff; }
.story-card.locked .cover { background: var(--line); }
.story-card.locked .cv-art svg { opacity: .35; filter: grayscale(1); }
.story-card.locked .cv-disc { background: var(--card); }
.story-card.locked .cv-disc .ico { color: var(--muted); }
.story-card.locked .cv-s { background: var(--card); color: var(--ink-2); }
.story-card .info { min-width: 0; align-self: center; padding: 2px 0; }
.st-meta { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.st-score { color: var(--ok); white-space: nowrap; }
.st-score .ico { width: 13px; height: 13px; stroke-width: 3; margin: -2px 2px 0 0; }
.story-card b { display: block; font-family: var(--font-display); font-size: 18px; line-height: 1.22; letter-spacing: -.01em; }
.story-card small { display: block; margin-top: 1px; color: var(--primary-ink); font-size: 14px; font-weight: 700; }
.story-card p { margin: 5px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.42; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.story-card.locked b { color: var(--ink-2); }
.story-card.locked small { color: var(--muted); }
@media (min-width: 700px) { .st-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- leitor ---------- */
.story .lesson-top { gap: 8px; }
.st-tools { display: flex; gap: 4px; }
.st-tgl {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
  background: none; color: var(--muted); transition: background-color .15s, color .15s;
}
.st-tgl:hover { background: var(--line); }
.st-tgl[aria-pressed="true"] { background: var(--tint-2); color: var(--primary-ink); }
.st-tgl .ico { width: 22px; height: 22px; }
.story-head { display: flex; gap: 14px; align-items: flex-start; margin: 2px 0 22px; padding-bottom: 18px; border-bottom: 1px dashed var(--line-strong); }
.sh-cover { position: relative; flex: none; width: 64px; height: 80px; overflow: hidden; border-radius: 14px; background: linear-gradient(160deg, var(--band) 0%, var(--band-2) 100%); }
.sh-cover .cv-disc { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
.sh-cover .cv-disc .ico { width: 19px; height: 19px; }
.sh-txt { min-width: 0; }
.sh-lv { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.stage .story-head h2 { margin: 2px 0 0; font-size: 25px; line-height: 1.15; letter-spacing: -.02em; }
.story-head small { display: block; margin-top: 2px; color: var(--primary-ink); font-size: 14.5px; font-weight: 700; }
.story-head p { margin: 8px 0 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.story-feed { display: flex; flex-direction: column; gap: 14px; padding-bottom: 16px; }
.sline { position: relative; display: flex; align-items: flex-end; gap: 8px; max-width: 92%; align-self: flex-start; cursor: pointer; animation: pop .22s ease-out; }
.sline.c1 { align-self: flex-end; flex-direction: row-reverse; }
.sline .av {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  font-family: var(--font-display); font-weight: 800; font-size: 17px; color: #fff; background: var(--primary);
  box-shadow: inset 0 -3px 0 var(--primary-edge);
}
.sline.c1 .av { background: var(--band); box-shadow: inset 0 -3px 0 rgb(0 0 0 / .25); }
.sline.c2 .av { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 -3px 0 var(--accent-edge); }
.sline .bubble {
  min-width: 0; padding: 10px 12px 8px 14px; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 20px 20px 20px 6px; transition: border-color .2s, box-shadow .2s, opacity .2s;
}
.sline.c1 .bubble { background: var(--tint); border-color: var(--tint-2); border-radius: 20px 20px 6px 20px; }
.sline.c2 .bubble { background: var(--accent-wash); border-color: var(--accent-soft); }
.sline.cur .bubble { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.sline.c2.cur .bubble { border-color: var(--accent-edge); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.sline .who { margin: 0 0 2px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--primary-ink); }
.sline.c2 .who { color: var(--accent-ink); }
.sline .row { display: block; }
.sline .txt { font-size: 18.5px; line-height: 1.45; }
.sline .acts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.sline .say { width: 44px; height: 36px; border-radius: 11px; }
.sline .say .ico { width: 19px; height: 19px; }
.tr-b {
  display: grid; place-items: center; width: 44px; height: 36px; padding: 0; border: 0; border-radius: 11px;
  background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink-2); transition: background-color .15s, color .15s;
}
.tr-b:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.tr-b[aria-expanded="true"] { background: var(--ink); color: var(--card); }
.tr-b .ico { width: 19px; height: 19px; }
.tr-w { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .22s ease-out, opacity .22s ease-out; }
.tr-w > .tr { min-height: 0; overflow: hidden; }
.sline.show .tr-w { grid-template-rows: 1fr; opacity: 1; }
.sline .tr { display: block; margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.sline.show .tr { padding-top: 6px; margin-top: 6px; border-top: 1px dashed var(--line-strong); }
.sline.narr { align-self: center; max-width: 94%; }
.sline.narr .bubble { padding: 8px 4px; text-align: center; background: transparent; border: 0; box-shadow: none; }
.sline.narr .txt { color: var(--ink-2); font-style: italic; font-size: 17px; }
.sline.narr .txt:lang(ko), .sline.narr .txt:lang(ja), .sline.narr .txt:lang(zh) { font-style: normal; } /* sem itálico falso em Hangul */
.sline.narr .acts { justify-content: center; }
.sline.narr .say { background: var(--line); color: var(--ink-2); box-shadow: none; }
.sline.narr.cur .bubble { box-shadow: none; }
.sline.narr.cur .txt { color: var(--ink); }
.gloss {
  text-decoration: underline dotted var(--accent-edge) 2px; text-underline-offset: 4px; cursor: help; border-radius: 4px;
  transition: background-color .15s;
}
.gloss:hover, .gloss:focus-visible { background: var(--accent-soft); }
.gloss-pop {
  position: absolute; z-index: 25; max-width: min(320px, calc(100vw - 16px)); padding: 10px 14px 10px 10px; border-radius: 16px;
  background: var(--toast); color: var(--toast-ink); box-shadow: 0 14px 34px -10px rgb(0 0 0 / .45); animation: gpop .18s ease-out;
}
.gloss-pop::after {
  content: ""; position: absolute; left: calc(var(--ax, 50%) - 7px); bottom: -7px; width: 14px; height: 14px;
  background: inherit; transform: rotate(45deg); border-radius: 0 0 3px 0;
}
.gloss-pop.below::after { bottom: auto; top: -7px; border-radius: 3px 0 0 0; }
.gp-row { display: flex; align-items: center; gap: 12px; }
.gloss-pop .say { width: 44px; height: 44px; }
.gp-t b { display: block; font-family: var(--font-display); font-size: 18px; line-height: 1.2; }
.gp-t span { display: block; font-size: 15px; line-height: 1.35; opacity: .86; }
@keyframes gpop { from { transform: translateY(4px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.story-q {
  margin: 4px 0 0; padding: 14px 14px 16px; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-1); animation: pop .22s ease-out;
}
.sq-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--accent-ink); font-size: 12.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.sq-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent-soft); }
.sq-ic .ico { width: 17px; height: 17px; }
.story-q.answered { padding: 10px 14px; box-shadow: none; background: transparent; border-style: dashed; }
.q-done { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 15px; }
.q-done .ico { width: 20px; height: 20px; stroke-width: 2.6; }
.q-done.ok .ico { color: var(--ok); }
.q-done.bad .ico { color: var(--bad); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- tela final ---------- */
.story-end { gap: 14px; }
.se-mascot { align-self: center; width: 132px; height: 132px; animation: medal .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.se-mascot svg { width: 100%; height: 100%; }
.story-end > p b { color: var(--ink); }
.se-words { padding: 14px 16px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.se-words h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-family: var(--font-body); font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.se-words h3 .ico { width: 17px; height: 17px; color: var(--primary-ink); }
.se-words ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.se-words li { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 10px; border-radius: 10px; background: var(--tint); font-size: 14.5px; }
.se-words li b { font-weight: 700; color: var(--ink); }
.se-words li span { color: var(--ink-2); font-size: 13.5px; }
.se-words small { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; }
.se-note { font-size: 14.5px !important; }
.story-end .btn.ghost { margin-top: -4px; }

/* integração: os filtros de nível rolam na horizontal; o esmaecido na borda direita mostra que há mais */
@media (max-width: 599px) { .st-filter { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); } }
/* integração: no coreano o body tem overflow-wrap: anywhere (langs/ko.js); o selo da capa não pode quebrar "TRANCADA" */
.cover .cv-s { white-space: nowrap; overflow-wrap: normal; }


/* ================= acabamento (revisão de design 30/10) ================= */
/* capa do leitor: cena larga com a ilustração do tema e o elenco */
.story-head { flex-direction: column; gap: 14px; }
.story-head .sh-cover { width: 100%; height: 156px; border-radius: 22px; box-shadow: inset 0 -5px 0 rgb(0 0 0 / .16); }
.story-head .sh-cover > div[aria-hidden] { position: absolute; inset: 0; }
.story-head .sh-cover .cv-th { left: auto; right: 22px; top: 50%; width: 104px; height: 104px; margin: -60px 0 0 0; }
.story-head .sh-cover .cv-disc { left: auto; right: 34px; top: 50%; width: 64px; height: 64px; margin: -40px 0 0 0; }
.story-head .sh-cover .cv-disc .ico { width: 30px; height: 30px; }
.sh-cast { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 8px; max-width: calc(100% - 150px); flex-wrap: wrap; }
.sh-who {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px;
  background: rgb(255 255 255 / .95); color: var(--ink-fixed); box-shadow: 0 4px 10px -6px rgb(0 0 0 / .45);
}
.sh-who .avatar.av-ill { width: 30px; height: 30px; }
.sh-who small { font-size: 13px; font-weight: 800; letter-spacing: .01em; }

/* falas: personagem ilustrado alinhado ao topo do balão, na mesma cor do balão */
.sline { align-items: flex-start; gap: 10px; }
.sline .av { width: 44px; height: 44px; margin-top: 2px; padding: 0; background: none; box-shadow: none; }
.sline.c1 .av, .sline.c2 .av { background: none; box-shadow: none; }
.sline .av .avatar.av-ill { width: 44px; height: 44px; }
.sline .bubble { border-radius: 6px 20px 20px 20px; }
.sline.c1 .bubble { border-radius: 20px 6px 20px 20px; }

/* narração: cartão de leitura alinhado à esquerda (sem texto solto e centralizado) */
.sline.narr { align-self: stretch; max-width: 100%; }
.sline.narr .bubble {
  width: 100%; max-width: none; padding: 10px 14px 8px 16px; text-align: left; background: var(--card); border: 1.5px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 14px;
}
.sline.narr .who { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-ink); }
.sline.narr .who .ico { width: 15px; height: 15px; }
.sline.narr .txt { color: var(--ink); font-style: normal; font-size: 18px; }
.sline.narr .acts { justify-content: flex-end; }
.sline.narr .say { background: var(--primary); color: #fff; box-shadow: inset 0 -3px 0 var(--primary-edge); }
.sline.narr.cur .bubble { border-color: var(--accent-edge); border-left-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

/* linha de pronúncia (LANG.pron: pinyin do chinês) sob a fala da história; muted, fonte do corpo, letter-spacing leve */
.sline .pron { display: block; margin-top: 2px; color: var(--muted); font-family: var(--font-body); font-size: 14.5px; font-weight: 500; font-style: normal; letter-spacing: .03em; line-height: 1.4; overflow-wrap: normal; word-break: normal; }
.sline.narr .pron { font-size: 14px; }
