/* ============================================================
   a4Renderer.css — стили, вынесенные из a4Renderer.js
   Подключить в index.html ПОСЛЕ основного style.css:
   <link rel="stylesheet" href="a4Renderer.css">
   ============================================================ */

/* ── Плейсхолдер (пустое поле) ─────────────────────────────── */
.is-empty {
    opacity: 0.4;
}

/* ── Drag-ручка модуля ──────────────────────────────────────── */
.mod-drag-wrapper {
    position: relative;
}

.mod-drag-handle {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: rgba(0, 0, 0, 0.25);
    font-size: 13px;
    line-height: 1;
    user-select: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10;
}

.mod-drag-handle.visible {
    opacity: 1;
}

/* ── Состояния drag-over ────────────────────────────────────── */
.drag-over-top {
    border-top: 3px solid #3b82f6 !important;
}

.drag-over-bottom {
    border-bottom: 3px solid #3b82f6 !important;
}

/* ── Модуль в процессе перетаскивания ───────────────────────── */
.dragging-module {
    opacity: 0.5;
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* ── Заголовок автодополнения ───────────────────────────────── */
/* .heading-autocomplete и .hac-row перенесены в css/style.css
   (единый источник стилей дропдаунов, используют CSS-токены) */

/* ── Единая рамка эпизода (А4) ──────────────────────────────── */
.doc-episode-wrapper {
    position: relative;
    border: 2.5px solid #185FA5;
    border-radius: 10px;
    padding: 32px 18px 18px;
    margin: 36px 0 28px;
    background: transparent;
    /* Корректное разбиение на страницы при печати */
    page-break-inside: auto;
    break-inside: auto;
}

/* Табик с названием, прикреплённый к верхней границе рамки */
.doc-episode-header-tab {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: #185FA5;
    color: #fff;
    padding: 3px 18px;
    font-size: 11px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    border-radius: 6px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    user-select: none;
}

/* Старый подвал — оставляем для обратной совместимости, но скрываем */
.doc-group-footer-a4 { display: none; }
.doc-episode-header  { display: none; }

/* ── Разделитель рендер-ноды ────────────────────────────────── */
.doc-render-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 32px 0 24px;
    color: #a0aec0;
    font-size: 11px;
    font-family: sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
    user-select: none;
}

.doc-render-line {
    flex: 1;
    height: 1px;
    background: #cbd5e0;
    opacity: 0.3;
}

.doc-render-label {
    flex-shrink: 0;
    opacity: 0.4;
}

/* ── Drag-ручка текстовой ноды (левый край) ─────────────────── */
.doc-block-drag-handle {
    position: absolute;
    left: -15px;
    top: 0;
    bottom: 0;
    width: 15px;
    cursor: grab;
    z-index: 10;
}

/* ── Страница А4 ────────────────────────────────────────────── */
.doc-page-node-wrapper {
    position: relative;
    margin-bottom: 100px;
    padding: 0;
}

