/* Tutor Quest — daily mission for private tutors.
 * Wave 4b: no more floating widget/drag/pill. Content lives inside the shared
 * control-surface pane (#nabgolControlSurface); .nabgol-progress-chip is the
 * only persistently visible surface, in the page header. */
:root {
  --tq-ink: #0b3d2e;
  --tq-gold: #e8b84a;
  --tq-coral: #ff6b4a;
  --tq-mint: #1fa97a;
  --tq-sky: #2bb0ed;
  --tq-card: rgba(255, 252, 245, 0.96);
  --tq-shadow: 0 10px 28px rgba(11, 61, 46, 0.18);
}

/* First screen must stay calm: hide the progress chip while welcome/empty is visible. */
body:is(.desktop-chat, .mobile-chat):has(#emptyState:not([style*="display: none"])) #nabgolProgressChip {
  display: none !important;
}

/* Forever F0: JS toggles nabgol-empty-chat — beats desktop flex display rule */
body.nabgol-empty-chat #nabgolProgressChip {
  display: none !important;
  pointer-events: none !important;
}

/* —— Header chip: the only persistently visible progress surface —— */
.nabgol-progress-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  line-height: 1.25;
  font-family: Vazirmatn, Tahoma, sans-serif;
}

.nabgol-progress-chip .btn-label {
  white-space: nowrap;
}

.nabgol-progress-chip-streak {
  font-size: 0.78em;
  opacity: 0.75;
}

.icon-btn.nabgol-progress-chip {
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.nabgol-progress-chip-count {
  font-size: 0.78em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.nabgol-progress-chip.is-celebrate {
  animation: tq-bounce 0.55s ease;
}

.nabgol-progress-chip.is-levelup,
.nabgol-progress-chip.is-complete-pulse {
  animation: tq-level 0.7s ease;
}

/* 2026-08-22 — the panel hosts two tabs (mission + the 16-button learner
   toolbar that used to live in the side panel). Wave 4b (measured in a real
   browser, not just jsdom): this content now lives inside the shared
   control-surface pane, which already scrolls its own body
   (.nabgol-cs-body { overflow: auto } in control-surface.css) exactly like the
   letter/studio content does — no bespoke height/scroll of its own here. A
   self-contained max-height was tried and measured wrong: the mobile sheet
   host sizes itself with an auto height plus its own max-height cap, so a
   percentage or fixed height on this panel cannot see that cap and silently
   overflowed past the visible sheet, burying the CTA again. */
.tutor-quest-panel {
  background: var(--tq-card);
  color: #16352b;
  border-radius: 18px;
  box-shadow: var(--tq-shadow);
  border: 1px solid rgba(11, 61, 46, 0.08);
  overflow: hidden;
  animation: tq-pop 0.22s ease;
  font-family: Vazirmatn, Tahoma, sans-serif;
  direction: rtl;
}

.tutor-quest-panel.is-celebrate {
  animation: tq-bounce 0.55s ease;
}

.tutor-quest-panel.is-levelup,
.tutor-quest-panel.is-complete-pulse {
  animation: tq-level 0.7s ease;
}

.tq-pane[hidden] {
  display: none !important;
}

/* Two doors, one card: «مأموریت امروز» (stats) and «ابزار یادگیری» (the tools). */
.tq-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 12px 8px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(11, 61, 46, 0.07);
}

.tq-tab {
  border: 0;
  border-radius: 9px;
  padding: 9px 8px;
  min-height: 40px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  color: #3c5a4e;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.tq-tab:hover {
  color: #0b3d2e;
}

.tq-tab[aria-selected="true"] {
  background: #fffdf7;
  color: #0b3d2e;
  box-shadow: 0 2px 6px rgba(11, 61, 46, 0.12);
}

.tq-tab:focus-visible {
  outline: 2px solid var(--tq-mint);
  outline-offset: 1px;
}

/* ---- Learner toolbar (moved out of #splitPanel) ---- */
.tq-tools {
  padding: 2px 12px 12px;
  display: grid;
  gap: 12px;
}

.tq-tools-context {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(43, 176, 237, 0.1);
  border: 1px solid rgba(43, 176, 237, 0.2);
  color: #0b4a63;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.tq-tools-empty {
  margin: 0;
  padding: 14px 4px;
  font-size: 12px;
  color: #4a6358;
  text-align: center;
}

.tq-tool-group h3 {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 800;
  color: #0b3d2e;
}

.tq-tool-note {
  margin: 0 0 6px;
  font-size: 10.5px;
  line-height: 1.45;
  /* #4a6358 on --tq-card measures 6.37:1 — safe for this size (see .tq-list note). */
  color: #4a6358;
}

.tq-tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.tq-tool {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(11, 61, 46, 0.14);
  border-radius: 12px;
  background: #fffdf7;
  color: #16352b;
  font-family: inherit;
  text-align: right;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.tq-tool:hover:not(:disabled) {
  border-color: rgba(31, 169, 122, 0.5);
  background: #fff;
}

.tq-tool:active:not(:disabled) {
  transform: translateY(1px);
}

.tq-tool:focus-visible {
  outline: 2px solid var(--tq-mint);
  outline-offset: 1px;
}

.tq-tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tq-tool.is-active {
  border-color: var(--tq-mint);
  background: rgba(31, 169, 122, 0.13);
  box-shadow: inset 0 0 0 1px rgba(31, 169, 122, 0.35);
}

.tq-tool-ico {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1;
}

.tq-tool-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.tq-tool-label {
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.tq-tool-hint {
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.4;
  color: #4a6358;
  overflow-wrap: anywhere;
}

/* «چقدر کمکت کنم؟» is one choice out of three — a segmented row, not a list. */
.tq-tool-group-guidance .tq-tool-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.tq-tool-seg {
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  padding: 8px 6px;
}

.tq-tool-seg .tq-tool-text {
  justify-items: center;
  text-align: center;
}

.tq-tool-seg .tq-tool-hint {
  font-size: 9.5px;
}

.tq-move-hint {
  display: none !important;
}

@keyframes tq-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.tq-head {
  padding: 14px 14px 8px;
  background: linear-gradient(180deg, rgba(232, 184, 74, 0.18), transparent);
}

.tq-head strong {
  display: block;
  font-size: 15px;
}

.tq-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: #4a6b5d;
  line-height: 1.45;
}

.tq-parent-share {
  flex: 1 1 auto;
  border: 1px solid rgba(11, 61, 46, 0.2);
  background: #fff;
  color: #0b3d2e;
  font-weight: 700;
  font-size: 13px;
  font-family: inherit;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  min-height: 44px;
}

.tq-bars {
  padding: 4px 14px 10px;
  display: grid;
  gap: 8px;
}

.tq-bar {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
}

.tq-bar i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--tq-mint), var(--tq-gold));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
  max-width: 100%;
  transition: width 0.35s ease;
}

