/* Vocabulary trainer — the word squares on /decks (js/vocab/word-canvas.js).
   The session chrome (top bar, tools, track, summary) reuses the kana
   Trainer's .tr-* classes from css/trainer.css; this file owns the prompt
   and the squares (.dw-*). Scoped to .tr-session--words. */

.tr-session--words {
  --dw-guide: var(--canvas-grid, rgba(32, 80, 126, .18));
  --dw-ghost: rgba(120, 130, 160, .16);
  --dw-ghost-line: rgba(100, 110, 140, .35);
  --dw-reveal: rgba(120, 130, 160, .6);
  max-width: 560px;
}
html.dark .tr-session--words {
  --dw-ghost: rgba(160, 170, 200, .16);
  --dw-ghost-line: rgba(180, 190, 220, .35);
  --dw-reveal: rgba(170, 180, 205, .55);
}

/* ── Prompt: the meaning, the kanji, the status ─────────────────── */
.dw-prompt { display: block; text-align: center; margin: 0 0 16px; }   /* overrides .tr-prompt's 3-column grid */
.dw-prompt { position: relative; }
.dw-prompt__meaning { font-family: var(--tr-serif, 'Newsreader', Georgia, serif); font-weight: 500; font-size: clamp(24px, 4.2vw, 34px); line-height: 1.2; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; margin: 0 auto; outline: none; }
.dw-prompt__meaning.is-clipped { cursor: help; }
.dw-prompt__meaning:focus-visible { box-shadow: 0 0 0 2px var(--accent-line, rgba(32,80,126,.24)); border-radius: 6px; }
/* Full definition: a floating bubble under the line — absolutely
   positioned so it never pushes the slots or the canvas. */
.dw-prompt__full { position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); z-index: 6; width: max-content; max-width: min(92vw, 520px);
  padding: 10px 14px; border-radius: 12px; background: var(--card, #faf6ee); border: 1px solid var(--line-2, #d7cdb6); box-shadow: 0 12px 30px rgba(40, 50, 70, .14);
  font-size: 15px; line-height: 1.45; color: var(--text, inherit); text-align: center; white-space: normal; pointer-events: none; }
.dw-prompt__full[hidden] { display: none; }
@media (hover: hover) {
  .dw-prompt:has(.dw-prompt__meaning.is-clipped:hover) .dw-prompt__full[hidden] { display: block; }
}
.dw-prompt .tr-prompt__status { display: inline-block; margin-top: 8px; }
.tr-prompt.is-swap .dw-prompt__meaning { animation: tr-swap .38s cubic-bezier(.2, .8, .2, 1) both; }

/* ── Slot row (one per kana) — never wraps ───────────────────────── */
.dw-slots { display: flex; flex-wrap: nowrap; justify-content: center; gap: 6px; margin: 0 auto 14px; max-width: 100%; --dw-slot: 44px; }
.dw-slot { position: relative; flex: 0 0 auto; width: var(--dw-slot); height: var(--dw-slot); box-sizing: border-box; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-2, #d7cdb6); background: var(--inset, #fcfaf5); display: grid; place-items: center;
  transition: border-color .15s, box-shadow .15s, background .15s; }
