/* Chinese grammar hub (/chinese/grammar/). Generated page: see generate_grammar_pages.py */
.gg { padding: 32px 20px 8px; max-width: 900px; }
.gg h1 { font-size: clamp(28px, 5vw, 42px); margin-bottom: .4em; }
.gg h2 { font-size: clamp(22px, 3.6vw, 30px); margin: 48px 0 .5em; scroll-margin-top: 16px; }
.gg section[id], .gg .gg-cat, .gg details { scroll-margin-top: 16px; }
.gg-lede { font-size: 1.15rem; color: var(--ink); max-width: 760px; }
.gg-toc { font-size: .95rem; color: var(--muted); margin: 0 0 8px; line-height: 1.9; }
.gg-toc strong { color: var(--ink); }

/* 12 rules */
.gg-rules { list-style: none; counter-reset: rule; padding: 0; margin: 20px 0 0; }
.gg-rules > li { counter-increment: rule; position: relative; padding: 0 0 26px 52px;
  border-bottom: 1px solid var(--border); margin-bottom: 26px; }
.gg-rules > li:last-child { border-bottom: 0; margin-bottom: 0; }
.gg-rules > li::before { content: counter(rule); position: absolute; left: 0; top: -2px;
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary-tint); color: var(--primary-dark);
  font-weight: 800; display: flex; align-items: center; justify-content: center; }
.gg-rules h3 { font-size: 1.2rem; margin-bottom: .4em; }
.gg-ex { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; margin: 10px 0; }
.gg-ex .zh { font-size: 1.35rem; line-height: 1.5; }
.gg-ex .trad, .gg-ex .py { color: var(--muted); }
.gg-ex .trad .lbl { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-right: 4px; background: var(--card); }
.gg-ex .en { margin-top: 2px; }
.gg-more { font-size: .95rem; margin: 8px 0 0; }

/* Most searched table */
.gg-table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 12px; }
.gg-table { display: table; width: 100%; border-collapse: collapse; font-size: .97rem; }
.gg-table th { background: var(--bg-soft); text-align: left; padding: 10px 14px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.gg-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.gg-table tr:last-child td { border-bottom: 0; }
.gg-table td:first-child { font-weight: 700; white-space: nowrap; }
.gg-table td.pat { color: var(--muted); }

/* Search */
.gg-search { margin: 18px 0 10px; }
.gg-search label { display: block; font-weight: 700; margin-bottom: 6px; }
.gg-search input { width: 100%; font: inherit; font-size: 1.05rem; padding: 12px 16px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--card); color: var(--ink); -webkit-appearance: none; appearance: none; }
.gg-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(52,168,83,.18); }
.gg-status { color: var(--muted); font-size: .95rem; margin: 8px 0 0; min-height: 1.2em; }

/* Topic chips */
.gg-catnav ul { list-style: none; padding: 0; margin: 6px 0 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.gg-catnav a { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--bg-soft);
  border: 1px solid var(--border); color: var(--ink); font-size: .9rem; font-weight: 600; }
.gg-catnav a:hover { border-color: var(--primary); color: var(--primary-dark); }
.gg-catnav .n { color: var(--muted); font-weight: 700; margin-left: 2px; }

/* Category + level lists */
.gg-cat { margin-top: 34px; }
.gg-cat h3, .gg-level summary { font-size: 1.25rem; }
.gg .count { color: var(--muted); font-size: .85rem; font-weight: 700; margin-left: 6px; }
.gg .desc { color: var(--muted); margin: 4px 0 12px; }
.gg-points { list-style: none; padding: 0; margin: 0; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.gg-points li[hidden] { display: none; }
.gg-points a { display: flex; flex-direction: column; height: 100%; padding: 10px 12px; color: var(--ink);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  transition: border-color .15s ease; }
.gg-points a:hover { border-color: var(--primary); color: var(--ink); }
.gg-points .t { font-weight: 700; line-height: 1.35; }
.gg-points .meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 3px; }
.gg-points .pat { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.gg-points .lv { flex: none; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.lv1 { background: #e7f4ec; color: #1e7a3d; }
.lv2 { background: #e5f3fb; color: #1f6688; }
.lv3 { background: #fdf3dc; color: #8a5a00; }
.lv4 { background: #fbe9e3; color: #a2401f; }
.lv5 { background: #efe8f8; color: #5f3d8f; }
.gg-level { border: 1px solid var(--border); border-radius: 12px; padding: 0 16px; margin: 10px 0; }
.gg-level summary { cursor: pointer; font-weight: 700; padding: 14px 0; list-style-position: inside; }
.gg-level[open] { padding-bottom: 16px; }
.gg-level .desc { margin-top: 0; }

#how-to-learn ol { padding-left: 22px; }
#how-to-learn li { margin-bottom: 8px; }

@media (max-width: 480px) {
  .gg { padding-top: 24px; }
  .gg-rules > li { padding-left: 0; }
  .gg-rules > li::before { position: static; margin-bottom: 8px; width: 32px; height: 32px; }
  .gg-points { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .gg-table-wrap { border: 0; border-radius: 0; }
  .gg-table, .gg-table tbody, .gg-table tr, .gg-table td { display: block; }
  .gg-table thead { display: none; }
  .gg-table tr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
  .gg-table td { padding: 0; border: 0; white-space: normal; }
  .gg-table td:first-child { white-space: normal; font-size: 1.05rem; }
  .gg-table td.pat { font-size: .9rem; margin: 2px 0; }
}
.searching .gg-cat .desc { display: none; }
.searching .gg-cat { margin-top: 22px; }

/* dark theme: level pills get dark tints with light text */
@media (prefers-color-scheme: dark) {
  .lv1 { background: #183526; color: #7fd69a; }
  .lv2 { background: #16303f; color: #8ccbec; }
  .lv3 { background: #3a2f17; color: #f0c870; }
  .lv4 { background: #3d231a; color: #f2a78c; }
  .lv5 { background: #2c2240; color: #c7aef0; }
}
