/* beehoc components (GUI plan 1.5): the pieces every page is built from,
   drawn once from css/tokens.css. Button, card, chip, tag, stat tile,
   progress bar, dialog, loading and empty states; design.html shows them
   all, in light and dark. Every learning page loads it (templates/head.html).

   Every class starts with bh- so this file can sit beside a page's own
   stylesheet (.btn, .chip, .card already mean other things there) while
   the pages move over one at a time. A level colour comes in through
   --lv / --lv-soft: honey by default, a level's colour under .lv-n5 …
   .lv-n1 (both in tokens.css). */

/* ---------- Button ----------
   Primary is the one thing to do next; secondary sits beside it; ghost is
   a quiet way out; danger ends or deletes something. */
.bh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 11px 18px;
  background: var(--accent);
  color: var(--ink-inverse);
  box-shadow: var(--shadow-btn);
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.bh-btn:not(:disabled):hover { background: var(--accent-hover); }
.bh-btn:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
.bh-btn--secondary { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.bh-btn--secondary:not(:disabled):hover { background: var(--surface-3); border-color: var(--line-strong); }
.bh-btn--ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); box-shadow: none; }
.bh-btn--ghost:not(:disabled):hover { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.bh-btn--danger { background: var(--flag-soft); color: var(--flag); border-color: var(--flag); }
.bh-btn--danger:not(:disabled):hover { background: var(--flag); color: var(--ink-inverse); }
.bh-btn--sm { font-size: 12.5px; padding: 7px 13px; }
.bh-btn--block { display: flex; width: 100%; }
.bh-btn:disabled { opacity: .4; cursor: default; box-shadow: none; }

/* ---------- Card ----------
   A surface that groups one thing. A card that is itself a link lifts on
   hover; an accent card is the one to look at first. */
.bh-card {
  display: block;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
}
a.bh-card { text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
a.bh-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.bh-card--accent { background: var(--accent-soft); border-color: var(--accent-line); }
/* Block even as spans, so a card can be a <button> or <a>. */
.bh-card__eyebrow, .bh-card__title, .bh-card__meta { display: block; }
.bh-card__eyebrow { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.bh-card__title { font-size: var(--text-lg); font-weight: 700; margin: var(--space-1) 0 0; }
.bh-card__meta { font-size: var(--text-sm); color: var(--ink-soft); margin: var(--space-1) 0 0; }

/* ---------- Chip ----------
   A choice the learner taps: a level, a filter. aria-pressed="true" (or
   aria-current) marks the chosen one, in the level colour when there is
   one. */
.bh-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.bh-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 13px;
  background: var(--surface);
  color: var(--ink-soft);
}
.bh-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.bh-chip[aria-pressed="true"], .bh-chip[aria-current] {
  background: var(--lv);
  border-color: var(--lv);
  color: var(--ink-inverse);
}

/* ---------- Tag ----------
   A short status that is read, not tapped. */
.bh-tag {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  background: var(--surface-2);
  color: var(--ink-soft);
}
.bh-tag--accent { background: var(--accent-soft); color: var(--accent); }
.bh-tag--ok { background: var(--ok-soft); color: var(--ok); }
.bh-tag--flag { background: var(--flag-soft); color: var(--flag); }
.bh-tag--level { background: var(--lv-soft); color: var(--lv); }

/* ---------- Stat tile ----------
   One number and what it counts. --warn when the number needs attention. */
.bh-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-3); }
.bh-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
}
.bh-stat__num { font-family: var(--font-mono); font-size: 26px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--lv); }
.bh-stat__label { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.bh-stat--warn .bh-stat__num { color: var(--flag); }

/* ---------- Progress bar ----------
   <div class="bh-progress" role="progressbar" aria-valuenow="40" …>
     <div class="bh-progress__fill" style="width:40%"></div></div> */
.bh-progress { height: 8px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.bh-progress__fill { height: 100%; border-radius: inherit; background: var(--lv); transition: width .3s ease; }
.bh-progress--thin { height: 4px; }

/* ---------- Dialog ----------
   A native <dialog> opened with showModal(), so focus and Esc come free. */
.bh-dialog {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  padding: 22px 24px 24px;
}
.bh-dialog::backdrop { background: var(--backdrop); }
.bh-dialog__title { font-family: var(--font-display); font-size: var(--text-xl); margin: 0 0 var(--space-2); }
.bh-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }

/* ---------- Loading (GUI plan 2.4) ----------
   Grey shapes where the content will be, in place of "Đang tải…"; the
   words stay for a screen reader. js/site-nav.js: bhLoading(). */
.bh-loading { display: grid; gap: var(--space-3); }
.bh-skeleton {
  display: block;
  height: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: bh-pulse 1.4s ease-in-out infinite;
}
.bh-skeleton--card { height: 76px; border-radius: var(--radius-card); }
.bh-skeleton--short { width: 60%; }
.bh-skeleton--inline { display: inline-block; width: 8em; height: 1em; vertical-align: middle; }
@keyframes bh-pulse { 50% { opacity: .5; } }

/* Read aloud, not shown. */
.bh-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Empty (GUI plan 2.4) ----------
   An empty list says why and offers the way on: one sentence, one button.
   js/site-nav.js: bhEmpty(). */
.bh-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  text-align: center;
  padding: 24px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-card);
  color: var(--ink-soft);
}
.bh-empty p { margin: 0; max-width: 34em; }

/* ---------- Hint (GUI plan 3.4) ----------
   One line the first time a mode opens; js/site-nav.js: bhHint(). */
.bh-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-3) 0;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--teal-soft);
  color: var(--ink);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.bh-hint__text { flex: 1; padding-top: 4px; }
.bh-hint__close {
  flex: none; font: inherit; font-size: 18px; line-height: 1; cursor: pointer;
  width: 32px; height: 32px; border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--ink-soft);
}
.bh-hint__close:hover { background: var(--surface); color: var(--ink); }

.bh-btn:focus-visible, .bh-chip:focus-visible, a.bh-card:focus-visible, .bh-hint__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .bh-btn, a.bh-card, .bh-progress__fill { transition: none; }
  .bh-skeleton { animation: none; }
  .bh-btn:not(:disabled):active, a.bh-card:hover { transform: none; }
}

/* Touch targets (GUI plan 2.2): 44 px on touch or narrow screens. */
@media (pointer: coarse), (max-width: 720px) {
  .bh-btn, .bh-chip { min-height: 44px; }
  .bh-hint__close { width: 44px; height: 44px; }
}
