/*
 * Book-style zhuyin (bopomofo) annotation for literatelanguages.com.
 * Mirrors the Literate Chinese app's ZhuyinStack: horizontal text, the
 * zhuyin for each character stacked vertically in a narrow column to its
 * right, the tone mark beside the junction of the last two symbols (beside
 * the symbol when there is only one), and the neutral-tone dot on top.
 *
 * Markup (written by generate_zhuyin_practice.py):
 *   <span class="zc">字<span class="zy n2 t4" aria-hidden="true"><i>ㄗ</i><i>ˋ</i>...
 *   .n1/.n2/.n3 = number of symbols, .t1-.t5 = tone (5 = neutral).
 * Tone marks are drawn with ::after so copied text is the characters only.
 * Hiding zhuyin uses visibility, so every column keeps its width and the
 * text never reflows when the reader toggles it.
 */

:root { --zy-ink: #46536a; --zy-hl: #ffeaa8; }
@media (prefers-color-scheme: dark) { :root { --zy-ink: #b4c0cc; --zy-hl: #3d3517; } }

.zt {
  font-family: "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--ink);
}
.zt p { margin: 0 0 .35em; line-height: 1; }

/* one character + its zhuyin column */
.zc, .zp {
  display: inline-flex;
  align-items: center;
  height: 1.9em;
  vertical-align: top;
}
.zy {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 1.2em;            /* in zhuyin units (font-size below) */
  margin-right: .62em;     /* tone-mark slot before the next character */
  font-size: .47em;
  line-height: 1;
  color: var(--zy-ink);
  transform: translateY(.06em);
  user-select: none;
  -webkit-user-select: none;
}
.zy i { display: block; font-style: normal; height: 1em; }

/* tone mark beside the stack */
.zy::after {
  position: absolute;
  left: 90%;
  font-size: 1.2em;
  line-height: 1;
}
.zy.t2::after { content: "ˊ"; }
.zy.t3::after { content: "ˇ"; }
.zy.t4::after { content: "ˋ"; }
/* ink of the modifier letters rides near the top of their em box, so the
   box sits lower than the geometric junction (tuned against print) */
.zy.n1::after { top: .05em; }
.zy.n2::after { top: .7em; }
.zy.n3::after { top: 1.6em; }

/* neutral tone: a drawn dot on top of the stack, in flow so the whole
   block (dot included) centers on the character */
.zy.t5::before {
  content: "";
  display: block;
  width: .32em; height: .32em;
  border-radius: 50%;
  background: currentColor;
  margin-bottom: .14em;
}

/* punctuation and other unannotated text */
.zp { padding-right: .05em; }

/* a word and the punctuation after it never split across lines */
.zw { white-space: nowrap; }

/* hide zhuyin to test yourself: the space stays */
.zt.zy-off .zy { visibility: hidden; }

@media (max-width: 480px) {
  .zt { font-size: 1.55rem; }
}

/* ---------- /chinese/zhuyin/reading-practice/ page ---------- */
.zp-wrap { max-width: 820px; margin: 0 auto; }
.zp-wrap h2 { margin-top: 40px; }
.zp-steps { margin: 0 0 1rem 1.3rem; }
.zp-steps li { margin-bottom: 6px; }
.zp-table { margin: 16px 0 22px; font-size: .96rem; }
.zp-table th { background: var(--bg-soft); text-align: left; padding: 9px 12px; border-bottom: 2px solid var(--border); }
.zp-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.zp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 8px 6px 16px; margin: 18px 0; box-shadow: var(--shadow-sm); width: fit-content; max-width: 100%; }
.zp-bar span { color: var(--muted); font-weight: 700; font-size: .9rem; }
.zbtn { border: 1px solid var(--border); background: var(--card); color: var(--ink); border-radius: 999px;
  padding: 6px 14px; font: 700 .9rem/1.2 inherit; font-family: inherit; cursor: pointer; }
.zbtn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.zstory { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px 8px;
  margin: 18px 0 24px; box-shadow: var(--shadow-sm); scroll-margin-top: 130px; }
.zstory h3 { margin: 0 0 4px; font-size: 1.2rem; }
.znum { display: inline-block; min-width: 1.7em; height: 1.7em; line-height: 1.7em; border-radius: 50%;
  background: var(--primary-tint); color: var(--primary-ink); text-align: center; font-size: .85rem; margin-right: 4px; }
.zmeta { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }
.ztools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.zstory .zt { cursor: pointer; }
/* highlight the cells themselves: the inline .zs box does not match the
   taller character cells */
.zs.on .zc, .zs.on .zp { background: var(--zy-hl); }
@media (hover: hover) { .zs:hover .zc, .zs:hover .zp { background: var(--bg-soft); } .zs.on:hover .zc, .zs.on:hover .zp { background: var(--zy-hl); } }
.zt p.zx, .zx { display: none; font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: .98rem; line-height: 1.5; color: var(--ink); background: var(--bg-soft); border-left: 3px solid var(--primary);
  border-radius: 6px; padding: 6px 12px; margin: 2px 0 14px !important; }
.zx span { display: none; }
.zt .zx.has-on, .zstory.en-on .zt .zx { display: block; }
.zx span.on, .zstory.en-on .zx span { display: inline; }
.zfoot { font-size: .95rem; margin: 10px 0 10px; }
.zp-demo { margin: 6px 0 14px; padding: 10px 14px; background: var(--bg-soft); border-radius: 12px; width: fit-content; max-width: 100%; }
@media (max-width: 560px) {
  .zp-table { font-size: .86rem; }
  .zp-table th, .zp-table td { padding: 7px 6px; }
  .zp-table .zn { display: none; }
  .zstory { padding: 14px 12px 6px; }
}
