/* hkcharacter.com — 香港小學字詞表 筆順查字（純靜態 sample）
   Palette 參考 app 嘅 AppColors v2：primary #ff942d / primaryDark #C6532E / ink #1F3B4E */
:root {
  color-scheme: light;
  --paper: #FAF6EE;
  --paper-deep: #F1E9D8;
  --card: #FFFFFF;
  --ink: #1F3B4E;
  --muted: #52646F;
  --line: #E4DAC6;
  --vermilion: #BD4E2A;
  --vermilion-dark: #A03D1C;
  --orange: #FF942D;
  --orange-soft: #FFE3D8;
  --sky: #2D6C9F;
  --note-bg: #FFF3D1;
  --note-line: #E3A62B;
  --note-ink: #5C3F06;
  --err: #A4281A;
  --font-sans: "PingFang HK", "Noto Sans HK", "Noto Sans CJK TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Songti TC", "Noto Serif HK", "Noto Serif CJK TC", "PMingLiU", "STSong", serif;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(46, 22, 15, .06), 0 10px 30px -12px rgba(46, 22, 15, .22);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
svg[hidden] { display: none; }
.wrap { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: 16px; }
a { color: var(--sky); text-underline-offset: 3px; }
a:hover { color: var(--vermilion-dark); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0 0 1em; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .92em; background: var(--paper-deep); padding: .08em .4em; border-radius: 4px; }

:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: rgba(250, 246, 238, .9); }
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.brand .seal { color: var(--vermilion); flex: none; }
.bar-link { font-size: 14px; font-weight: 600; color: var(--vermilion-dark); text-decoration: none; padding: 10px 4px; }
.bar-link:hover { text-decoration: underline; }

/* ---------- hero ---------- */
.hero { padding-top: 28px; padding-bottom: 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.search { min-width: 0; margin-bottom: 14px; }
.eyebrow { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .12em; color: var(--vermilion-dark); }
.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(26px, 6.4vw, 40px);
  text-wrap: balance;
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: .01em;
}

