/* TOEIC Buổi Tối — css/v-home.css — [v-home]
   Màn hình chào (#welcome…), trang Hôm nay (#home), Hồ sơ (#profile), Bảng xếp hạng (#board).
   Chỉ thêm class tiền tố home-; màu lấy từ token của css/app.css nên dùng chung cho theme sáng và tối. */

/* ───────────────────────── 1. Màn hình chào ───────────────────────── */
.home-welcome { display: grid; gap: var(--s7); grid-template-columns: minmax(0, 1fr); padding-top: var(--s3); }
.home-welcome-main, .home-welcome-side { display: grid; gap: var(--s6); min-width: 0; align-content: start; grid-template-columns: minmax(0, 1fr); }
.home-hero { display: grid; gap: var(--s4); justify-items: start; grid-template-columns: minmax(0, 1fr); }
.home-hero .page-head { width: 100%; }
.home-hero .ruler { width: 100%; }
.home-hero .page-sub { color: var(--ink); font-size: var(--fs-lg); line-height: 1.55; }

.home-who { gap: var(--s4); border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.home-who-label { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; line-height: var(--lh-tight); }
.home-who-panel { display: grid; gap: var(--s3); padding-top: var(--s4); border-top: 1px dashed var(--line-strong); }
.home-panel-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; line-height: var(--lh-tight); }
.home-hint-warn { color: var(--warn-ink); font-weight: 500; }

/* lộ trình: 3 giai đoạn nối nhau bằng một đường kẻ, số giai đoạn là vòng chữ kiểu phiếu tô */
.home-road { display: grid; }
.home-phase { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: var(--s4); padding-bottom: var(--s6); }
.home-phase:last-child { padding-bottom: 0; }
.home-phase::before { content: ""; position: absolute; left: 21px; top: 48px; bottom: 4px; width: 2px; border-radius: 1px; background: var(--line); }
.home-phase:last-child::before { display: none; }
.home-phase-no {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 1.15rem;
}
.home-phase-body { display: grid; gap: 6px; min-width: 0; padding-top: 2px; }
.home-phase-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.home-phase-title { font-size: var(--fs-lg); font-weight: 700; }
.home-phase-goal { color: var(--muted); font-size: 0.95rem; max-width: 60ch; }
.home-phase-weeks { display: grid; gap: 3px; margin-top: var(--s1); font-size: var(--fs-sm); }
.home-phase-weeks li { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: var(--s2); }
.home-phase-wk { color: var(--muted); font-weight: 600; }

@media (min-width: 900px) {
  .home-welcome { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s9); align-items: start; padding-top: var(--s5); }
}
@media (min-width: 900px) and (min-height: 720px) {
  .home-welcome-main.is-sticky { position: sticky; top: calc(var(--s6) + env(safe-area-inset-top, 0px)); }
}

/* các bước sau khi nhập tên: cột hẹp cho dễ đọc */
.view.home-narrow { width: 100%; max-width: 640px; margin-inline: auto; padding-top: var(--s3); }
.home-setup { gap: var(--s6); }
.home-q { display: grid; gap: var(--s3); min-width: 0; }
.home-q-title { display: flex; align-items: center; gap: var(--s3); font-size: var(--fs-lg); }
.home-q-no {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--muted); font-size: 0.9rem;
}
/* 4 mức điểm / 4 mức phút luôn nằm trên MỘT hàng, chia đều (không để "90 phút" rơi xuống dòng) */
.home-q .seg-block { flex-wrap: nowrap; }
.home-q .seg-block .seg-opt { flex: 1 1 0; min-width: 0; padding-inline: 2px; }
@media (max-width: 419px) { .home-q .seg-block .seg-opt { font-size: var(--fs-sm); } }
/* 3 mức trình độ: xếp dọc trên điện thoại, một hàng 3 thẻ từ 640px (không để lẻ 2 + 1) */
.home-q .seg-cards { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .home-q .seg-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } .home-q .seg-cards .seg-opt { align-content: start; } }
.home-q .input[type="date"] { max-width: 260px; }
.home-setup-plan { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--sunken); font-size: 0.95rem; }
.home-setup-plan .icon { margin-top: 3px; color: var(--muted); }
.home-setup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.home-setup-actions .hint { flex: 1 1 100%; }
@media (max-width: 559px) { .home-setup-actions .btn { flex: 1 1 100%; white-space: normal; } }

