/* Мобильный режим (html.mobile): поурочная лента вместо разворотов. Строит js/mobile.js. */

.m-app { display: none; }
html.mobile .stage { display: none; }
html.mobile body { background: #fff; overflow: hidden; }
html.mobile .m-app {
  display: flex; flex-direction: column;
  position: fixed; inset: 0;
  background: #fff; color: #1a1a1a;
  font-family: Georgia, 'Times New Roman', serif;
}

/* --- шапка: название урока и Enhavo ------------------------------------------ */
.m-head {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 12px 0 16px;
  border-bottom: 1.5px solid #2c5a49;
  background: #fbfaf7;
}
.m-title { flex: 1; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-enhavo, .m-vortoj {
  flex: none;
  font: italic 16px Georgia, serif;
  padding: 7px 14px;
  background: #fff; color: inherit;
  border: 1.5px solid #8a8378; border-radius: 6px;
}
.m-vortoj.on { background: #e3ecdf; border-color: #2f6b3a; }

/* --- лента уроков: горизонтальный свайп, внутри урока — вертикальная прокрутка ---- */
.m-deck {
  flex: 1; min-height: 0;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.m-deck::-webkit-scrollbar { display: none; }
.m-lesson {
  flex: 0 0 100%;
  height: 100%;
  overflow-y: auto; overflow-x: hidden;
  scroll-snap-align: start; scroll-snap-stop: always;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px 40px;
  font-size: 18px; line-height: 1.55;
}
.m-body::after { content: ''; display: block; clear: both; }

/* обложка */
.m-cover { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.m-cover-page { width: 740px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.m-cover-page > .page { margin: 0; }
.m-hint { font-style: italic; color: #777; font-size: 15px; margin: 14px 0 0; }

/* --- текст урока ---------------------------------------------------------------- */
.m-p { margin: 0; }                         /* строки одного абзаца книги — подряд */
.m-p.m-end, .m-p:last-child { margin-bottom: .8em; }   /* пустая строка в книге — отступ */
.m-p::after { content: ''; display: block; clear: both; }
.m-mark { font-weight: bold; }

/* всё, что было «под бумагу», — в поток и по ширине экрана */
.m-lesson img { max-width: 100% !important; height: auto !important; }
.m-lesson .lesson-title, .m-lesson .lesson-sub { text-align: center !important; margin-left: 0 !important; }
.m-lesson .lesson-title { font-size: 20px !important; margin: 4px 0 2px !important; }
.m-lesson .lesson-sub { font-size: 22px !important; margin: 0 0 10px !important; }
.m-lesson [class^="lesson-head"] { position: static !important; height: auto !important; margin: 0 0 12px !important; display: flex; flex-direction: column; }
.m-lesson [class^="lesson-head"] > * { position: static !important; width: auto !important; transform: none !important; background: none !important; padding: 0 !important; }
.m-lesson [class^="lesson-head"] .ttl { order: -1; text-align: center; }
.m-lesson [class^="lesson-head"] .t1, .m-lesson [class^="lesson-head"] .t2 { order: -1; text-align: center; font-size: 22px !important; }
.m-lesson [class^="lesson-head"] img { width: 100% !important; margin: 0 auto !important; }
.m-lesson .garden-img, .m-lesson .house-img, .m-lesson .hanako-img, .m-lesson .kids-img, .m-lesson .tree-img { width: 100% !important; margin: 0 auto 12px !important; }
.m-lesson .photo-cap img { width: 100% !important; }

/* картинки с полей — в абзац, справа с обтеканием */
.m-fig {
  float: right; clear: right;
  width: 34%; max-width: 140px;
  margin: 4px 0 6px 12px;
  text-align: center; font-size: 13px; font-style: italic; line-height: 1.25;
}
.m-fig .margin-fig { margin: 0 !important; display: block; }
.m-fig img { max-width: 100% !important; margin: 0 auto 2px !important; display: block; }
.m-fig .pmap { display: block; }

/* обтекаемые картинки внутри текста: без выходов на поля */
.m-lesson .fl-gap, .m-lesson .skip { display: none !important; }
.m-lesson .fl-after { float: right !important; clear: right; margin: 4px 0 8px 12px !important; max-width: 48%; }
.m-lesson .fl-after img, .m-lesson .fl-after svg { max-width: 100% !important; width: auto; }
.m-lesson .tablo-fig, .m-lesson .princino-fig, .m-lesson .statuo-fig, .m-lesson .muzeo-fig,
.m-lesson .stupoj-fig, .m-lesson .mantuko-fig, .m-lesson .longa-fig, .m-lesson .jmap2, .m-lesson .invitilo {
  width: auto !important; max-width: 48% !important; margin: 4px 0 8px 12px !important;
}
.m-lesson .invitilo { max-width: 100% !important; float: none !important; margin: 10px auto !important; font-size: 17px; }
.m-lesson .longa-fig svg { width: 100%; height: auto; }

/* схемы с координатами — целиком, по центру, с масштабом */
.m-lesson .ftree, .m-lesson .famchart, .m-lesson .minitree {
  float: none !important; margin: 12px auto !important;
}
.m-lesson .ftree { zoom: .85; }
.m-lesson .famchart { zoom: .9; }
.m-lesson .jmap, .m-lesson .panel16 { width: 100% !important; margin: 10px 0 !important; }
.m-lesson .jmap { font-size: 12px; }
.m-lesson .kalendaro .k-grid { font-size: 13px; row-gap: 8px; }
.m-lesson .kalendaro .k-grid b { font-size: 9px; }
.m-lesson .kalendaro .k-box { padding: 6px 4px 10px; }

/* примеры и таблицы грамматики */
.m-lesson .ex, .m-lesson .ex0, .m-lesson .fish-row { padding-left: 10px !important; }
.m-lesson .tempo { grid-template-columns: 1fr !important; padding-left: 10px !important; }
.m-lesson .pairs i:nth-child(even) { padding-left: 28px !important; }
.m-lesson .numlist { padding-left: 26px !important; }
.m-lesson .fish-row { height: auto; flex-wrap: wrap; gap: 8px; }
.m-lesson .letter .l-close .r { padding-left: 30%; }

/* --- конец урока: ◀ · Vortoj · ▶ и словарь ---------------------------------------- */
.m-foot {
  clear: both;
  display: flex; align-items: center; justify-content: space-between;
  margin: 26px 0 10px; padding-top: 14px;
  border-top: 1.5px solid #2c5a49;
}
.m-nav {
  width: 48px; height: 48px;
  font-size: 18px; line-height: 1;
  background: #fbfaf7; color: #1a1a1a;
  border: 1.5px solid #8a8378; border-radius: 4px;
}
.m-lesson:nth-child(2) .m-nav[data-go="-1"] { visibility: visible; }
.m-lesson:last-child .m-nav[data-go="1"] { visibility: hidden; }
.m-vocab { margin-top: 10px; }
.m-vtitle { font-size: 18px; margin-bottom: 8px; }
.m-vocab ul {
  list-style: none; margin: 0; padding: 0;
  columns: 7.2em auto; column-gap: 14px; column-rule: 1px solid #000;
  font-size: 17px; line-height: 1.6;
}
.m-vocab li { break-inside: avoid; }

/* --- содержание ----------------------------------------------------------------------- */
.m-toc { position: fixed; inset: 0; z-index: 50; background: rgba(30,26,20,.45); display: flex; align-items: flex-start; justify-content: center; padding: 12px; }
.m-toc[hidden] { display: none; }
.m-toc-card { background: #fff; width: 100%; max-height: calc(100% - 24px); overflow-y: auto; border-radius: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.m-toc-head { position: sticky; top: 0; background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font-size: 22px; font-weight: bold; border-bottom: 1.5px solid #000; }
.m-toc-close { width: 40px; height: 40px; font-size: 28px; background: none; border: none; color: #555; }
.m-toc ol { list-style: none; margin: 0; padding: 6px 0; }
.m-toc li button {
  display: flex; gap: 12px; width: 100%;
  padding: 10px 16px; text-align: left;
  font: 17px/1.3 Georgia, serif; color: inherit; background: none; border: none;
}
.m-toc .n { flex: none; width: 1.6em; font-weight: bold; text-align: right; }
.m-toc li.cur button { background: #eef3ea; }
.m-toc li.cur .n { color: #2f6b3a; }

/* режим снимков (?shot=N): урок во всю высоту */
html.m-shot .m-app { position: static; width: 390px; }   /* headless Chrome не даёт окно уже ~500px */
html.m-shot body { overflow: visible; }
html.m-shot .m-deck { display: block; overflow: visible; }
html.m-shot .m-lesson { height: auto; overflow: visible; }
html.m-shot .m-vocab { display: block; }

/* картинка-поплавок из обёртки страницы (стр. 8) */
.m-lesson .float-fig { float: right; width: 34%; max-width: 140px; margin: 4px 0 6px 12px; }
/* карта с полей (стр. 91) — крупно, по центру: подписи должны читаться */
.m-fig:has(.pmap) { float: none; width: 75%; max-width: none; margin: 10px auto 12px; display: block; }

/* несколько картинок из одной строки полей — рядом, по центру */
.m-figrow {
  clear: both;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 6px 18px;
  margin: 6px 0 10px;
}
.m-figrow .m-fig { float: none; width: auto; max-width: 30%; margin: 0; }
.m-figrow .m-fig img { max-height: 120px; width: auto; }

/* подпись над картинкой (kuko над тарелкой) */
.m-fig .margin-fig { display: flex; flex-direction: column; align-items: center; }
.m-fig .m-above { order: -1; }

/* слова с подсказкой: пояснение (s-ro = sinjoro) — точки, разбор (sen-patr-in-a) — волна */
.m-note { cursor: pointer; text-decoration-line: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.m-note.m-dot  { text-decoration-style: dotted; text-decoration-color: #2f6b3a; }
.m-note.m-wave { text-decoration-style: wavy; text-decoration-color: #2f6b3a; text-decoration-thickness: 1px; }
.m-tip {
  position: absolute; z-index: 40;
  max-width: calc(100% - 16px);
  padding: 8px 12px;
  background: #fbfaf7; color: #1a1a1a;
  border: 1.5px solid #2c5a49; border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  font: italic 17px/1.35 Georgia, serif;
}
.m-tip[hidden] { display: none; }
.m-tip b { font-style: normal; }
.m-tip .m-tip-pic { display: block; max-height: 90px; width: auto; margin: 0 auto 6px; }
