/* Two Trees Chinese. A picture book: the first screen is sky and a hill, the lessons are on white. Leaf green, one orange button. Each character sits on a white tile. */
@font-face { font-family: 'WenKai'; src: url(fonts/wenkai.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url(fonts/fredoka.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(fonts/nunito.woff2) format('woff2'); font-weight: 200 1000; font-display: swap; }

:root {
  --paper: #f1f8ee;
  --card: #ffffff;
  --ink: #22332b;
  --soft: #4d5c53;
  --line: #d3e2cf;
  --green: #2e9b5e;
  --green-deep: #1e7a47;
  --orange: #c4500c;
  --sky: #cfebf7;
  --hill: #9ed98f;
  --sun: #ffd45c;
  --stone: #e8efe5;
  --stone-ink: #586556;
  --wrong: #b3261e;
  --col: 70rem;
  --gap: clamp(1rem, 4vw, 2rem);
  --edge: max(var(--gap), (100vw - var(--col)) / 2); /* from the column to the side of the window */
  --body: 'Nunito', system-ui, sans-serif;
  --display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --zi: 'WenKai', 'Kaiti SC', 'KaiTi', serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--card); color-scheme: light; scrollbar-color: var(--green) var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--card); color: var(--ink); font: 500 1.125rem/1.55 var(--body); -webkit-text-size-adjust: 100%; }
