/* Chinese Decoding: styles (derived from the Japanese Decoding sheet). Colours follow /theme.css of agrill.at. */
@font-face {
  font-family: 'Inter';
  src: url(/fonts/inter-latin-wght-normal.woff2) format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #edf0f5;
  --surface: #e2e6ed;
  --surface-2: #d4d9e4;
  --border: #bcc4d0;
  --text: #364259;
  --muted: #546475;
  --faint: #6e8099;
  --accent: #c47a3a;
  --romaji: #4a7fc1;
  --particle-bg: #f3e3d3;
  --particle-text: #9a5a24;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161a21;
    --surface: #1e232c;
    --surface-2: #272d38;
    --border: #343c4a;
    --text: #e3e7ee;
    --muted: #a9b3c3;
    --faint: #8391a6;
    --accent: #e29a5a;
    --romaji: #7fb0ec;
    --particle-bg: #3a2c1f;
    --particle-text: #f0b47c;
  }
}
:root[data-theme="dark"] {
  --bg: #161a21;
  --surface: #1e232c;
  --surface-2: #272d38;
  --border: #343c4a;
  --text: #e3e7ee;
  --muted: #a9b3c3;
  --faint: #8391a6;
  --accent: #e29a5a;
  --romaji: #7fb0ec;
  --particle-bg: #3a2c1f;
  --particle-text: #f0b47c;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
  padding: 2rem 1rem 4rem;
}
.wrap { max-width: 860px; margin: 0 auto; }
a { color: var(--accent); }
.back { font-size: .85rem; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--accent); }

