/* ==========================================================================
   ADQS Exam v2 — Student SPA Tree of Knowledge Arena Stylesheet
   Tree of Knowledge (#view-tree) student styles:
   stage, canvas, checkin, workspace, badges, leaderboard & word counter.
   ========================================================================== */

/* ---------- Tree of Knowledge stage (Phase 7.2) ---------- */
.tree-screen { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.tree-screen__title { margin: 0; font-size: 20px; color: var(--text); }
.tree-screen__subtitle { margin: 0; font-size: 13.5px; color: var(--text-muted); }
.tree-screen__stage {
  position: relative; width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 70vh;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.tree-canvas { display: block; width: 100%; height: 100%; }

/* ---------- Top-level view router (Phase 8.1) ---------- */
#view-tree {
  position: relative;
  z-index: 100;
  width: 100vw;
  min-height: 100vh;
  background: var(--bg);
}

/* ---------- Tree check-in (Phase 7.4) ---------- */
.tree-checkin { display: flex; justify-content: center; padding: 8px 0; }
.tree-checkin__card {
  width: 100%; max-width: 520px;
  display: grid; gap: 14px;
  padding: 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.tree-checkin__eyebrow {
  margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-text);
}
.tree-checkin__title { margin: 0; font-size: 19px; color: var(--text); }
.tree-checkin__question {
  margin: 0; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 15px; font-weight: 600; line-height: 1.6; color: var(--text);
  white-space: pre-wrap;
}
.tree-checkin__meta { margin: 0; font-size: 13px; color: var(--text-muted); }

/* ---------- Tree interactive workspace (Phase 7.4) ---------- */
.tree-workspace { display: flex; flex-direction: column; gap: 12px; }
.tree-workspace__header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.tree-workspace__status { display: flex; flex-wrap: wrap; gap: 8px; }
.tree-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  background: var(--accent-weak); color: var(--accent-text);
}
.tree-badge--vitality { background: var(--ok-weak); color: var(--ok); }
/* Phase 9.1 — the countdown badge turns urgent in the last minute. */
.tree-badge--time { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.tree-badge--time.is-urgent { background: var(--danger-weak); color: var(--danger); border-color: var(--danger); }

/* Phase 9.1 — SPEED_QUIZ prompt card, above the canvas. */
.tree-quiz-prompt {
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--accent-weak); border: 1px solid var(--accent);
  font-size: 17px; font-weight: 700; line-height: 1.5; color: var(--accent-text);
  white-space: pre-wrap;
}

/* Phase 8.3 — compact audio toggle that sits in the workspace header. */
.btn-icon-muted {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; flex-shrink: 0;
  font-size: 16px; line-height: 1;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.btn-icon-muted:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-icon-muted[aria-pressed="false"] { opacity: .6; }

/* Phase 8.4 — sticky 4-team mini-leaderboard. Sticks under the workspace header
   so a student typing down the page still sees the live Tổ standings. */
.tree-leaderboard {
  position: sticky; top: 0; z-index: 6;
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
}
.tree-leaderboard__badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
/* The student's own Tổ is highlighted so it is findable at a glance. */
.tree-leaderboard__badge.is-my-team {
  background: var(--accent-weak); color: var(--accent-text);
  border-color: var(--accent);
}
/* The first team to reach 100% keeps the crown. */
.tree-leaderboard__badge.is-champion {
  background: var(--warn-weak); color: var(--warn);
  border-color: var(--warn);
}

/* The stage is sticky on a tall screen so the tree stays visible while the
   student types, but collapses to a comfortable 35vh on mobile where a sticky
   header would eat the whole viewport. */
.tree-workspace .tree-screen__stage { aspect-ratio: auto; height: 35vh; min-height: 200px; }
@media (min-width: 720px) {
  .tree-workspace .tree-screen__stage {
    position: sticky; top: 12px; z-index: 5;
    height: 46vh; max-height: 520px;
  }
}

.tree-fruit-info {
  margin: 0; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--warn-weak); border: 1px solid var(--warn);
  font-size: 13px; font-weight: 600; color: var(--warn);
}

.tree-answer {
  display: grid; gap: 10px;
  padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.tree-answer__question { font-size: 13.5px; font-weight: 700; color: var(--text-muted); }
.tree-answer__input {
  width: 100%; padding: 11px 13px; resize: vertical;
  font: inherit; font-size: 14.5px; line-height: 1.6;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.tree-answer__input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.tree-answer__input::placeholder { color: var(--text-faint); }
.tree-answer__footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

/* The counter turns amber at the threshold and green once met, so "can I submit
   yet?" is answerable without reading the numbers. */
.tree-word-counter {
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  transition: color .2s ease;
}
.tree-word-counter.is-met { color: var(--ok); }
.tree-word-counter.is-short { color: var(--warn); }