.home-place { gap: var(--s5); }
.home-facts { display: grid; gap: var(--s3); }
.home-facts li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); line-height: 1.55; }
.home-facts .icon { margin-top: 3px; color: var(--brand); }
.home-place-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
@media (max-width: 559px) { .home-place-actions .btn { flex: 1 1 100%; white-space: normal; } }
.home-place-exit { display: flex; margin-bottom: calc(var(--s3) * -1); }
.home-place-exit .btn { margin-left: -8px; color: var(--muted); }

.home-result { gap: var(--s5); }
.home-result-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4) var(--s6); }

/* ───────────────────────── 2. Trang Hôm nay ───────────────────────── */
/* một cột trên điện thoại; hai cột (.is-wide, do js/views/dashboard.js xếp lại DOM từ 900px) trên màn hình rộng */
.home-dash { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); min-width: 0; }
.home-dash > *, .home-col > * { min-width: 0; }
.home-dash.is-wide { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.home-col { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); min-width: 0; }

/* thẻ chính: nhiệm vụ hôm nay */
.home-task { gap: var(--s4); }
.home-task-head { display: grid; gap: var(--s1); min-width: 0; }
.home-task-title { font-size: var(--fs-xl); text-wrap: balance; }
.home-task-chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.home-task-lead { color: var(--muted); font-size: 0.95rem; max-width: 62ch; padding-top: var(--s3); border-top: 1px solid var(--line); }
.home-task-cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
.home-task-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s3); min-width: 0; color: var(--muted); font-size: var(--fs-sm); }
.home-task-note .btn { margin-left: -12px; }
@media (max-width: 559px) { .home-task-cta > .btn { flex: 1 1 100%; } }

/* "Ôn lại 5 phút": việc làm trước, tô bằng màu dạ quang nhạt */
.home-warm {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s3);
  min-height: 56px; padding: var(--s3) var(--s4); border: 1px solid var(--mark-line); border-radius: var(--r-md);
  background: var(--mark-soft); color: var(--ink); text-decoration: none;
}
.home-warm:hover { border-color: var(--ink); }
.home-warm-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--mark); color: var(--on-mark); }
.home-warm-main { display: grid; gap: 1px; min-width: 0; }
.home-warm-title { font-weight: 600; }
.home-warm-text { font-size: var(--fs-sm); color: var(--muted); }

.home-score { gap: var(--s4); }

