/* rt-utils.css — JS-generated elements + Social + Responsive + Spoiler + Utils */

/* ============================================================
   USER SEARCH MODAL — нов дизайн
   ============================================================ */

#rt-user-search-modal .rt-modal-content {
    max-width: 480px;
    padding:   0;
    overflow:  hidden;
}

.rt-user-search-header {
    padding:       24px 24px 16px;
    border-bottom: 1px solid var(--rt-border);
}

.rt-user-search-title {
    margin:         0 0 4px;
    font-family:    var(--rt-font-display);
    font-size:      20px;
    font-weight:    700;
    color:          var(--rt-text);
    letter-spacing: -0.01em;
}

.rt-user-search-subtitle {
    margin:    0;
    font-size: 13px;
    color:     var(--rt-text-muted);
}

.rt-user-search-input-wrap {
    position:      relative;
    padding:       14px 20px;
    border-bottom: 1px solid var(--rt-border);
}

.rt-user-search-icon {
    position:        absolute;
    left:            32px;
    top:             50%;
    transform:       translateY(-50%);
    font-size:       16px;
    color:           var(--rt-text-light);
    pointer-events:  none;
}

.rt-user-search-input,
#rt-user-search-input {
    width:          100%;
    padding:        10px 12px 10px 36px;
    border:         1px solid var(--rt-border);
    border-radius:  var(--rt-r2);
    font-size:      14px;
    font-family:    var(--rt-font-body);
    background:     var(--rt-surface2);
    color:          var(--rt-text);
    box-sizing:     border-box;
    transition:     border-color .15s, box-shadow .15s;
}
.rt-user-search-input:focus,
#rt-user-search-input:focus {
    outline:      none;
    border-color: var(--rt-primary);
    box-shadow:   0 0 0 3px var(--rt-primary-soft);
    background:   var(--rt-card-bg);
}
.rt-user-search-input::placeholder,
#rt-user-search-input::placeholder { color: var(--rt-text-light); }

#rt-user-search-results {
    max-height: 380px;
    overflow-y: auto;
    padding:    8px 0;
}

.rt-user-results-list {
    display:        flex;
    flex-direction: column;
}

.rt-user-card {
    display:       flex;
    align-items:   center;
    gap:           14px;
    padding:       12px 20px;
    cursor:        pointer;
    transition:    background .15s;
    border-bottom: 1px solid var(--rt-border);
}
.rt-user-card:last-child { border-bottom: none; }
.rt-user-card:hover { background: var(--rt-surface2); }

.rt-user-card-info {
    flex:      1;
    min-width: 0;
}

.rt-user-card-name {
    font-size:     14px;
    font-weight:   700;
    color:         var(--rt-text);
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
}

.rt-user-card-login {
    font-size:  12px;
    color:      var(--rt-text-muted);
    margin-top: 2px;
}

.rt-user-card-meta { margin-top: 4px; }

.rt-user-private-badge {
    display:       inline-block;
    font-size:     11px;
    font-weight:   600;
    color:         var(--rt-text-light);
    background:    var(--rt-surface2);
    border:        1px solid var(--rt-border);
    border-radius: var(--rt-r1);
    padding:       2px 7px;
}

.rt-user-card-actions { flex-shrink: 0; margin-top: 0; }

.rt-user-follow-btn {
    padding:       7px 14px;
    font-size:     12px;
    font-weight:   600;
    border-radius: var(--rt-r2);
    border:        1px solid var(--rt-primary);
    cursor:        pointer;
    transition:    all .15s;
    background:    var(--rt-primary);
    color:         var(--rt-primary-fg);
    font-family:   var(--rt-font-body);
    white-space:   nowrap;
}
.rt-user-follow-btn:hover:not(:disabled) {
    background: var(--rt-primary-hover);
    border-color: var(--rt-primary-hover);
}
.rt-user-follow-btn:disabled { opacity: .6; cursor: not-allowed; }

.rt-user-follow-btn.rt-btn-following {
    background:   var(--rt-surface2);
    color:        var(--rt-text-muted);
    border-color: var(--rt-border);
}
.rt-user-follow-btn.rt-btn-following:hover:not(:disabled) {
    background:   var(--rt-danger-soft);
    color:        var(--rt-danger);
    border-color: var(--rt-danger);
}
/* ============================================================
   Column View — Accordion layout + Grid книги
   ============================================================ */

