/* Little Words — flashcard player styles (engine-flashcards surface) */

html, body { margin: 0; padding: 0; background: var(--lw-bg); }
body { overflow-x: hidden; }

.pl-wrap { max-width: 560px; margin: 0 auto; padding: 8px 14px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .pl-wrap { max-width: 640px; padding-top: 16px; } }

/* top bar */
.pl-top {
  display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 4px 0;
}
.pl-back {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: var(--lw-tap-min); min-height: var(--lw-tap-min);
  border-radius: var(--lw-radius-round);
  color: var(--lw-ink); text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: 0 10px; background: transparent;
}
.pl-back:hover { background: var(--lw-bg-warm); }
.pl-title {
  flex: 1; text-align: center; font-family: var(--lw-font-display);
  font-weight: 660; font-size: 1.02rem; color: var(--lw-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-title .em { margin-right: 6px; }
.pl-parent-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--lw-tap-min); padding: 6px 14px;
  border-radius: var(--lw-radius-round);
  border: 2px solid var(--lw-line-strong);
  background: var(--lw-surface); color: var(--lw-ink);
  font-family: var(--lw-font-body); font-weight: 650; font-size: .85rem;
  cursor: pointer; touch-action: manipulation;
}
.pl-parent-toggle[aria-pressed="true"] {
  background: var(--lw-ink); border-color: var(--lw-ink); color: #fff;
}

