/* ==========================================================================
   [RU] СТИЛИ МОДУЛЯ АВТОЗАКЛАДОК «ПРОДОЛЖИТЬ ЧТЕНИЕ» v1.2 (Стиль «Церковный листок»)
   [EN] READING HISTORY BOOKMARK WIDGET STYLES v1.2 ("Church Leaflet" Aesthetic)
   ========================================================================== */

.lestvica-rh-root {
    --rh-bg: #fdfaf5;
    --rh-bg-bottom: #f6efe3;
    --rh-surface-hover: rgba(212, 175, 55, 0.11);
    --rh-text: #3a3128;
    --rh-text-muted: #7a6e5f;
    --rh-head: #2b2118;
    --rh-gold: #d4af37;
    --rh-gold-dark: #a68221;
    --rh-burgundy: #7a1c1c;
    --rh-border: rgba(212, 175, 55, 0.45);
    --rh-divider: rgba(166, 130, 33, 0.22);
    --rh-shadow: 0 12px 32px rgba(42, 31, 18, 0.18), 0 2px 8px rgba(42, 31, 18, 0.08);
    --rh-top: 80px;
    --rh-right: 22px;

    position: fixed;
    top: var(--rh-top);
    right: var(--rh-right);
    z-index: 9990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    box-sizing: border-box;
    transition: opacity 0.25s ease;
}

.lestvica-rh-root[hidden],
.lestvica-rh-root.is-hidden-by-hermit:not(.is-resume-preview) {
    display: none !important;
}

/* [RU] Временный показ уведомления «Вы здесь» поверх Келейного режима на 5 секунд */
/* [EN] Temporary 5-second "You are here" overlay preview above Hermit Mode */
.lestvica-rh-root.is-resume-preview {
    z-index: 10000001 !important;
}

.lestvica-rh-root *,
.lestvica-rh-root *::before,
.lestvica-rh-root *::after {
    box-sizing: border-box;
}

/* =======================================================
   [RU] КОМПАКТНЫЙ ЯЗЫЧОК-ЗАКЛАДКА ПОД ПРАВЫМ КРАЕМ МЕНЮ
   [RU] В свернутом состоянии почти прозрачен, кроме цифры; при наведении проявляется полностью
   [EN] COMPACT BOOKMARK TAB UNDER THE RIGHT EDGE OF MENU
   [EN] Nearly transparent when collapsed except the counter digit; fully visible on hover
   ======================================================= */
.lestvica-rh-tab {
    pointer-events: auto;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 6px 12px 7px 12px !important;
    margin: 0 !important;
    background: rgba(253, 250, 245, 0.07) !important;
    color: var(--rh-head) !important;
    border: 1px solid rgba(212, 175, 55, 0.14) !important;
    border-top: 2px solid rgba(212, 175, 55, 0.18) !important;
    border-radius: 0 0 12px 12px !important;
    box-shadow: none !important;
    font-family: 'Lora', Georgia, serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
    letter-spacing: 0.2px !important;
    cursor: pointer !important;
    text-transform: none !important;
    min-height: auto !important;
    height: auto !important;
    width: auto !important;
    transform: translateY(0);
    opacity: 1;
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.25s ease,
                box-shadow 0.28s ease,
                background 0.28s ease,
                border-color 0.28s ease !important;
}

.lestvica-rh-tab-icon {
    width: 15px;
    height: 15px;
    color: var(--rh-gold-dark);
    flex: 0 0 auto;
    opacity: 0.14;
    transition: opacity 0.28s ease, color 0.25s ease;
}

.lestvica-rh-tab-text {
    white-space: nowrap;
    opacity: 0.14;
    transition: opacity 0.28s ease, color 0.25s ease;
}

/* [RU] Цифра счетчика всегда остается на 100% четкой и непрозрачной */
/* [EN] Counter digit always stays 100% crisp and fully opaque */
.lestvica-rh-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--rh-burgundy);
    color: #fdfaf5;
    border: 1px solid rgba(212, 175, 55, 0.72);
    box-shadow: 0 2px 8px rgba(42, 31, 18, 0.38);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    opacity: 1 !important;
    transition: transform 0.24s ease, box-shadow 0.24s ease;
}