/* Expanded колона заема целия ред на десктоп */
.rt-board.rt-has-expanded .rt-column.rt-expanded {
    grid-column: 1 / -1;
    order: 5;
}

/* Свитите колони на десктоп — без preview */
.rt-board.rt-has-expanded .rt-column:not(.rt-expanded) .rt-col-preview-strip {
    display: none;
}

/* На мобилно — НЕ прилагаме grid-column и order,
   expanded колоната се разгъва в рамките на нормалния layout */
@media (max-width: 768px) {
    .rt-board.rt-has-expanded .rt-column.rt-expanded {
        grid-column: auto;
        order: 0;
    }
    /* Останалите колони остават на местата си */
    .rt-board.rt-has-expanded .rt-column:not(.rt-expanded) {
        display: block;
    }
}

/* Grid layout за книгите в expanded колона */
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list {
    display:               grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap:                   16px;
    padding:               0 0 16px !important;
    min-height:            200px;
    list-style:            none;
    margin-top:            16px;
}

/* Карта в grid режим */
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-card {
    display:        flex;
    flex-direction: column;
    padding:        0;
    margin-bottom:  0;
    border-left:    none !important;
    border-radius:  10px;
    overflow:       hidden;
    cursor:         pointer;
    transition:     transform 0.15s, box-shadow 0.15s;
    min-height:     0;
}
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-card:hover {
    transform:  translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
}

/* Корица */
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-cover {
    width:         100%;
    aspect-ratio:  2 / 3;
    margin-bottom: 0;
    border-radius: 0;
    flex-shrink:   0;
}

/* Съдържание */
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-content {
    padding:        8px;
    flex:           1;
    display:        flex;
    flex-direction: column;
    gap:            4px;
}

/* Заглавие */
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-title {
    font-size:          0.85em;
    font-weight:        700;
    line-height:        1.3;
    display:            -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow:           hidden;
}

/* Автор */
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-author {
    font-size:     0.78em;
    margin-bottom: 2px;
}

/* Статус dropdown */
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-actions {
    display:        flex;
    flex-direction: column;
    gap:            4px;
    margin-top:     6px;
}

/* Коментари и ревюта */
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-community-actions {
    display:     flex;
    gap:         4px;
    margin-top:  auto;
    padding-top: 8px;
    flex-wrap:   wrap;
}

.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-series,
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-meta,
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-date {
    display: block;
}
.rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-delete-btn {
    display: flex;
}

/* Корица вляво, след страниците всичко е на цялата ширина */
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-card {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        column-gap: 14px;
        row-gap: 4px;
        align-items: start;
        padding: 10px;
    }

    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-cover {
        width: 96px;
        aspect-ratio: 2 / 3;
        margin: 0;
        grid-column: 1;
        grid-row: 1 / span 5;
        align-self: start;
    }

    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-content {
        display: contents;
    }

    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-header,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-author,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-series,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-user-tags,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-meta {
        grid-column: 2;
        min-width: 0;
    }

    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-actions,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-genres,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-moods,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-rating,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-date,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-community-actions {
        grid-column: 1 / -1;
    }

    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-community-actions {
        margin-top: 4px;
    }

    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-genres,
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-moods {
        display: flex;
        flex-wrap: wrap;
    }

