/* ─────────────────────────────────────────────────────────────────
   css/doc-helper.css  (2026-06-24)
   "Talk to a letter" modal. Mirrors the coloring-page / game-wizard
   brand chrome (white paper card, navy gradient header, amber accent,
   spring motion) so it reads as one system. Scoped to .doc-modal.
   Honors prefers-reduced-motion.
   ───────────────────────────────────────────────────────────────── */

.doc-modal {
  background: radial-gradient(at 0% 0%, rgba(232, 163, 61, 0.05) 0%, transparent 55%), #ffffff;
  color: #1f1b2e;
  border: 1px solid rgba(12, 21, 48, 0.08);
  border-radius: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 20px 60px rgba(12, 21, 48, 0.30);
  transform: translateY(16px) scale(0.97);
  transition: transform 360ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)), opacity 240ms ease;
  width: min(560px, 94vw);
}
.smart-tpl-modal.open .doc-modal { transform: none; }
.doc-modal .smart-tpl-modal-head { background: linear-gradient(180deg, #1A1A2E 0%, #161527 100%); border-bottom: 1px solid rgba(232, 168, 56, 0.20); }
.doc-modal .smart-tpl-modal-icon { filter: drop-shadow(0 2px 6px rgba(232, 168, 56, 0.30)); }
.doc-modal .smart-tpl-modal-head h3 { color: #F5EDE0; letter-spacing: -0.01em; }
.doc-modal .smart-tpl-modal-close { color: rgba(245, 237, 224, 0.85); transition: background 140ms ease, transform 140ms ease; }
.doc-modal .smart-tpl-modal-close:hover { background: rgba(245, 237, 224, 0.16); color: #fff; transform: rotate(90deg); }
.doc-modal .smart-tpl-label { color: #2a2438; }

.dh-note {
  display: flex; align-items: flex-start; gap: 0.5rem;
  font-size: 0.82rem; line-height: 1.4; color: #2c5450;
  background: #eef7f6; border: 1px solid #cfe7e4; border-radius: 12px;
  padding: 0.6rem 0.75rem; margin-bottom: 1rem;
}
.dh-note strong { color: #1f3f3c; }
.dh-nokey {
  font-size: 0.9rem; line-height: 1.5; color: #5a4a1e;
  background: #fff6e0; border: 1px solid #f0d896; border-radius: 12px; padding: 0.7rem 0.85rem;
}

/* File picker */
.dh-file-native { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.doc-modal .dh-filebtn {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.75rem 0.85rem;
  border: 1.5px dashed #D6CFC0; border-radius: 14px; background: #FBF8F2; color: #4a4458;
  font-weight: 600; cursor: pointer; box-shadow: 0 1px 3px rgba(12, 21, 48, 0.05);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}
.doc-modal .dh-filebtn:hover { border-color: var(--amber, #E8A838); background: #fff7e6; transform: translateY(-1px); }
.doc-modal .dh-filebtn:active { transform: scale(0.985); }
.dh-file-native:focus-visible + .dh-filebtn { border-color: #E8A838; border-style: solid; box-shadow: 0 0 0 3px rgba(232, 168, 56, 0.20); }
.dh-filename { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-modal .dh-read {
  width: 100%; margin-top: 0.4rem;
  background: linear-gradient(180deg, #F2B24A 0%, #E8A838 100%); border-color: #E2A02E;
  box-shadow: 0 4px 14px rgba(232, 168, 56, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 180ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)), box-shadow 180ms ease, filter 180ms ease;
}
.doc-modal .dh-read:hover:not([disabled]) { transform: translateY(-2px); filter: brightness(1.03); }
.doc-modal .dh-read:active:not([disabled]) { transform: translateY(0) scale(0.985); }
.doc-modal .dh-read[disabled] { filter: grayscale(0.25); box-shadow: none; }

.dh-error { font-size: 0.85rem; color: #b42318; background: #fdf0ee; border: 1px solid #f3c6c0; border-radius: 12px; padding: 0.6rem 0.75rem; margin-top: 0.65rem; }

/* Result sections */
.dh-result { margin-top: 1rem; animation: dhIn 360ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)); }
@keyframes dhIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.dh-sec { margin-bottom: 1rem; }
.dh-sec h4 { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.35rem; font-size: 0.95rem; color: #1a1a2e; }
.dh-plain { font-size: 1.02rem; line-height: 1.55; color: #211c30; }
.dh-todolist { margin: 0; padding-left: 1.2rem; line-height: 1.6; }
.dh-todolist li { margin-bottom: 0.25rem; }
.dh-tts {
  border: none; background: rgba(232, 168, 56, 0.14); color: #8a5a00; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%; font-size: 0.95rem; line-height: 1; flex-shrink: 0;
  transition: background 140ms ease, transform 140ms ease;
}
.dh-tts:hover { background: rgba(232, 168, 56, 0.26); }
.dh-tts:active { transform: scale(0.9); }
.dh-fulltext { margin-bottom: 1rem; }
.dh-fulltext summary { cursor: pointer; font-size: 0.85rem; color: #4a6076; font-weight: 600; }
.dh-fulltext pre { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 0.82rem; color: #4a4458; background: #faf8f2; border: 1px solid var(--rh-line, #e3e0d6); border-radius: 10px; padding: 0.7rem; margin-top: 0.5rem; max-height: 30vh; overflow: auto; }

/* Chat */
.dh-chat { display: flex; flex-direction: column; gap: 0.5rem; max-height: 36vh; overflow-y: auto; margin: 0.5rem 0 0.8rem; }
.dh-bubble { display: flex; align-items: flex-start; gap: 0.4rem; max-width: 92%; }
.dh-bubble-text { padding: 0.55rem 0.75rem; border-radius: 14px; font-size: 0.95rem; line-height: 1.45; }
.dh-bubble--user { align-self: flex-end; }
.dh-bubble--user .dh-bubble-text { background: #e8a838; color: #2a2008; border-bottom-right-radius: 4px; }
.dh-bubble--assistant { align-self: flex-start; }
.dh-bubble--assistant .dh-bubble-text { background: #f1efe9; color: #211c30; border-bottom-left-radius: 4px; }
.dh-thinking .dh-bubble-text { color: #8a8a8a; }
.dh-ask { display: flex; gap: 0.5rem; }
.dh-ask input {
  flex: 1 1 auto; font: inherit; padding: 0.65rem 0.8rem; min-height: 48px;
  border: 1.5px solid #d8d3c7; border-radius: 12px; background: #faf8f2; color: #1f1b2e;
}
.dh-ask input:focus { outline: none; border-color: #E8A838; box-shadow: 0 0 0 3px rgba(232, 168, 56, 0.18); }
.doc-modal .dh-ask .smart-tpl-go { background: linear-gradient(180deg, #F2B24A 0%, #E8A838 100%); border-color: #E2A02E; flex: 0 0 auto; }

.doc-modal #dhClose { color: #4a4458; border-color: rgba(12, 21, 48, 0.16); }
.doc-modal #dhClose:hover { background: #f6f3ee; color: #1f1b2e; }

@media (prefers-reduced-motion: reduce) {
  .doc-modal, .doc-modal .dh-read, .doc-modal .dh-filebtn, .dh-tts { transition: none; }
  .dh-result { animation: none; }
}
