/* ==========================================================================
   HSK 1 Study Site — stylesheet
   ========================================================================== */

:root {
  --bg:        #0f1115;
  --bg-soft:   #171a21;
  --bg-card:   #1c202a;
  --border:    #2a2f3d;
  --text:      #e6e9ef;
  --text-dim:  #9aa3b2;
  --accent:    #e8a33d;
  --accent-2:  #d8542f;
  --good:      #4ba97a;
  --bad:       #e05b5b;
  --radius:    12px;
  --mono:      ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --han:       "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Heiti SC", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:      #faf8f5;
    --bg-soft: #f2eee8;
    --bg-card: #ffffff;
    --border:  #e2dcd2;
    --text:    #1e2128;
    --text-dim:#6b7280;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1020px; margin: 0 auto; padding: 0 20px; }

/* ------------------------------------------------------------------ header */
header.site {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
header.site .wrap {
  display: flex; align-items: center; gap: 24px;
  min-height: 60px; flex-wrap: wrap;
}
.brand {
  font-weight: 700; font-size: 1.05rem; color: var(--text);
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .zh { font-family: var(--han); color: var(--accent); font-size: 1.3rem; }

nav.main { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
nav.main a {
  color: var(--text-dim); padding: 6px 11px; border-radius: 7px;
  font-size: .9rem; font-weight: 500;
}
nav.main a:hover { background: var(--bg-card); color: var(--text); text-decoration: none; }
nav.main a.active { background: var(--accent); color: #1a1206; }

/* -------------------------------------------------------------------- hero */
.hero { padding: 48px 0 32px; border-bottom: 1px solid var(--border); }
.hero h1 { margin: 0 0 6px; font-size: 2.1rem; letter-spacing: -.02em; }
.hero .zh-big {
  font-family: var(--han); font-size: 3rem; line-height: 1.15;
  margin: 0 0 4px; color: var(--accent);
}
.hero .py { font-family: var(--mono); color: var(--text-dim); font-size: 1.05rem; }
.hero p.lead { color: var(--text-dim); max-width: 62ch; margin: 14px 0 0; }

.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .72rem;
  color: var(--accent); font-weight: 700; margin-bottom: 10px;
}

/* ------------------------------------------------------------------ layout */
main { padding: 36px 0 90px; }
section { margin-bottom: 44px; }
section > h2 {
  font-size: 1.35rem; margin: 0 0 4px;
  display: flex; align-items: center; gap: 10px;
}
section > h2::before {
  content: ""; width: 4px; height: 20px; background: var(--accent);
  border-radius: 2px; flex: none;
}
section > .sub { color: var(--text-dim); font-size: .92rem; margin: 0 0 18px; }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* lesson cards on the index */
a.lesson-card {
  display: block; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; color: var(--text);
  transition: border-color .15s, transform .15s;
}
a.lesson-card:hover {
  border-color: var(--accent); text-decoration: none; transform: translateY(-2px);
}
a.lesson-card .n {
  font-family: var(--mono); font-size: .75rem; color: var(--accent);
  letter-spacing: .1em; text-transform: uppercase;
}
a.lesson-card .zh { font-family: var(--han); font-size: 1.6rem; margin: 6px 0 2px; }
a.lesson-card .py { font-family: var(--mono); font-size: .85rem; color: var(--text-dim); }
a.lesson-card .en { font-size: .95rem; margin-top: 5px; }
a.lesson-card .bl { font-size: .85rem; color: var(--text-dim); margin-top: 9px; }

/* ------------------------------------------------------------ vocab tables */
table.vocab {
  width: 100%; border-collapse: collapse; font-size: .94rem;
}
table.vocab th {
  text-align: left; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-dim); font-weight: 600;
  padding: 0 12px 8px; border-bottom: 1px solid var(--border);
}
table.vocab td {
  padding: 11px 12px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.vocab tr:last-child td { border-bottom: none; }
table.vocab tr:hover td { background: var(--bg-soft); }

.c-han  { font-family: var(--han); font-size: 1.4rem; line-height: 1.3; white-space: nowrap; }
.c-py   { font-family: var(--mono); color: var(--accent); white-space: nowrap; }
.c-say  { color: var(--text-dim); font-style: italic; white-space: nowrap; }
.c-en   { }
.c-type { font-size: .78rem; color: var(--text-dim); white-space: nowrap; }

.note {
  display: block; font-size: .84rem; color: var(--text-dim);
  margin-top: 4px; padding-left: 10px; border-left: 2px solid var(--border);
}

.table-scroll { overflow-x: auto; }

/* ----------------------------------------------------------- grammar boxes */
.gram {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.gram h3 { margin: 0 0 10px; font-size: 1.08rem; }
.gram .pattern {
  font-family: var(--mono); font-size: .9rem; background: var(--bg-soft);
  border-left: 3px solid var(--accent); padding: 10px 14px;
  border-radius: 0 6px 6px 0; margin-bottom: 12px; overflow-x: auto;
}
.gram .body { color: var(--text-dim); font-size: .93rem; margin-bottom: 14px; }
.gram .body strong, .gram .body em { color: var(--text); }

.ex { border-top: 1px solid var(--border); padding-top: 12px; }
.ex .row {
  display: grid; grid-template-columns: minmax(140px, auto) 1fr;
  gap: 4px 18px; padding: 8px 0;
}
.ex .row + .row { border-top: 1px dashed var(--border); }
.ex .row .l .h { font-family: var(--han); font-size: 1.15rem; }
.ex .row .l .p { font-family: var(--mono); font-size: .82rem; color: var(--accent); }
.ex .row .r .s { font-style: italic; color: var(--text-dim); font-size: .86rem; }
.ex .row .r .e { font-size: .92rem; }

/* --------------------------------------------------------------- callouts */
.callout {
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
  border: 1px solid var(--border); background: var(--bg-card);
}
.callout.warn { border-left: 4px solid var(--accent-2); }
.callout.tip  { border-left: 4px solid var(--good); }
.callout h4 { margin: 0 0 8px; font-size: .95rem; }
.callout ul { margin: 0; padding-left: 20px; }
.callout li { margin-bottom: 7px; font-size: .92rem; }
.callout li:last-child { margin-bottom: 0; }
.bad { color: var(--bad); font-family: var(--han); }

/* ---------------------------------------------------------------- goals */
ul.goals { list-style: none; padding: 0; margin: 0; }
ul.goals li {
  padding: 9px 0 9px 28px; position: relative;
  border-bottom: 1px solid var(--border); font-size: .93rem;
}
ul.goals li:last-child { border-bottom: none; }
ul.goals li::before {
  content: "→"; position: absolute; left: 4px; color: var(--accent);
}

/* --------------------------------------------------------------- controls */
.controls {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 18px;
}
input.search, select.filter {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); padding: 9px 13px; border-radius: 8px;
  font-size: .92rem; font-family: inherit;
}
input.search { flex: 1; min-width: 200px; }
input.search:focus, select.filter:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button.toggle {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); padding: 8px 14px; border-radius: 8px;
  font-size: .87rem; cursor: pointer; font-family: inherit;
  transition: all .15s;
}
button.toggle:hover { border-color: var(--accent); color: var(--text); }
button.toggle.on { background: var(--accent); border-color: var(--accent); color: #1a1206; }

/* hide-mode: blur until hovered */
.hide-py  .c-py,  .hide-py  .ex .row .l .p, .hide-py  .hero .py { filter: blur(5px); transition: filter .12s; }
.hide-en  .c-en,  .hide-en  .ex .row .r .e { filter: blur(5px); transition: filter .12s; }
.hide-han .c-han, .hide-han .ex .row .l .h { filter: blur(6px); transition: filter .12s; }
.hide-py  .c-py:hover,  .hide-py  .p:hover,
.hide-en  .c-en:hover,  .hide-en  .e:hover,
.hide-han .c-han:hover, .hide-han .h:hover { filter: none; }

/* ------------------------------------------------------------- flashcards */
.fc-stage { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.flashcard {
  width: 100%; max-width: 520px; min-height: 260px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  padding: 34px; cursor: pointer; text-align: center; user-select: none;
}
.flashcard:hover { border-color: var(--accent); }
.flashcard .fc-han { font-family: var(--han); font-size: 3.4rem; line-height: 1.2; }
.flashcard .fc-py  { font-family: var(--mono); font-size: 1.2rem; color: var(--accent); }
.flashcard .fc-say { font-style: italic; color: var(--text-dim); }
.flashcard .fc-en  { font-size: 1.15rem; }
.flashcard .fc-hint { font-size: .8rem; color: var(--text-dim); margin-top: 8px; }
.fc-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.fc-count { font-family: var(--mono); font-size: .85rem; color: var(--text-dim); }

/* -------------------------------------------------------------- prev/next */
.pager {
  display: flex; justify-content: space-between; gap: 14px;
  border-top: 1px solid var(--border); padding-top: 24px; margin-top: 40px;
}
.pager a {
  padding: 12px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); flex: 1; max-width: 46%;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a.next { text-align: right; margin-left: auto; }
.pager .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); }
.pager .ttl { font-family: var(--han); font-size: 1.15rem; color: var(--text); }

footer.site {
  border-top: 1px solid var(--border); padding: 26px 0;
  color: var(--text-dim); font-size: .85rem;
}

.badge {
  display: inline-block; font-size: .72rem; font-family: var(--mono);
  padding: 2px 8px; border-radius: 20px; background: var(--bg-soft);
  border: 1px solid var(--border); color: var(--text-dim);
}

@media (max-width: 640px) {
  .hero .zh-big { font-size: 2.2rem; }
  .hero h1 { font-size: 1.5rem; }
  .ex .row { grid-template-columns: 1fr; }
  nav.main { margin-left: 0; width: 100%; }
  .pager { flex-direction: column; }
  .pager a { max-width: 100%; }
}
