/* Sam and Tim reading app.
   Layout: one full-screen page; the child's work fills the middle, a thin strip
   along the bottom belongs to the parent. Black ink on white, no grays that carry
   meaning, because the Daylight screen is grayscale. */
:root {
  --paper: #ffffff;
  --ink: #000000;
  --faint: #c9c9c9;      /* only for the letter a child traces over */
  --rule: 3px;
  --serif: "Noto Serif", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --u: min(1vw, 1.3333vh); /* one unit of a 4:3 screen */
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 18px; line-height: 1.4;
  overscroll-behavior: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
}
#app { height: 100%; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

button, .btn {
  font: inherit; color: var(--ink); background: var(--paper);
  border: var(--rule) solid var(--ink); border-radius: 8px;
  padding: 0.55em 1.1em; min-height: 56px; min-width: 56px; cursor: pointer;
}
button.solid { background: var(--ink); color: var(--paper); }
button:disabled { border-style: dashed; opacity: 1; cursor: default; }
button:focus-visible, .tile:focus-visible, .box:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
button:active { transform: translateY(1px); }

/* ---------- home ---------- */
.home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(3 * var(--u)); padding: 24px; text-align: center; }
.home h1 { font-size: calc(6 * var(--u)); font-weight: 400; margin: 0; letter-spacing: 0.02em; }
.home .where { font-size: calc(2.2 * var(--u)); margin: 0; }
.home .where b { font-size: 1.6em; font-weight: 400; padding: 0 0.15em; }
.begin { font-size: calc(4.2 * var(--u)); padding: 0.5em 1.6em; border-width: 4px; border-radius: 14px; }
.today { display: flex; gap: calc(1.4 * var(--u)); align-items: center; }
.today i, .dots i { display: block; width: calc(2 * var(--u)); height: calc(2 * var(--u)); border: var(--rule) solid var(--ink); border-radius: 50%; }
.today i.on, .dots i.on { background: var(--ink); }
.home .note { font-size: 15px; max-width: 34em; margin: 0; }

/* the parents' mark in the corner: press and hold */
.mark { position: fixed; top: 10px; right: 10px; width: 52px; height: 52px; min-height: 0; min-width: 0; padding: 0;
  border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); z-index: 5; touch-action: none; }
.mark::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--ink); transform: scale(0.25); }
.mark.holding::after { transform: scale(1); transition: transform 1.2s linear; }

/* ---------- a session ---------- */
.stage { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dots { display: flex; gap: 8px; padding: 14px 76px 0 16px; flex-wrap: wrap; min-height: 34px; }
.dots i { width: 12px; height: 12px; border-width: 2px; }
.work { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(3.5 * var(--u)); padding: 8px 16px; position: relative; }

.strip { border-top: var(--rule) solid var(--ink); display: flex; align-items: center; gap: 14px; padding: 10px 16px; min-height: 84px; }
.strip .cue { flex: 1; min-width: 0; font-size: 17px; line-height: 1.3; font-style: italic; }
.strip .cue b { font-style: normal; }
.strip .acts { display: flex; gap: 12px; flex-shrink: 0; }
.strip button { font-size: 18px; white-space: nowrap; }

.letter { font-size: calc(46 * var(--u)); line-height: 0.9; height: 1em; display: flex; align-items: center; justify-content: center; }
.speaker { width: calc(11 * var(--u)); height: calc(11 * var(--u)); min-width: 72px; min-height: 72px; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center; }
.speaker svg { width: 55%; height: 55%; }

.row { display: flex; gap: calc(2.6 * var(--u)); justify-content: center; align-items: center; flex-wrap: wrap; }
.tile, .box {
  width: calc(17 * var(--u)); height: calc(17 * var(--u)); min-width: 76px; min-height: 76px;
  font-family: var(--serif); font-size: calc(11.5 * var(--u)); line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0 0 0.12em;
  background: var(--paper); color: var(--ink);
}
.tile { border: var(--rule) solid var(--ink); border-radius: 12px; }
.tile.big { width: calc(21 * var(--u)); height: calc(21 * var(--u)); font-size: calc(14.5 * var(--u)); }
.tile.used { visibility: hidden; }
.tile.wrong { border-style: dashed; position: relative; }
.tile.wrong::after { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; border-top: var(--rule) solid var(--ink); transform: rotate(-20deg); }
.tile.hint, .box.hint { border-width: 8px; }
.tile.right { background: var(--ink); color: var(--paper); }
.box { border: none; border-bottom: 6px solid var(--ink); border-radius: 0; }
.box.empty { border: var(--rule) dashed var(--ink); border-radius: 12px; }
.box.sel { border: 6px solid var(--ink); border-radius: 12px; }
.boxes.done .box { border-bottom-width: 6px; }

/* blending */
.blendwrap { display: inline-flex; flex-direction: column; align-items: stretch; gap: calc(1.5 * var(--u)); max-width: 100%; }
.word { display: flex; justify-content: center; font-size: calc(30 * var(--u)); line-height: 1; }
.word span { padding: 0 0.03em 0.08em; border-bottom: 8px solid transparent; }
.word span.on { border-bottom-color: var(--ink); }
.track { position: relative; height: calc(9 * var(--u)); min-height: 64px; touch-action: none; }
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: var(--rule) solid var(--ink); }
.track::after { content: ""; position: absolute; right: -2px; top: 50%; width: 22px; height: 22px; border-top: var(--rule) solid var(--ink); border-right: var(--rule) solid var(--ink); transform: translateY(-50%) rotate(45deg); transform-origin: center; margin-top: 1px; }
.knob { position: absolute; top: 50%; left: 0; width: calc(8 * var(--u)); height: calc(8 * var(--u)); min-width: 56px; min-height: 56px; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); }

