/* ================================================================
   INTERACTIVE.CSS — Styling for the Creative Interactivity Layer
   Sounds toggle, timers, badges, path map, new question types,
   stats & review modals. Soft modern look. Loaded LAST.
   ================================================================ */

/* ── SHAKE (wrong answer feedback) ── */
@keyframes softShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.shake { animation: softShake 0.4s var(--ease); }

/* ── TOPBAR ACTION BUTTONS ── */
.nb-actions { display: flex; align-items: center; gap: 6px; }
.nb-act { position: relative; }
.nb-act-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--rose); color: #fff;
  border-radius: var(--r-pill); font-size: 0.62rem; font-weight: 700;
  display: none; align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 2px 6px rgba(239,68,68,0.4);
}
@media (max-width: 768px) {
  #nb-stats-btn, #nb-sound-toggle { display: none; }
  .nb-actions { gap: 3px; }
}

/* ── PER-QUESTION SPEED TIMER BAR ── */
.nb-qtimer {
  height: 6px; background: rgba(99,102,241,0.12);
  border-radius: var(--r-pill); overflow: hidden; margin-bottom: 0.7rem;
}
.nb-qtimer-fill {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--primary), var(--violet));
  border-radius: var(--r-pill);
  transition: width 30s linear;
}
.nb-speed-pop {
  position: fixed; transform: translateX(-50%); z-index: 9999; pointer-events: none;
  background: var(--surface); color: var(--primary-deep);
  border: 1px solid rgba(99,102,241,0.25); border-radius: var(--r-pill);
  box-shadow: var(--sh-md);
  font-weight: 700; font-size: 0.95rem; padding: 5px 14px;
  animation: softSpeedUp 1.1s ease-out forwards;
}
@keyframes softSpeedUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, -6px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -44px) scale(1); }
}

/* ================================================================
   GENERIC MODAL
   ================================================================ */
.nb-modal-overlay {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(15,23,42,0.45); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; padding: 1.25rem;
}
.nb-modal-overlay.open { display: flex; animation: softFade 0.2s ease; }
@keyframes softFade { from { opacity: 0; } to { opacity: 1; } }
.nb-modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  width: 100%; max-width: 680px; max-height: 88vh; display: flex; flex-direction: column;
  animation: softModalIn 0.35s var(--spring) both;
  overflow: hidden;
}
@keyframes softModalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.nb-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.nb-modal-head h2 { font-size: 1.15rem; font-weight: 800; color: var(--ink); }
.nb-modal-close {
  width: 36px; height: 36px; background: var(--surface2); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--r-sm); font-weight: 700;
  transition: all 0.18s var(--ease);
}
.nb-modal-close:hover { background: var(--rose-tint); color: #B91C1C; border-color: rgba(239,68,68,0.3); }
.nb-modal-body { padding: 1.4rem; overflow-y: auto; }
.nb-empty { text-align: center; color: var(--text-muted); padding: 1.5rem; font-weight: 600; }
.nb-sub { font-weight: 800; margin: 1rem 0 0.6rem; color: var(--ink); }

/* ================================================================
   BADGES
   ================================================================ */
.nb-badges-progress { text-align: center; font-weight: 700; margin-bottom: 1rem; color: var(--text-sec); }
.nb-badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 0.9rem; }
.nb-badge-card {
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 1.1rem 0.75rem; text-align: center;
  background: var(--surface); box-shadow: var(--sh-xs);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.nb-badge-card.got { background: var(--emerald-tint); border-color: rgba(16,185,129,0.30); }
.nb-badge-card.got:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.nb-badge-card.locked { background: var(--surface2); opacity: 0.7; }
.nb-badge-ic { font-size: 2.2rem; }
.nb-badge-card.locked .nb-badge-ic { filter: grayscale(1); opacity: 0.6; }
.nb-badge-name { font-weight: 800; margin: 0.4rem 0 0.2rem; color: var(--ink); }
.nb-badge-desc { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }

/* ================================================================
   LEARNING PATH MAP
   ================================================================ */
.nb-path-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0.5rem 0; }
.nb-path-node {
  display: flex; align-items: center; gap: 1rem; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 0.75rem 1rem; box-shadow: var(--sh-xs); position: relative;
  width: 86%; animation: softModalIn 0.35s var(--spring) both; animation-delay: calc(var(--i) * 0.05s);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
}
.nb-path-node:nth-child(4n+1) { align-self: flex-start; }
.nb-path-node:nth-child(4n+3) { align-self: flex-end; }
.nb-path-node:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: rgba(99,102,241,0.30); }
.nb-path-link { width: 2px; height: 26px; background: var(--border-md); margin: 0 auto; border-radius: 2px; }
.nb-path-dot {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 800;
  background: var(--primary-tint); color: var(--primary-deep);
}
.nb-path-node.done  { background: var(--emerald-tint); border-color: rgba(16,185,129,0.25); }
.nb-path-node.done .nb-path-dot  { background: var(--emerald); color: #fff; }
.nb-path-node.current { background: var(--primary-tint); border-color: rgba(99,102,241,0.35); }
.nb-path-node.current .nb-path-dot { background: linear-gradient(135deg, var(--primary), var(--violet)); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,0.35); }
.nb-path-node.locked { background: var(--surface2); cursor: not-allowed; opacity: 0.7; }
.nb-path-node.locked .nb-path-dot { background: var(--border); color: var(--text-muted); }
.nb-path-num { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); }
.nb-path-name { font-weight: 800; color: var(--ink); }
.nb-path-here {
  position: absolute; top: -10px; left: 12px;
  background: linear-gradient(135deg, var(--primary), var(--violet)); color: #fff;
  font-size: 0.66rem; font-weight: 700; padding: 2px 10px; border-radius: var(--r-pill);
  box-shadow: 0 4px 10px rgba(99,102,241,0.35);
}

