
/* page style: hanzi */
body[data-site-route="/hanzi/"] {
  min-height: 100dvh;
}

body[data-site-route="/hanzi/"] > hanzi-matrix {
  display: block;
  max-width: none;
  min-height: 100dvh;
  width: 100%;
}

body[data-site-route="/hanzi/"] hanzi-matrix :is(.page,.tool-page) {
  max-width: none;
  width: 100%;
}

body[data-site-route="/hanzi/"] {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --fg: #1c1c1a;
  --surface: #fffefa;
  --muted: #6b6963;
  --cell: #fffefa;
  --cell-hover: color-mix(in oklab,var(--surface),var(--fg) 4%);
  --focus: #315f68;
  --overlay: rgba(251,250,247,0.95);
  background: var(--bg);
  color: var(--fg);
  font-family: ui-serif,"Songti SC",STSong,"Noto Serif CJK SC","Noto Serif CJK TC",serif;
  overflow: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

html:has(body[data-site-route="/hanzi/"]),
body[data-site-route="/hanzi/"] {
  height: 100%;
  margin: 0;
  min-height: 100%;
}

body[data-site-route="/hanzi/"] * {
  box-sizing: border-box;
}

hanzi-matrix .hanzi-stage {
  display: grid;
  place-items: center;
  padding: clamp(3px,0.5vw,8px);
}

hanzi-matrix .matrix {
  aspect-ratio: 1.4;
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(70,minmax(0,1fr));
  grid-template-rows: repeat(50,minmax(0,1fr));
  max-height: 100%;
  max-width: 100%;
  padding: 0;
  width: min(100%, calc(100cqh * 1.4));
}

hanzi-matrix .cell {
  align-items: center;
  background: var(--cell);
  border: 0;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  font-family: inherit;
  font-size: clamp(5px,min(1.15cqw,1.35cqh),14px);
  height: 100%;
  justify-content: center;
  line-height: 1;
  min-width: 0;
  padding: 0;
  width: 100%;
}

hanzi-matrix .cell:hover {
  background: var(--cell-hover);
}

hanzi-matrix .cell.selected {
  box-shadow: inset 0 0 0 2px var(--focus);
  position: relative;
  z-index: 1;
}

hanzi-matrix .detail {
  align-items: center;
  backdrop-filter: blur(10px);
  background: var(--overlay);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 16px;
  position: fixed;
  z-index: 10;
}

hanzi-matrix .detail[hidden] {
  display: none;
}

hanzi-matrix .detail-card {
  display: grid;
  gap: clamp(14px,3vw,24px);
  justify-items: center;
  max-width: min(720px,100%);
  position: relative;
  width: 100%;
}

hanzi-matrix .detail-close {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  color: var(--muted);
  cursor: pointer;
  font: 600 12px/16px var(--mono);
  padding: 7px 10px;
  position: fixed;
  right: var(--canvas-edge);
  top: var(--canvas-edge);
}

hanzi-matrix .detail-close:hover {
  background: var(--surface-soft);
  border-color: var(--fg);
  color: var(--fg);
}

hanzi-matrix .pinyin {
  color: var(--muted);
  font: 22px/1.2 ui-sans-serif,system-ui,sans-serif;
  min-height: 28px;
  text-align: center;
}

hanzi-matrix .middle {
  align-items: center;
  display: grid;
  gap: clamp(12px,3vw,28px);
  grid-template-columns: 44px minmax(0,1fr);
  justify-items: center;
  width: min(460px,100%);
}

hanzi-matrix .zhuyin {
  color: var(--muted);
  font-size: 26px;
  line-height: 1.15;
  min-height: 160px;
  writing-mode: vertical-rl;
}

hanzi-matrix .big-char {
  font-size: clamp(150px,42vw,340px);
  line-height: 0.95;
  min-width: 0;
  text-align: center;
}

hanzi-matrix .english {
  color: var(--fg);
  font: 20px/1.45 ui-sans-serif,system-ui,sans-serif;
  max-width: 52ch;
  min-height: 30px;
  text-align: center;
}

@media (max-width:640px) {
  hanzi-matrix .hanzi-stage {
    place-items: start;
  }

  hanzi-matrix .matrix {
    max-height: none;
    max-width: none;
    width: 840px;
  }
}

@media (prefers-color-scheme:dark) {
  body[data-site-route="/hanzi/"] {
    --bg: #111210;
    --fg: #f1f0ea;
    --surface: #171815;
    --muted: #aaa79f;
    --cell: #171815;
    --cell-hover: color-mix(in oklab,var(--surface),var(--fg) 8%);
    --focus: #8ebbc2;
    --overlay: rgba(17,18,16,0.96);
  }
}