/* tracing */
.tracebox { position: relative; width: min(100%, calc(70 * var(--u))); flex: 1; min-height: 0; max-height: calc(58 * var(--u)); border: var(--rule) solid var(--ink); border-radius: 12px; overflow: hidden; }
.tracebox .ghost { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: calc(44 * var(--u)); line-height: 1; color: var(--faint); }
.tracebox canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

/* end of session */
.end { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(3 * var(--u)); text-align: center; padding: 24px; }
.end h2 { font-size: calc(7 * var(--u)); font-weight: 400; margin: 0; }
.end p { margin: 0; font-size: 18px; font-style: italic; max-width: 32em; }

/* ---------- parents' pages ---------- */
.parent { flex: 1; overflow: auto; -webkit-user-select: text; user-select: text; padding: 18px max(18px, env(safe-area-inset-right)) 40px max(18px, env(safe-area-inset-left)); }
.parent .top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.parent h2 { font-size: 26px; font-weight: 400; margin: 0 auto 0 0; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs button { min-height: 48px; padding: 0.3em 0.9em; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.parent h3 { font-size: 20px; font-weight: 700; margin: 22px 0 8px; }
.parent p { max-width: 44em; margin: 8px 0; }
.parent table { border-collapse: collapse; width: 100%; max-width: 860px; font-variant-numeric: tabular-nums; }
.parent th, .parent td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--ink); vertical-align: middle; }
.parent th { font-weight: 700; border-bottom-width: 2px; }
.parent td.big { font-size: 28px; line-height: 1; }
.tablewrap { overflow-x: auto; }
.clip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--ink); max-width: 860px; }
.clip .name { font-size: 34px; width: 2.6em; line-height: 1; }
.clip .tip { flex: 1; min-width: 12em; font-size: 15px; }
.clip button, .clip .btn { min-height: 48px; padding: 0.3em 0.8em; font-size: 16px; display: inline-flex; align-items: center; }
.clip input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.clip .has { font-size: 14px; width: 6.5em; }
.form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; max-width: 620px; align-items: center; }
.form label { min-width: 0; }
.form small { display: block; font-size: 13px; }
.parent input[type=password], .parent .btnrow input[type=text] { font: inherit; width: min(100%, 18em); padding: 10px; border: 2px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); }
.form input[type=number], .form input[type=text], .form select { font: inherit; width: 7.5em; padding: 8px; border: 2px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); }
.form input[type=text] { width: 12em; }
.form input[type=checkbox] { width: 28px; height: 28px; accent-color: #000; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.status { border: 2px solid var(--ink); border-radius: 8px; padding: 10px 14px; max-width: 44em; margin: 10px 0; }
textarea.dump { width: 100%; max-width: 860px; height: 180px; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; border: 2px solid var(--ink); border-radius: 6px; padding: 8px; }

@media (prefers-reduced-motion: reduce) { .mark.holding::after { transition: none; } }
@media (max-width: 560px) {
  .strip { flex-wrap: wrap; }
  .strip .cue { flex-basis: 100%; }
}
