/* ============================================================================
   RADNEWS ACCENTS v1.0.0 — 04.12.2026 (серия «Чтения Пришвина»; журнал radnews §126)
   «Акценты»: mark.rn-hl в тексте статей — .is-idea (мысль, янтарное волнистое),
   .is-term (понятие автора, голубой пунктир), .is-fact (цифра или факт, зеленая линия).
   «Режим выжимки»: html.rn-digest — абзацы и иллюстрации приглушены, остаются
   заголовки, акценты, вехи (aside.rn-key) и вопросы (details.rn-ask).
   Подключается mu-плагином radnews-accents.php ПОСЛЕ tech.css; токены палитры — там же.
   Панель (легенда + переключатель «Выжимка») строит accents.js в каждой статье потока.
   Класс html.rn-acc-ready ставит accents.js (скрипт работает) — с ним включены переходы.
   ========================================================================== */

:root {
    --rn-hl-idea: var(--rn-amber);
    --rn-hl-term: var(--rn-accent);
    --rn-hl-fact: var(--rn-green);
    --rn-hl-idea-bg: rgba(255, 176, 0, 0.09);
    --rn-hl-term-bg: rgba(53, 195, 255, 0.08);
    --rn-hl-fact-bg: rgba(93, 211, 158, 0.09);
    --rn-dim: rgba(214, 221, 230, 0.3); /* приглушенный текст, темная тема */
    --rn-hl-idea-bg-on: rgba(255, 176, 0, 0.2);
    --rn-hl-term-bg-on: rgba(53, 195, 255, 0.17);
    --rn-hl-fact-bg-on: rgba(93, 211, 158, 0.18);
}

html.rn-light {
    --rn-hl-idea: #a36600;
    --rn-hl-term: #0077b8;
    --rn-hl-fact: #0f8a5f;
    --rn-hl-idea-bg: rgba(255, 190, 20, 0.2);
    --rn-hl-term-bg: rgba(0, 119, 184, 0.09);
    --rn-hl-fact-bg: rgba(15, 138, 95, 0.12);
    --rn-dim: rgba(23, 34, 46, 0.32);
    --rn-hl-idea-bg-on: rgba(255, 190, 20, 0.4);
    --rn-hl-term-bg-on: rgba(0, 119, 184, 0.17);
    --rn-hl-fact-bg-on: rgba(15, 138, 95, 0.2);
}

