/* Stroke Tops look: a red-tracing practice book (描紅簿).
   Cream paper, red 田字格, pencil characters and teacher-red marks.
   Fonts: Klee One (board characters) and Hanken Grotesk (everything else), both SIL OFL, subsets in docs/fonts. */
@font-face { font-family: "Klee One"; src: url("fonts/KleeOne-SemiBold-subset.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("fonts/HankenGrotesk-subset.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  --st-page: #F3EEDC;
  --st-label: #FBF8EE;
  --st-ink: #1D1B18;
  --st-red: #E0574F;
  --st-grid: #D66A62;
  --st-maple: #DED6C6;
  --pl-font: "Hanken Grotesk", system-ui, "PingFang TC", "Noto Sans TC", sans-serif;
  --pl-topbar-bg: #F3EEDC;
  --pl-topbar-text: #1D1B18;
  --pl-control-text: #1D1B18;
  --pl-control-bg: #FBF8EE;
  --pl-control-border: #1D1B18;
  --pl-focus: #1D1B18;
  --pl-overlay: rgb(29 27 24 / .5);
  --pl-card-bg: #FBF8EE;
  --pl-card-text: #1D1B18;
  --pl-card-muted: #2E2B26;
  --pl-card-border: #1D1B18;
  --pl-primary: #1D1B18;
  --pl-primary-text: #FBF8EE;
  --pl-shadow: rgb(29 27 24 / .25);
  --pl-share-bg: #FBF8EE;
  --pl-radius-control: 4px;
  --pl-radius-card: 3px;
  --pl-radius-picture: 2px;
  font-family: var(--pl-font);
  background: var(--st-page);
  color: var(--st-ink);
}

body {
  background-color: var(--st-page);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .37 0 0 0 0 .2 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23f)' opacity='.09'/%3E%3C/svg%3E");
}

/* the top bar sits on the page like a ruled header line */
[data-pl="topbar"] { box-shadow: 0 1px 0 rgb(29 27 24 / .55), 0 3px 0 rgb(224 87 79 / .0); }
[data-pl="back"] { font-weight: 700; letter-spacing: .01em; }
[data-pl="back"] { display: inline-flex; align-items: center; gap: 6px; }
[data-pl="back"] img { flex: 0 0 auto; }
.pl-topbar__actions button { font-weight: 700; color: var(--st-ink); }

.shell { padding-top: calc(64px + env(safe-area-inset-top)); }
#play-screen { padding-top: 4px; }
.level-row { padding: 0 2px; }
.level-name { font: 700 17px/1.2 var(--pl-font); letter-spacing: .005em; }
.move-count { font: 600 14px/1 var(--pl-font); color: var(--st-ink); font-variant-numeric: tabular-nums; }
.instruction:empty { display: none; }

/* the board is the page itself: no card, full width */
.board-shell {
  width: calc(100% + 24px);
  margin: 4px -12px 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible;
}
#board:focus-visible { outline: 3px solid var(--st-ink); outline-offset: -3px; }
#hand-demo, #success-effect { display: none !important; }