/* [RU] Полное проявление при наведении мыши или фокусе */
/* [EN] Full reveal on hover or keyboard focus */
.lestvica-rh-tab:hover,
.lestvica-rh-tab:focus-visible {
    background: linear-gradient(180deg, var(--rh-bg) 0%, var(--rh-bg-bottom) 100%) !important;
    color: var(--rh-burgundy) !important;
    border-color: var(--rh-border) !important;
    border-top-color: var(--rh-gold) !important;
    box-shadow: 0 8px 22px rgba(42, 31, 18, 0.22) !important;
    transform: translateY(1px);
    outline: none;
}

.lestvica-rh-tab:hover .lestvica-rh-tab-icon,
.lestvica-rh-tab:focus-visible .lestvica-rh-tab-icon,
.lestvica-rh-tab:hover .lestvica-rh-tab-text,
.lestvica-rh-tab:focus-visible .lestvica-rh-tab-text {
    opacity: 1 !important;
}

.lestvica-rh-tab:hover .lestvica-rh-tab-count,
.lestvica-rh-tab:focus-visible .lestvica-rh-tab-count {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(122, 28, 28, 0.32);
}

.lestvica-rh-root.is-open .lestvica-rh-tab {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    position: absolute;
    top: 0;
    right: 0;
}

/* =======================================================
   [RU] ВЫПЛЫВАЮЩАЯ ИЗ-ПОД МЕНЮ ПЛАШКА «ПРОДОЛЖИТЬ ЧТЕНИЕ»
   [EN] SLIDE-DOWN PANEL EMERGING FROM UNDER THE MENU
   ======================================================= */
.lestvica-rh-panel {
    pointer-events: none;
    width: 360px;
    max-width: calc(100vw - 24px);
    background: linear-gradient(180deg, var(--rh-bg) 0%, var(--rh-bg-bottom) 100%);
    color: var(--rh-text);
    border: 1px solid var(--rh-border);
    border-top: none;
    border-radius: 0 0 14px 14px;
    box-shadow: var(--rh-shadow);
    overflow: hidden;
    transform-origin: top right;
    transform: translateY(-16px) scaleY(0.94);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.26s ease,
                visibility 0.26s ease;
}

.lestvica-rh-root.is-open .lestvica-rh-panel {
    pointer-events: auto;
    transform: translateY(0) scaleY(1);
    opacity: 1;
    visibility: visible;
}

/* [RU] Тонкая золотая нить на стыке с меню */
/* [EN] Thin golden thread along the top edge under the menu */
.lestvica-rh-gold-thread {
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.35) 0%, #d4af37 50%, rgba(212, 175, 55, 0.35) 100%);
}

/* [RU] Шапка плашки */
/* [EN] Panel header */
.lestvica-rh-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px 10px 15px;
    border-bottom: 1px solid var(--rh-divider);
    background: rgba(212, 175, 55, 0.06);
}

.lestvica-rh-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lestvica-rh-header-icon {
    width: 16px;
    height: 16px;
    color: var(--rh-burgundy);
    flex: 0 0 auto;
}

.lestvica-rh-title {
    font-family: 'Playfair Display', 'Lora', Georgia, serif;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--rh-head);
    letter-spacing: 0.3px;
}

.lestvica-rh-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.lestvica-rh-icon-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 50% !important;
    color: var(--rh-text-muted) !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease !important;
}

.lestvica-rh-icon-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

.lestvica-rh-icon-btn:hover {
    background: rgba(212, 175, 55, 0.16) !important;
    border-color: var(--rh-border) !important;
    color: var(--rh-head) !important;
}

/* =======================================================
   [RU] СПИСОК ПОСЛЕДНИХ СТРАНИЦ (ДО 3 ПУНКТОВ)
   [EN] RECENT PAGES LIST (UP TO 3 ITEMS)
   ======================================================= */
.lestvica-rh-list {
    display: flex;
    flex-direction: column;
    max-height: 370px;
    overflow-y: auto;
}

.lestvica-rh-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px 11px 15px;
    border-bottom: 1px dashed var(--rh-divider);
    transition: background 0.2s ease;
}

.lestvica-rh-item:last-child {
    border-bottom: none;
}

.lestvica-rh-item:hover {
    background: var(--rh-surface-hover);
}

.lestvica-rh-item.is-current {
    background: rgba(212, 175, 55, 0.1);
}