/* ================================================================
   STATS DASHBOARD
   ================================================================ */
.nb-stat-cards { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.7rem; margin-bottom: 0.5rem; }
.nb-kpi {
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 0.9rem 0.5rem; text-align: center;
  box-shadow: var(--sh-xs);
}
.nb-kpi b { display: block; font-size: 1.25rem; font-weight: 800; color: var(--ink); }
.nb-kpi span { font-size: 0.72rem; font-weight: 600; color: var(--text-sec); }
.nb-stat-row { margin-bottom: 0.8rem; }
.nb-stat-head { display: flex; justify-content: space-between; font-weight: 700; color: var(--text-sec); margin-bottom: 0.3rem; font-size: 0.9rem; }
.nb-stat-bar { height: 10px; background: rgba(99,102,241,0.10); border-radius: var(--r-pill); overflow: hidden; }
.nb-stat-bar span { display: block; height: 100%; border-radius: var(--r-pill); transition: width 0.7s var(--ease); }
.nb-advice {
  margin-top: 1rem; padding: 0.9rem 1.1rem;
  background: var(--primary-tint); border: 1px solid rgba(99,102,241,0.20);
  border-radius: var(--r-md); font-weight: 600; color: var(--text-primary);
}
.nb-review-line {
  margin-top: 1rem; padding: 0.9rem 1.1rem;
  background: var(--sky-tint); border: 1px solid rgba(14,165,233,0.20);
  border-radius: var(--r-md); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-weight: 600; color: var(--text-primary);
}
@media (max-width: 600px) { .nb-stat-cards { grid-template-columns: repeat(2,1fr); } }

/* ================================================================
   SRS REVIEW SESSION
   ================================================================ */