/* 4 ô số liệu trong một thẻ, ngăn nhau bằng kẻ mảnh */
.home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; padding: 0; }
.home-tile { display: grid; gap: 6px; align-content: start; min-width: 0; padding: var(--s4); border-top: 1px solid var(--line); }
.home-tile:nth-child(odd) { border-right: 1px solid var(--line); }
.home-tile:nth-child(-n+2) { border-top: 0; }
.home-tile-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.home-tile-value { font-size: var(--fs-2xl); line-height: 1.1; }
.home-tile-value small { font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.home-tile-sub { font-size: var(--fs-sm); line-height: 1.4; color: var(--muted); }
.home-tile .btn { justify-self: start; margin-top: 2px; }
.home-tile .bar { margin-block: 2px; }
.home-shields { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.home-shield { display: inline-grid; color: var(--line-strong); }
.home-shield .icon { width: 16px; height: 16px; }
.home-shield.is-on { color: var(--warn); }
.home-shield.is-on .icon { fill: currentColor; }
#home-streak .home-tile-label .icon { color: var(--warn); }
#home-level .home-tile-label .icon { color: var(--brand); }

/* dải 7 ngày của tuần */
.home-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.home-week li { min-width: 0; }
.home-day {
  display: grid; justify-items: center; align-content: center; gap: 1px; width: 100%; min-height: 78px; padding: 6px 2px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink); text-decoration: none;
}
a.home-day:hover { border-color: var(--ink); background: var(--surface-2); }
.home-day-wd { font-size: 0.72rem; font-weight: 600; color: var(--muted); line-height: 1.2; }
.home-day-no { font-size: 1.15rem; line-height: 1.2; }
.home-day-mark { display: grid; place-items: center; height: 18px; color: var(--muted); }
.home-day-mark .icon { width: 16px; height: 16px; stroke-width: 2.2; }
.home-day.is-passed { background: var(--ok-soft); border-color: var(--ok); }
.home-day.is-passed .home-day-mark { color: var(--ok-ink); }
.home-day.is-done { background: var(--sunken); border-color: var(--pencil); }
.home-day.is-done .home-day-mark { color: var(--ink); }
.home-day.is-today { border-color: var(--brand); border-width: 2px; box-shadow: 0 0 0 3px var(--brand-soft); }
.home-day.is-today .home-day-no { color: var(--brand); }
.home-day.is-locked { border-style: dashed; background: none; color: var(--muted); }
@media (min-width: 640px) { .home-week { gap: var(--s2); } .home-day { min-height: 84px; } }

.home-weak-go { color: var(--brand); font-weight: 600; }
@media (max-width: 379px) { .home-weak-go { display: none; } }

.home-board {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s3);
  min-height: 56px; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); text-decoration: none;
}
.home-board:hover { background: var(--surface-2); border-color: var(--line-strong); }
.home-board > .icon { color: var(--muted); }
.home-board-text b { font-size: 1.1rem; }

/* ───────────────────────── 3. Hồ sơ ───────────────────────── */
.home-id { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); }
.home-id-main { display: grid; gap: 1px; flex: 1 1 200px; min-width: 0; }
.home-id-name { font-size: var(--fs-xl); overflow-wrap: anywhere; }

/* thành tích: một cột trên điện thoại (đọc được trọn tên và điều kiện), nhiều cột từ 480px */
.home-badges { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
@media (min-width: 480px) { .home-badges { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
@media (max-width: 639px) { .home-badges.is-short .home-badge:nth-child(n+7) { display: none; } }
@media (min-width: 640px) { .home-badges-more { display: none; } }
.home-badges-more { justify-self: start; margin-left: -12px; }
.home-badges-more[aria-expanded="true"] .icon { transform: rotate(180deg); }
.home-badge {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: var(--s3); min-width: 0;
  padding: var(--s3); border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--muted);
}
.home-badge-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--sunken); color: var(--muted); }
.home-badge-ico .icon { width: 18px; height: 18px; }
.home-badge-main { display: grid; gap: 2px; min-width: 0; }
.home-badge-title { font-weight: 600; line-height: 1.3; }
.home-badge-desc { font-size: var(--fs-xs); line-height: 1.4; }
.home-badge.is-earned { border-style: solid; border-color: var(--line); background: var(--surface); color: var(--ink); }
.home-badge.is-earned .home-badge-ico { background: var(--mark); color: var(--on-mark); }
.home-badge.is-earned .home-badge-desc { color: var(--muted); }

