/* Trang chủ TTOnline: chỉ nạp ở front page. Dùng biến màu của theme nên tự đổi theo chế độ sáng/tối. */

.th-page {
  --th-grid: color-mix(in srgb, var(--brand) 30%, transparent);
  --th-grid-soft: color-mix(in srgb, var(--brand) 15%, transparent);
  --th-seal: #c8372d;
  --th-han: "KaiTi", "Kaiti SC", "STKaiti", "楷体", "Noto Serif SC", "Songti SC", serif;
  --th-gap: clamp(44px, 6.5vw, 84px);
}
.th-page a:focus-visible,
.th-page summary:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; border-radius: 6px; }

/* ---------- Hero ---------- */
.th-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: clamp(28px, 5vw, 76px);
  align-items: center;
  padding-top: clamp(8px, 2.5vw, 32px);
}
.th-hero h1 {
  margin: 0 0 18px;
  max-width: 14em;
  font-size: clamp(2.1rem, 4.6vw, 3.8rem);
  line-height: 1.08;
  letter-spacing: -.035em;
  font-weight: 800;
  text-wrap: balance;
}
.th-hero p {
  margin: 0 0 26px;
  max-width: 33em;
  font-size: 1.125rem;
  color: var(--muted);
}
.th-hero .tto-search { max-width: 560px; margin: 0 0 18px; }
.th-hero .tto-search input { padding: 15px 16px; font-size: 1rem; }
.th-hero .tto-search .btn { padding-inline: 22px; }
.th-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.th-cta .btn { padding: 12px 22px; font-weight: 650; }
.th-ghost {
  display: inline-block;
  padding: 11px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--txt);
  font-weight: 600;
  text-decoration: none;
}
.th-ghost:hover { border-color: var(--brand); color: var(--brand); }

/* Tờ giấy tập viết (米字格) */
.th-sheet {
  position: relative;
  justify-self: center;
  width: min(100%, 420px);
  padding: 22px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 28px 50px -30px color-mix(in srgb, var(--txt) 45%, transparent);
  transform: rotate(1.5deg);
}
.th-cell, .th-mini {
  container-type: inline-size;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px solid var(--th-grid);
  border-radius: 2px;
  background:
    linear-gradient(to right, transparent calc(50% - .5px), var(--th-grid-soft) calc(50% - .5px), var(--th-grid-soft) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), var(--th-grid-soft) calc(50% - .5px), var(--th-grid-soft) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to top right, transparent calc(50% - .5px), var(--th-grid-soft) calc(50% - .5px), var(--th-grid-soft) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom right, transparent calc(50% - .5px), var(--th-grid-soft) calc(50% - .5px), var(--th-grid-soft) calc(50% + .5px), transparent calc(50% + .5px));
}
.th-han { font-family: var(--th-han); font-size: clamp(120px, 15vw, 230px); line-height: 1; color: var(--txt); }
.th-mini { border-width: 1.5px; }
.th-mini span { font-family: var(--th-han); font-size: 64px; line-height: 1; }
@supports (font-size: 1cqw) {
  .th-han { font-size: 74cqw; }
  .th-mini span { font-size: 70cqw; }
}
.th-trace { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.th-mini.t0 span { color: var(--txt); }
.th-mini.t1 span { color: color-mix(in srgb, var(--txt) 38%, transparent); }
.th-mini.t2 span { color: color-mix(in srgb, var(--txt) 22%, transparent); }
.th-mini.t3 span { color: color-mix(in srgb, var(--txt) 11%, transparent); }
.th-cap { display: flex; align-items: baseline; gap: 10px; margin: 14px 2px 0; color: var(--muted); font-size: .95rem; }
.th-cap b { color: var(--txt); font-size: 1.15rem; font-weight: 650; }
.th-seal {
  position: absolute;
  top: -14px; right: -12px;
  display: grid; place-items: center;
  width: 54px; height: 54px;
  border-radius: 6px;
  background: var(--th-seal);
  color: #fff;
  font-family: var(--th-han);
  font-size: 30px; line-height: 1;
  transform: rotate(-6deg);
  box-shadow: 0 8px 16px -8px rgba(200, 55, 45, .65);
}

/* ---------- Khối chung ---------- */
.th-section { margin-top: var(--th-gap); }
.th-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 22px; }
.th-head h2 { margin: 0; font-size: clamp(1.4rem, 2.5vw, 1.95rem); line-height: 1.2; letter-spacing: -.02em; font-weight: 750; }
.th-head p { margin: 6px 0 0; color: var(--muted); }
.th-head > a { color: var(--brand); font-weight: 600; text-decoration: none; }
.th-head > a:hover { text-decoration: underline; }
.th-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .85rem; }