.dw-slot__glyph { font-family: "Noto Sans JP", "Noto Sans CJK JP", sans-serif; font-size: calc(var(--dw-slot) * 0.56); line-height: 1; color: var(--text, inherit); pointer-events: none; }
.dw-slot--active { border-color: var(--accent, #20507e); box-shadow: 0 0 0 3px var(--accent-bg, rgba(32, 80, 126, .12)); background: var(--card, #faf6ee); }
.dw-slot--active::after { content: ''; position: absolute; left: 4px; right: 4px; bottom: 3px; height: 2px; border-radius: 1px; background: var(--accent, #20507e); animation: dw-breathe 1.6s ease-in-out infinite; }
@keyframes dw-breathe { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.dw-slot--read { border-color: var(--line-2, #d7cdb6); }
.dw-slot--unread { border-color: var(--orange, #bd7a14); }
.dw-slot--unread .dw-slot__glyph { color: var(--orange, #bd7a14); font-weight: 700; }
.dw-slot--answer { cursor: pointer; }
.dw-slot--right { border-color: color-mix(in srgb, var(--green, #2f8f5b) 55%, transparent); background: color-mix(in srgb, var(--green, #2f8f5b) 12%, transparent); }
.dw-slot--wrong { border-color: color-mix(in srgb, var(--red, #b1322a) 60%, transparent); background: color-mix(in srgb, var(--red, #b1322a) 12%, transparent); }
.dw-slot--revealed { border-style: dashed; }
.dw-slot--viewing { box-shadow: 0 0 0 3px var(--accent-bg, rgba(32, 80, 126, .12)); border-color: var(--accent, #20507e); }
.dw-slot__clear { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-2, #d7cdb6); background: var(--card, #faf6ee); color: var(--muted, #6b7280); font: 700 12px/1 system-ui, sans-serif; cursor: pointer; padding: 0; display: grid; place-items: center; }
.dw-slot__clear:hover { color: var(--accent, #20507e); border-color: var(--accent, #20507e); }
.dw-slot__clear[hidden] { display: none; }

/* ── The one canvas ─────────────────────────────────────────────── */
.dw-stage { display: flex; justify-content: center; }
.dw-canvas-wrap { position: relative; width: 100%; max-width: 340px; aspect-ratio: 1 / 1; border-radius: 20px; overflow: hidden; touch-action: none;
  border: 1px solid var(--canvas-border, #d7e0ea); box-shadow: var(--shadow-card, none);
  background:
    repeating-linear-gradient(90deg, var(--dw-guide) 0 6px, transparent 6px 12px) center / 100% 1px no-repeat,
    repeating-linear-gradient(180deg, var(--dw-guide) 0 6px, transparent 6px 12px) center / 1px 100% no-repeat,
    var(--inset, #fcfaf5);
  transition: border-color .2s, box-shadow .2s; }
.dw-canvas-wrap canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.dw-canvas-wrap--unread { border-color: var(--orange, #bd7a14); }
.dw-canvas-wrap--answer { border-color: color-mix(in srgb, var(--accent, #20507e) 45%, transparent); }
.dw-canvas-clear { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-2, #d7cdb6); background: var(--card, #faf6ee); color: var(--muted, #6b7280); font: 700 16px/1 system-ui, sans-serif; cursor: pointer; padding: 0; display: grid; place-items: center; opacity: .85; }
.dw-canvas-clear:hover { opacity: 1; color: var(--accent, #20507e); border-color: var(--accent, #20507e); }
.dw-canvas-clear[hidden] { display: none; }

/* Tools wrap on narrow screens instead of overflowing. */
.tr-session--words .tr-tools { margin-top: 18px; flex-wrap: wrap; }
.tr-track-chip.is-word { font-family: "Noto Sans JP", "Noto Sans CJK JP", sans-serif; font-weight: 500; font-size: 13px; min-width: 34px; padding: 0 8px; }

/* Summary chips carry whole words. */
.tr-sum-chip.is-word { font-size: 14px; padding: 0 8px; min-width: 40px; }

@media (max-width: 560px) {
  .dw-prompt__meaning { font-size: 22px; }
  .dw-slots { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .dw-slot--active::after { animation: none; }
}

/* Retry line under the squares (a square that matched nothing was wiped). */
.dw-feedback { min-height: 1.4em; margin-top: 10px; text-align: center; font-size: 13px; font-weight: 600; color: var(--red, #b1322a); opacity: 0; transition: opacity .2s; }
.dw-feedback.is-on { opacity: 1; }

/* ── Verdict tokens (2026-09-15) ─────────────────────────────────── */
.tr-session--words { --dw-answer: var(--accent, #20507e); --dw-wrong-ink: rgba(177, 50, 42, .35); }
html.dark .tr-session--words { --dw-answer: var(--accent, #6ea7d8); --dw-wrong-ink: rgba(224, 122, 96, .4); }
.dw-feedback.is-ok { color: var(--green, #2f8f5b); }

/* ── Known word (2026-09-15): the pill transforms into a split ──── */
.dw-known { position: relative; display: inline-flex; min-width: 156px; }
.dw-known__btn { width: 100%; justify-content: center; }
.dw-known__btn[hidden] { display: none; }
.dw-known__split { display: inline-flex; width: 100%; border-radius: 999px; overflow: hidden;
  border: 1px solid var(--accent, #20507e); background: var(--inset, #fcfaf5); box-shadow: 0 0 0 3px var(--accent-bg, rgba(32, 80, 126, .12)); }
.dw-known__split[hidden] { display: none; }
.dw-known__half { flex: 1 1 50%; font: inherit; font-size: 14px; font-weight: 700; padding: 9px 10px; border: 0; background: transparent; color: var(--text, inherit); cursor: pointer; white-space: nowrap; }
.dw-known__half--later { flex: 0 0 auto; min-width: 60px; background: var(--accent, #20507e); color: #fff; }
.dw-known__half--always { color: var(--muted, #6b7280); border-left: 1px solid var(--line-2, #d7cdb6); }
.dw-known__half:hover { color: var(--accent, #20507e); }
.dw-known__half--later:hover { color: #fff; background: var(--accent-light, #2f6c9e); }
.tr-track-chip.is-known { opacity: .55; border-style: dashed; }
.vdm-card-due.is-known { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }

/* ── Verdict: colour + motion only, nothing moves (2026-09-15) ────── */
.tr-session--words { --dw-wrong: #d1583a; }
html.dark .tr-session--words { --dw-wrong: #e8846a; }
.dw-slot--wrong { border-color: color-mix(in srgb, var(--dw-wrong) 70%, transparent); background: color-mix(in srgb, var(--dw-wrong) 16%, transparent); }
.dw-slot--wrong .dw-slot__glyph { color: var(--dw-wrong); }
.dw-slots--shake { animation: dw-slots-shake .5s ease; }
@keyframes dw-slots-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); } 30% { transform: translateX(7px); }
  45% { transform: translateX(-5px); } 60% { transform: translateX(5px); }
  75% { transform: translateX(-2px); } 90% { transform: translateX(2px); }
}
.dw-check { min-width: 104px; justify-content: center; }
.dw-check.is-continue { background: var(--accent, #20507e); color: #fff; border-color: transparent; }
.dw-check.is-continue:hover { color: #fff; }
.tr-session--words.is-revealed #ds-hint, .tr-session--words.is-revealed #ds-known { opacity: .4; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .dw-slots--shake { animation: none; } }
/* The written-chips strip keeps its height from the first card, so the
   first chip never pushes the footer. */
.tr-session--words .tr-track { min-height: 30px; }
/* Fireworks overlay: its own layer above the writing canvas, so a burst
   never blocks the pen or gets wiped by a redraw. */
.dw-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Guided (hinted) slot feedback: a wipe on too many misses, a nudge on a
   half stroke — same as the Workbook squares. */
.dw-canvas-wrap--shake { animation: dw-shake .42s ease; }
.dw-canvas-wrap--nudge { animation: dw-nudge .3s ease; }
@keyframes dw-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes dw-nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