/* ------------------------------------------------------------- акценты */
body.rn-tech.single-post .post-content mark.rn-hl {
    /* паддинг компенсируется отрицательным маргином — переносы строк не меняются */
    color: var(--rn-ink-bright);
    background-color: var(--rn-hl-bg, transparent);
    padding: 0.04em 0.25em;
    margin: 0 -0.25em;
    border-radius: 3px;
    -webkit-box-decoration-break: clone;
            box-decoration-break: clone;
    text-decoration-line: underline;
    text-decoration-skip-ink: none;
    text-underline-offset: 0.24em;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.rn-tech.single-post .post-content mark.rn-hl.is-idea {
    --rn-hl-bg: var(--rn-hl-idea-bg);
    text-decoration-style: wavy;
    text-decoration-color: var(--rn-hl-idea);
    text-decoration-thickness: 1px;
}

body.rn-tech.single-post .post-content mark.rn-hl.is-term {
    --rn-hl-bg: var(--rn-hl-term-bg);
    text-decoration-style: dashed;
    text-decoration-color: var(--rn-hl-term);
    text-decoration-thickness: 1px;
}

body.rn-tech.single-post .post-content mark.rn-hl.is-fact {
    --rn-hl-bg: var(--rn-hl-fact-bg);
    text-decoration-style: solid;
    text-decoration-color: var(--rn-hl-fact);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.2em;
    font-variant-numeric: tabular-nums;
}

@media (hover: hover) {
    body.rn-tech.single-post .post-content mark.rn-hl {
        position: relative;
        cursor: help;
    }

    body.rn-tech.single-post .post-content mark.rn-hl::after {
        content: attr(data-tip);
        position: absolute;
        left: -0.3em;
        bottom: calc(100% + 0.3em);
        z-index: 20;
        padding: 4px 8px;
        border: 1px solid var(--rn-line);
        border-radius: 3px;
        background: var(--rn-panel-2);
        box-shadow: var(--rn-shadow);
        color: var(--rn-ink-bright);
        font-family: var(--rn-font-mono);
        font-size: 0.68rem;
        font-style: normal;
        font-weight: 400;
        letter-spacing: 0.04em;
        line-height: 1.4;
        text-transform: none;
        white-space: nowrap;
        opacity: 0;
        transform: translateY(3px);
        transition: opacity 0.15s ease, transform 0.15s ease;
        pointer-events: none;
    }

    body.rn-tech.single-post .post-content mark.rn-hl:hover::after {
        opacity: 1;
        transform: none;
    }
}

/* плавное включение/выключение выжимки — только когда скрипт фичи работает */
html.rn-acc-ready body.rn-tech.single-post .post-content :is(p, li, blockquote, figcaption) {
    transition: color 0.35s ease;
}

html.rn-acc-ready body.rn-tech.single-post .post-content :is(figure, img) {
    transition: opacity 0.35s ease;
}

/* --------------------------------------------------- режим выжимки */
@media screen {

    html.rn-digest body.rn-tech.single-post .post-content :is(p, li, blockquote, figcaption, td, th, dt, dd, pre):not(:where(aside.rn-key *, details.rn-ask > summary *, details.rn-ask[open] .rn-ask__a *)),
    html.rn-digest body.rn-tech.single-post .post-content :is(p, li, blockquote, figcaption, td, th, dt, dd, pre) :is(a, em, i, strong, b, span, q, cite, small, u, s, code, abbr, sub, sup, time, del, ins):not(:where(mark.rn-hl *, aside.rn-key *)) {
        color: var(--rn-dim);
    }

    html.rn-digest body.rn-tech.single-post .post-content :is(p, li, blockquote, figcaption) a:not(:where(mark.rn-hl *)) {
        text-decoration-color: currentColor;
    }

    html.rn-digest body.rn-tech.single-post .post-content blockquote {
        border-left-color: currentColor;
    }

    html.rn-digest body.rn-tech.single-post .post-content :is(figure, img, video, iframe, embed, hr):not(:where(aside.rn-key *, details.rn-ask *)) {
        opacity: 0.22;
    }

    html.rn-digest body.rn-tech.single-post .post-content mark.rn-hl {
        color: var(--rn-ink-bright);
    }

    html.rn-digest body.rn-tech.single-post .post-content mark.rn-hl.is-idea { --rn-hl-bg: var(--rn-hl-idea-bg-on); }
    html.rn-digest body.rn-tech.single-post .post-content mark.rn-hl.is-term { --rn-hl-bg: var(--rn-hl-term-bg-on); }
    html.rn-digest body.rn-tech.single-post .post-content mark.rn-hl.is-fact { --rn-hl-bg: var(--rn-hl-fact-bg-on); }

    /* подглядывание: абзац или иллюстрация под курсором проявляются (только hover-устройства) */
    @media (hover: hover) {

        html.rn-digest body.rn-tech.single-post .post-content :is(p, li, blockquote):not(:where(aside.rn-key *, details.rn-ask *)):hover,
        html.rn-digest body.rn-tech.single-post .post-content :is(p, li, blockquote):not(:where(aside.rn-key *, details.rn-ask *)):hover :is(a, em, i, strong, b, span, q, cite, small, u, s, code, abbr, sub, sup, time) {
            color: var(--rn-ink);
        }

        html.rn-digest body.rn-tech.single-post .post-content :is(p, li, blockquote):not(:where(aside.rn-key *, details.rn-ask *)):hover a:not(:where(mark.rn-hl *)) {
            color: var(--rn-accent);
            text-decoration-color: var(--rn-accent-glow);
        }

        html.rn-digest body.rn-tech.single-post .post-content :is(figure, img):not(:where(aside.rn-key *, details.rn-ask *)):hover {
            opacity: 1;
        }
    }
}

/* ------------------------------------------------------------- панель статьи */
.rn-acc {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    margin: 0.6rem 0 0;
    font-family: var(--rn-font-mono);
    -webkit-user-select: none;
            user-select: none;
}

/* без скелета (нет ни акцентов, ни вех, ни вопросов) панель видна только в режиме выжимки */
.rn-acc[hidden],
.rn-acc--plain {
    display: none;
}

html.rn-digest .rn-acc--plain {
    display: flex;
}

/* легенда: сами подписи несут свой тип подчеркивания */
.rn-acc__legend {
    display: inline-flex;
    align-items: baseline;
    gap: 0.95rem;
    font-size: 0.6rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--rn-muted);
}