/* Responsive — десктоп breakpoints */
@media (max-width: 1200px) {
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Мобилно — една колона, за тест на същото оформление */
@media (max-width: 768px) {
    .rt-column.rt-expanded .rt-col-filter-wrap {
        position: sticky;
        top: 0;
        z-index: 3;
        background: transparent;
        background: color-mix(in oklab, var(--col-color) 5%, var(--rt-bg));
        padding-top: 4px;
        padding-bottom: 8px;
        margin-bottom: 4px;
    }
    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-card {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .rt-board.rt-has-expanded .rt-column.rt-expanded .rt-list .rt-book-cover {
        width: 76px;
        height: auto;
        aspect-ratio: 2 / 3;
    }
}
/* ── Calendar Day Popup ─────────────────────────────────────── */
.rt-cal-has-events { cursor: pointer; }
.rt-cal-has-events:hover { opacity: 0.85; }

#rt-cal-popup {
    position: absolute;
    z-index: 9999;
    background: var(--rt-card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,.18);
    min-width: 220px;
    max-width: 280px;
    overflow: hidden;
}
#rt-cal-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--rt-primary);
    color: var(--rt-primary-fg);
    font-size: 14px;
    font-family: var(--rt-font-body);
}
#rt-cal-popup-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
#rt-cal-popup-body { padding: 10px 14px; }
.rt-cal-popup-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}
.rt-cal-popup-item:last-child { border-bottom: none; }
.rt-cal-popup-icon { font-size: 18px; flex-shrink: 0; }
.rt-cal-popup-info { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.rt-cal-popup-info strong { color: var(--rt-text); }
.rt-cal-popup-info span   { color: var(--rt-text-muted); font-size: 12px; }
.rt-cal-popup-info em     { color: var(--rt-primary); font-size: 11px; font-style: normal; }
.rt-cal-popup-title-link {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font: inherit !important;
    font-weight: 700 !important;
    color: var(--rt-text) !important;
    cursor: pointer;
    text-align: left;
    text-decoration: underline dotted !important;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: inherit !important;
}
.rt-cal-popup-title-link:hover,
.rt-cal-popup-title-link:focus {
    color: var(--rt-primary) !important;
    background: none !important;
    outline: none !important;
}
/* ============================================================
   JS-GENERATED ELEMENTS — класове за всички inline styles от JS
   ============================================================ */

/* ── Stars (inline генерирани от JS) ── */
.rt-star-wrap {
    display: inline-flex;
    gap: 1px;
    vertical-align: middle;
    line-height: 1;
}

.rt-star-char {
    position: relative;
    display: inline-block;
    color: var(--rt-star-empty);
    line-height: 1;
    white-space: nowrap;
}

.rt-star-char-fill {
    position: absolute;
    left: 0; top: 0;
    overflow: hidden;
    color: var(--rt-star);
    white-space: nowrap;
    line-height: 1;
}

/* ── Avatar (генериран от JS) ── */
.rt-js-avatar {
    border-radius: 999px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-family: var(--rt-font-body);
}
.rt-js-avatar-primary {
    background: var(--rt-primary);
    color: var(--rt-primary-fg);
}
.rt-js-avatar-accent {
    background: var(--rt-accent);
    color: var(--rt-accent-fg);
}

.rt-user-avatar-wrap {
    position: relative;
    border-radius: 999px;
    overflow: hidden;
    flex-shrink: 0;
}

.rt-user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 999px;
    display: block;
}

/* Page header: avatar + greeting/title (TBR, Wishlist) */
.rt-page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0 0 24px 0;
}

.rt-page-header-text {
    min-width: 0;
    flex: 1;
}