.message { min-height: 1.3em; margin: 6px 4px 2px; text-align: center; color: #4A463E; font-size: 14px; }
.message.refused { color: #8E2F28; }

/* buttons: paper, a 2 px ink outline and a hard ink shadow that goes when pressed */
button {
  border: 2px solid var(--st-ink); border-radius: 4px; background: var(--st-label); color: var(--st-ink);
  box-shadow: 2px 2px 0 var(--st-ink);
  font-family: var(--pl-font); font-weight: 700; font-variant-numeric: tabular-nums;
}
button:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.pl-topbar__actions button, [data-pl="back"] { box-shadow: none; }
.pl-topbar__actions button:active { transform: none; }
.primary-button { background: var(--st-ink); color: var(--st-label); border-color: var(--st-ink); box-shadow: 2px 2px 0 #6E675A; }
.primary-button:active { transform: translate(2px, 2px); box-shadow: none; }
.pl-howto-footer button { border-width: 2px; box-shadow: 2px 2px 0 var(--st-ink); }
.pl-howto-footer .pl-howto-start { box-shadow: 2px 2px 0 #6E675A; }
.controls { padding: 2px 0 8px; }
.controls button { min-width: 108px; }

/* the result: a slip tucked under the board; the teacher's marks are on the board itself */
#play-screen:has(#result-screen:not([hidden])) .controls { display: none; }
#play-screen:has(#result-screen:not([hidden])) .message { display: none; }
.result-card {
  margin: 6px 0 12px; padding: 12px 14px 14px;
  border: 0; border-top: 2px solid var(--st-ink); border-radius: 0; background: transparent; text-align: center;
  animation: st-slip .35s ease-out both;
}
@keyframes st-slip { from { opacity: .2; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.result-title { font: 700 22px/1.15 var(--pl-font); color: var(--st-ink); }
.result-marks { margin: 4px 0 4px; font: 600 15px/1.2 var(--pl-font); font-variant-numeric: tabular-nums; }
.share-line { margin: 0 auto 12px; font-size: 13px; color: #57524A; }
.result-actions { gap: 10px; }
.result-card.st-open #again-button { order: -1; background: var(--st-ink); color: var(--st-label); box-shadow: 2px 2px 0 #6E675A; }
.result-card.st-open #next-button { background: var(--st-label); color: var(--st-ink); box-shadow: 2px 2px 0 var(--st-ink); }

/* level list: copybook squares */
.map-heading h1 { font: 700 30px/1.1 var(--pl-font); letter-spacing: 0; }
#map-screen .eyebrow { color: #57524A; }
.level-map { gap: 10px; }
.level-tile { min-height: 72px; border-radius: 2px; background: var(--st-label); box-shadow: 2px 2px 0 var(--st-ink); }
.level-tile strong { font-size: 15px; }
.level-tile.complete { border-color: var(--st-ink); background: #FBF8EE; position: relative; }
.level-tile.complete::after {
  content: ""; position: absolute; right: 8px; top: 8px; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--st-red); border-radius: 48% 52% 50% 46%; transform: rotate(-12deg);
}

.sheet-extra { margin: 23px 2px 0; padding-top: 13px; border-top: 1px dashed rgb(201 62 56 / .55); }
.sheet-extra h2 { margin: 0; font: 700 19px/1.2 var(--pl-font); }
.sheet-extra > p { margin: 4px 0 10px; color: #625C53; font-size: 14px; }
.daily-sheets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.daily-sheet { min-width: 0; padding: 8px 4px; font-size: 14px; }
.learned-characters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.character-card { min-height: 58px; padding: 7px; border: 1px solid var(--st-ink); background: var(--st-label); box-shadow: 2px 2px 0 rgb(29 27 24 / .22); }
.character-card strong { display: inline-block; width: 30px; color: var(--st-red); font: 600 28px/1 "Klee One", serif; vertical-align: middle; }
.character-card span { display: inline-block; max-width: calc(100% - 35px); color: #625C53; font-size: 11px; line-height: 1.35; vertical-align: middle; }
.learned-empty { grid-column: 1 / -1; margin: 0; color: #625C53; font-size: 14px; }
html[lang="zh-Hant"] [data-pl="howto-lines"], html[lang="zh-Hant"] .level-tile small, html[lang="zh-Hant"] .share-line,
html[lang="zh-Hant"] .instruction, html[lang="zh-Hant"] .message { font-weight: 400; }
html[lang="zh-Hant"] .level-name, html[lang="zh-Hant"] .result-title, html[lang="zh-Hant"] .level-tile strong { font-weight: 600; }

/* How to play: a page from the practice book */
[data-pl="howto-card"] { padding: 18px 18px 16px; box-shadow: 4px 4px 0 var(--st-ink); border-width: 2px; }
[data-pl="howto-card"] h2 { font: 700 23px/1.1 var(--pl-font); margin-bottom: 12px; }
[data-pl="howto-pictures"] { gap: 6px; }
[data-pl="howto-pictures"] canvas { width: min(calc((100vw - 88px) / 3), 122px); min-width: 0; min-height: 0; border: 1px solid rgb(29 27 24 / .35); }
[data-pl="howto-lines"] { color: var(--st-ink); font-weight: 600; font-size: 15px; line-height: 1.35; padding-left: 22px; }
[data-pl="howto-lines"] li::marker { font-weight: 700; }

@media (max-width: 380px) {
  .shell { padding-left: 8px; padding-right: 8px; }
  .board-shell { width: calc(100% + 16px); margin: 4px -8px 0; }
  .controls button { min-width: 96px; }
}
@media (min-width: 700px) { .shell { background: rgb(251 248 238 / .5); } }