/* progress */
.pl-progress { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.pl-progress-bar {
  flex: 1; height: 10px; border-radius: var(--lw-radius-round);
  background: var(--lw-bg-warm); overflow: hidden;
}
.pl-progress-fill {
  height: 100%; width: 0; border-radius: var(--lw-radius-round);
  background: linear-gradient(90deg, var(--lw-primary), var(--lw-primary-deep));
  transition: width var(--lw-dur-slow) var(--lw-ease-out);
}
.pl-count { font-weight: 700; font-size: .9rem; color: var(--lw-ink-soft); white-space: nowrap; }

/* parent strip */
.pl-parent { display: none; }
.pl-parent.on { display: block; animation: lw-pop-in var(--lw-dur) var(--lw-ease-pop) both; }
.pl-parent-label { font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--lw-primary-deep); margin: 2px 0 6px; }
.pl-parent-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.pl-parent-strip::-webkit-scrollbar { display: none; }
.pl-mini {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 64px; min-height: 64px; gap: 2px;
  border-radius: var(--lw-radius); border: 2px solid var(--lw-line);
  background: var(--lw-surface); cursor: pointer; touch-action: manipulation;
  font-family: var(--lw-font-body);
}
.pl-mini .em { font-size: 1.4rem; line-height: 1; }
.pl-mini .w { font-size: .62rem; font-weight: 700; color: var(--lw-ink-soft); max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-mini.cur { border-color: var(--lw-primary-deep); background: var(--lw-bg-warm); }
.pl-mini.done .w::after { content: " ✓"; color: var(--lw-leaf); }

/* stage */
.pl-stage { position: relative; }
.pl-card {
  position: relative; overflow: hidden;
  border-radius: var(--lw-radius-lg);
  background: var(--lw-surface);
  border: 1px solid var(--lw-line);
  box-shadow: var(--lw-shadow);
  padding: 14px 14px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.pl-card.slide-next { animation: pl-slide-l var(--lw-dur-slow) var(--lw-ease-pop) both; }
.pl-card.slide-prev { animation: pl-slide-r var(--lw-dur-slow) var(--lw-ease-pop) both; }
@keyframes pl-slide-l {
  0% { transform: translateX(56px) rotate(2deg); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@keyframes pl-slide-r {
  0% { transform: translateX(-56px) rotate(-2deg); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

.pl-deckchip { align-self: flex-start; display: none; }
.pl-deckchip.on { display: inline-flex; }

.pl-imgbtn {
  position: relative; display: block; width: min(72vw, 320px); aspect-ratio: 1;
  border: none; padding: 0; cursor: pointer; background: var(--lw-bg-warm);
  border-radius: var(--lw-radius); overflow: hidden; touch-action: manipulation;
}
.pl-imgbtn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-imgbtn .ph {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: clamp(64px, 30vw, 130px); line-height: 1;
  background: radial-gradient(circle at 50% 42%, #fff 0%, var(--lw-bg-warm) 78%);
}
.pl-imgbtn .ph-letter {
  font-family: var(--lw-font-display); font-weight: 760; color: var(--lw-primary-deep);
  text-shadow: 0 4px 0 rgba(194, 78, 54, .18);
}
.pl-imgbtn.playing { animation: lw-pulse-ring 900ms ease-out infinite; }
.pl-imgbtn:active { transform: scale(.985); }

/* annotation canvas sits over the image */
.pl-drawc { position: absolute; inset: 0; touch-action: none; pointer-events: none; }
.pl-card.drawing .pl-drawc { pointer-events: auto; cursor: crosshair; }

/* text layers */
.pl-text {
  min-height: 74px; display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--lw-font-display); color: var(--lw-ink);
  padding: 0 6px;
}
.pl-text[data-level="1"] { font-size: clamp(2rem, 9vw, 2.7rem); font-weight: 700; }
.pl-text[data-level="2"] { font-size: clamp(1.4rem, 6.4vw, 1.9rem); font-weight: 660; }
.pl-text[data-level="3"] { font-size: clamp(1.12rem, 5vw, 1.45rem); font-weight: 600; line-height: 1.3; }
.pl-text .swap { animation: lw-pop-in var(--lw-dur) var(--lw-ease-pop) both; }

/* parent prompt line */
.pl-prompt {
  display: none; margin-top: 2px; text-align: center;
  font-size: .95rem; color: var(--lw-ink-soft); background: var(--lw-bg-warm);
  border-radius: var(--lw-radius); padding: 10px 14px;
}
.pl-prompt.on { display: block; }

/* nav chevrons */
.pl-navbtn {
  position: absolute; top: 42%; transform: translateY(-50%); z-index: 5;
  width: 48px; height: 48px; border-radius: 50%;
  border: 2px solid var(--lw-line); background: var(--lw-surface); color: var(--lw-ink);
  font-size: 1.3rem; cursor: pointer; box-shadow: var(--lw-shadow-soft);
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.pl-navbtn:active { transform: translateY(-50%) scale(.94); }
.pl-navbtn[disabled] { opacity: .3; cursor: default; }
.pl-navbtn.prev { left: -6px; }
.pl-navbtn.next { right: -6px; background: var(--lw-primary-deep); border-color: var(--lw-primary-deep); color: #fff; }
@media (min-width: 900px) {
  .pl-navbtn { width: 56px; height: 56px; }
  .pl-navbtn.prev { left: -30px; }
  .pl-navbtn.next { right: -30px; }
}

/* controls */
.pl-controls {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 14px; flex-wrap: wrap;
}
.pl-ctl {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: none; background: transparent; cursor: pointer; padding: 0;
  font-family: var(--lw-font-body); touch-action: manipulation;
}
.pl-ctl .bub {
  width: 58px; height: 58px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  background: var(--lw-surface); border: 2px solid var(--lw-line-strong);
  box-shadow: 0 3px 0 var(--lw-line-strong);
  transition: transform var(--lw-dur-quick) var(--lw-ease-pop);
}
.pl-ctl:active .bub { transform: translateY(2px) scale(.96); box-shadow: none; }
.pl-ctl .lab { font-size: .72rem; font-weight: 700; color: var(--lw-ink-soft); }
.pl-ctl.primary .bub { background: var(--lw-primary-deep); border-color: var(--lw-primary-pressed); color: #fff; box-shadow: 0 3px 0 var(--lw-primary-pressed); }
.pl-ctl[aria-pressed="true"] .bub { background: var(--lw-ink); border-color: var(--lw-ink); color: #fff; box-shadow: 0 3px 0 #0e1730; }
.pl-ctl.rec-live .bub { background: #E5484D; border-color: #C13538; color: #fff; animation: lw-pulse-ring 900ms ease-out infinite; }
.pl-ctl.hidden { display: none; }
.pl-ctl .dot {
  position: absolute; margin-left: 38px; margin-top: -2px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--lw-sun);
  border: 2px solid var(--lw-surface); display: none;
}
.pl-ctl.has-dot .dot { display: block; }

.pl-privacy {
  margin-top: 10px; text-align: center; font-size: .78rem; color: #6E665C;
}

/* dial row */
.pl-dial-row { display: flex; justify-content: center; margin-top: 14px; }

/* toolbars (draw + note) */
.pl-toolbar {
  display: none; align-items: center; justify-content: center; gap: 10px;
  margin-top: 12px; padding: 10px; border-radius: var(--lw-radius);
  background: var(--lw-surface); border: 1px solid var(--lw-line); box-shadow: var(--lw-shadow-soft);
}
.pl-toolbar.on { display: flex; animation: lw-pop-in var(--lw-dur) var(--lw-ease-pop) both; }
.pl-swatch {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; padding: 0; touch-action: manipulation;
}
.pl-swatch[aria-pressed="true"] { border-color: var(--lw-ink); transform: scale(1.1); }
.pl-toolbtn {
  min-height: 40px; padding: 6px 14px; border-radius: var(--lw-radius-round);
  border: 2px solid var(--lw-line-strong); background: var(--lw-surface);
  font-weight: 700; font-size: .85rem; color: var(--lw-ink); cursor: pointer;
}
.pl-note-box { width: 100%; }
.pl-note-box textarea {
  width: 100%; min-height: 84px; resize: vertical;
  font-family: var(--lw-font-body); font-size: .95rem; color: var(--lw-ink);
  border: 2px solid var(--lw-line-strong); border-radius: var(--lw-radius);
  padding: 10px; background: var(--lw-bg);
}
.pl-note-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: .78rem; color: #6E665C; }

/* inline message (mic denied etc.) */
.pl-msg {
  display: none; margin-top: 10px; padding: 10px 14px; border-radius: var(--lw-radius);
  background: var(--lw-bg-warm); color: var(--lw-ink-soft); font-size: .88rem; text-align: center;
}
.pl-msg.on { display: block; animation: lw-pop-in var(--lw-dur) var(--lw-ease-pop) both; }

/* celebration overlay */
.pl-done {
  position: fixed; inset: 0; z-index: 80; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(30, 42, 74, .45);
}
.pl-done.on { display: flex; }
.pl-done-card {
  position: relative; width: min(92vw, 420px); text-align: center;
  background: var(--lw-surface); border-radius: var(--lw-radius-lg);
  padding: 30px 22px 26px; box-shadow: var(--lw-shadow);
  animation: lw-pop-in var(--lw-dur-slow) var(--lw-ease-pop) both;
}
.pl-done-card .big { font-size: 64px; line-height: 1; animation: lw-wiggle 900ms ease-in-out infinite; }
.pl-done-card h2 { font-size: 1.7rem; margin: 10px 0 4px; }
.pl-done-card p { margin: 0 0 18px; color: var(--lw-ink-soft); }
.pl-done-card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* loading / error states */
.pl-load { text-align: center; padding: 60px 20px; color: var(--lw-ink-soft); }
.pl-load .spin {
  width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 50%;
  border: 5px solid var(--lw-bg-warm); border-top-color: var(--lw-primary-deep);
  animation: pl-spin 900ms linear infinite;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }

/* parent-mode simplification: hide clinician tools */
.pl-wrap.parent .pl-ctl.clin { display: none; }

/* real card art in parent strip minis */
.pl-mini .em-img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; display: block; margin: 0 auto 2px; }

/* pl-title is an h1 for a11y; keep prior visual */
.pl-title { margin: 0; font-size: inherit; font-weight: inherit; }


/* ---------- variant A: clinician trial tally ---------- */
.pl-tallybtn {
  min-height: 48px; padding: 8px 18px; border-radius: var(--lw-radius-round);
  font-size: 1rem; font-weight: 800; cursor: pointer; border: 2px solid transparent;
  touch-action: manipulation;
}
.pl-tallybtn.yes { background: #DDF3E4; color: #18794E; border-color: #B4DFC4; }
.pl-tallybtn.almost { background: #FFF1D6; color: #AD5700; border-color: #F3D6A4; }
.pl-tallybtn.later { background: #FFE9E3; color: #CA3214; border-color: #F5C6B9; }
.pl-tallybtn:active { transform: translateY(1px) scale(.97); }
.pl-tallyline { font-size: .85rem; color: var(--lw-ink-soft); font-weight: 600; }
.pl-sum { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--lw-radius); background: var(--lw-bg-warm, #FBF5E9); border: 1px solid var(--lw-line); }
.pl-sum-line { font-weight: 800; margin-bottom: 4px; }
.pl-sum-revisit { font-size: .92rem; color: var(--lw-ink-soft); margin-bottom: 10px; }
.pl-sum-copied { display: block; margin-top: 6px; font-size: .85rem; color: #18794E; font-weight: 600; min-height: 1.2em; }

/* ---------- round-5 R1: session persistence / report exports ---------- */
.pl-resume { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px;
  background:var(--lw-bg-warm,#FFF0E8); border:1px solid var(--lw-line,#EFE9DF);
  border-radius:14px; padding:10px 14px; margin:10px auto 0; max-width:640px;
  font-size:.92rem; color:var(--lw-ink,#1E2A4A); }
.pl-resume-btns { display:flex; gap:6px; }
.pl-resume .pl-toolbtn.ghost { background:transparent; }
.pl-sum-actions { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin:10px 0 2px; }
.pl-sum-actions .lw-btn { min-height:44px; }
.pl-sum-privacy { font-size:.8rem; opacity:.75; margin:6px 0 0; }
.pl-past { margin-top:14px; border-top:1px solid var(--lw-line,#EFE9DF); padding-top:10px; text-align:left; }
.pl-past-head, .pl-report-savedhead { font-weight:700; font-size:.9rem; margin:4px 0 6px; }
.pl-past-row { display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:4px 0; font-size:.85rem; }
.pl-past-meta { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pl-past-btns { display:flex; gap:6px; flex:none; }
.pl-report { position:fixed; inset:0; z-index:60; background:rgba(30,42,74,.45);
  display:flex; align-items:center; justify-content:center; padding:16px; overflow:auto; }
.pl-report-card { background:var(--lw-bg,#FFFBF5); border-radius:18px; padding:20px 22px;
  max-width:560px; width:100%; max-height:88vh; overflow:auto; text-align:center; }
.pl-report-card h2 { margin:0 0 4px; }
.pl-report-line { margin:0 0 10px; font-size:.92rem; }
.pl-report-table { width:100%; border-collapse:collapse; font-size:.85rem; margin:8px 0; }
.pl-report-table th, .pl-report-table td { border-bottom:1px solid var(--lw-line,#EFE9DF);
  padding:5px 6px; text-align:left; }
#lw-print-report { display:none; }
@media print {
  body.lw-printing-report > :not(#lw-print-report) { display:none !important; }
  body.lw-printing-report #lw-print-report { display:block; font:12pt/1.5 monospace; white-space:pre-wrap; }
}
