/* a-plus — 「다른 상황에서도」(같은 표현, 다른 상황 · 2026-12-01 1일째 시험판). js/a-plus.js 가 그리는 무대.
   모양은 a-recap.css 의 .rc-* (먹색 무대 · 불빛 단추 하나 · 메신저 대본)를 그대로 쓰고, 여기에는 다른 점만:
     정지 그림(.ap-still)과 그 위 말풍선(.ap-bub: 말하는 사람 머리 바로 위, 꼬리는 그 사람 쪽 아래로),
     대본에서 내가 말할 줄 표시(.ap-tag), 핵심 표현 밑줄(.w.key .kw — 쉼표 · 마침표는 빼고),
     내 차례: 영어는 낱말 막대로 가리고(.veil) '힌트 보기', 말한 뒤 점수(.ap-score: 대사 띠 · .ap-rs: 대본 줄 · .ap-end: 끝 화면 장면별).
   색은 again.css 의 먹색 · 불빛 토큰만. 움직임은 이즈 아웃 0.4초 하나, 움직임 줄이기를 켜면 끈다. */

.ap-frame { aspect-ratio: 16 / 9; }
/* 움직이는 층(a-plus.js camTo): 그림 · 영상 · 불빛 · 말풍선을 함께 담아 transform 으로만 이동 · 확대(말풍선이 머리에 붙어 같이 움직임) */
.ap-zoom { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
/* 말하는 사람 쪽 은은한 불빛(투명도만 바뀜) */
.ap-glow { position: absolute; left: 50%; top: 45%; width: 30%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; opacity: 0;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--lamp) 26%, transparent), color-mix(in srgb, var(--lamp) 8%, transparent) 55%, transparent);
  transition: opacity .6s var(--motion-e); }
.ap-glow.on { opacity: 1; }
/* 내 차례 마이크 둘레: '다 말했어요' 둘레 고리가 내 목소리 크기에 맞춰 커졌다 작아진다(크기 · 투명도만) */
.ap .rc-said { position: relative; }
.ap-lv { position: absolute; inset: -6px; border: 2px solid var(--lamp); border-radius: 999px; opacity: .3; pointer-events: none; will-change: transform, opacity; }
.ap-still { display: block; width: 100%; height: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--night-2); transition: filter var(--motion-t) var(--motion-e); }
.ap-still[hidden], .ap-frame video[hidden] { display: none; }
.rc.ap[data-m="say"] .ap-still { filter: brightness(.55) saturate(.75); }

/* 정지 그림 위 말풍선: 말하는 사람 머리 바로 위(아래 끝을 그림 높이 36% 자리에), 꼬리는 그 사람 쪽 아래로 */
.ap-bub { position: absolute; bottom: 64%; max-width: 46%; margin: 0; padding: 10px 16px 12px; border-radius: 16px; background: var(--on-night); color: var(--lamp-ink);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--night) 35%, transparent); font-size: clamp(1rem, 1.7vw, 1.375rem); font-weight: 500; line-height: 1.35;
  overflow-wrap: break-word; } /* 낱말은 넘칠 때만 끊음(본문의 anywhere 를 쓰면 좁은 말풍선에서 낱말 중간이 끊긴다) */
.ap-bub::after { content: ''; position: absolute; bottom: -9px; width: 18px; height: 18px; background: inherit; transform: rotate(45deg); border-radius: 0 0 4px 0; }
.ap-bub[hidden] { display: none; }
.ap-bub[data-side="left"] { left: 14%; }
.ap-bub[data-side="left"]::after { left: 32px; }
.ap-bub[data-side="right"] { right: 18%; }
.ap-bub[data-side="right"]::after { right: 32px; }
.ap-bub b { display: block; margin-bottom: 2px; font-size: 16px; font-weight: 600; color: var(--lamp-ink); opacity: .7; }
.ap-bub .w.key .kw { text-decoration: underline 2px var(--lamp); text-underline-offset: .2em; }
.ap-bub.pop { animation: ap-pop .55s var(--motion-e); }
/* 뜰 때 살짝 들썩: 아래에서 올라와 조금 더 오른 뒤 제자리로 */
@keyframes ap-pop { 0% { opacity: 0; transform: translateY(6px); } 55% { opacity: 1; transform: translateY(-3px); } 100% { opacity: 1; transform: none; } }

/* 핵심 표현 밑줄: 낱말 글자에만(뒤에 붙은 문장 부호는 빼고) */
.ap .w.key { text-decoration: none; }
.ap .rc-en .w.key .kw, .ap .rc-sub .w.key .kw { text-decoration: underline 2px var(--lamp); text-underline-offset: .2em; }