.nb-review-card {
  border: 1px solid var(--border); border-radius: var(--r-lg); min-height: 180px; cursor: pointer;
  position: relative; box-shadow: var(--sh-sm); overflow: hidden; background: var(--surface);
  display: grid;
  transition: box-shadow 0.2s var(--ease);
}
.nb-review-card:hover { box-shadow: var(--sh-md); }
.nb-rc-front, .nb-rc-back {
  grid-area: 1/1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.6rem; padding: 1.5rem; transition: opacity 0.2s;
  border-bottom: 4px solid var(--primary);
}
.nb-rc-back { border-bottom-color: var(--violet); }
.nb-review-card .nb-rc-back { opacity: 0; }
.nb-review-card.flipped .nb-rc-front { opacity: 0; }
.nb-review-card.flipped .nb-rc-back { opacity: 1; }
.nb-rc-en { font-family: var(--ff-en); font-size: 2rem; font-weight: 800; color: var(--ink); }
.nb-rc-hint { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.nb-rc-ar { font-size: 1.8rem; font-weight: 800; color: var(--ink); }
.nb-review-actions { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.6rem; margin-top: 1rem; }
.nb-review-actions .btn { color: #fff; font-weight: 700 !important; border-radius: var(--r-md) !important; box-shadow: var(--sh-sm) !important; }
.nb-review-actions .srs-hard { background: var(--rose) !important; }
.nb-review-actions .srs-good { background: var(--amber) !important; color: #fff !important; }
.nb-review-actions .srs-easy { background: var(--emerald) !important; color: #fff !important; }
.nb-review-done, .nb-review-line b { color: var(--ink); }
.nb-review-done { text-align: center; font-size: 1.1rem; font-weight: 800; padding: 1rem; }

/* ================================================================
   NEW QUESTION TYPES — ARRANGE & FILL
   ================================================================ */
/* Arrange */
.nb-order-answer {
  min-height: 52px; border: 1.5px dashed var(--border-md); border-radius: var(--r-md);
  background: var(--surface); padding: 0.6rem; margin-bottom: 0.8rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
}
.nb-order-answer.correct { background: var(--emerald-tint); border: 1.5px solid var(--emerald); }
.nb-order-answer.wrong { background: var(--rose-tint); border: 1.5px solid var(--rose); }
.nb-order-placeholder { color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }
.nb-order-correct { font-family: var(--ff-en); font-weight: 800; color: var(--ink); }
.nb-order-bank { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.nb-token {
  font-family: var(--ff-en); font-weight: 700; font-size: 1rem; color: var(--primary-deep);
  background: var(--primary-tint); border: 1px solid rgba(99,102,241,0.25); border-radius: var(--r-sm);
  padding: 0.4rem 0.85rem; box-shadow: var(--sh-xs);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s;
}
.nb-token:hover { transform: translateY(-2px); box-shadow: var(--sh-sm); }
.nb-token:active { transform: translateY(0); box-shadow: none; }
.nb-token.placed { background: var(--sky-tint); color: #0369A1; border-color: rgba(14,165,233,0.30); }

/* Fill in */
.nb-fill-blank {
  display: inline-block; min-width: 60px; border-bottom: 2px solid var(--primary);
  text-align: center; color: var(--primary-deep); font-weight: 800;
}
.nb-fill-row { display: flex; gap: 0.6rem; align-items: stretch; }
.nb-fill-input {
  flex: 1; font-family: var(--ff-en); font-size: 1.05rem; font-weight: 700; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--border-md); border-radius: var(--r-sm);
  padding: 0.6rem 0.9rem; outline: none; min-width: 0;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.nb-fill-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99,102,241,0.14); }
.nb-fill-input.correct { background: var(--emerald-tint); border-color: var(--emerald); color: #065F46; }
.nb-fill-input.wrong { background: var(--rose-tint); border-color: var(--rose); color: #991B1B; }
.nb-check-fill { white-space: nowrap; }
.nb-fill-correct {
  margin-top: 0.6rem; font-weight: 700; color: var(--primary-deep);
  background: var(--primary-tint); border: 1px solid rgba(99,102,241,0.20);
  border-radius: var(--r-sm); padding: 0.5rem 0.85rem;
}

@media (hover: none) {
  .nb-token:hover, .nb-badge-card.got:hover, .nb-path-node:hover { transform: none; }
}