.tq-bar-xp i {
  background: linear-gradient(90deg, var(--tq-sky), var(--tq-gold));
}

.tq-mastery {
  margin: 8px 10px 4px;
  padding: 8px 8px 4px;
  border-radius: 12px;
  background: rgba(11, 61, 46, 0.06);
}
.tq-mastery-label {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #3d5c4f;
}
.tq-mastery-note {
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 1.45;
  color: #6a4a12;
}
.tq-bar-mastery i {
  background: linear-gradient(90deg, var(--tq-mint), #0f5c45);
}
.tq-bar-mastery.is-weak i {
  background: linear-gradient(90deg, #e3b34a, #0f5c45);
}

.tq-bar span {
  color: #3d5c4f;
}

.tq-bar b {
  font-variant-numeric: tabular-nums;
  color: var(--tq-ink);
  min-width: 42px;
  text-align: left;
}

.tq-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid rgba(11, 61, 46, 0.08);
}

.tq-cols section {
  padding: 10px 12px 12px;
  min-height: 110px;
}

.tq-cols section:first-child {
  border-left: 1px solid rgba(11, 61, 46, 0.08);
}

.tq-cols h3 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #0b3d2e;
}

.tq-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: 132px;
  overflow: auto;
  user-select: text;
  -webkit-user-select: text;
  cursor: default;
}

.tq-list li {
  font-size: 11px;
  line-height: 1.4;
  background: rgba(11, 61, 46, 0.05);
  border-radius: 8px;
  padding: 6px 8px;
}

.tq-done li {
  background: rgba(31, 169, 122, 0.12);
}

.tq-left li {
  background: rgba(255, 107, 74, 0.1);
}

.tq-list li.is-empty {
  background: transparent;
  /* Measured 2026-08-20: #6a8578 on this card's --tq-card (~rgb(255,252,245))
     only hit 3.91:1 (fails 4.5:1 AA for 11px text). #4a6358 hits 6.37:1. */
  color: #4a6358;
}

.tq-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px 12px;
  align-items: center;
  border-top: 1px solid rgba(11, 61, 46, 0.08);
  background: var(--tq-card);
}

.tq-cta {
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(135deg, #ff8a3d, #ff6b4a 40%, #e8b84a);
  color: #2a1608;
  box-shadow: 0 6px 14px rgba(255, 107, 74, 0.28);
}

.tq-cta:hover {
  filter: brightness(1.04);
}

@keyframes tq-bounce {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.08); }
  70% { transform: scale(0.97); }
}

