/* The menu on the left (js/side-nav.js), on trial behind ?menu=moi.
   From 1024 px it stays beside the page; below that it is a drawer that
   the ☰ in the header and "Khoá học" in the bottom bar open. */
:root { --side-nav-w: 252px; --side-nav-lead: 60px; }

.side-nav {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--side-nav-w);
  z-index: 45;
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.side-nav-top {
  display: flex;
  align-items: center;
  min-height: var(--header-h, 64px);
  padding-left: var(--side-nav-lead);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-2);
}
.side-nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
  text-decoration: none;
}
.side-nav-brand .brand-mark { width: 26px; height: 26px; }

/* The language at the top: only that language's pages are listed below. */
.side-nav-lang { position: relative; margin: 0 var(--space-3) var(--space-1); }
.side-nav-lang-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  min-height: 44px;
  cursor: pointer;
}
.side-nav-lang-btn small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-faint); }
.side-nav-mark {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
}
.side-nav-lang-btn .nav-chevron { margin-left: auto; width: 12px; height: 12px; color: var(--ink-faint); }
.side-nav-langs {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 2;
  display: grid;
  gap: 2px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}
.side-nav-langs[hidden] { display: none; }
.side-nav-langs a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}
.side-nav-langs a:hover, .side-nav-langs a[aria-current="true"] { background: var(--surface-2); }

.side-nav-list { overflow-y: auto; padding: var(--space-1) 10px var(--space-5); min-height: 0; }
.side-nav-group { margin-top: var(--space-3); }
.side-nav-head {
  padding: 0 8px 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.side-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.3;
}
.side-nav-item:hover { background: var(--surface-2); }
.side-nav-item[aria-current="page"] {
  background: var(--accent-soft);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--honey-2);
}
.side-nav-icon { width: 20px; flex: none; text-align: center; font-size: 15px; }
.side-nav-tag {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--ink-soft);
  white-space: nowrap;
}
/* A level or a band under its course: N5–N1 under "Khoá JLPT", the three
   bands under "Luyện thi IELTS". */
.side-nav-sub { padding-left: 38px; min-height: 34px; font-size: 13.5px; color: var(--ink-soft); }
.side-nav-sub::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--line-strong);
}
.side-nav-sub[aria-current="page"] { color: var(--ink); }
.side-nav-sub[aria-current="page"]::before { background: var(--honey-2); }
.side-nav-item:focus-visible, .side-nav-lang-btn:focus-visible, .side-nav-langs a:focus-visible, .side-nav-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* One ☰, fixed at the top left, opens and closes the menu at every width
   and never moves: the menu's logo and the header's logo sit at the same
   spot beside it. */
.side-nav-open {
  display: none;
  position: fixed;
  z-index: 50;
  top: calc(env(safe-area-inset-top, 0px) + (var(--header-h, 64px) - 44px) / 2);
  left: max(8px, env(safe-area-inset-left, 0px));
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.side-nav-open svg { width: 22px; height: 22px; }
body.has-side-nav .side-nav-open { display: grid; }
body.in-session .side-nav-open, body.in-exam .side-nav-open { display: none; }
.side-nav-shade { display: none; }

/* Wide screens: the menu sits beside the page; "Bài học" is no longer needed. */
@media (min-width: 1024px) {
  body.has-side-nav { padding-left: var(--side-nav-w); }
  body.has-side-nav .main-nav { display: none; }
  body.has-side-nav .site-header .brand { display: none; }
  /* Search and the account stay at the right, as before the menu. */
  body.has-side-nav .nav-search { margin-left: auto; }
  /* Folded away with the ☰: the header gets its ☰ and logo back. */
  body.has-side-nav.side-nav-closed { padding-left: 0; }
  body.side-nav-closed .side-nav { display: none; }
  body.has-side-nav.side-nav-closed .site-header .brand { display: flex; }
  body.has-side-nav.side-nav-closed .site-header-inner { max-width: none; padding-left: var(--side-nav-lead); }
  body.has-side-nav.in-session, body.has-side-nav.in-exam { padding-left: 0; }
  body.in-session .side-nav, body.in-exam .side-nav { display: none; }
}

/* Narrow screens: a drawer. */
@media (max-width: 1023px) {
  body.has-side-nav .main-nav { display: none; }
  body.has-side-nav .site-header-inner { padding-left: var(--side-nav-lead); }
  body.has-side-nav .nav-search { margin-left: auto; }
  .side-nav { width: min(86vw, 320px); transform: translateX(-102%); visibility: hidden; box-shadow: var(--shadow-lift); }
  .side-nav.is-open { transform: none; visibility: visible; }
  .side-nav-shade.is-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 44;
    border: 0;
    background: var(--backdrop);
  }
  .side-nav-item { min-height: 44px; }
  .side-nav-sub { min-height: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  .side-nav { transition: transform 0.2s ease, visibility 0.2s; }
}
@media (pointer: coarse), (max-width: 720px) {
  .side-nav-item, .side-nav-sub { min-height: 44px; }
}

/* Pages of one language at a time: the menu says which, so their own
   language switches step aside (Bộ từ, Nghe phân biệt âm, Nghe chép chính tả). */
body.has-side-nav #wordsLangs,
body.has-side-nav .ls-langs,
body.has-side-nav #langTabs { display: none; }

/* JLPT and French course pages: the menu already holds the level (N5–N1
   under Khoá JLPT), the way home and every tab of the page (Lộ trình, Thi
   thử, Luyện đọc, Luyện từ; Lịch học), so the breadcrumb, the level chips
   and the tab bar step aside. One way in per page. "Số đếm" keeps its tabs:
   its Lộ trình is not in the menu. */
body.has-side-nav .course-top,
body.has-side-nav.lv-n1 .tabs, body.has-side-nav.lv-n2 .tabs, body.has-side-nav.lv-n3 .tabs,
body.has-side-nav.lv-n4 .tabs, body.has-side-nav.lv-n5 .tabs,
body.has-side-nav.lv-fr .tabs { display: none; }

/* A course's Hôm nay (js/drill.js): one place per thing.
   - The streak: the "N ngày liên tiếp" card at the side; not again as a
     line in the exam countdown or the course's head card.
   - Practice modes: each deck's own buttons (Ghép thẻ, Nhớ ngược, Đặt câu,
     Điền câu) and the "Ôn trộn" card in the deck list; not again in the
     "Luyện thêm" box. */
body.has-side-nav #deckList .streak-note,
body.has-side-nav .tp-more { display: none; }

/* "Tuỳ chỉnh lượng thẻ" once: the button beside "Bắt đầu học" opens the
   panel, so the panel's own heading row at the foot of the page goes. */
body.has-side-nav details.today-settings > summary { display: none; }

/* A tab bar with a single tab (Từ vựng tiếng Anh: only "Hôm nay") leads
   nowhere: it is not shown. */
.wrap > header .tabs:has(> :only-child) { display: none; }

/* Course pages without a level badge (Từ vựng tiếng Anh, Số đếm): the
   title grid of css/n1-drill.css keeps a column for the badge, which
   squeezed the subtitle into a narrow column beside the title on a phone.
   They get their badge too. */
body[data-course="en-vocab"] { --lv: var(--teal); }
body[data-course="en-vocab"] .page-title::before { content: "EN"; }
body[data-course="counters"] .page-title::before { content: "数"; }