.home-profile-grid { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); align-items: start; min-width: 0; }
.home-profile-grid > * { min-width: 0; }
@media (min-width: 900px) { .home-profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.home-settings, .home-danger { gap: 0; }
.home-settings > .card-title, .home-danger > .card-title { padding-bottom: var(--s3); }
.home-set { display: grid; gap: var(--s3); padding-block: var(--s4); border-top: 1px solid var(--line); min-width: 0; }
.home-set:last-child { padding-bottom: 0; }
.home-set-text { display: grid; gap: 2px; min-width: 0; }
.home-set-title { font-weight: 600; }
.home-set-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); min-width: 0; }
.home-set-ctl .field-error { flex: 1 1 100%; }
/* điện thoại: bộ chọn chiếm trọn chiều ngang, các mức nằm trên một hàng */
@media (max-width: 559px) {
  .home-set-ctl .seg { display: flex; flex-wrap: nowrap; width: 100%; }
  .home-set-ctl .seg-opt { flex: 1 1 auto; min-width: 0; padding-inline: 6px; }
}
@media (max-width: 419px) { .home-set-ctl .seg-opt { font-size: var(--fs-sm); } }
.home-date { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); min-width: 0; }
.home-date .input { width: auto; flex: 0 1 220px; min-width: 170px; }
.home-danger .home-set { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
@media (max-width: 479px) { .home-danger .home-set { grid-template-columns: minmax(0, 1fr); } }

.home-data { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5) var(--s4); }
.home-data .stat-value small { margin-left: 5px; }
@media (min-width: 640px) { .home-data { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ───────────────────────── 4. Bảng xếp hạng ───────────────────────── */
.home-board-body { display: grid; gap: var(--s3); min-width: 0; }
.home-board-note { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2); color: var(--muted); font-size: 0.95rem; }
.home-board-note .icon { margin-top: 3px; }
/* 3 tab chia đều chiều ngang trên điện thoại để không tab nào bị cắt chữ */
@media (max-width: 559px) {
  #home-board-tab { gap: 0; }
  #home-board-tab .tab { flex: 1 1 0; min-width: 0; justify-content: center; padding-inline: var(--s1); }
}
.home-board-me {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4);
  padding: var(--s3) var(--s4); border-radius: var(--r-lg); background: var(--sunken);
}
.home-invite { gap: var(--s4); border-color: var(--line-strong); }
.home-invite-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); }
.home-invite-row .field { flex: 1 1 220px; }
.home-invite-row .btn { min-height: 48px; }
@media (max-width: 559px) { .home-invite-row .btn { flex: 1 1 100%; } }

.home-rank { display: grid; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.home-rank-row {
  display: grid; grid-template-columns: 32px 36px minmax(0, 1fr) auto; align-items: center; gap: var(--s3);
  min-height: 62px; padding: var(--s2) var(--s4) var(--s2) var(--s3); border-top: 1px solid var(--line);
}
.home-rank-row:first-child { border-top: 0; }
.home-rank-no { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: 1rem; color: var(--muted); }
.home-rank-row.is-top .home-rank-no { background: var(--mark-soft); box-shadow: inset 0 0 0 1px var(--mark-line); color: var(--ink); }
.home-rank-row.is-first .home-rank-no { background: var(--mark); box-shadow: none; color: var(--on-mark); }
.home-rank-who { display: grid; gap: 1px; min-width: 0; }
.home-rank-line { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
/* tên dài (tối đa 24 ký tự) được xuống tối đa 2 dòng thay vì bị cắt */
.home-rank-name {
  font-weight: 600; min-width: 0; line-height: 1.3; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.home-rank-line .chip { flex: none; }
.home-rank-sub { font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-rank-end { display: grid; justify-items: end; gap: 1px; text-align: right; }
.home-rank-val { font-size: 1.05rem; white-space: nowrap; }
.home-rank-day { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.home-rank-row.is-me { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.home-rank-row.is-me .avatar { background: var(--surface); }
/* điện thoại hẹp: bỏ ảnh đại diện và tên cấp để tên người học đủ chỗ */
@media (max-width: 399px) {
  .home-rank-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .home-rank-row .avatar { display: none; }
}
@media (max-width: 479px) { .home-rank-lv { display: none; } }
.home-rank-gap { display: grid; place-items: center; height: 28px; border-top: 1px solid var(--line); color: var(--muted); }
@media (min-width: 640px) {
  .home-rank-row { grid-template-columns: 36px 36px minmax(0, 1fr) auto; padding-inline: var(--s4) var(--s5); }
  .home-rank-end { grid-template-columns: auto 104px; align-items: baseline; gap: var(--s4); }
}