/* 내 차례: 대사 띠와 대본 줄의 영어를 낱말 길이 막대로 가린다('내가 주인공'과 같은 모양) */
.ap .rc-sub-en.veil { display: inline; min-width: 0; border: 0; word-spacing: .25em; }
.ap .rc-sub-en.veil .w, .ap .rc-row.veil .rc-en .w { color: transparent; border-bottom: 3px solid color-mix(in srgb, var(--on-night) 30%, transparent); border-radius: 2px; user-select: none; transition: none; }
.ap .veil .w .kw { text-decoration-color: transparent; }
.ap .rc-row.veil .rc-en { word-spacing: .25em; }

/* 내 차례 단추: 힌트 보기(조용한 단추) + 다 말했어요(테두리 단추) */
.ap-turn-act { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.ap-turn-act[hidden] { display: none; }
.ap-turn-act .rc-said { margin-left: 0; }
.ap-hint { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: 0; padding: 0 12px; border: 0; border-radius: 999px; background: transparent;
  color: var(--on-night-sub); font: inherit; font-size: 16px; cursor: pointer; }
.ap-hint:hover { background: var(--night-3); color: var(--on-night); }
.ap-hint .i { width: 18px; height: 18px; }
.ap-hint:disabled { color: var(--lamp); cursor: default; background: transparent; }

/* 점수 글자(대사 띠 · 대본 줄 · 끝 화면이 같이 씀) */
.ap-s-k { color: var(--on-night-sub); }
.ap-s-v { font-size: 24px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--on-night); }
.ap-s-v small { margin-left: 2px; font-size: 16px; font-weight: 500; }
.ap-s-t { color: var(--on-night); }
[data-m="good"] > .ap-s-v, [data-m="good"] > .ap-s-t, [data-m="good"] .ap-rs-sum .ap-s-v { color: var(--lamp); }

/* ① 내 차례 자리: 대사 띠 바로 아래 한 줄 */
.ap-score { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 12px; margin: 8px 0 0; font-size: 16px; line-height: 1.4; }
.ap-score[hidden] { display: none; }

/* ② 대본 줄 아래: 얼굴 칸 자리를 비우고 말풍선 밑에 */
.ap .rc-row:has(> .ap-rs) { flex-wrap: wrap; }
.ap .rc-row:has(> .ap-rs) > .rc-bub { max-width: calc(100% - 60px); } /* 얼굴 + 간격(휴대폰 40+12, 넓은 화면 44+12)보다 넉넉히: 말풍선이 얼굴 밑 줄로 내려가지 않게 */
.ap-rs { flex: 1 0 100%; min-width: 0; margin: 4px 0 0; padding: 0 0 0 56px; font-size: 16px; line-height: 1.4; }
.ap .rc-row.right > .ap-rs { padding: 0 56px 0 0; }
.ap-rs-sum { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-height: 44px; margin: 0; padding: 8px 14px; border: 1px solid var(--night-line); border-radius: 999px;
  background: transparent; color: var(--on-night); font: inherit; font-size: 16px; text-align: left; }
p.ap-rs-sum { align-items: center; border-style: dashed; }
button.ap-rs-sum { cursor: pointer; }
button.ap-rs-sum:hover { border-color: var(--on-night-dim); }
.ap-rs-sum .ap-s-v { font-size: 20px; }
.ap-rs-sum .i { align-self: center; width: 18px; height: 18px; color: var(--on-night-sub); transition: transform var(--motion-t) var(--motion-e); }
.ap-rs-sum[aria-expanded="true"] .i { transform: rotate(180deg); }
.ap-rs-out { margin-top: 8px; }
.ap-rs-out[hidden] { display: none; }
.ap-rs-out .pron { padding: 16px; }

/* ③ 끝 화면: 장면별 내 점수 */
.ap-end { margin: 32px 0 0; padding: 24px; border-radius: 16px; background: var(--night-2); }
.ap-end[hidden] { display: none; }
.ap-end-h { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.4; color: var(--lamp); }
.ap-end-avg { margin: 4px 0 16px; font-size: 16px; line-height: 1.5; color: var(--on-night-sub); }
.ap-end-avg b { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--on-night); }
.ap-end-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.ap-end-list > li { min-width: 0; padding: 16px; border-radius: 12px; background: var(--night-3); }
.ap-end-t { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 12px; margin: 0 0 8px; font-size: 16px; font-weight: 500; line-height: 1.5; color: var(--on-night); }
.ap-end-t small { font-size: 16px; font-weight: 400; color: var(--on-night-sub); }
.ap-end-list ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ap-end-list ul li { display: grid; gap: 2px; }
.ap-end-en { font-size: 16px; line-height: 1.45; color: var(--on-night-sub); }
.ap-end-s { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; font-size: 16px; line-height: 1.4; }
.ap-end-s .ap-s-v { font-size: 20px; }