.rn-acc__li {
    white-space: nowrap;
    text-decoration-line: underline;
    text-decoration-skip-ink: none;
    text-underline-offset: 0.2em;
}

.rn-acc__li.is-idea {
    text-decoration-style: wavy;
    text-decoration-color: var(--rn-hl-idea);
    text-decoration-thickness: 1px;
}

.rn-acc__li.is-term {
    text-decoration-style: dashed;
    text-decoration-color: var(--rn-hl-term);
    text-decoration-thickness: 1px;
}

.rn-acc__li.is-fact {
    text-decoration-style: solid;
    text-decoration-color: var(--rn-hl-fact);
    text-decoration-thickness: 2px;
}

.rn-acc__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    height: 27px;
    margin-left: auto;
    padding: 0 11px 0 9px;
    border: 1px solid var(--rn-line);
    border-radius: 14px;
    background: var(--rn-bg-2);
    color: var(--rn-ink);
    font-family: var(--rn-font-mono);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.rn-acc__btn:hover {
    border-color: var(--rn-amber);
    color: var(--rn-amber);
}

.rn-acc__btn:focus-visible {
    outline: 2px solid var(--rn-accent-glow);
    outline-offset: 1px;
}

.rn-acc__dot {
    width: 8px;
    height: 8px;
    border: 1px solid var(--rn-muted);
    border-radius: 50%;
    background: transparent;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.rn-acc__btn[aria-pressed="true"] {
    border-color: var(--rn-amber);
    background: rgba(255, 176, 0, 0.1);
    color: var(--rn-amber);
}

.rn-acc__btn[aria-pressed="true"] .rn-acc__dot {
    border-color: var(--rn-amber);
    background: var(--rn-amber);
    box-shadow: 0 0 8px var(--rn-amber);
}

.rn-acc__n {
    min-width: 1.7em;
    padding: 0 0.3em;
    border-radius: 9px;
    background: var(--rn-line-soft);
    color: var(--rn-muted);
    font-size: 0.6rem;
    line-height: 1.6;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.rn-acc__hint {
    display: none;
    flex-basis: 100%;
    font-size: 0.7rem;
    line-height: 1.55;
    letter-spacing: 0;
    text-transform: none;
    color: var(--rn-muted);
    -webkit-user-select: text;
            user-select: text;
}

html.rn-digest .rn-acc__hint {
    display: block;
}

.rn-acc__peek {
    display: none;
}

@media (hover: hover) {
    .rn-acc__peek {
        display: inline;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.rn-tech.single-post .post-content mark.rn-hl,
    html.rn-acc-ready body.rn-tech.single-post .post-content :is(p, li, blockquote, figcaption, figure, img),
    .rn-acc__btn,
    .rn-acc__dot {
        transition: none;
    }
}

@media print {
    .rn-acc {
        display: none !important;
    }

    body.rn-tech.single-post .post-content mark.rn-hl {
        color: inherit;
        background: none;
        text-decoration: none;
    }
}
