/* Telling time worksheets: a railway station clock. Paper white, navy ink, one signal red (the hub and the minute
   marks that matter), geometric headings like a platform sign. Clocks are the only drawn things; the rest stays flat. */
:root {
  --bg: #f6f4ee; --paper: #ffffff; --ink: #18212d; --muted: #4a5563; --line: #d9d6cc; --line2: #8a8f97;
  --accent: #1f3a5f; --accent-ink: #ffffff; --accent-soft: #e3e9f1; --red: #b3261e;
  --face: #ffffff; --hand: #18212d; --yours: #1f5f8f;
  --ok: #1b6b3a; --ok-soft: #e1f1e6; --bad: #a3261b; --bad-soft: #fbe4e1; --warn: #6b4d00; --warn-soft: #f6ecd0;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --head: "Futura", "Century Gothic", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d; --paper: #18202a; --ink: #e6ebf1; --muted: #b3bdc9; --line: #2c3643; --line2: #6e7a88;
    --accent: #9cc2ee; --accent-ink: #0d1824; --accent-soft: #1f2d3d; --red: #ff8a80;
    --face: #f4f2ec; --hand: #18212d; --yours: #1f5f8f;
    --ok: #86d5a2; --ok-soft: #15301f; --bad: #ff9b8f; --bad-soft: #3d1f1b; --warn: #efc46a; --warn-soft: #382e15;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 9; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; font-weight: 700; }

.hero { padding: 20px 0 4px; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); margin: 0 0 6px; }
.lede { margin: 0; max-width: 64ch; }

/* setup: four menus and New set */
.setup { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; margin: 14px 0 10px; }
.setup label { display: flex; flex-direction: column; gap: 2px; font-weight: 600; min-width: 0; max-width: 100%; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line2); border-radius: var(--r); }
select { min-height: 44px; padding: 6px 10px; max-width: 100%; min-width: 0; }
.setup .print-row { flex-basis: 100%; }
.setup .share-out { flex-basis: 100%; margin: 0; }
@media (max-width: 520px) { .setup label { flex: 1 1 140px; } .setup label.wide { flex-basis: 100%; } .setup select { width: 100%; } }
.btn { font: inherit; min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 6px 14px; }
.btn:hover { filter: brightness(0.96); }
.link { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 10px 4px; min-height: 44px; }
.note { margin: 8px 0; padding: 10px 12px; background: var(--warn-soft); border-radius: var(--r); overflow-wrap: anywhere; }
.note.info { background: var(--accent-soft); }

/* the set */
.sheet { background: var(--paper); border-top: 4px solid var(--accent); padding: 12px 18px 16px; margin: 6px 0 18px; }
@media (max-width: 480px) { .sheet { padding: 10px 12px 14px; margin-left: -8px; margin-right: -8px; } }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.sheet-head h2 { margin: 0; font-size: 1.3rem; }
.code { font-family: var(--mono); letter-spacing: 0.06em; }
.lvname { font-family: var(--sans); font-weight: 500; color: var(--muted); font-size: 1rem; }
.score { margin: 0; color: var(--muted); }
details.rules summary, details.work summary, details.recent summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
details.rules ul { margin: 4px 0 10px; padding-left: 20px; max-width: 78ch; }
details.rules li { margin: 0 0 6px; }

.qs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .qs { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; } }
/* one clock: the face on the left, the instruction (and words) beside it, the answer row under both */
.q { display: grid; grid-template-columns: 128px minmax(0, 1fr); grid-template-areas: "face lab" "face words" "ans ans" "fb fb" "work work";
  gap: 4px 14px; padding: 14px 0 10px; border-top: 1px solid var(--line); align-content: start; }