/* 대본: 내가 말할 줄 표시 */
.ap-tag { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 16px; line-height: 1.5; color: var(--lamp); }
.ap-tag .i { width: 16px; height: 16px; }
.ap-me .rc-bub { border-color: color-mix(in srgb, var(--lamp) 40%, transparent); }

/* 긴 대사(a-plus.js fitBub 가 그림 경계를 재서 차례로 붙임): ① 넓게 ② 글자 한 단계 작게 ③ 그림 위쪽 안에 */
.ap-bub.wide { max-width: 72%; }
.ap-bub.wide[data-side="left"] { left: 4%; }
.ap-bub.wide[data-side="right"] { right: 4%; }
.ap-bub.small { padding: 6px 12px 8px; font-size: clamp(.875rem, 1.35vw, 1.125rem); line-height: 1.3; }
.ap-bub.small b { margin-bottom: 0; font-size: 14px; }
.ap-bub.top { top: 3%; bottom: auto; }
/* 말하는 사람 머리 자리가 자료에 있을 때(a-plus.js headX: 줄의 x 또는 장면 cast[who].x): 말풍선 왼쪽 끝 = --ap-x, 꼬리 가운데 = --ap-tail */
.ap-bub.at, .ap-bub.at[data-side] { left: var(--ap-x); right: auto; }
.ap-bub.at::after, .ap-bub.at[data-side]::after { left: calc(var(--ap-tail) - 9px); right: auto; }

@media (max-width: 560px) {
  .ap-bub { bottom: 62%; max-width: 58%; padding: 6px 12px 8px; font-size: 16px; }
  .ap-bub[data-side="left"] { left: 8%; }
  .ap-bub[data-side="right"] { right: 10%; }
  .ap-bub::after { bottom: -7px; width: 14px; height: 14px; }
  .ap-bub.at::after, .ap-bub.at[data-side]::after { left: calc(var(--ap-tail) - 7px); }
  .ap-bub b { display: none; } /* 휴대폰: 이름은 아래 띠에 */
  .ap-bub.wide { max-width: 84%; }
  .ap-bub.small { padding: 4px 10px 6px; font-size: 14px; }
  .ap-turn-act { flex: 1 1 100%; justify-content: space-between; margin-left: 0; }
  .ap-rs { padding-left: 52px; }
  .ap .rc-row.right > .ap-rs { padding: 0 52px 0 0; }
  .ap-end { margin-top: 24px; padding: 16px; }
}
/* 머리 위 끝 세로 자리가 자료에 있을 때(a-plus.js fitHead: cast[who].y): 꼬리 끝이 머리 위 끝보다 조금 위에 오도록 위쪽 자리(--ap-y)를 정한다.
   위로 넘치면 그림 맨 위에 붙여 얼굴 옆으로 비키고(.beside), 꼬리는 옆에서 머리 쪽을 가리킨다(--ap-ty: 꼬리 세로 가운데). 휴대폰 · PC 같은 규칙 */
.ap-bub.aty, .ap-bub.aty.top { top: var(--ap-y); bottom: auto; }
.ap-bub.beside::after, .ap-bub.beside[data-side]::after { top: calc(var(--ap-ty) - 9px); bottom: auto; }
@media (max-width: 560px) {
  .ap-bub.beside::after, .ap-bub.beside[data-side]::after { top: calc(var(--ap-ty) - 7px); }
}
/* 머리가 말풍선보다 아래일 때(.long): 꼬리를 늘려 말풍선 아래 모서리에서 머리 위 끝 바로 위 점까지 뾰족한 쐐기(길이 · 각도는 a-plus.js) */
.ap-bub.long::after, .ap-bub.long[data-side]::after { left: var(--ap-lx); right: auto; top: calc(var(--ap-ly) - 6px); bottom: auto; width: var(--ap-ll); height: 12px;
  border-radius: 0; transform-origin: 0 50%; transform: rotate(var(--ap-la)); clip-path: polygon(0 0, 100% 50%, 0 100%); }
@media (prefers-reduced-motion: reduce) {
  .ap-still, .ap-rs-sum .i { transition: none; }
  .ap-bub.pop { animation: none; }
  .ap-zoom { transform: none !important; }
  .ap-glow, .ap-lv { display: none; }
}
