/* ============================================================
   character-decks.css — /character-decks. Prebuilt kana study
   decks with Write + Recognize modes. New-theme tokens, light+dark.
   ============================================================ */

.cd-page { width: 100%; }

/* The view-swap relies on the `hidden` attribute, but several of these
   elements carry display:flex (inline or via a class) which would otherwise
   beat the UA `[hidden]` rule. Force hidden to win across the whole page. */
.cd-page [hidden] { display: none !important; }

.cd-hero { text-align: center; margin-bottom: 18px; }
.cd-hero .eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint, #7a6260);
}
.cd-hero h1 { font-size: 1.9rem; margin: .12em 0 .15em; color: var(--text, #1f1a1a); }
.cd-hero p { color: var(--text-muted, #54403a); font-size: .96rem; line-height: 1.5; margin: 0 auto; max-width: 620px; }

.cd-loading, .cd-error { text-align: center; color: var(--text-muted, #54403a); padding: 28px 0; }

/* ── Deck home ────────────────────────────────────────────── */
.cd-group { margin: 22px 0; }
.cd-group-title {
  font-size: 1.05rem; color: var(--text, #1f1a1a); margin: 0 0 10px;
  padding-bottom: 6px; border-bottom: 1.5px solid var(--container-border, #d9cdb4);
}
.cd-deck-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.cd-deck {
  display: flex; flex-direction: column; gap: 5px; text-align: left; cursor: pointer;
  font-family: inherit; padding: 12px 14px; border-radius: 12px;
  background: var(--bg, #fbf6ea); border: 1.5px solid var(--container-border, #d9cdb4);
  color: var(--text, #1f1a1a); transition: border-color .15s, transform .1s;
}
@media (hover: hover) { .cd-deck:hover { border-color: var(--accent, #b32a2a); transform: translateY(-1px); } }
.cd-deck-name { font-size: .95rem; font-weight: 700; }
.cd-deck-glyphs {
  font-family: 'Noto Sans JP', sans-serif; font-size: 1.25rem; line-height: 1.1;
  color: var(--text-muted, #54403a); letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cd-deck-meta { font-size: .72rem; color: var(--text-faint, #7a6260); }

/* ── Study view ───────────────────────────────────────────── */
.cd-study-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.cd-study-top .cd-deck-title { font-size: 1.05rem; font-weight: 700; color: var(--text, #1f1a1a); }
.cd-exit {
  font-family: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  background: transparent; border: 1.5px solid var(--container-border, #d9cdb4);
  color: var(--text-muted, #54403a); border-radius: 8px; padding: 6px 12px;
}
.cd-study-meta { display: flex; align-items: center; gap: 12px; }
.cd-progress { font-size: .8rem; font-weight: 600; color: var(--text-faint, #7a6260); }

/* Mode toggle (segmented) */
.cd-mode {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px;
  background: var(--bg-outer, #f4ede0); border: 1.5px solid var(--container-border, #d9cdb4);
}
.cd-mode-btn {
  appearance: none; border: none; cursor: pointer; font-family: inherit;
  font-size: .8rem; font-weight: 700; padding: 6px 14px; border-radius: 7px;
  background: transparent; color: var(--text-muted, #54403a);
}
.cd-mode-btn.is-active { background: var(--accent, #b32a2a); color: #fff; }

/* Mode hint — tells the user which SRS score the current mode trains. */
.cd-mode-hint {
  text-align: center; font-size: .76rem; color: var(--text-faint, #7a6260);
  margin: 2px auto 12px; max-width: 440px;
}

.cd-stage {
  max-width: 420px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

/* Write mode */
.cd-write-prompt { text-align: center; min-height: 44px; }
.cd-prompt-romaji { display: block; font-size: 1.7rem; font-weight: 800; color: var(--text, #1f1a1a); }
.cd-prompt-sub { display: block; font-size: .85rem; color: var(--text-muted, #54403a); margin-top: 2px; }
#cd-canvas-wrap {
  position: relative; width: 100%; max-width: 360px; aspect-ratio: 1/1; margin: 0 auto;
  background: transparent; border: 1.5px solid var(--container-border, #d9cdb4);
  border-radius: 14px; overflow: hidden; touch-action: none;
}
#cd-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.cd-answer {
  font-family: 'Noto Sans JP', sans-serif; font-size: 2.4rem; line-height: 1;
  color: var(--accent, #b32a2a); text-align: center;
}

/* Recognize mode — a square card that swaps front (glyph) ↔ back (reading).
   Explicit square + simple show/hide (no aspect-ratio / 3D, which collapse
   in this flex context). Matches the write canvas's square footprint. */
.cd-flip { width: 100%; display: flex; justify-content: center; }
.cd-flip-card {
  width: min(360px, 78vw); height: min(360px, 78vw); cursor: pointer;
  border-radius: 16px; padding: 16px; text-align: center;
  background: var(--bg, #fbf6ea); border: 1.5px solid var(--container-border, #d9cdb4);
}
.cd-flip-inner { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.cd-flip-face { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.cd-flip-card .cd-flip-back { display: none; }
.cd-flip-card.flipped .cd-flip-front { display: none; }
.cd-flip-card.flipped .cd-flip-back { display: flex; }
.cd-flip-front .cd-flip-glyph { font-family: 'Noto Sans JP', sans-serif; font-size: 5rem; line-height: 1; color: var(--text, #1f1a1a); }
.cd-flip-front .cd-flip-hint { font-size: .76rem; color: var(--text-faint, #7a6260); }
.cd-flip-back .cd-flip-romaji { font-size: 2rem; font-weight: 800; color: var(--accent, #b32a2a); }
.cd-flip-back .cd-flip-pron { font-size: .9rem; color: var(--text-muted, #54403a); }
.cd-flip-back .cd-flip-example { font-family: 'Noto Sans JP', sans-serif; font-size: .9rem; color: var(--text-faint, #7a6260); margin-top: 4px; }

/* Reveal + rating */
.cd-reveal-btn {
  font-family: inherit; font-size: .92rem; font-weight: 700; cursor: pointer;
  padding: 10px 28px; border-radius: 10px; border: none;
  background: var(--accent, #b32a2a); color: #fff;
}
.cd-rate { display: flex; gap: 8px; width: 100%; max-width: 360px; }
.cd-rate-btn {
  flex: 1; font-family: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
  padding: 12px 6px; border-radius: 10px; border: 1.5px solid var(--container-border, #d9cdb4);
  background: var(--bg, #fbf6ea); color: var(--text, #1f1a1a);
}
.cd-rate-again { border-color: #b1322a; color: #b1322a; }
.cd-rate-good  { border-color: #c08a2a; color: #9a6a16; }
.cd-rate-easy  { border-color: #2f8f5b; color: #2f8f5b; }
@media (hover: hover) { .cd-rate-btn:hover { filter: brightness(.97); transform: translateY(-1px); } }

/* Summary */
.cd-summary-inner { text-align: center; padding: 30px 12px; }
.cd-summary-check {
  width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--green, #2f8f5b); color: #fff; font-size: 30px; line-height: 56px;
}
.cd-summary-inner h2 { font-size: 1.4rem; color: var(--text, #1f1a1a); margin: 0 0 6px; }
.cd-summary-stats { color: var(--text-muted, #54403a); margin-bottom: 16px; }
.cd-summary-actions { display: flex; gap: 10px; justify-content: center; }

/* ── Deck-card "Progress" affordance ──────────────────────────── */
.cd-deck-meta {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.cd-deck-progress-link {
  font-size: .72rem; font-weight: 700; color: var(--accent, #20507e);
  white-space: nowrap; cursor: pointer;
}
@media (hover: hover) { .cd-deck-progress-link:hover { text-decoration: underline; } }

/* ── Per-deck progress modal ──────────────────────────────────── */
.cd-prog-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .3s;
  padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.cd-prog-backdrop.visible { opacity: 1; pointer-events: auto; }
.cd-prog-modal { max-width: 440px; width: 100%; margin: auto; padding: 20px 0; flex-shrink: 0; }
.cd-prog-card {
  background: var(--bg, #fbf6ea); border: 1px solid var(--container-border, #d9cdb4);
  border-radius: 20px; padding: 22px 22px 12px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}
.cd-prog-header { text-align: center; position: relative; margin-bottom: 14px; }
.cd-prog-title { font-size: 1.25rem; font-weight: 700; color: var(--text, #1f1a1a); margin: 0 0 6px; }
.cd-prog-overall { font-size: .85rem; color: var(--text-muted, #54403a); }
.cd-prog-overall strong { color: var(--accent, #20507e); font-size: 1.05rem; }
.cd-prog-close {
  position: absolute; top: -6px; right: -6px; width: 32px; height: 32px;
  border: none; background: transparent; color: var(--text-faint, #7a6260);
  font-size: 22px; line-height: 1; cursor: pointer; border-radius: 8px;
}
@media (hover: hover) { .cd-prog-close:hover { color: var(--accent, #20507e); } }

.cd-prog-legend {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
  margin-top: 10px; font-size: .68rem; font-weight: 600; color: var(--text-muted, #54403a);
}
.cd-prog-key { display: inline-flex; align-items: center; gap: 4px; }
.cd-prog-key::before {
  content: ""; width: 10px; height: 10px; border-radius: 3px; display: inline-block;
}
.cd-prog-key--write::before { background: var(--accent, #20507e); }
.cd-prog-key--read::before  { background: #c0267e; }
.cd-prog-key--sched::before { display: none; }

/* "N due for review now" badge in the header. */
.cd-prog-duenow {
  display: inline-block; margin-left: 10px; padding: 1px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700;
  color: #fff; background: #c0267e;
}

.cd-prog-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: min(60vh, 520px); overflow-y: auto; padding: 2px;
}
.cd-prog-empty { text-align: center; color: var(--text-muted, #54403a); padding: 24px 0; }
.cd-prog-note {
  margin: 12px 2px 2px; padding-top: 12px; border-top: 1px solid var(--container-border, #d9cdb4);
  font-size: .72rem; line-height: 1.45; color: var(--text-faint, #7a6260); text-align: center;
}

.cd-prog-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 8px; border-radius: 10px;
  border: 1px solid transparent;
}
.cd-prog-row.is-learned { background: color-mix(in srgb, var(--green, #2f8f5b) 8%, transparent); }
.cd-prog-char {
  width: 46px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.cd-prog-glyph { font-family: 'Noto Sans JP', sans-serif; font-size: 1.5rem; line-height: 1; color: var(--text, #1f1a1a); }
.cd-prog-romaji { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint, #7a6260); }

.cd-prog-gauges { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cd-prog-gauge { display: flex; align-items: center; gap: 8px; }
.cd-prog-gauge-name {
  width: 44px; flex-shrink: 0; font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted, #54403a);
}
.cd-prog-track {
  flex: 1; height: 8px; border-radius: 5px; overflow: hidden; min-width: 0;
  background: var(--subtle-bg, #efe6d3);
}
.cd-prog-fill { display: block; height: 100%; border-radius: 5px; transition: width .5s ease; }
.cd-prog-gauge--write .cd-prog-fill { background: var(--accent, #20507e); }
.cd-prog-gauge--read .cd-prog-fill  { background: #c0267e; }
.cd-prog-gauge.is-learned .cd-prog-fill { background: var(--green, #2f8f5b); }
.cd-prog-val {
  width: 46px; flex-shrink: 0; text-align: right; font-size: .64rem; font-weight: 700;
  color: var(--text-muted, #54403a);
}
.cd-prog-gauge.is-learned .cd-prog-val { color: var(--green, #2f8f5b); }
.cd-prog-gauge.is-new .cd-prog-val { color: var(--text-faint, #7a6260); font-weight: 600; }

/* Next-review schedule chip (when the card comes back). */
.cd-prog-sched {
  width: 52px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: flex-end;
  gap: 2px; font-size: .64rem; font-weight: 700; white-space: nowrap;
  color: var(--text-faint, #7a6260);
}
.cd-prog-sched-i { font-size: .9em; opacity: .8; }
.cd-prog-sched.is-due { color: #c0267e; }
.cd-prog-sched.is-soon { color: var(--accent, #20507e); }
.cd-prog-sched.is-scheduled { color: var(--text-muted, #54403a); }
.cd-prog-sched.is-none { color: var(--text-faint, #7a6260); opacity: .5; font-weight: 600; }

/* Summary-screen "View progress" button sits inline with the others. */
.cd-summary-actions .cd-prog-open-btn { }

/* Summary-screen "View progress" button sits inline with the others. */
.cd-summary-actions .cd-prog-open-btn { }
