/* Matemaatika — step-by-step lessons (js/lesson-*.js, js/lessons-*.js) */

.lesson-ov .modal { width: min(520px, 100%); }
.lesson {
  display: flex; flex-direction: column; gap: 10px;
  --c1: #ff7a59; --c2: #3b82f6; --c3: #23a55a;   /* first number, second number, result */
  --ph: #7a5cc7; --pt: #2f74e0; --po: #e2583a;   /* hundreds, tens, ones */
}
.ls-head { display: flex; align-items: center; gap: 10px; }
.ls-ico { font-size: 26px; line-height: 1; }
.ls-titles { flex: 1; min-width: 0; }
.ls-titles small { display: block; font-size: 12px; font-weight: 800; color: #7a5cc7; text-transform: uppercase; letter-spacing: .05em; }
.ls-q { display: block; font-size: 19px; font-weight: 900; line-height: 1.25; font-variant-numeric: tabular-nums; }
.ls-note { font-size: 13.5px; line-height: 1.4; background: #ece5ff; color: #45357f; border-radius: 12px; padding: 7px 11px; }
.ls-dots { display: flex; gap: 6px; justify-content: center; }
.ls-dots i { width: 9px; height: 9px; border-radius: 50%; background: #e7dfcf; transition: transform .15s; }
.ls-dots i.was { background: #ffc4b3; }
.ls-dots i.now { background: var(--accent); transform: scale(1.3); }
.ls-board {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 150px; padding: 12px 8px; overflow: hidden;
  background: #fff; border: 2px solid var(--line); border-radius: 18px;
  font-variant-numeric: tabular-nums;
}
.ls-say { font-size: 17px; line-height: 1.45; }
.ls-nav { display: grid; grid-template-columns: 1fr 1.7fr; gap: 10px; }
.ls-nav .btn { padding: 0 10px; min-height: 52px; }
.ls-end { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; visibility: hidden; }
.ls-end.on { visibility: visible; }
.ls-link { min-height: 40px; padding: 0 14px; border-radius: 12px; font-weight: 800; font-size: 15px; color: #5a43a8; background: #ece5ff; }
.ls-link:hover { background: #e0d6ff; }

/* ---------- counters ---------- */
.dt { position: relative; flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-style: normal; background: #cfc6b2; }
.dt b { font-size: 12.5px; font-weight: 900; color: #fff; line-height: 1; }
.dt.c1, .rod.c1, .sg.c1, .tag.c1, .bond b.c1 { background: var(--c1); }
.dt.c2, .sg.c2, .tag.c2, .bond b.c2 { background: var(--c2); }
.dt.c3 { background: var(--c3); }
.tag.c0 { background: #5b5e7a; }
.dt.ghost { background: #eaf2ff; border: 2px dashed var(--c2); animation: ghost 1s ease-in-out infinite alternate; }
.dt.x { background: #e6dfd0; }
.dt.x::after { content: ''; position: absolute; left: -2px; right: -2px; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 2px; background: var(--bad); transform: rotate(-45deg); }
.dt.x b { color: #8a8474; }
.rodw { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.rodw b { min-width: 24px; text-align: center; font-size: 12.5px; font-weight: 900; color: var(--accent-d); }
.rod { display: block; width: 11px; height: 56px; border-radius: 4px; background-image: repeating-linear-gradient(to bottom, transparent 0 4.6px, rgba(255, 255, 255, .6) 4.6px 5.6px); }

.lrow { display: flex; align-items: flex-end; justify-content: center; gap: 8px 10px; flex-wrap: wrap; max-width: 100%; }
.grp { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pile { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 4px; max-width: 136px; min-height: 24px; }
.pile.wide { max-width: 290px; }
.cap { min-height: 1.3em; font-size: 15px; font-weight: 900; line-height: 1.3; white-space: nowrap; }
.lop { align-self: center; font-size: 24px; font-weight: 900; color: var(--muted); }
.tf { display: grid; grid-template-columns: repeat(5, 22px); gap: 3px; padding: 5px; border: 2px solid #cfc6b2; border-radius: 10px; background: #faf6ec; }
.tf-c { width: 22px; height: 22px; border-radius: 6px; background: #efe8d8; display: flex; align-items: center; justify-content: center; }
.tf .dt { width: 18px; height: 18px; }

/* ---------- writing ---------- */
.leq { font-size: 26px; font-weight: 900; line-height: 1.2; white-space: nowrap; }
.leq b { color: var(--good); }
.leq .z { color: var(--c2); }
.leq .z.off { opacity: .25; }
.tag { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 15px; font-weight: 900; color: #fff; white-space: nowrap; }
.lrows { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 17px; font-weight: 800; color: #4c4f66; }
.lshort { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lshort small { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bond { display: inline-flex; flex-direction: column; align-items: center; }
.bond b { min-width: 34px; height: 30px; padding: 0 9px; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 900; color: #fff; background: #5b5e7a; }
.bond svg { display: block; height: 18px; }
.bond path { stroke: #b9b2a2; stroke-width: 2; fill: none; }
.bd-p { display: grid; justify-items: center; }
.bond b.ph { background: var(--ph); } .bond b.pt { background: var(--pt); } .bond b.po { background: var(--po); }

/* ---------- number line ---------- */
.nl { display: block; width: 100%; max-width: 380px; height: auto; overflow: visible; }
.nl-ax { stroke: #b9b2a2; stroke-width: 2; stroke-linecap: round; }
.nl-p circle { fill: #8a8474; }
.nl-p text { font-size: 12.5px; font-weight: 800; fill: var(--ink); text-anchor: middle; }
.nl-p.cur circle { fill: var(--accent); }
.nl-p.cur text { font-size: 15px; font-weight: 900; fill: var(--accent-d); }
.nl-j { color: var(--c2); }
.nl-j.c1 { color: var(--c1); } .nl-j.ph { color: var(--ph); } .nl-j.pt { color: var(--pt); } .nl-j.po { color: var(--po); }
.nl-j path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1; }
.nl-j polygon { fill: currentColor; }
.nl-j text { font-size: 12.5px; font-weight: 900; fill: currentColor; text-anchor: middle; }

/* ---------- rows of counters ---------- */
.arr { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.arr-r { display: flex; align-items: center; gap: 4px; }
.arr .dt { width: 18px; height: 18px; }
.arr .dt.gap { margin-left: 9px; }
.arr-t { min-width: 2.4em; margin-left: 6px; font-size: 15px; font-weight: 900; color: var(--accent-d); }
.arr.sm, .arr.sm .arr-r { gap: 3px; }
.arr.sm .dt { width: 14px; height: 14px; }
.arr.sm .arr-t { font-size: 13.5px; line-height: 14px; }

/* ---------- bars ---------- */
.segs { display: flex; gap: 3px; width: 100%; max-width: 340px; }
.sg { min-width: 0; padding: 8px 4px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #fff; }
.sg small { font-size: 12.5px; font-weight: 800; white-space: nowrap; }
.sg b { font-size: 20px; font-weight: 900; line-height: 1.1; }

.pb { width: 100%; max-width: 340px; padding: 0 2px; }
.pb-m { position: relative; height: 30px; }
.bm { position: absolute; height: 8px; border: 2px solid #8a8474; }
.bm em { position: absolute; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 13.5px; font-weight: 900; white-space: nowrap; color: var(--ink); }
.bm.l em { left: 0; transform: none; }
.bm.r em { left: auto; right: 0; transform: none; }
.pb-m.top .bm { bottom: 3px; border-bottom: 0; border-radius: 6px 6px 0 0; }
.pb-m.top .bm em { bottom: 8px; }
.pb-m.bot .bm { top: 3px; border-top: 0; border-radius: 0 0 6px 6px; }
.pb-m.bot .bm em { top: 8px; }
.pb-c { display: flex; height: 40px; border-radius: 9px; overflow: hidden; background: #efe8d8; box-shadow: inset 0 0 0 2px #cfc6b2; }
.pc { min-width: 0; border-right: 2px solid #fff; }
.pc:last-child { border-right: 0; }
.pc.sl { border-right-width: 1px; }
.pc.on { background: var(--c1); }
.pc.keep { background: var(--c3); }
.pc.plus { background: #8fd3a8; background-image: repeating-linear-gradient(45deg, transparent 0 5px, rgba(255, 255, 255, .45) 5px 10px); }
.pc.off { background: #e6dfd0; background-image: repeating-linear-gradient(45deg, transparent 0 5px, rgba(229, 72, 77, .45) 5px 7px); }

/* ---------- hundreds, tens and ones ---------- */
.pvt { display: grid; gap: 4px 6px; align-items: center; width: 100%; max-width: 320px; }
.pvh { font-size: 11.5px; font-weight: 800; text-align: center; }
.pvh.ph { color: var(--ph); } .pvh.pt { color: var(--pt); } .pvh.po { color: var(--po); }
.pvl { font-size: 17px; font-weight: 900; text-align: right; padding-right: 4px; white-space: nowrap; }
.pvc { height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 900; }
.pvc.ph { background: #ece5ff; color: #5a43a8; } .pvc.pt { background: #e2edff; color: #1f5fd0; } .pvc.po { background: #ffe6de; color: #c9472b; }
.pvc.sum { color: #fff; }
.pvc.sum.ph { background: var(--ph); } .pvc.sum.pt { background: var(--pt); } .pvc.sum.po { background: var(--po); }
.pvc.todo { border: 2px dashed #d9cfbb; }

/* ---------- where lessons are opened from ---------- */
.q-help { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.q-help.one { grid-template-columns: 1fr; }
.q-help button { min-height: 44px; padding: 3px 6px; border-radius: 13px; font-weight: 800; font-size: 15px; line-height: 1.2; }
.q-help small { display: block; font-size: 12px; font-weight: 600; opacity: .8; }
.eg-btn { color: #45357f; background: #ece5ff; }
.show-btn { color: #45357f; background: #ece5ff; box-shadow: 0 4px 0 #d3c6f7; width: 100%; }
.show-btn:active:not(:disabled) { box-shadow: 0 1px 0 #d3c6f7; }
.learn { display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; flex-wrap: wrap; margin-top: 12px; padding: 9px 12px; border-radius: 15px; background: #ece5ff; color: #45357f; font-size: 14.5px; font-weight: 800; }
.learn-row { display: flex; gap: 6px; }
.learn-btn { min-width: 62px; min-height: 40px; padding: 0 8px; border-radius: 11px; background: #fff; box-shadow: 0 3px 0 #d3c6f7; }
.learn-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #d3c6f7; }

@keyframes ghost { from { opacity: .45; } to { opacity: 1; } }

/* phones held upright: the lesson is a sheet at the bottom, buttons under the thumbs */
@media (max-width: 540px) {
  .lesson-ov { align-items: flex-end; padding: 0; }
  .lesson-ov .modal { width: 100%; border-radius: 24px 24px 0 0; padding: 14px 12px calc(12px + env(safe-area-inset-bottom)); animation: rise .22s; }
  .ls-say { font-size: 16.5px; }
}
/* phones held sideways: picture on the left, words and buttons on the right */
@media (orientation: landscape) and (max-height: 560px) {
  .lesson-ov .modal { width: min(820px, 100%); padding: 10px 14px; }
  .lesson { display: grid; grid-template-columns: 1.15fr 1fr; gap: 6px 14px; align-items: center; }
  .ls-head, .ls-note, .ls-dots { grid-column: 1 / -1; }
  .ls-note { display: none; }
  .ls-board { grid-row: span 3; padding: 6px; }
  .ls-say { font-size: 15.5px; line-height: 1.35; }
  .ls-nav .btn { min-height: 44px; }
  .q-help button { min-height: 36px; }
}