@keyframes tq-level {
  0%, 100% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.12) rotate(-2deg); }
  60% { transform: scale(1.06) rotate(2deg); }
}

.tutor-quest-toast {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #0b3d2e;
  color: #fff8e7;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transition: 0.2s ease;
  z-index: 80;
  pointer-events: none;
}

.tutor-quest-toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tq-coach,
.tq-celebrate-banner,
.tq-beta {
  margin: 0 14px 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
}

.tq-coach {
  background: rgba(43, 176, 237, 0.12);
  color: #0b4a63;
  border: 1px solid rgba(43, 176, 237, 0.22);
}

.tq-beta {
  background: rgba(15, 118, 110, 0.08);
  color: #0f5c56;
  border: 1px dashed rgba(15, 118, 110, 0.28);
  font-weight: 600;
}

.tq-celebrate-banner {
  background: linear-gradient(135deg, rgba(232, 184, 74, 0.28), rgba(31, 169, 122, 0.18));
  color: #0b3d2e;
  border: 1px solid rgba(232, 184, 74, 0.35);
}

body.mobile-chat .tq-cols {
  grid-template-columns: 1fr;
}

body.mobile-chat .tq-cols section:first-child {
  border-left: 0;
  border-bottom: 1px solid rgba(11, 61, 46, 0.08);
}

/* World-class W2 — structured check_result (display-only, not a choice widget).
   Card follows the real theme flag (html[data-theme] on #htmlRoot, set by
   toggleTheme()/loadTheme() in assets/script.js) — dark is the base rule here
   because absence of the attribute renders dark everywhere else in this
   codebase (see chat-action-buttons.css :root, control-surface.css). Light is
   the html[data-theme="light"] override.
   Measured 2026-08-21 (WCAG relative-luminance formula, card flattened onto
   the assistant-bubble backdrop per theme, #161b22 night / #ffffff day):
   the brand teal/amber/red only clear 4.5:1 AA on ONE of the two cards each —
   pass/partial need a darker shade for the light card, fail/confidence need a
   lighter shade for the dark card. Single-hue text would silently fail AA on
   whichever card that hue wasn't tuned for. */
