/* 注音閃卡 — 頁面專屬樣式。
 * 版面、工具列、圖示鈕來自 /app.css（body.fill 滿版模式）；
 * 這裡只留閃卡自己的東西：卡面、漢字與注音排版、筆順覆蓋層。 */

/* 教育部標準楷書的子集：只含 cards.json 用到的字（約 270 字，~240 KB，
   全字庫 ~16 MB）。cards.json 改了要重跑 build-font-subset.py。 */
@font-face {
  font-family: 'CustomKaiti';
  src: url('./edukai-subset.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ---- 卡片 ---- */

.deck {
  position: relative;
  flex: 1;
  min-height: 0;
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  /* 左右滑動切卡：交給 JS 處理，不要讓瀏覽器攔走手勢 */
  touch-action: none;
}

.deck-body {
  width: 100%;
  height: 100%;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  /* 漢字字級以卡片內容高為基準自動縮放（見 app.js 的 characterFontSize） */
  container-type: size;
}

.empty {
  cursor: default;
  color: var(--dim);
  font-size: 14px;
}

/* 最愛（右上角） */
.fav-btn {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-color: transparent;
  color: var(--faint);
  box-shadow: none;
}
.fav-btn:hover { background: var(--panel-hi); }
.fav-btn svg { width: 24px; height: 24px; }
.fav-btn.on { color: var(--accent); background: transparent; border-color: transparent; }
.fav-btn.on:hover { background: var(--panel-hi); }

/* ---- 漢字 + 注音 ---- */

.chars {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12em;   /* 隨字級縮放 */
}

.char-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 左右兩側等寬留白，讓漢字維持置中（右側放注音） */
.gutter {
  width: 2.5rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char {
  margin: 0 0.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: normal;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  font-family: 'CustomKaiti', 'Kaiti SC', 'Kaiti TC', 'BiauKai', 'STKaiti', 'KaiTi', '楷体', '楷體', 'Kai', serif;
}
.char:hover { background: transparent; }

/* iOS 沒有楷體系統字，webfont 失敗時退回黑體而非襯線體 */
@supports (-webkit-touch-callout: none) {
  .char {
    font-family: 'CustomKaiti', 'PingFang SC', 'PingFang TC', 'Hiragino Sans GB', 'Heiti SC', 'Heiti TC', sans-serif;
  }
}

/* 注音：直排符號，聲調標在最後一個符號右上；輕聲標在第一個符號正上方 */
.zhuyin {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.25rem;
  line-height: 1.25;
}
.zhuyin.hidden { visibility: hidden; }
.zhuyin span { position: relative; }
.zhuyin .tone {
  position: absolute;
  top: -0.75rem;
  right: -0.75rem;
  font-size: 1.5rem;
}
.zhuyin .tone.neutral {
  right: auto;
  left: 50%;
  transform: translateX(-50%);
}

/* ---- 筆順覆蓋層 ---- */

.stroke {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  cursor: default;
  background: var(--surface);
}

.stroke-head {
  flex-shrink: 0;
  height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.stroke-title { min-width: 0; }
.stroke-title .t { font-size: 14px; font-weight: 500; }
.stroke-title .s {
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stroke-acts { flex-shrink: 0; display: flex; align-items: center; gap: 4px; }
.stroke-acts .icon-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border-color: transparent;
  color: var(--dim);
}
.stroke-acts .icon-btn:hover { background: var(--panel-hi); color: var(--ink); }
.stroke iframe {
  flex: 1;
  min-height: 0;
  border: 0;
  background: #fff;
}

/* ---- 上一個 / 計數 / 下一個 ---- */

.nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nav button {
  width: 33%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  background: var(--surface);
}
.nav button svg { width: 20px; height: 20px; }
.nav .count {
  width: 33%;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ---- 頁尾 ---- */

.page-foot {
  flex-shrink: 0;
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
}
.page-foot a { color: var(--dim); text-decoration: underline; text-underline-offset: 2px; }
.page-foot a:hover { color: var(--ink); }