.rt-page-header-line {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.rt-page-header-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.rt-page-header-tools .rt-theme-switch {
    position: relative;
}

.rt-page-header-tools .rt-theme-toggle {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    font-size: 18px;
    line-height: 1;
    color: var(--rt-text-muted);
    background: var(--rt-card-bg);
}

.rt-page-header-tools .rt-theme-toggle:hover,
.rt-page-header-tools .rt-theme-toggle:focus-visible {
    color: var(--rt-primary);
    border-color: var(--rt-primary);
    background: var(--rt-card-bg);
    box-shadow: none;
}

.rt-page-header .rt-page-greeting {
    margin-bottom: 8px;
}

.rt-page-header-line .rt-page-greeting {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}

.rt-page-header .rt-page-title {
    font-size: 30px;
    line-height: 1.2;
    margin-bottom: 0;
}

.rt-profile-bio-wrap {
    margin: 8px 0 0;
    max-width: 42em;
}

.rt-profile-bio {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--rt-text-muted);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.rt-profile-bio.is-clamped {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.rt-profile-bio-more {
    margin-top: 4px;
    padding: 0;
    border: none !important;
    background: transparent !important;
    color: var(--rt-text-muted) !important;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    box-shadow: none !important;
    text-decoration: underline;
    text-underline-offset: 2px;
    -webkit-tap-highlight-color: transparent;
}

.rt-profile-bio-more:hover,
.rt-profile-bio-more:focus,
.rt-profile-bio-more:focus-visible,
.rt-profile-bio-more:active {
    background: transparent !important;
    box-shadow: none !important;
    color: var(--rt-text) !important;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .rt-page-header .rt-page-title {
        font-size: 21px;
    }

    .rt-wishlist-card-title {
        font-size: 15px;
    }

    .rt-wl-title-input {
        font-size: 18px;
    }
}

@media (max-width: 768px) {
    .rt-page-header {
        gap: 12px;
    }

    .rt-page-header-tools {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}

/* ── Book Detail sidebar ── */
.rt-bd-author-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.rt-bd-author-name {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.3;
}

.rt-bd-reader-count {
    font-size: 12px;
    color: var(--rt-text-muted);
}

.rt-bd-readers-text {
    font-size: 12px;
    color: var(--rt-text-muted);
}

/* Avatar stack border */
.rt-bd-avatar-border {
    border: 2px solid var(--rt-card-bg);
    border-radius: 999px;
}

.rt-bd-reader-link {
    display: inline-flex;
    text-decoration: none;
    color: inherit;
}

.rt-bd-reader-link:hover {
    opacity: 0.92;
}

/* Buttons в cover колона */
.rt-bd-cover-btn-full {
    justify-content: center;
    width: 100%;
}

/* Rating bar fill — width се слага inline само за процента */
.rt-bd-rating-bar-star {
    color: var(--rt-star);
    font-size: 11px;
}

.rt-bd-rating-bar-num {
    width: 8px;
    text-align: right;
    color: var(--rt-text-muted);
}

/* Avg rating strong number */
.rt-bd-avg-num {
    font-family: var(--rt-font-display);
    font-size: 16px;
    letter-spacing: -0.01em;
}

/* Year в author ред */
.rt-bd-year {
    color: var(--rt-text-light);
}

/* Sidebar community score meta */
.rt-bd-score-stars-wrap {
    margin-bottom: 3px;
}

/* ── As-books (автор/поредица modal) ── */
.rt-as-in-list {
    color: var(--rt-success);
    font-size: 12px;
    font-weight: 600;
}

.rt-as-star {
    color: var(--rt-star);
}

.rt-as-count {
    color: var(--rt-text-light);
    font-size: 11px;
}

/* ── Stats ── */
.rt-stat-card-value-colored {
    /* color се слага inline само за конкретния токен */
}

/* Genre bars (CSS, не canvas) */
.rt-genre-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rt-genre-bar-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.rt-genre-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.rt-genre-bar-name {
    font-weight: 600;
    color: var(--rt-text);
}

.rt-genre-bar-count {
    color: var(--rt-text-muted);
    font-weight: 500;
}

.rt-genre-bar-track {
    height: 6px;
    background: var(--rt-surface2);
    border-radius: 999px;
    overflow: hidden;
}

.rt-genre-bar-fill {
    height: 100%;
    border-radius: 999px;
    /* background и width се слагат inline — динамични стойности */
}

/* Stat card label горе */
.rt-stat-card .rt-stat-label {
    margin-bottom: 8px;
    order: -1;
}

/* Legend dots за compare */
.rt-legend-dot-a { background: var(--rt-primary); }
.rt-legend-dot-b { background: var(--rt-accent); }

/* ── Community ── */
.rt-star-css {
    /* --fill се слага inline — динамична стойност */
}

/* ── Discovery ── */
.rt-discovery-empty {
    text-align: center;
    color: var(--rt-text-light);
    padding: 40px;
}

.rt-discovery-badge-count {
    color: var(--rt-text-light);
    font-size: 11px;
}

/* ── Utils ── */
.rt-no-results {
    color: var(--rt-text-light);
    text-align: center;
    padding: 30px;
}

/* Amazon buy btn в cover col */
.rt-bd-cover-col .rt-amazon-buy-btn {
    display: block;
    text-align: center;
}