.doc-page-node-paper {
    position: relative;
    background: #fff;
    width: 100%;
    aspect-ratio: 1 / 1.414;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: 1fr auto 1fr auto;
    padding: 10% 12% 8%;
    overflow: hidden;
    font-family: 'Courier New', 'Courier', monospace;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* ── Зоны страницы А4 ───────────────────────────────────────── */
.doc-page-zone-top {
    grid-row: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ⚡ v172: .full-height удалён — растяжка верхней зоны на grid-row 1/4
   сталкивалась с всегда-занятыми (призраки v171) центром и низом: грид
   выдавливал их в неявную колонку, НАЗВАНИЕ/О ПРОЕКТЕ уезжали вбок.
   .empty-hint-zone удалён как мёртвый (подсказка пустого листа снята в v171). */

.doc-page-zone-center {
    grid-row: 2;
    display: flex;
    flex-direction: column;
}

.doc-page-zone-bottom {
    grid-row: 3;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.doc-page-zone-footer {
    grid-row: 4;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* ── Поля страницы А4 ───────────────────────────────────────── */
.page-field {
    outline: none;
    min-height: 1.4em;
}

.page-field-title {
    font-size: 1.7em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #222;
    text-align: center;
    white-space: pre-wrap;
}

.page-field-about {
    font-size: 0.95em;
    line-height: 1.7;
    color: #444;
    text-align: center;
    white-space: pre-wrap;
}

.page-field-date {
    font-size: 0.85em;
    color: #666;
    text-align: center;
    letter-spacing: 1px;
}

.page-field-freetext {
    flex: 1;
    min-height: 0;
    font-size: 1em;
    line-height: 1.9;
    color: #222;
    white-space: pre-wrap;
    overflow-y: auto;
}

/* ── Строка копирайта ───────────────────────────────────────── */
.doc-module-copyright-row {
    width: 100%;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
}

.page-copyright-sign {
    font-size: 0.85em;
    color: #666;
    user-select: none;
    flex-shrink: 0;
    line-height: 1.4em;
}

/* ── Freetext-обёртка ───────────────────────────────────────── */
.page-freetext-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ── Выравнивание для title/about ───────────────────────────── */
.doc-module-title,
.doc-module-about {
    width: 100%;
    text-align: center;
}

.doc-module-date {
    width: 100%;
    text-align: center;
}

/* ── Шапка блока сцены: номер + заголовок + время в одну строку ─── */
.doc-block-heading-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

/* Переопределяем margin-bottom из style.css (там 8px — ломает строку) */
.doc-block-heading-wrapper .doc-block-heading {
    margin-bottom: 0;
    flex-shrink: 0;
}

/* Поле заголовка растягивается на всё доступное пространство */
.doc-block-heading-wrapper .doc-block-heading[contenteditable="true"] {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

/* Время — прижато вправо, не сжимается */
.doc-block-time-a4 {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: #888;
    white-space: nowrap;
    padding: 1px 4px;
    background: rgba(0,0,0,0.04);
    border-radius: 4px;
}
/* ═══ ⚡ v169. ТУЛБАР СЦЕНАРНОГО ХОЛСТА ═══════════════════════════════════
   Полоса под .canvas-header. Кнопки — форма .imgtool-btn (тулбар холста
   рисования) в компактном размере; состояния и цвета — токены темы. */
.a4-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 10px;
    background: var(--ui-bg-deep);
    border-bottom: 1px solid var(--ui-border);
    user-select: none;
    flex-shrink: 0;
}
.a4tb-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--ui-text-dim);
    width: 28px;
    height: 26px;
    padding: 0;
    border-radius: var(--ui-radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.a4tb-btn:hover:not(:disabled) { background: rgba(255,255,255,0.08); color: var(--ui-text); }
.a4tb-btn.on { background: var(--ui-accent); color: #fff; }
.a4tb-btn:disabled { opacity: 0.35; cursor: default; }
.a4tb-sep { width: 1px; height: 16px; background: var(--ui-border); margin: 0 6px; }
.a4tb-spacer { flex: 1; }
.a4tb-read { width: auto; padding: 0 10px; gap: 6px; font-size: 11px; font-family: var(--ui-font); }

/* ═══ ⚡ v169. РЕЖИМ ЧТЕНИЯ ══════════════════════════════════════════════
   Весь лист — сплошной выделяемый текст; служебной механики нет. */
#a4-canvas.a4-read-mode, #a4-canvas.a4-read-mode * { user-select: text !important; }
/* ⚡ v177 (Денис): сценарный шрифт и в режиме чтения. У .a4-paper/.a4-content
   своего font-family НЕТ — Courier в редакторе несут сами поля блоков
   (.doc-block-heading, .mod-a4-*), а rm-абзацы наследовали шрифт контейнера
   (в рендер-ноде — sans панели). Типографика задаётся ЗДЕСЬ, на rm-content,
   и одинакова в обоих местах показа. */
.a4-content.rm-content { font-family: 'Courier New', 'Courier', monospace; font-size: 14px; line-height: 1.6; color: #111; }
.rm-content p { margin: 0 0 1em; }
.rm-heading { font-weight: bold; text-transform: uppercase; }
.rm-dialog { text-align: center; padding: 0 100px; }
.rm-page { text-align: center; }

/* ⚡ v177. РЕЖИМ ЧТЕНИЯ: НАСТОЯЩИЕ ЛИСТЫ, КАК В PDF (paginateReadSheets).
   ВАЖНО: .a4-wrapper — display:flex СО СТРОЧНЫМ направлением (style.css);
   с одним листом это незаметно, а несколько листов чтения ложились БОК О БОК
   (репорт Дениса со скрином рендер-ноды). В чтении — колонкой по центру. */
.a4-read-mode .a4-wrapper { flex-direction: column; align-items: center; }

/* ⚡ v177. РЕЖИМ ЧТЕНИЯ: НАСТОЯЩИЕ ЛИСТЫ, КАК В PDF (paginateReadSheets).
   Класс на КОНТЕЙНЕРЕ (.a4-read-mode) — работает и в #a4-canvas, и в
   #rep-script-content рендер-ноды. Градиент «линий разрыва» одного длинного
   листа глушим: разрывы теперь настоящие — отступ между листами. */
/* Текст листов чтения выделяем и в рендер-ноде (правило v169 выше — только
   для #a4-canvas). */
.a4-read-mode .a4-paper.rm-sheet, .a4-read-mode .a4-paper.rm-sheet * { user-select: text; }
.a4-read-mode .a4-paper.rm-sheet {
    background-image: none !important;
    height: auto;
    min-height: 1123px;
    margin: 0 0 28px;
}
.a4-read-mode .a4-paper.rm-sheet:last-child { margin-bottom: 0; }
.a4-read-mode .rm-pageno {
    position: absolute;
    bottom: 14px;
    right: 18px;
    font-size: 10px;
    font-family: sans-serif;
    color: #a0a0a0;
    letter-spacing: 0.5px;
    pointer-events: none;
    user-select: none !important;
}

/* ═══ ⚡ v171. ПЛЕЙСХОЛДЕРЫ ЗОН ТИТУЛЬНОГО ЛИСТА ══════════════════════════
   Призрачные кнопки на пустых местах листа: клик создаёт блок своей зоны.
   Вид — язык существующих плейсхолдеров А4 (приглушённый текст .is-empty) +
   синева фокуса, которой лист подсвечивает активные поля. */
.page-zone-ph {
    align-self: center;
    color: #999;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    text-align: center;
    padding: 5px 14px;
    margin: 2px 0;
    border: 1px dashed rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    opacity: 0.55;
    transition: opacity 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
}
.page-zone-ph:hover {
    opacity: 1;
    color: #185FA5;
    border-color: rgba(55, 138, 221, 0.45);
    background: rgba(24, 95, 165, 0.06);
}
/* В режиме чтения и на печати призраков нет — они не контент. */
#a4-canvas.a4-read-mode .page-zone-ph { display: none; }
@media print { .page-zone-ph { display: none; } }