.nabgol-check-result {
  margin: 0.55rem 0 0.35rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(232, 184, 74, 0.22);
  background: rgba(20, 36, 30, 0.92);
  color: #e8f5ef;
  font-size: 0.92rem;
  line-height: 1.55;
  direction: rtl;
}
html[data-theme="light"] .nabgol-check-result {
  border-color: rgba(11, 61, 46, 0.12);
  background: rgba(255, 252, 245, 0.92);
  color: #0b3d2e;
}
.nabgol-check-result-head {
  font-weight: 700;
  margin-bottom: 0.35rem;
}
/* dark card: measured 5.44:1 / 5.42:1 / 4.58:1 · light card: 4.67:1 / 4.53:1 / 5.19:1 */
.nabgol-check-result[data-verdict="pass"] .nabgol-check-result-head { color: #1fa97a; }
.nabgol-check-result[data-verdict="partial"] .nabgol-check-result-head { color: #c48a12; }
.nabgol-check-result[data-verdict="fail"] .nabgol-check-result-head { color: #da6354; }
html[data-theme="light"] .nabgol-check-result[data-verdict="pass"] .nabgol-check-result-head { color: #18825e; }
html[data-theme="light"] .nabgol-check-result[data-verdict="partial"] .nabgol-check-result-head { color: #9a6c0e; }
html[data-theme="light"] .nabgol-check-result[data-verdict="fail"] .nabgol-check-result-head { color: #c23b2a; }
.nabgol-check-result-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nabgol-check-result-steps li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: baseline;
  padding: 0.2rem 0;
}
.nabgol-check-result-mark {
  font-weight: 700;
  min-width: 1.1em;
}
.nabgol-check-result-steps li.is-ok .nabgol-check-result-mark { color: #1fa97a; }
.nabgol-check-result-steps li.is-bad .nabgol-check-result-mark { color: #da6354; }
html[data-theme="light"] .nabgol-check-result-steps li.is-ok .nabgol-check-result-mark { color: #18825e; }
html[data-theme="light"] .nabgol-check-result-steps li.is-bad .nabgol-check-result-mark { color: #c23b2a; }
.nabgol-check-result-label { font-weight: 600; }
.nabgol-check-result-why {
  flex: 1 1 100%;
  opacity: 0.85;
  font-size: 0.88em;
  padding-inline-start: 1.4em;
}
.nabgol-check-result-note,
.nabgol-check-result-hint,
.nabgol-check-result-confidence {
  margin-top: 0.4rem;
  font-size: 0.9em;
}
/* dark card: 4.61:1 · light card: 6.62:1 */
.nabgol-check-result-confidence {
  font-weight: 600;
  color: #ce701b;
}
html[data-theme="light"] .nabgol-check-result-confidence {
  color: #8a4b12;
}

/* W5 — platform passport badges */
.tq-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem 0.15rem;
  max-width: 100%;
  overflow-x: hidden;
}
.tq-badge {
  font-size: 0.72rem;
  line-height: 1.25;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(20, 36, 30, 0.12);
  background: rgba(20, 36, 30, 0.04);
  color: inherit;
  opacity: 0.45;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.tq-badge.is-on {
  opacity: 1;
  border-color: rgba(232, 184, 74, 0.4);
  background: rgba(232, 184, 74, 0.12);
  font-weight: 600;
}
html[data-theme="light"] .tq-badge.is-on {
  border-color: rgba(31, 169, 122, 0.45);
  background: rgba(31, 169, 122, 0.12);
}

/* W4 — learning atlas (کجای درسم): vertical only, no h-scroll @390 */
.tutor-atlas {
  position: fixed;
  inset: 0;
  z-index: 12050;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(12, 18, 16, 0.45);
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
}
.tutor-atlas[hidden] { display: none !important; }
.tutor-atlas-sheet {
  width: min(100vw, 420px);
  max-width: 100%;
  max-height: min(88dvh, 640px);
  background: #15241e;
  color: #e8f5ef;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: hidden;
}
.tutor-atlas-head {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.9rem 1rem 0.55rem;
  border-bottom: 1px solid rgba(20, 36, 30, 0.08);
  flex: 0 0 auto;
}
.tutor-atlas-head strong {
  display: block;
  font-size: 1.02rem;
  line-height: 1.35;
  word-break: break-word;
}
.tutor-atlas-sub {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  opacity: 0.78;
  line-height: 1.4;
  word-break: break-word;
}
.tutor-atlas-close {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  min-width: 36px;
  min-height: 36px;
  cursor: pointer;
  color: inherit;
  flex: 0 0 auto;
}
.tutor-atlas-list {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0.65rem 1.1rem;
  max-width: 100%;
}
.tutor-atlas-node {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0.2rem 0;
  padding: 0.55rem 0.65rem;
  padding-inline-start: calc(0.65rem + (var(--atlas-depth, 0) * 0.85rem));
  border: 1px solid rgba(232, 184, 74, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  text-align: start;
  cursor: pointer;
  min-height: 44px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.tutor-atlas-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  /* Darkened from #9aa7a0 to clear WCAG 1.4.11 (>=3:1) against the node's
     #fff light-theme background; still >=3:1 against the dark node bg. */
  background: #819188;
  flex: 0 0 auto;
}
/* Same WCAG 1.4.11 pass: darkened from #d4a017, keeping the amber hue. */
.tutor-atlas-node.is-learning .tutor-atlas-dot { background: #b28613; }
.tutor-atlas-node.is-checking .tutor-atlas-dot { background: #2f7dd1; }
/* Same WCAG 1.4.11 pass: darkened from #1fa97a, keeping the green hue. */
.tutor-atlas-node.is-mastered .tutor-atlas-dot { background: #1da074; }
.tutor-atlas-title {
  flex: 1 1 8rem;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.35;
}
.tutor-atlas-meta {
  flex: 0 1 auto;
  font-size: 0.75rem;
  opacity: 0.72;
}
.tutor-atlas-empty {
  margin: 1rem;
  opacity: 0.75;
  font-size: 0.9rem;
}
/* Wave-08 planning pick: the top-ranked (weight × weakness × due) suggestion —
   visually distinct from the plain chapter/topic list below it. */
.tutor-atlas-suggest-row {
  padding: 0 0.65rem 0.3rem;
}
.tutor-atlas-suggest {
  border-color: rgba(232, 184, 74, 0.45);
  background: rgba(212, 160, 23, 0.14);
}
.tutor-atlas-suggest .tutor-atlas-title {
  color: #f0d488;
}
html[data-theme="light"] .tutor-atlas-suggest {
  border-color: #d4a017;
  background: #fff8e6;
}
html[data-theme="light"] .tutor-atlas-suggest .tutor-atlas-title {
  color: #6b4e0a;
}
@media (max-width: 390px) {
  .tutor-atlas,
  .tutor-atlas-sheet,
  .tutor-atlas-list,
  .tutor-atlas-node {
    overflow-x: hidden;
    max-width: 100%;
  }
  .tutor-atlas-sheet { width: 100vw; border-radius: 14px 14px 0 0; }
}
html[data-theme="light"] .tutor-atlas-sheet {
  background: #f7faf8;
  color: #14241e;
}
html[data-theme="light"] .tutor-atlas-node {
  background: #fff;
  border-color: rgba(20, 36, 30, 0.1);
}