h1 { font-size: 1.8rem; line-height: 1.2; margin: .6rem 0 .2rem; }
.zh, h1 .zh { font-family: "PingFang TC", "Hiragino Sans CNS", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", "Heiti TC", sans-serif; }
.sub { color: var(--muted); margin: 0; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .03em; color: var(--particle-text); background: var(--particle-bg); border-radius: 4px; padding: .1rem .45rem; margin-left: .4rem; vertical-align: middle; }

.intro { background: var(--surface); border-radius: 10px; padding: 1rem 1.2rem; margin: 1.5rem 0; font-size: .92rem; }
.intro p { margin: .4rem 0; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.2rem 0 .5rem; position: sticky; top: 0; background: var(--bg); padding: .6rem 0; z-index: 2; }
.controls label { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .3rem .8rem; cursor: pointer; user-select: none; }
.controls input { accent-color: var(--accent); }
.player { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; }
.player audio { width: 100%; max-width: 520px; height: 40px; }
.embed { margin: 1.2rem 0 .4rem; }
.embed iframe { display: block; width: 100%; max-width: 760px; height: 240px; border: 0; border-radius: 10px; }
.embed.multi { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.embed.multi iframe { max-width: none; }
@media (max-width: 700px) { .embed.multi { grid-template-columns: 1fr; } }
.player-hint { font-size: .85rem; color: var(--accent); font-weight: 600; }

/* song */
section.part { margin: 1.8rem 0 0; }
section.part h2 { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 0 0 .6rem; border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.line { position: relative; background: var(--surface); border-radius: 10px; padding: .7rem .9rem .6rem; margin: .5rem 0; }
.line .mora { float: right; margin: 0 0 .3rem .6rem; font-size: .7rem; font-weight: 600; color: var(--faint); background: var(--surface-2); border-radius: 999px; padding: .05rem .5rem; cursor: help; }
.part-note { margin: -.3rem 0 .5rem; font-size: .82rem; color: var(--faint); font-style: italic; }
.notes { font-size: .88rem; }
.words { display: flex; flex-wrap: wrap; gap: .2rem .9rem; align-items: flex-start; }
.w { display: inline-flex; flex-direction: column; align-items: flex-start; }
.w .j { font-size: 1.45rem; line-height: 1.3; }
.w .r { font-size: .95rem; color: var(--romaji); font-weight: 500; }
.j.new { text-decoration: underline dotted var(--accent); text-decoration-thickness: 2px; text-underline-offset: .28em; }
.w .g { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.w .g.p { font-weight: 700; letter-spacing: .04em; color: var(--particle-text); background: var(--particle-bg); border-radius: 3px; padding: 0 .3rem; cursor: pointer; }
.en { margin-top: .45rem; padding-top: .4rem; border-top: 1px dashed var(--border); font-size: .9rem; color: var(--muted); font-style: italic; }

body.hide-r .w .r, body.hide-g .w .g, body.hide-en .en { display: none; }

/* index */
.songs { list-style: none; padding: 0; margin: 1.5rem 0; }
.songs a { display: block; background: var(--surface); border-radius: 10px; padding: .9rem 1.1rem; margin: .5rem 0; text-decoration: none; color: var(--text); border: 1px solid transparent; }
.songs a:hover { border-color: var(--accent); }
.songs .t { font-size: 1.25rem; }
.songs .s { color: var(--muted); font-size: .88rem; }

.legend { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; font-size: .85rem; margin: .6rem 0 0; }
.legend dt { font-weight: 700; color: var(--particle-text); }
.legend dd { margin: 0; color: var(--muted); }
footer { margin-top: 3rem; font-size: .8rem; color: var(--faint); }

@media (max-width: 520px) {
  .w .j { font-size: 1.25rem; }
  .words { gap: .2rem .7rem; }
}

/* explanation popup (tip.js) */
[data-tip] { cursor: pointer; }
.tip { position: fixed; z-index: 1000; max-width: min(18rem, calc(100vw - 16px)); padding: .45rem .65rem; border-radius: 6px;
  background: var(--text); color: var(--bg); font-size: .82rem; line-height: 1.35; box-shadow: 0 4px 14px rgba(0,0,0,.25); pointer-events: none; }
.tip[hidden] { display: none; }

/* audio following and sync mode */
.line.cued { cursor: pointer; }
.line.now { background: var(--surface-2); box-shadow: inset 4px 0 0 var(--accent); }
.line.done { opacity: .55; }
.sync { background: var(--particle-bg); border-radius: 10px; padding: .8rem 1rem; margin: .4rem 0 1rem; font-size: .9rem; }
.sync p { margin: 0 0 .6rem; }
.sync button { font: inherit; padding: .5rem 1rem; margin: 0 .5rem .5rem 0; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.sync .sync-mark { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; min-width: 12rem; }
.sync textarea { display: block; width: 100%; height: 6rem; font: .8rem ui-monospace, monospace; }

/* multi-voice stories */
.line.speech { border-left: 3px solid var(--romaji); }
.line .who { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em; color: var(--romaji); margin-bottom: .2rem; }
.chapters { display: flex; justify-content: space-between; margin: 2rem 0 0; font-size: .95rem; }

/* Long info boxes are closed drop-downs (notes on song pages, the method on the overview). */
details.intro { padding: .7rem 1.2rem; margin: 1rem 0; }
details.intro > summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--accent); }
details.intro[open] > summary { margin-bottom: .6rem; }

/* Chant lines: one cell per beat. One Chinese character = one syllable = one beat; the dot is the stroke of the wooden drum,
   the larger orange dot marks the first beat of a phrase group. Cells light up in time with the recording. */
.line.chant .mora { cursor: help; }
.beats { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .55rem 0; margin: .15rem 0 .55rem; }
.bgrp { display: flex; flex-wrap: wrap; padding: 0 .3rem; border-left: 2px solid var(--border); }
.bgrp:first-child { padding-left: 0; border-left-color: transparent; }
.bt { position: relative; width: 3.05rem; padding: .95rem 0 .15rem; text-align: center; border-radius: 8px; transition: background .07s; }
.bt::before { content: ""; position: absolute; top: .3rem; left: 50%; width: .4rem; height: .4rem; margin-left: -.2rem; border-radius: 50%; background: var(--faint); transition: transform .07s, background .07s; }
.bt.acc::before { top: .16rem; width: .68rem; height: .68rem; margin-left: -.34rem; background: var(--accent); }
.bt.first::before { box-shadow: 0 0 0 3px var(--particle-bg); }
.bt .h { display: block; font-size: 1.7rem; line-height: 1.15; }
.bt .k { display: block; font-size: .78rem; color: var(--muted); }
.bt .r { display: block; font-size: .78rem; color: var(--romaji); font-weight: 500; }
.bt.on { background: var(--surface-2); }
.bt.on::before { transform: scale(1.9); background: var(--accent); }
.bt.on .h { color: var(--accent); }
body.hide-b .beats, body.hide-b .line.chant .mora { display: none; }
body.hide-r .bt .r, body.hide-r .bt .k { display: none; }
@media (max-width: 520px) { .bt { width: 2.7rem; } .bt .h { font-size: 1.5rem; } }

/* English part of a title: beside the Japanese title on the overview, below it on a song page */
.songs .t .en, h1 .en { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: .95rem; font-weight: 400; color: var(--muted); margin-left: .7rem; }
h1 .en { display: block; margin: .2rem 0 0; font-size: 1.05rem; }

/* extra recordings and copy-for-Suno boxes */
.extra-audio { margin: .4rem 0 1rem; }
.extra-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .35rem 0; }
.extra-label { color: var(--muted); font-size: .9rem; min-width: 11rem; }
.extra-row audio { flex: 1 1 280px; max-width: 100%; }
.prompts textarea { width: 100%; box-sizing: border-box; font: .85rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface); color: var(--text); border: 1px solid var(--border, rgba(128,128,128,.35)); border-radius: 8px; padding: .6rem .7rem; resize: vertical; margin-bottom: .8rem; }
.prompt-head { display: flex; align-items: center; gap: .8rem; margin: .8rem 0 .3rem; }
.prompt-head .copy { font: inherit; font-size: .85rem; padding: .2rem .8rem; border-radius: 6px; border: 1px solid var(--accent); background: transparent; color: var(--accent); cursor: pointer; }
.prompt-head .txt { font-size: .85rem; }

/* zhuyin row (optional) */
.w .z { font-size: .82rem; color: var(--faint); letter-spacing: .06em; min-height: 1.1em; }
body.hide-z .w .z { display: none; }
.w .r { white-space: nowrap; }

/* HSK word list */
.vocab summary { cursor: pointer; font-weight: 600; }
.vocab .vf { display: flex; flex-wrap: wrap; gap: .4rem; margin: .7rem 0; }
.vocab .vf button { font: inherit; font-size: .82rem; padding: .25rem .75rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.vocab .vf button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.vocab table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.vocab th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: .3rem .4rem; }
.vocab td { padding: .22rem .4rem; border-top: 1px solid var(--border); vertical-align: baseline; }
.vocab td.c { font-size: 1.05rem; }
.vocab td.p { color: var(--romaji); }
.vocab a { cursor: pointer; text-decoration: none; }
.vocab .lv { font-size: .7rem; color: var(--faint); }
.vocab .scroll { max-height: 26rem; overflow: auto; border-radius: 8px; }
.line.flash { box-shadow: inset 4px 0 0 var(--accent), 0 0 0 2px var(--accent); }
.sec-count { font-weight: 400; color: var(--faint); text-transform: none; letter-spacing: 0; }
.stat { display: inline-block; font-size: .72rem; font-weight: 600; color: var(--romaji); background: var(--surface-2); border-radius: 4px; padding: .1rem .45rem; margin-left: .5rem; }

.songs .t .en, h1 .en { border-top: 0; padding-top: 0; margin-top: 0; }
