@font-face {
  font-family: 'Museum Chalk';
  src: url('./fonts/museum-chalk.woff2') format('woff2');
  font-display: swap;
}

.mosaic-gate .scene-caption {
  border-color: #c9a572;
  background: #131d27eb;
  box-shadow: inset 0 0 0 3px #131d27, inset 0 0 0 4px #c9a5725e;
  padding: 12px 16px;
}
.mosaic-gate .scene-caption h1 { font-family: 'Museum Chalk', var(--serif); font-weight: 400; }
.mosaic-gate .scene-action { color: #ffdb9d; }
#app:has(> .chalk-lesson) { background: #141b1c; }

.lesson.chalk-lesson {
  --ink: #fff1d9;
  --muted: #d8d1bd;
  --gold: #ffd484;
  --line: #837e70;
  --slate: #242828;
  color-scheme: dark;
  width: min(calc(100% - 20px), 1470px);
  margin: 10px auto;
  padding: clamp(14px, 2.4vw, 34px);
  border: clamp(6px, 1.1vw, 15px) solid transparent;
  border-radius: 15px;
  background: radial-gradient(ellipse at 52% 8%, #ffffff0b, transparent 80%) padding-box,
    repeating-linear-gradient(153deg, #ffffff02 0 1px, transparent 1px 5px) padding-box,
    linear-gradient(var(--slate), #202323) padding-box,
    url('./media/chalk-mosaic.webp') center / cover border-box, #514339 border-box;
  box-shadow: 0 8px 24px #090a0a9c;
  color: var(--ink);
}
.lesson.chalk-lesson:not(.chalk-experiment) { padding-block-start: clamp(7px, 1.3vh, 13px); }
.chalk-lesson :is(.task h1, .chalk-question h1) {
  font-family: 'Museum Chalk', var(--serif);
  font-weight: 400;
  color: #fff1da;
  letter-spacing: 0;
}
.chalk-lesson .task h1 { font-size: 1.75rem; }
.chalk-lesson :is(.prompt,.task-clue,.ratio,.ratio .colon,.ratio-operation,strong,.model-tip,.legend span,.copy-counts dd,.equation,.stepper output,.rack-caption,.copy-counts dt) { color: var(--ink); }
.lesson.chalk-lesson .lesson-progress { color: var(--gold); }
#app[data-lesson-backdrop] .chalk-lesson :is(.diagram,.calculation,.interaction) { background: #1e2222; border-color: #817765; }
#app[data-lesson-backdrop] .chalk-lesson .model-tip { color: var(--muted); }
.chalk-lesson :is(.rack,.bundle,.drop-slot) { background: #2b302f; color: var(--ink); border-color: #8e8371; }
.chalk-lesson .bundle.lit { background: #38392f; border-color: #e1b879; }
.chalk-lesson .mark.gold { border-radius: 17%; }
.chalk-lesson .mark.blue { border-radius: 50%; }
.chalk-lesson .mark.ghost { border: 2px dashed #92bfdf; border-radius: 50%; }
.chalk-lesson :is(.options label,.entry input,.records,.secondary,.quiet,.clue-digits li) {
  background: #303635;
  color: var(--ink);
  border-color: #ab9c82;
}
.chalk-lesson .records :is(td,th) { background: #262c2b; color: var(--ink); border-color: #827767; }
.chalk-lesson :is(.options label:has(input:checked),button[aria-pressed="true"]) { background: #4e4435; color: #fff2dd; border-color: #e1b879; }
.chalk-lesson .primary { background: #f1cd92; color: #28221b; border-color: #f1cd92; box-shadow: none; }
.chalk-lesson .primary:hover { background: #ffe0ad; color: #28221b; }
.chalk-lesson .primary:disabled { opacity: .58; }
.chalk-lesson .success { background: #253e37; color: #e2ffe3; border-color: #9fc0a7; }
.chalk-lesson .feedback { color: #ffc49e; }
.chalk-lesson :is(button,input):focus-visible, .chalk-lesson .options label:focus-within { outline-color: #ffd484; }

.chalk-experiment { display: grid; gap: clamp(12px,2.1vh,24px); }
.chalk-question { text-align: center; }
.chalk-question h1 { font-size: clamp(1.65rem,2.6vw,2.2rem); line-height: 1.2; }
.chalk-question p { margin-top: .3rem; font-size: clamp(1rem,1.6vw,1.2rem); }
.chalk-models { --chalk-gap: clamp(10px,2vw,28px); display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: var(--chalk-gap); align-items: start; }
.chalk-models > section { display: grid; min-width: 0; gap: 8px; grid-template-rows: 3em auto; }
.chalk-original { grid-column: 1; }
.chalk-models h2 { font-size: clamp(1rem,1.85vw,1.3rem); font-weight: 650; }
.chalk-models h2 .ratio { color: var(--gold); margin-left: .2em; font: inherit; }
.chalk-result { grid-column: 2 / span 2; }
.chalk-changed { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--chalk-gap); align-items: start; }
.chalk-models .rack { container-type: inline-size; display: grid; grid-template-rows: 4.2em auto; min-width: 0; padding: 0; border: 0; background: transparent; }
.chalk-models .rack-caption { margin: 0; font-size: 1rem; line-height: 1.4; overflow-wrap: anywhere; }
.chalk-models .bundles { display: block; }
.chalk-models :is(.bundle,.chalk-empty) { border-radius: 10px; border: 1px dashed #c5bda8; background: #262929; }
#app .chalk-models .bundle { --chalk-pad: clamp(7px,1.35vw,20px); --chalk-mark-gap: clamp(3px,.65vw,9px); --chalk-tile: clamp(16px,calc((100cqw - 2 * var(--chalk-pad) - 4 * var(--chalk-mark-gap) - 2px) / 5),68px); display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: repeat(2,var(--chalk-tile)); width: 100%; min-height: auto; gap: clamp(6px,1.1vw,16px); padding: var(--chalk-pad); }
.chalk-experiment .chalk-models .rail { display: grid; width: 100%; grid-template-columns: repeat(5,var(--chalk-tile)); gap: var(--chalk-mark-gap); }
.chalk-models .rail .mark { width: var(--chalk-tile); height: var(--chalk-tile); aspect-ratio: 1; justify-self: start; align-self: start; }
.chalk-slot { position: relative; min-width: 0; }
.chalk-slot.is-empty .bundle { position: relative; }
.chalk-slot.is-empty .mark { visibility: hidden; }
.chalk-empty-label { position: absolute; inset: 4.2em 8px 0; display: grid; place-items: center; text-align: center; font-size: 1rem; line-height: 1.4; pointer-events: none; }
.chalk-models .chalk-empty { border-color: #898273; background: transparent; }
.chalk-models .chalk-copy-motion .rail { position: relative; z-index: 1; }
.chalk-feedback { display: grid; align-items: center; block-size: 9rem; min-block-size: 9rem; overflow: auto; overscroll-behavior: contain; }
.chalk-equation { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px 16px; text-align: center; }
.chalk-equation[hidden] { display: none; }
.chalk-equation > span:first-child { display: inline-flex; align-items: baseline; gap: .22em; white-space: nowrap; font: 400 clamp(2.15rem,5vw,4.25rem)/.85 'Museum Chalk',var(--serif); }
.chalk-equation .ratio { color: inherit; font: inherit; }
.chalk-written { animation: chalk-stroke 480ms ease-out both; }
.chalk-lesson [data-writing-pending] > * { visibility: hidden; }
@keyframes chalk-stroke { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
.chalk-controls { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: 8px; }
.chalk-controls button { min-width: 0; min-height: 44px; font-size: clamp(.95rem,1.6vw,1.15rem); overflow-wrap: anywhere; }
.gate-simulation .chalk-controls { grid-template-columns: 1fr 1fr auto auto; }
.gate-simulation .chalk-controls .quiet { border-style: dashed; }
.workbench-return { margin-block-start: 5px; }
.workbench-return .quiet { min-height: 44px; }
.open-museum .scene-caption .primary { margin-block-start: 8px; pointer-events: auto; }

@media (max-width: 700px) {
  .gate-simulation .chalk-controls { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .gate-simulation .chalk-controls .primary { grid-column: auto; }
}

@media (orientation: landscape) and (min-width: 620px) {
  .chalk-lesson:not(.chalk-experiment) .lesson-workspace { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); align-items: start; }
  .chalk-lesson .lesson-tools { grid-template-columns: minmax(0, 1fr); }
  .chalk-experiment { min-height: min(calc(100svh - 82px), 730px); grid-template-rows: auto 1fr auto auto; }
  .chalk-models { align-self: center; }
}
@media (orientation: landscape) and (min-width: 620px) and (max-height: 500px) {
  .lesson.chalk-experiment { margin-block: 4px; padding-block: 7px; gap: 6px; }
  .chalk-question h1 { font-size: 1.65rem; }
  .chalk-feedback { block-size: 7.5rem; min-block-size: 7.5rem; }
  .chalk-models { width: min(100%, 680px); justify-self: center; }
  #app .chalk-models .bundle { --chalk-tile: 26px; gap: 5px; padding-block: 5px; }
  .chalk-models .rail .mark { max-width: 26px; }
}
@media (max-width: 619px) and (orientation: portrait) {
  .chalk-models { grid-template-columns: minmax(0, 1fr); }
  .chalk-models > section:first-child { width: calc((100% - var(--chalk-gap)) / 2); }
  .chalk-original,.chalk-result { grid-column: 1; }
  .chalk-result { padding-block-start: 10px; border-block-start: 1px solid #aaa08d80; }
  .chalk-feedback { block-size: 12rem; min-block-size: 12rem; }
  .chalk-controls { grid-template-columns: repeat(2,minmax(0, 1fr)); }
  .chalk-controls .primary { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .chalk-written { animation: none; } }
html[data-reduced] .chalk-written { animation: none; }
