/* ============================================================
   css/components/rich-text.css
   ------------------------------------------------------------
   Оформление текста из редактора панели (описания спектаклей,
   новости, биографии, страницы «Зрителям»): всё внутри контейнера
   с классом .rich-text. Классы .rt-* ставит сам редактор
   (admin-app/src/components/editor/extensions.ts); серверная
   очистка HTML оставляет в тексте только классы с префиксом rt-
   (panel/api/src/Support/Sanitizer.php), остальные срезает.
   Цвета здесь — для тёмного фона; под светлую тему сайта их
   переопределяет css/pages/new-home.css (html.ss .rich-text …).
   Подключается там, где есть такой текст: <!--#ss:styles rich-text-->.
   ============================================================ */

.rich-text p {
    margin: 0 0 0.9em;
}
.rich-text p:last-child {
    margin-bottom: 0;
}

/* contenteditable выводит каждую строку как <div>. Держим их строками с
   небольшим межстрочным ритмом; пустой <div><br></div> остаётся пустой
   строкой-разделителем (напр. между актами либретто). */
.rich-text div {
    margin: 0 0 0.5em;
}
.rich-text div:last-child {
    margin-bottom: 0;
}

/* Заголовки внутри форматированного текста (акты либретто и т.п.). */
.rich-text h2,
.rich-text h3,
.rich-text h4 {
    font-family: 'Le Murmure', 'Cormorant Garamond', serif;
    font-weight: 100;
    color: var(--primary-gold-light, #f3e9ce);
    line-height: 1.2;
    margin: 1.2em 0 0.5em;
}
.rich-text h2 { font-size: 1.5rem; }
.rich-text h3 { font-size: 1.25rem; }
.rich-text h4 { font-size: 1.05rem; }
.rich-text :first-child { margin-top: 0; }

.rich-text strong,
.rich-text b {
    font-weight: 600;
    color: rgba(243, 233, 206, 0.85);
}

.rich-text em,
.rich-text i {
    font-style: italic;
}

.rich-text u {
    text-decoration-color: color-mix(in srgb, var(--primary-gold) 60%, transparent);
    text-underline-offset: 2px;
}

.rich-text a {
    color: var(--primary-gold, #e6c27a);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: color-mix(in srgb, var(--primary-gold) 50%, transparent);
    transition: color 0.15s, text-decoration-color 0.15s;
}
.rich-text a:hover {
    color: #f0d28a;
    text-decoration-color: color-mix(in srgb, var(--primary-gold) 90%, transparent);
}

.rich-text blockquote {
    margin: 1em 0;
    padding: 0.5em 1.1em;
    border-left: 2px solid color-mix(in srgb, var(--primary-gold) 50%, transparent);
    color: rgba(243, 233, 206, 0.75);
    font-style: italic;
    background: color-mix(in srgb, var(--primary-gold) 4%, transparent);
    border-radius: 0 3px 3px 0;
}

.rich-text ul,
.rich-text ol {
    margin: 0.6em 0;
    padding-left: 1.4em;
}
.rich-text li {
    margin-bottom: 0.3em;
}
.rich-text li::marker {
    color: color-mix(in srgb, var(--primary-gold) 60%, transparent);
}

/* ============================================================
   Расширенный набор редактора новостей
   ------------------------------------------------------------
   Всё оформление — КЛАССАМИ и data-атрибутами, без inline style:
   санитайзеры (серверный Panel\Support\Sanitizer и публичный
   js/sanitize-html.js) вырезают атрибут style безусловно. Заодно
   палитра остаётся в рамках бренда, а BVI-режим может всё
   перекрыть одним правилом.
   ============================================================ */

/* ── Заголовки нижних уровней ─────────────────────────────── */
.rich-text h5,
.rich-text h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--primary-gold-light, #f3e9ce);
    line-height: 1.3;
    margin: 1.1em 0 0.4em;
}
.rich-text h5 { font-size: 0.98rem; }
.rich-text h6 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Начертания ───────────────────────────────────────────── */
.rich-text s { text-decoration-color: color-mix(in srgb, var(--error) 70%, transparent); }

/* Индексы не должны раздвигать строки — отсюда line-height:0. */
.rich-text sub,
.rich-text sup {
    font-size: 0.72em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}
.rich-text sup { top: -0.5em; }
.rich-text sub { bottom: -0.25em; }

.rich-text mark {
    background: color-mix(in srgb, var(--primary-gold) 26%, transparent);
    color: inherit;
    padding: 0.05em 0.25em;
    border-radius: 2px;
}

/* ── Цвет текста и выделение (палитра бренда, не произвольная) ── */
.rich-text .rt-c-gold   { color: var(--primary-gold); }
.rich-text .rt-c-light  { color: var(--primary-gold-light); }
.rich-text .rt-c-white  { color: var(--text-primary); }
.rich-text .rt-c-muted  { color: var(--text-muted); }
.rich-text .rt-c-accent { color: var(--accent-premiere); }
.rich-text .rt-c-tour   { color: var(--accent-tour); }

.rich-text .rt-hl-gold   { background: color-mix(in srgb, var(--primary-gold) 26%, transparent); }
.rich-text .rt-hl-warm   { background: color-mix(in srgb, var(--accent-premiere) 24%, transparent); }
.rich-text .rt-hl-cool   { background: color-mix(in srgb, var(--accent-tour) 24%, transparent); }
.rich-text .rt-hl-danger { background: color-mix(in srgb, var(--error) 24%, transparent); }
.rich-text [class*='rt-hl-'] {
    padding: 0.05em 0.25em;
    border-radius: 2px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* ── Размер текста ────────────────────────────────────────── */
.rich-text .rt-fs-sm { font-size: 0.86em; }
.rich-text .rt-fs-lg { font-size: 1.15em; }
.rich-text .rt-fs-xl { font-size: 1.35em; }

/* ── Выравнивание / интерлиньяж / отступ абзаца ───────────── */
.rich-text .rt-align-center  { text-align: center; }
.rich-text .rt-align-right   { text-align: right; }
.rich-text .rt-align-justify { text-align: justify; hyphens: auto; }

.rich-text .rt-lh-tight { line-height: 1.35; }
.rich-text .rt-lh-loose { line-height: 2.1; }

.rich-text .rt-indent-1 { padding-left: 2em; }
.rich-text .rt-indent-2 { padding-left: 4em; }
.rich-text .rt-indent-3 { padding-left: 6em; }

/* ── Чек-лист ─────────────────────────────────────────────────
   Настоящий <input type=checkbox> санитайзер вырезает (он в DROP),
   да и на публичной странице интерактивность не нужна — рисуем
   рамку псевдоэлементом. */
.rich-text .rt-tasklist {
    list-style: none;
    padding-left: 0;
}
.rich-text .rt-task {
    position: relative;
    padding-left: 1.9em;
    margin-bottom: 0.45em;
}
.rich-text .rt-task > p { margin-bottom: 0.3em; }
.rich-text .rt-task::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.3em;
    width: 1.05em;
    height: 1.05em;
    border: 1px solid color-mix(in srgb, var(--primary-gold) 45%, transparent);
    border-radius: 3px;
    background: color-mix(in srgb, var(--primary-gold) 6%, transparent);
}
.rich-text .rt-task[data-checked='true']::after {
    content: '';
    position: absolute;
    left: 0.33em;
    top: 0.45em;
    width: 0.34em;
    height: 0.62em;
    border: solid var(--primary-gold);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.rich-text .rt-task[data-checked='true'] { color: var(--text-muted); }

/* ── Выносная цитата ──────────────────────────────────────── */
.rich-text .rt-pullquote {
    border-left: none;
    background: none;
    padding: 0.2em 0;
    margin: 1.4em 0;
    font-family: 'Le Murmure', 'Cormorant Garamond', serif;
    font-weight: 100;
    font-style: normal;
    font-size: 1.6rem;
    line-height: 1.3;
    color: var(--primary-gold-light);
    text-align: center;
}

/* ── Блоки-примечания ─────────────────────────────────────── */
.rich-text .rt-callout {
    --rt-callout-tint: var(--primary-gold);
    position: relative;
    margin: 1.3em 0;
    padding: 1em 1.2em 1em 3em;
    border: 1px solid color-mix(in srgb, var(--rt-callout-tint) 28%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--rt-callout-tint) 7%, transparent);
    color: rgba(255, 255, 255, 0.78);
}
.rich-text .rt-callout > :last-child { margin-bottom: 0; }
.rich-text .rt-callout::before {
    position: absolute;
    left: 1.05em;
    top: 0.95em;
    font-size: 1.05em;
    line-height: 1.4;
    color: var(--rt-callout-tint);
}
.rich-text .rt-callout[data-kind='note']    { --rt-callout-tint: var(--primary-gold); }
.rich-text .rt-callout[data-kind='info']    { --rt-callout-tint: var(--accent-tour); }
.rich-text .rt-callout[data-kind='warning'] { --rt-callout-tint: var(--accent-premiere); }
.rich-text .rt-callout[data-kind='note']::before    { content: '✎'; }
.rich-text .rt-callout[data-kind='info']::before    { content: 'i'; font-style: italic; font-weight: 700; }
.rich-text .rt-callout[data-kind='warning']::before { content: '!'; font-weight: 700; }

/* ── Иллюстрация внутри текста ────────────────────────────────
   Ширину задаёт страница через --rt-media (на новости это
   --ns-media, чтобы фото в тексте совпало по ширине с обложкой
   и видео). Без переменной — во всю ширину контейнера. */
.rich-text .rt-figure {
    margin: 1.8em 0;
    max-width: 100%;
}
.rich-text .rt-figure img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}
.rich-text .rt-figure figcaption {
    margin-top: 0.7em;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-muted);
}
.rich-text .rt-figure__credit {
    display: block;
    margin-top: 0.15em;
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--text-muted) 75%, transparent);
}