/* ---------- Ba lối vào ---------- */
.th-paths { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.th-path {
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 236px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--txt);
  text-decoration: none;
  transition: border-color .15s ease;
}
.th-path:hover { border-color: var(--brand); }
.th-path.vocab { grid-column: span 5; background: var(--chip-bg); border-color: transparent; }
.th-path.dialogue { grid-column: span 4; }
.th-path.writing { grid-column: span 3; background: #14213d; border-color: transparent; color: #f2f6ff; }
.th-path.writing:hover { border-color: #7aa2ff; }
[data-theme="dark"] .th-path.writing { border-color: var(--line); }
.th-paths.is-two .vocab { grid-column: span 7; }
.th-paths.is-two .dialogue { grid-column: span 5; }
.th-path .glyph {
  position: absolute; top: 4px; right: 20px;
  font-size: clamp(110px, 12vw, 176px); line-height: 1.1; font-weight: 700;
  opacity: .1; pointer-events: none;
}
.th-path h3 { margin: 0 0 6px; font-size: 1.4rem; letter-spacing: -.01em; }
.th-path p { margin: 0 0 16px; max-width: 24em; opacity: .82; }
.th-path .count { font-weight: 700; font-size: .95rem; }

/* ---------- Chủ đề ---------- */
.th-topics { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.th-topics a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--txt);
  font-size: .95rem; font-weight: 550;
  text-decoration: none;
}
.th-topics a:hover { border-color: var(--brand); color: var(--brand); }
.th-topics small { color: var(--muted); font-size: .8rem; font-weight: 500; }
.th-more { margin-top: 14px; }
.th-more summary { display: inline-block; cursor: pointer; list-style: none; padding: 6px 2px; color: var(--brand); font-weight: 600; }
.th-more summary::-webkit-details-marker { display: none; }
.th-more .when-open { display: none; }
.th-more[open] .when-open { display: inline; }
.th-more[open] .when-closed { display: none; }
.th-more[open] summary { margin-bottom: 10px; }

/* ---------- Bộ từ vựng mới ---------- */
.th-packs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.th-pack {
  display: flex; flex-direction: column; gap: 14px;
  min-height: 200px; padding: 22px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--txt); text-decoration: none;
}
.th-pack:hover, .th-dlg:hover { border-color: var(--brand); }
.th-words { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.th-w { display: flex; flex-direction: column; }
.th-w b { font-size: 2rem; line-height: 1.2; font-weight: 500; }
.th-w i { font-style: normal; color: var(--muted); font-size: .8rem; }
.th-pack h3 { margin: auto 0 0; font-size: 1.1rem; line-height: 1.3; }

/* ---------- Hội thoại mới ---------- */
.th-dlgs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.th-dlg {
  display: flex; flex-direction: column; gap: 16px;
  padding: 22px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--txt); text-decoration: none;
}
.th-dlg-head { display: block; }
.th-dlg-head h3 { margin: 0 0 4px; font-size: 1.1rem; line-height: 1.3; }
.th-bubbles { display: grid; gap: 8px; }
.th-bubbles > span { display: block; max-width: 90%; padding: 10px 14px; border-radius: 14px; line-height: 1.4; }
.th-bubbles .a { justify-self: start; border-bottom-left-radius: 4px; background: var(--chip-bg); }
.th-bubbles .b { justify-self: end; border-bottom-right-radius: 4px; background: color-mix(in srgb, var(--brand) 14%, var(--surface)); }
.th-bubbles b { display: block; font-size: 1.15rem; font-weight: 500; }
.th-bubbles i { display: block; font-style: normal; color: var(--muted); font-size: .85rem; }

/* ---------- Dải tính năng ---------- */
.th-feats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.th-feat { padding: 28px 26px; border-left: 1px solid var(--line); }
.th-feat:first-child { padding-left: 0; border-left: 0; }
.th-feat .han { display: block; margin-bottom: 14px; color: var(--brand); font-size: 2.5rem; line-height: 1; font-weight: 500; }
.th-feat h3 { margin: 0 0 6px; font-size: 1.05rem; }
.th-feat p { margin: 0; max-width: 22em; color: var(--muted); font-size: .93rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .th-hero { grid-template-columns: 1fr; }
  .th-sheet { width: min(100%, 340px); justify-self: start; margin-top: 8px; }
  .th-paths .vocab, .th-paths .dialogue, .th-paths.is-two .vocab, .th-paths.is-two .dialogue { grid-column: span 6; }
  .th-paths .writing { grid-column: span 12; min-height: 170px; }
  .th-packs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .th-feats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .th-feat:nth-child(odd) { padding-left: 0; border-left: 0; }
  .th-feat:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 650px) {
  .th-paths .vocab, .th-paths .dialogue, .th-paths.is-two .vocab, .th-paths.is-two .dialogue { grid-column: span 12; }
  .th-path { min-height: 170px; padding: 22px; }
  .th-packs, .th-dlgs { grid-template-columns: 1fr; }
  .th-sheet { width: min(100%, 300px); }
  .th-seal { top: -10px; right: -6px; width: 46px; height: 46px; font-size: 26px; }
  .th-feats { grid-template-columns: 1fr; }
  .th-feat, .th-feat:nth-child(odd) { padding: 22px 0; border-left: 0; }
  .th-feat + .th-feat { border-top: 1px solid var(--line); }
  .th-hero .tto-search { flex-wrap: wrap; }
  .th-hero .tto-search input { flex: 1 1 100%; }
  .th-hero .tto-search .btn { flex: 1 1 100%; padding-block: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .th-page * { transition: none !important; }
}