::selection { background: var(--sun); color: var(--ink); }
:focus-visible { outline: 3px solid var(--green-deep); outline-offset: 3px; border-radius: 8px; }
a { color: var(--green-deep); text-underline-offset: .2em; }
button { font: inherit; color: inherit; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ico { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.top, main, .foot { width: min(100% - 2 * var(--gap), var(--col)); margin-inline: auto; }
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem 1rem; padding-block: .75rem; border-image: conic-gradient(var(--sky) 0 0) fill 0 / 0 / 0 100vmax; }
.brand { display: inline-flex; align-items: center; gap: .6rem; min-height: 44px; font: 600 1.3rem var(--display); color: var(--ink); text-decoration: none; }
.brand svg { height: 2.4rem; width: auto; }
.brand .big { color: var(--green-deep); }
.brand .small { color: #e39a12; }
/* On a phone the note always has its own line. If it wrapped only when it did not fit, the wider fallback font would wrap it and the web font would pull it back up: the page jumps. */
.series { flex-basis: 100%; color: var(--soft); font-size: 1rem; }
@media (min-width: 30rem) { .series { flex-basis: auto; } }

h1 { margin: 0; font: 600 clamp(2.1rem, 5.6vw, 3.4rem)/1.1 var(--display); letter-spacing: -.01em; }
h1 span { display: block; }
h1 em { font-style: normal; color: var(--green-deep); }
h2 { margin: 0 0 .3rem; font: 600 clamp(1.6rem, 4vw, 2.2rem)/1.2 var(--display); }
h3 { margin: 2.5rem 0 1rem; font: 600 1.3rem var(--display); color: var(--green-deep); }

/* Hero: the first lesson as a picture. One tree, two trees, three trees, on a hill under the sky, edge to edge. */
.intro {
  --foot: clamp(2.5rem, 6vw, 4rem);
  position: relative; isolation: isolate; display: grid; gap: 2rem; align-items: center; padding-block: clamp(1rem, 4vw, 2.5rem) var(--foot);
  border-image: linear-gradient(var(--sky) 0 calc(100% - 2.5rem), var(--hill) 0) fill 0 / 0 / 0 100vmax;
}
@media (min-width: 56rem) { .intro { grid-template-columns: 1fr 1.05fr; gap: 3.5rem; } .scene::after { left: -3.5rem; right: calc(-1 * min(3.5rem, var(--edge))); } }
.lead { margin: 1.1rem 0 1.6rem; max-width: 34ch; color: var(--soft); font-size: 1.2rem; }
.cta {
  display: inline-flex; align-items: center; min-height: 3.5rem; padding: .6rem 1.8rem; border-radius: 999px;
  background: var(--orange); color: #fff; font: 600 1.25rem var(--display); text-decoration: none;
  box-shadow: 0 5px 0 #8f3a08; transition: transform .1s, box-shadow .1s;
}
.cta:hover { transform: translateY(2px); box-shadow: 0 3px 0 #8f3a08; }
.cta:active { transform: translateY(5px); box-shadow: none; }
.sub { display: block; margin-top: 1rem; color: var(--soft); font-size: 1rem; }

.scene {
  position: relative; margin: 0; padding: 1.6rem 0 0;
  display: grid; grid-template-columns: repeat(4, max-content); justify-content: center; align-items: center; gap: .9rem .6rem;
}
.scene::before { content: ''; position: absolute; z-index: -1; right: 8%; top: -2.4rem; width: 3.6rem; height: 3.6rem; border-radius: 50%; background: var(--sun); }
.scene::after { content: ''; position: absolute; z-index: -1; inset: -.4rem calc(-1 * var(--edge)) calc(-1 * var(--foot)); border-radius: 50% 50% 0 0 / 100% 100% 0 0; background: var(--hill); }
.eq { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center; position: relative; }
.pics { display: flex; justify-content: flex-end; align-items: flex-end; color: var(--green-deep); }
.pics svg { height: 3.6rem; width: auto; margin-left: -.7rem; }
.pics svg:first-child { margin-left: 0; }
.arrow { width: 1.5rem; height: 1.5rem; fill: none; stroke: var(--green-deep); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tile { display: grid; place-items: center; width: 4.4rem; height: 4.4rem; border-radius: 18px; background: var(--card); font: 3rem/1 var(--zi); box-shadow: 0 5px 14px rgb(30 80 50 / .16); }
.say { display: grid; line-height: 1.25; }
.say b { font: 600 1.3rem var(--display); }
.say span { color: #145233; font-weight: 700; } /* 5.6:1 on the hill, 7.4:1 on the sky */
@media (min-width: 30rem) {
  .scene { padding-top: 2.4rem; gap: 1.1rem .9rem; }
  .scene::before { top: -3rem; width: 4.6rem; height: 4.6rem; }
  .pics svg { height: 5.4rem; margin-left: -1rem; }
  .tile { width: 6rem; height: 6rem; font-size: 4.2rem; }
  .say b { font-size: 1.45rem; }
}

/* A character tile. On the route it is a round stone. */
.box { display: inline-grid; place-items: center; flex: none; width: var(--s, 4.5rem); height: var(--s, 4.5rem); border-radius: 18px; background: var(--card); border: 2px solid var(--line); color: var(--ink); font: calc(var(--s, 4.5rem) * .66)/1 var(--zi); }
.box.small { --s: 2.75rem; border-radius: 12px; }

/* Route: twelve stones. Dashed = not out yet. White with a green ring = open. Green = all three questions right. */
.map { margin-top: clamp(2rem, 5vw, 3.5rem); }
.map > p { margin: 0 0 1.5rem; color: var(--soft); }
/* min-height: the room the twelve stones take (4 rows of 3, or 2 rows of 6), held before course.json arrives so the text below does not jump. */
#route { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem .5rem; min-height: 41rem; align-content: start; }
@media (min-width: 40rem) { #route { grid-template-columns: repeat(6, 1fr); gap: 1.75rem 1rem; min-height: 19.75rem; } }
.stop button { display: grid; justify-items: center; gap: .1rem; width: 100%; min-height: 44px; padding: .6rem .25rem; background: none; border: 0; border-radius: 18px; text-align: center; line-height: 1.3; transition: background-color .15s; }
.stop button:hover, .stop button[aria-expanded="true"] { background: #e3f4e6; }
.stop .box { --s: 4.6rem; margin-bottom: .45rem; border-radius: 50%; transition: background-color .3s, color .3s, box-shadow .3s; }
.stop.is-open .box { border: 0; box-shadow: inset 0 0 0 3px var(--green), 0 5px 0 var(--green-deep); }
.stop.is-locked .box { background: var(--stone); border: 2px dashed #b4c6af; color: var(--stone-ink); }
.stop .num { font: 600 1.05rem var(--display); }
.stop .name, .stop .when { font-size: 1rem; color: var(--soft); }
.stop.is-locked .num { color: var(--soft); font-weight: 500; }
.stop .done { display: none; align-items: center; gap: .25rem; font-size: 1rem; font-weight: 700; color: var(--green-deep); }
.stop.is-lit .box { background: var(--green-deep); color: #fff; box-shadow: 0 5px 0 #14572f; }
.stop.is-lit .done { display: inline-flex; }
@media (prefers-reduced-motion: no-preference) {
  .stop.is-lit .box { animation: light .7s ease-out; }
  @keyframes light { 0% { transform: scale(1); } 40% { transform: scale(1.16) rotate(-4deg); } 100% { transform: scale(1); } }
}
#progress-note { margin: 1.5rem 0 0; font-size: 1rem; color: var(--soft); }
.plain { color: var(--soft); grid-column: 1 / -1; }

/* The open lesson: one white card. */
#stop { margin-top: clamp(2rem, 6vw, 3rem); padding: clamp(1.25rem, 4vw, 2.5rem); background: var(--card); border: 1px solid var(--line); border-radius: 28px; scroll-margin-top: 1rem; }
#stop:focus { outline: none; }
#stop h2 { margin-bottom: 1.5rem; }
.cols { display: grid; gap: 2.5rem; }
@media (min-width: 56rem) { .cols { grid-template-columns: minmax(0, 1fr) 20rem; gap: 4rem; align-items: start; } }
#stop .box { background: var(--paper); }

.family { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: max-content max-content minmax(5.5rem, 1fr); gap: 1rem .75rem; }
.family li { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: end; }
.parts { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; padding-bottom: .85rem; }
.op { color: var(--soft); font-family: system-ui, sans-serif; }
@media (max-width: 30rem) { .family { column-gap: .5rem; } .parts { gap: .2rem; } .parts .box.small { --s: 2.25rem; } }
.word { grid-column: 2; display: grid; justify-items: center; gap: .15rem; }
.py { color: var(--green-deep); font-size: 1.125rem; font-weight: 700; line-height: 1.2; }
.en { grid-column: 3; padding-bottom: 1.2rem; font: 600 1.3rem var(--display); }

/* Stroke order: the picked character is drawn in a practice square. */
.draw { display: grid; grid-template-columns: minmax(0, 13rem) 1fr; gap: 0 1.25rem; align-items: start; }
.draw h3 { grid-column: 1 / -1; }
.stage {
  aspect-ratio: 1; border: 2px solid var(--green); border-radius: 18px; overflow: hidden;
  background:
    linear-gradient(to right, #bfe3c9 50%, transparent 0) 0 50% / 12px 2px repeat-x,
    linear-gradient(to bottom, #bfe3c9 50%, transparent 0) 50% 0 / 2px 12px repeat-y,
    var(--card);
}
.stage svg { display: block; width: 100%; height: 100%; }
.guide { fill: #dde6da; }
.ink { fill: none; stroke: var(--ink); stroke-width: 200; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 2; }
.draw[data-done] .guide { fill: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .ink { animation: ink .32s ease-out both; }
  @keyframes ink { from { stroke-dashoffset: 1; visibility: hidden; } }
}
.cap { margin: 0 0 .75rem; min-height: 1.55em; }
.pick { display: flex; flex-wrap: wrap; gap: .5rem; }
.pick button { --s: 3rem; width: 3rem; height: 3rem; padding: 0; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); font: 2rem/1 var(--zi); transition: border-color .15s; }
.pick button:hover { border-color: var(--green); }
.pick button[aria-pressed="true"] { border-color: var(--green-deep); background: #e3f4e6; }

.q { margin: 0 0 1.25rem; padding: 1rem; border: 2px solid var(--line); border-radius: 18px; min-width: 0; display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; }
.q legend { padding: 0 .4rem; font-size: 1rem; color: var(--soft); }
.opts { display: flex; flex-wrap: wrap; gap: .5rem; }
.opts button, .again, .sheet {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .4rem 1.1rem;
  background: var(--paper); border: 2px solid var(--line); border-radius: 999px; color: var(--ink); font-weight: 600; text-decoration: none;
  transition: border-color .15s, background-color .15s;
}
.opts button:hover:not(:disabled), .again:hover, .sheet:hover { border-color: var(--green); background: #e3f4e6; }
.opts button:disabled { cursor: default; color: var(--soft); background: none; }
.opts button.is-answer { border-color: var(--green-deep); background: #e3f4e6; color: var(--green-deep); }
.opts button.is-wrong { border-color: var(--wrong); background: #fdecea; color: var(--wrong); }
.fix { grid-column: 1 / -1; margin: 0; }
.result { margin: 0; min-height: 1.6em; font-weight: 700; }
.again { margin-top: .5rem; border-color: var(--green-deep); }

.video { margin: 0 0 1rem; aspect-ratio: 9 / 16; border-radius: 18px; overflow: hidden; background: var(--ink); position: relative; }
.video iframe, .video img { display: block; width: 100%; height: 100%; border: 0; object-fit: cover; }
.video figcaption { position: absolute; inset: auto 0 0; padding: .6rem .8rem; background: rgb(34 51 43 / .92); color: #fff; font-size: 1rem; }
.sheet { width: 100%; justify-content: center; border-color: var(--green-deep); color: var(--green-deep); }
@media (max-width: 55.99rem) { .watch { max-width: 20rem; } }

#stop.is-locked .when { margin: 0 0 1rem; max-width: 46ch; }
.soon { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; color: var(--soft); }

/* Footer: a pale green ground, edge to edge. Left: who and the licence. Right: credits. */
.foot { margin-top: clamp(3rem, 8vw, 5rem); padding-block: 2.5rem 3rem; display: grid; gap: 2rem; font-size: 1rem; color: var(--soft); border-image: conic-gradient(var(--paper) 0 0) fill 0 / 0 / 0 100vmax; }
@media (min-width: 56rem) { .foot { grid-template-columns: 1fr 1.05fr; gap: 3.5rem; } }
.foot p { margin: 0 0 1rem; max-width: 38ch; }
.foot .mark { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; font: 600 1.3rem var(--display); color: var(--ink); }
.foot .mark svg { height: 2.4rem; width: auto; }
.foot .mark .big { color: var(--green-deep); }
.foot .mark .small { color: #e39a12; }
.foot p a { display: inline-block; padding-block: .75rem; }
.yt { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; padding: .4rem 1.2rem; border: 2px solid var(--green-deep); border-radius: 999px; background: var(--card); color: var(--green-deep); font-weight: 700; text-decoration: none; transition: background-color .15s; }
.yt:hover { background: #e3f4e6; }
.yt .ico { fill: currentColor; stroke-width: 2; }
.foot h2 { margin: .5rem 0 .25rem; font: 600 1.3rem var(--display); color: var(--ink); }
.credits { list-style: none; margin: 0; padding: 0; }
.credits li { display: grid; padding: .6rem 0; border-top: 1px solid var(--line); }
.credits li:first-child { border-top: 0; }
.credits a { display: inline-block; padding-block: .65rem; }
@media (min-width: 30rem) { .credits li { grid-template-columns: 8rem 1fr; align-items: center; } }
