/* Lớp hướng dẫn: nền tối bốn phía, 1 ô vuông sáng, hộp chữ và mũi tên (js/ui/coach.js). Nằm trên mọi popup. */
.coach { position: absolute; inset: 0; z-index: 120; pointer-events: none; }
.coach.hide { display: none; }
.coach-shade { position: absolute; background: rgb(14 20 10 / 0.8); pointer-events: auto; touch-action: none; }
.coach-ring {
  position: absolute; box-sizing: border-box; border: 4px solid #ffd34e; border-radius: 0.7rem; pointer-events: none;
  box-shadow: 0 0 0 2px rgb(58 38 22 / 0.8), 0 0 22px 4px rgb(255 211 78 / 0.75); animation: coach-glow 1.3s ease-in-out infinite;
}
.coach-lid { position: absolute; pointer-events: auto; touch-action: none; }

.coach-box {
  position: absolute; width: min(34rem, 62vw); max-height: calc(100% - 1rem); overflow-y: auto; pointer-events: auto; padding: 0.7rem 0.9rem 0.8rem;
  border: 3px solid var(--panel-line, #8d6a43); border-radius: 1rem; background: var(--paper-light, #fbf4e4); color: var(--ink, #3a2616);
  box-shadow: 0 4px 0 rgb(58 38 22 / 0.4), 0 10px 24px rgb(0 0 0 / 0.45);
}
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.2rem; }
.coach-progress { font-size: 0.8rem; font-weight: 800; color: var(--leaf, #3f6b39); }
.coach-exit { min-height: 2.75rem; min-width: 2.75rem; padding: 0 0.7rem; border: 0; background: none; color: var(--ink-soft, #6b5440); font: 700 0.85rem var(--font-body); text-decoration: underline; cursor: pointer; }
.coach-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; line-height: 1.15; margin-bottom: 0.25rem; }
.coach-text { display: flex; flex-direction: column; gap: 0.35rem; font-size: 1.05rem; line-height: 1.4; }
.coach-text p { margin: 0; }
.coach-kw { color: var(--keyword, #1257b0); font-weight: 800; }
.coach-next { margin-top: 0.6rem; min-height: 2.9rem; width: 100%; }

.coach-arrow { position: absolute; width: 28px; height: 28px; pointer-events: none; display: none; }
.coach-arrow i {
  position: absolute; inset: 0; display: block; background: #ffd34e; border: 3px solid #5a4028; box-sizing: border-box;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.coach-arrow[data-dir='up'] i { transform: rotate(0deg); --bob: -7px; animation: coach-bob-y 0.9s ease-in-out infinite; }
.coach-arrow[data-dir='down'] i { transform: rotate(180deg); --bob: 7px; animation: coach-bob-y 0.9s ease-in-out infinite; }
.coach-arrow[data-dir='left'] i { transform: rotate(-90deg); --bob: -7px; animation: coach-bob-x 0.9s ease-in-out infinite; }
.coach-arrow[data-dir='right'] i { transform: rotate(90deg); --bob: 7px; animation: coach-bob-x 0.9s ease-in-out infinite; }

.coach .nudge { animation: coach-nudge 360ms; }
.coach-ring.nudge { animation: coach-flash 360ms; }

@keyframes coach-glow { 50% { box-shadow: 0 0 0 2px rgb(58 38 22 / 0.8), 0 0 34px 10px rgb(255 211 78 / 0.95); } }
@keyframes coach-bob-x { 50% { translate: var(--bob, 0) 0; } }
@keyframes coach-bob-y { 50% { translate: 0 var(--bob, 0); } }
@keyframes coach-nudge { 20% { translate: -7px 0; } 40% { translate: 7px 0; } 60% { translate: -4px 0; } 80% { translate: 4px 0; } }
@keyframes coach-flash { 50% { border-color: #fff; box-shadow: 0 0 0 2px #fff, 0 0 40px 14px rgb(255 255 255 / 0.9); } }
.reduce-motion .coach-ring, .reduce-motion .coach-arrow i, .reduce-motion .coach .nudge { animation: none; }

@media (max-height: 26rem) {
  .coach-box { padding: 0.45rem 0.7rem 0.55rem; width: min(30rem, 64vw); }
  .coach-title { font-size: 1.05rem; }
  .coach-text { font-size: 0.95rem; line-height: 1.3; gap: 0.25rem; }
  .coach-next { min-height: 2.75rem; margin-top: 0.4rem; }
}

/* Hộp giải thích từ khoá luôn nằm trên lớp hướng dẫn để em bấm đóng được */
.popup-backdrop.kw-backdrop { z-index: 130; }

/* Hộp chữ thu nhỏ khi màn thấp mà vẫn phải nằm gọn phía trên nút (coach.js, place 'aboveRight') */
.coach-box.tight { padding: 0.4rem 0.65rem 0.5rem; }
.coach-box.tight .coach-title { font-size: 1rem; margin-bottom: 0.1rem; }
.coach-box.tight .coach-text { font-size: 0.9rem; line-height: 1.25; gap: 0.2rem; }
.coach-box.tight .coach-head { margin-bottom: 0; }
.coach-box.tight .coach-exit { min-height: 2rem; }