.lestvica-rh-item-link {
    flex: 1 1 auto;
    min-width: 0;
    text-decoration: none !important;
    color: inherit !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.lestvica-rh-item-title {
    font-family: 'Lora', Georgia, serif;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--rh-head);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.lestvica-rh-item-link:hover .lestvica-rh-item-title {
    color: var(--rh-burgundy);
}

.lestvica-rh-item-section {
    font-size: 12px;
    font-style: italic;
    line-height: 1.3;
    color: var(--rh-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lestvica-rh-item-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 11px;
    color: var(--rh-text-muted);
}

.lestvica-rh-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.45;
}

.lestvica-rh-badge-hermit {
    background: rgba(122, 28, 28, 0.11);
    color: var(--rh-burgundy);
    border: 1px solid rgba(122, 28, 28, 0.25);
}

.lestvica-rh-badge-normal {
    background: rgba(122, 110, 95, 0.1);
    color: #5d5144;
    border: 1px solid rgba(122, 110, 95, 0.24);
}

.lestvica-rh-badge-current {
    background: rgba(212, 175, 55, 0.22);
    color: #76580e;
    border: 1px solid rgba(212, 175, 55, 0.5);
}

.lestvica-rh-item-percent {
    font-weight: 600;
    color: var(--rh-gold-dark);
}

.lestvica-rh-item-time {
    opacity: 0.85;
}

/* [RU] Тонкая золотая полоска прогресса у каждого пункта */
/* [EN] Thin golden progress bar for each history item */
.lestvica-rh-item-progress-track {
    width: 100%;
    height: 2px;
    margin-top: 4px;
    border-radius: 2px;
    background: rgba(166, 130, 33, 0.18);
    overflow: hidden;
}

.lestvica-rh-item-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #c99d2c 0%, #d4af37 100%);
    border-radius: 2px;
    transition: width 0.25s ease;
}

/* [RU] Кнопка удаления отдельной закладки */
/* [EN] Single bookmark remove button */
.lestvica-rh-remove-btn {
    flex: 0 0 auto;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    padding: 0 !important;
    margin: -2px -4px 0 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 50% !important;
    color: var(--rh-text-muted) !important;
    font-size: 14px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    opacity: 0.45;
    box-shadow: none !important;
    transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease !important;
}

.lestvica-rh-item:hover .lestvica-rh-remove-btn {
    opacity: 0.85;
}

.lestvica-rh-remove-btn:hover {
    opacity: 1 !important;
    background: rgba(122, 28, 28, 0.1) !important;
    color: var(--rh-burgundy) !important;
}

/* =======================================================
   [RU] ПОДВАЛ ПЛАШКИ
   [EN] PANEL FOOTER
   ======================================================= */
.lestvica-rh-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 9px 15px;
    border-top: 1px solid var(--rh-divider);
    background: rgba(166, 130, 33, 0.04);
}

.lestvica-rh-hint {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 10.5px;
    color: var(--rh-text-muted);
    opacity: 0.8;
}

.lestvica-rh-clear-btn {
    padding: 2px 6px !important;
    margin: 0 !important;
    min-height: auto !important;
    height: auto !important;
    background: transparent !important;
    border: none !important;
    border-radius: 4px !important;
    color: var(--rh-burgundy) !important;
    font-family: system-ui, -apple-system, sans-serif !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
    cursor: pointer !important;
    opacity: 0.78;
    box-shadow: none !important;
    text-transform: none !important;
    transition: opacity 0.2s ease, background 0.2s ease !important;
}

.lestvica-rh-clear-btn:hover {
    opacity: 1 !important;
    background: rgba(122, 28, 28, 0.08) !important;
}

/* =======================================================
   [RU] МОБИЛЬНАЯ АДАПТАЦИЯ
   [EN] MOBILE ADAPTATION
   ======================================================= */
@media (max-width: 768px) {
    .lestvica-rh-root {
        right: 12px !important;
    }

    .lestvica-rh-panel {
        width: calc(100vw - 24px);
        max-width: 360px;
    }

    .lestvica-rh-tab {
        padding: 5px 10px 6px 10px !important;
        font-size: 12px !important;
    }

    .lestvica-rh-remove-btn {
        opacity: 0.72;
    }
}

@media (max-width: 420px) {
    .lestvica-rh-tab-text {
        display: none;
    }

    .lestvica-rh-tab {
        padding: 5px 8px 6px 8px !important;
        gap: 6px !important;
    }
}