/* Раскладка */
.rich-text .rt-figure[data-layout='text']   { max-width: var(--rt-media, 100%); }
.rich-text .rt-figure[data-layout='full']   { max-width: 100%; }
.rich-text .rt-figure[data-layout='center'] {
    max-width: var(--rt-media, 100%);
    margin-inline: auto;
}
.rich-text .rt-figure[data-layout='center'] figcaption { text-align: center; }

.rich-text .rt-figure[data-layout='left'],
.rich-text .rt-figure[data-layout='right'] {
    max-width: 46%;
    margin-top: 0.35em;
}
.rich-text .rt-figure[data-layout='left'] {
    float: left;
    margin-right: 1.8em;
}
.rich-text .rt-figure[data-layout='right'] {
    float: right;
    margin-left: 1.8em;
}

/* Размер — модификатор поверх раскладки. */
.rich-text .rt-figure[data-size='s'] { max-width: min(320px, 100%); }
.rich-text .rt-figure[data-size='l'][data-layout='left'],
.rich-text .rt-figure[data-size='l'][data-layout='right'] { max-width: 58%; }

/* Заголовок после обтекаемого фото не должен «наезжать». */
.rich-text h2, .rich-text h3, .rich-text h4 { clear: both; }

@media (max-width: 700px) {
    /* Обтекание на узком экране превращает текст в лапшу — разворачиваем
       все фото в колонку. Отступы обтекания тоже снимаем. */
    .rich-text .rt-figure[data-layout='left'],
    .rich-text .rt-figure[data-layout='right'],
    .rich-text .rt-figure[data-size='s'] {
        float: none;
        max-width: 100%;
        margin-inline: 0;
    }
    .rich-text .rt-indent-1,
    .rich-text .rt-indent-2,
    .rich-text .rt-indent-3 { padding-left: 1.2em; }
    .rich-text .rt-pullquote { font-size: 1.3rem; }
    .rich-text .rt-callout { padding: 0.9em 1em 0.9em 2.7em; }
}