@media (min-width: 400px) { .q { grid-template-columns: 148px minmax(0, 1fr); } }
@media (min-width: 1000px) { .q { grid-template-columns: 168px minmax(0, 1fr); } }
.side { display: contents; }
.face { grid-area: face; align-self: start; }
.face svg { display: block; width: 100%; height: auto; }
.qlab { grid-area: lab; font-weight: 600; align-self: end; }
.qn { font-family: var(--mono); color: var(--red); font-weight: 800; margin-right: 4px; }
.qn::after { content: "."; }
.words { grid-area: words; margin: 0; font-size: 1.15rem; font-family: var(--head); align-self: start; }
.arow { grid-area: ans; display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.cw { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; }
.cell { width: 100%; min-height: 44px; padding: 8px 10px; }
.cell.short { max-width: 10em; }
.cell.is-right { border-color: var(--ok); background: var(--ok-soft); }
.cell.is-close { border-color: var(--warn); background: var(--warn-soft); }
.cell.is-wrong, .cell.is-unread { border-color: var(--bad); background: var(--bad-soft); }
.mk { flex: 0 0 1.4em; font-weight: 800; text-align: center; }
.mk-right { color: var(--ok); } .mk-close { color: var(--warn); } .mk-wrong, .mk-unread { color: var(--bad); }
.cellfb { grid-area: fb; }
.fb { margin: 6px 0 0; }
.fb.right b { color: var(--ok); } .fb.close b { color: var(--warn); } .fb.wrong b, .fb.unread b { color: var(--bad); }
details.work { grid-area: work; }
.keyfig { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 8px; }
.kfig { flex: 0 0 72px; } .kfig svg { width: 72px; height: 72px; display: block; }
.kforms { margin: 0; padding-left: 18px; color: var(--muted); } .kforms li { margin: 0 0 4px; }
.kforms .kmain { color: var(--ink); font-weight: 700; }
.tag { color: var(--muted); } .koff, .kday { color: var(--muted); }
.ktime { margin: 0; font-size: 1.2rem; }

/* clock faces */
.clock .face { fill: var(--face); stroke: var(--hand); stroke-width: 3; }
.clock .tk { stroke: var(--hand); stroke-width: 1.4; }
.clock .tk5 { stroke: var(--hand); stroke-width: 3.2; }
.clock .nums { font: 700 20px var(--head); fill: var(--hand); text-anchor: middle; }
.clock .hh { stroke: var(--hand); stroke-width: 8; stroke-linecap: round; }
.clock .mh { stroke: var(--hand); stroke-width: 5; stroke-linecap: round; }
.clock .hub { fill: #b3261e; }
.clock.yours .hh, .clock.yours .mh { stroke: var(--yours); }
.digital .dface { fill: var(--face); stroke: var(--hand); stroke-width: 3; }
.digital .dtext { font: 700 46px var(--mono); fill: var(--hand); text-anchor: middle; }
.digital .dbox { fill: none; stroke: var(--line2); stroke-width: 2; }
.digital .dyours { font: 600 34px var(--mono); fill: var(--yours); text-anchor: middle; }
.digital .dcolon { font: 700 40px var(--mono); fill: var(--hand); text-anchor: middle; }
.k-dw .face, .k-wc:not(.has-clock) .face { align-self: center; }

.sheet-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.confirm { flex-basis: 100%; margin: 0; }
.save-hint { flex-basis: 100%; margin: 0; color: var(--muted); }

.share { margin: 0 0 22px; }
.print-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.print-row label { display: flex; flex-direction: column; gap: 2px; font-weight: 600; min-width: 0; max-width: 100%; }
.share-out label { display: flex; flex-direction: column; font-weight: 600; }
.share-out input { min-height: 44px; padding: 6px 10px; width: 100%; }
.share-out p { margin: 4px 0 0; }
.recent ul { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 4px 0; }
.recent .when { display: block; color: var(--muted); }
.hint { color: var(--muted); }

.content { max-width: 72ch; padding-bottom: 20px; }
.content h2 { font-size: 1.45rem; margin: 28px 0 8px; }
.ex { padding-left: 20px; } .ex li { margin: 0 0 6px; }
.faq details { border-top: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 650; padding: 10px 0; min-height: 44px; }
.faq p { margin: 0 0 12px; }
.sources { color: var(--muted); overflow-wrap: anywhere; }

footer { border-top: 1px solid var(--line); padding: 14px 0 28px; color: var(--muted); }
.sb-footer p { margin: 6px 0; }
.sb-more { overflow-wrap: anywhere; }
.sb-footer a { color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: min(92vw, 560px); background: var(--ink); color: var(--bg);
  padding: 10px 14px; border-radius: var(--r); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
.toast.top { bottom: auto; top: 16px; }
.toast.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.print-root { display: none; }

/* ---------- paper ---------- */
@page { margin: 10mm; }
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  body > main, footer, .skip, .toast { display: none !important; }
  .print-root { display: block; }
  .print-root .clock .face, .print-root .digital .dface { fill: #fff; stroke: #000; }
  .print-root .clock .tk, .print-root .clock .tk5, .print-root .clock .hh, .print-root .clock .mh { stroke: #000; }
  .print-root .clock .nums, .print-root .digital .dtext, .print-root .digital .dcolon { fill: #000; }
  .print-root .digital .dbox { stroke: #555; }
  .print-root .clock .hub { fill: #000; }
  .psheet, .pkey { break-after: page; }
  .print-root > section:last-child { break-after: auto; }
  .ph h2 { font-size: 17pt; margin: 0 0 3mm; }
  .pmeta { display: flex; flex-wrap: wrap; gap: 2mm 10mm; margin: 0 0 1.5mm; font-size: 11pt; }
  .prun { margin: 0 0 3mm; font-size: 10pt; color: #333; }
  .prun.cont { border-bottom: 0.4pt solid #000; padding-bottom: 1.5mm; }
  .pgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; column-gap: 6mm; }
  .pitem { display: grid; grid-template-columns: 40mm minmax(0, 1fr); gap: 3mm; height: 46mm; padding: 2.5mm 0; border-top: 0.4pt solid #999; break-inside: avoid; }
  .pface svg.clock { width: 40mm; height: 40mm; display: block; }
  .pface svg.digital { width: 40mm; height: 16mm; display: block; margin-top: 10mm; }
  .pside { display: flex; flex-direction: column; min-width: 0; }
  .pq { margin: 0 0 1mm; font-size: 10.5pt; }
  .pwords { margin: 1mm 0 0; font-size: 13pt; font-weight: 600; }
  .pl { display: block; border-bottom: 0.5pt solid #000; height: 11mm; }
  .pkey .ph h2 { margin-bottom: 1mm; }
  .pksets { columns: 2; column-gap: 8mm; }
  .pkl li { break-inside: avoid; }
  .pkset { break-inside: avoid; margin: 0 0 3mm; }
  .pkset h3 { font-size: 10.5pt; margin: 0 0 1mm; padding-top: 1mm; border-top: 0.6pt solid #000; }
  .pkl { margin: 0; padding-left: 6mm; font-size: 10pt; line-height: 1.25; }
  .pkl li { margin: 0 0 0.6mm; }
  .pkq { color: #333; }
  .pkm { font-size: 10.5pt; }
  .pka { color: #333; }
  .prules { break-inside: avoid; margin: 0 0 3mm; padding: 1mm 0 2mm; border-top: 0.6pt solid #000; border-bottom: 0.6pt solid #000; font-size: 10pt; }
  .prules h3 { font-size: 11pt; margin: 2mm 0 1mm; }
  .prules ul { margin: 0; padding-left: 5mm; }
}
