/* editor-live.css — live-превью редактора заметок (Obsidian Mobile).
 *
 * Строка документа рисуется как в режиме «Просмотр» (те же размеры
 * заголовков, те же интервалы), пока строка не активна. Активная строка —
 * textarea с сырым текстом, оформленная тем же классом блока (высота
 * строки не прыгает при переключении).
 *
 * Файл подключается отдельно от app.css — базовая типографика заметки
 * (app.css, «Типографика заметки») не меняется.
 */

.notes-view .live-seg {
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* те же поля, что у классического textarea-сегмента */
  padding: var(--s2) var(--s6);
}
.notes-view .live-seg > .live-row:first-child { padding-top: var(--s3); }

/* Пустая строка исходника — разделитель без высоты: в превью blank-строки
   схлопываются, интервал даёт margin абзаца (12px). */
.notes-view .live-line.is-empty { margin: 0; height: 0; }

.notes-view .live-row {
  position: relative;
  min-width: 0;
}

/* --- строка рендера ---------------------------------------------------- */
.notes-view .live-line {
  font-family: var(--note-font);
  font-size: var(--note-size);
  line-height: var(--note-lh);
  letter-spacing: normal;
  color: var(--text);
  margin: 0 0 12px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  cursor: text;
}

/* Заголовки — та же шкала, что в превью (28/23/20/18/17/16). */
.notes-view .live-h1 { font-size: 28px; line-height: 1.25; font-weight: 700; margin: 24px 0 8px; }
.notes-view .live-h2 { font-size: 23px; line-height: 1.3; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-h3 { font-size: 20px; line-height: 1.35; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-h4 { font-size: 18px; line-height: 1.4; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-h5 { font-size: 17px; line-height: 1.5; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-h6 { font-size: 16px; line-height: 1.5; font-weight: 600; margin: 24px 0 8px; }

/* Первый блок сегмента не «отрывается» от заголовка заметки. */
.notes-view .live-seg > .live-row:first-child .live-line { margin-top: 0; }

/* Списки: маркер в отдельной колонке 24px — текст на том же отступе,
   что в превью (padding-left: 24px). */
.notes-view .live-bullet {
  display: inline-block;
  width: 24px;
  color: var(--hint);
  user-select: none;
}
.notes-view .live-list-ul,
.notes-view .live-list-ol,
.notes-view .live-task { margin-bottom: 2px; }
.notes-view .live-list-ul .live-bullet,
.notes-view .live-list-ol .live-bullet { color: var(--hint); }

/* Чекбокс задачи (тап переключает). */
.notes-view .live-check {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: 0 8px 0 0;
  padding: 0;
  border: 1.8px solid var(--hint);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  vertical-align: -4px;
  flex: none;
}
.notes-view .live-check.is-on {
  background: var(--accent);
  border-color: var(--accent);
}
.notes-view .live-check.is-on::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid var(--accent-contrast);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Цитата: акцентная черта 2px + отступ текста 16px (как в превью). */
.notes-view .live-quote {
  border-left: 2px solid var(--accent);
  padding-left: 16px;
  color: var(--hint);
}

/* Блок кода — моноширинный, 14px. */
.notes-view .live-code-text {
  display: block;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 12px 16px;
  overflow-x: auto;
}

/* Разделитель — 1px --border, поля 24px. */
.notes-view .live-hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* Таблица (строка-разделитель трубы) — моноширинный сырой вид. */
.notes-view .live-table {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--hint);
}

/* --- инлайн-токены ------------------------------------------------------ */
.notes-view .live-strong { font-weight: 700; }
.notes-view .live-em { font-style: italic; }
.notes-view .live-strike { text-decoration: line-through; }
.notes-view .live-code {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--fill);
  padding: 1px 5px;
  border-radius: 6px;
}
.notes-view .live-link { color: var(--accent-link); }
.notes-view .live-wikilink { color: var(--accent); }
.notes-view .live-tag {
  color: var(--accent);
  background: var(--fill);
  border-radius: var(--r-pill);
  padding: 0 6px;
}
.notes-view .live-marker { color: var(--hint); }

/* --- активная строка: textarea с сырым текстом ------------------------- */
.notes-view .live-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 12px;
  padding: 0;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  font-family: var(--note-font);
  font-size: var(--note-size);
  line-height: var(--note-lh);
  letter-spacing: normal;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  caret-color: var(--accent);
}
/* Активная строка наследует типографику своего блока — высота строки
   при переключении «рендер → правка» не прыгает. */
.notes-view .live-input.live-h1 { font-size: 28px; line-height: 1.25; font-weight: 700; margin: 24px 0 8px; }
.notes-view .live-input.live-h2 { font-size: 23px; line-height: 1.3; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-input.live-h3 { font-size: 20px; line-height: 1.35; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-input.live-h4 { font-size: 18px; line-height: 1.4; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-input.live-h5 { font-size: 17px; line-height: 1.5; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-input.live-h6 { font-size: 16px; line-height: 1.5; font-weight: 600; margin: 24px 0 8px; }
.notes-view .live-input.live-quote {
  border-left: 2px solid var(--accent);
  padding-left: 16px;
  color: var(--text);
}
.notes-view .live-input.live-code-fence {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.notes-view .live-input.live-list-ul,
.notes-view .live-input.live-list-ol,
.notes-view .live-input.live-task { margin-bottom: 2px; }

/* Подсветка совпадений поиска внутри live-рендера. */
.notes-view .live-line mark.find-mark {
  background: color-mix(in srgb, var(--warning) 35%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

/* Десктоп: та же мера строки, что у классического сегмента (700px + поля). */
@media (min-width: 1024px) {
  .notes-view .live-seg {
    box-sizing: border-box;
    width: 100%;
    max-width: calc(var(--measure) + 2 * var(--measure-pad));
    margin-inline: auto;
    padding-inline: var(--measure-pad);
  }
}

/* Мобила: контейнер сегментов — скроллер (иначе живой текст уходил за
   нижний край панели и не прокручивался). */
@media (max-width: 600px) {
  .notes-view .note-editor-pane.mode-edit .editor-segments {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