.search label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.search-row { display: flex; gap: 10px; }
.search input {
  flex: 1; min-width: 0; height: 56px; padding: 0 18px;
  font: 600 26px/1 var(--font-sans); color: var(--ink);
  background: var(--card); border: 2px solid var(--ink); border-radius: 14px;
  box-shadow: 4px 4px 0 var(--orange-soft);
}
.search input::placeholder { color: #8A99A2; font-weight: 400; font-size: 18px; }
.search input:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.search .btn { height: 56px; padding-inline: 22px; font-size: 17px; border-radius: 14px; }

.try { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.try-label { font-size: 14px; color: var(--muted); }
.chip {
  min-width: 44px; height: 44px; padding: 0 10px;
  font: 600 20px/1 var(--font-sans); color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.try + .try { margin-top: 8px; }
.chip:hover { border-color: var(--vermilion); color: var(--vermilion-dark); }
.chip[aria-current="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.status { min-height: 1.2em; margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.status.is-error { color: var(--err); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font: 600 15px/1 var(--font-sans); cursor: pointer;
  border: 2px solid transparent; border-radius: 12px;
}
.btn-primary { background: var(--vermilion); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--vermilion-dark); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- tool ---------- */
.tool { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 24px; padding-bottom: 36px; }

.stage-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px;
}
.stage { position: relative; width: 100%; aspect-ratio: 1; background: #fff; border-radius: 8px; overflow: hidden; }
.stage svg, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage svg { z-index: 0; pointer-events: none; }
.stage canvas { z-index: 1; background: transparent; }
.stage canvas[hidden] { display: none; }
/* 字詞表以外嘅字：只顯示字形，隱藏筆順動畫控制（格線選擇保留） */
.stage-card[data-mode="glyph"] .anim-only { display: none; }
.stage-msg {
  position: absolute; inset: 0; z-index: 2; display: none; align-items: center; justify-content: center;
  padding: 16px; text-align: center; font-size: 16px; color: var(--muted); background: rgba(255, 255, 255, .86);
}
.stage-msg.is-on { display: flex; }
.stage-msg.is-error { color: var(--err); }

.controls { display: grid; gap: 12px; padding: 14px 4px 4px; }
.ctl-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; cursor: pointer; margin-inline-start: auto; }
.check input { width: 20px; height: 20px; accent-color: var(--vermilion); }

.seg-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.seg-group legend { padding: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .06em; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.seg label { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-width: 54px; min-height: 44px; padding: 0 12px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg label + label span { border-inline-start: 1px solid var(--line); }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--sky); outline-offset: -3px; }

/* ---------- info ---------- */
.info { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 18px 22px; }
.info-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.info-head h2 { font-family: var(--font-serif); font-size: 24px; font-weight: 800; }
.info-head h2 .big { color: var(--vermilion); }
.info-empty { color: var(--muted); }
.info-plain { margin: 0; font-size: 17px; line-height: 1.7; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 18px; }
.fact { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 0; }
.fact dt { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--muted); }
.fact dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.fact dd small { font-size: 13px; font-weight: 500; color: var(--muted); }

.note { margin: 0 0 18px; padding: 14px 16px; background: var(--note-bg); border: 1px solid var(--note-line); border-inline-start: 6px solid var(--note-line); border-radius: 12px; color: var(--note-ink); }
.note h3 { font-size: 13px; letter-spacing: .1em; font-weight: 700; margin-bottom: 4px; }
.note p { margin: 0; font-size: 17px; font-weight: 600; white-space: pre-line; }

.sub { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.sub small { font-weight: 500; color: var(--muted); }
.words { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.word { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; min-width: 0; }
.word-text { font-size: 20px; font-weight: 700; line-height: 1.3; }
.word-read { font-size: 13px; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.badge { display: inline-block; margin-top: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; color: var(--vermilion-dark); background: var(--orange-soft); border-radius: 999px; }
.phrases { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 18px; }
.phrases li { padding: 4px 12px; border: 1px dashed var(--line); border-radius: 999px; font-weight: 600; }

.official { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; }

/* ---------- about / faq ---------- */
.about { display: grid; gap: 28px; padding-top: 28px; padding-bottom: 36px; border-top: 1px dashed var(--line); }
.about h2 { font-family: var(--font-serif); font-size: 24px; font-weight: 800; margin-bottom: 12px; }
.about h3 { font-size: 16px; font-weight: 700; margin: 18px 0 4px; }
.about p { max-width: 62ch; }
.steps { margin: 6px 0 14px; padding-inline-start: 1.3em; max-width: 62ch; }
.steps li { margin-bottom: 6px; }
.deeplink-note { font-size: 14px; color: var(--muted); }
.faq h3 { color: var(--ink); }
.faq p { color: #33495A; }

/* ---------- CTA ---------- */
.cta { padding-bottom: 40px; }
.cta-box {
  display: grid; gap: 18px; padding: 24px 22px;
  background: var(--paper-deep); border: 1px solid var(--line); border-radius: var(--radius);
}
.cta h2 { font-family: var(--font-serif); font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.cta p { margin: 0; color: #33495A; max-width: 56ch; }
.cta-buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.store {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 1px;
  min-width: 150px; min-height: 52px; padding: 6px 18px;
  background: var(--card); color: var(--ink); text-decoration: none;
  border: 1.5px dashed #9AA8B0; border-radius: 12px; cursor: not-allowed;
}
.store-small { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--vermilion-dark); }
.store-name { font-size: 17px; font-weight: 700; line-height: 1.2; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 22px 0 36px; font-size: 13px; color: var(--muted); }
.site-footer p { margin: 0 0 6px; max-width: 70ch; }

/* ---------- wider screens ---------- */
@media (min-width: 640px) {
  .wrap { padding-inline: 24px; }
  .stage-col { width: 100%; max-width: 540px; margin-inline: auto; }
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .facts .fact dd { font-size: 18px; }
}
@media (min-width: 900px) {
  .wrap { padding-inline: 32px; }
  .tool { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 28px; align-items: stretch; padding-top: 24px; }
  .stage-col { position: sticky; top: 16px; align-self: start; max-width: none; margin-inline: 0; }
  /* 橫屏：右欄較短時拉長至與左欄等高；較長時保持自然高度 */
  .info-col { display: flex; flex-direction: column; }
  .info-col .info { flex: 1 1 auto; }
  .stage-col .stage { width: min(100%, max(260px, calc(100vh - 456px))); margin-inline: auto; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts .fact dd { font-size: 20px; }
  .about { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 48px; }
  .cta-box { grid-template-columns: 1fr auto; align-items: center; padding: 28px 32px; }
}
@media (min-width: 1200px) {
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .facts .fact dd { font-size: 18px; }
}
@media (max-width: 420px) {
  .search input { font-size: 24px; padding: 0 14px; }
  .search .btn { padding-inline: 16px; }
  .seg span { min-width: 46px; padding: 0 9px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
