/* "Recently Updated" list rows (components/recent-chapters/index.php): the home section and the list layout of
   /recently-updated (whose wrapper carries #recent-updated-section too). Grouped +N chapter cards, hover/tap popup. */

#recent-updated-section .recent-updated-skeleton {
    display: none;
}

#recent-updated-section.is-loading .recent-updated-content {
    display: none;
}

#recent-updated-section.is-loading .recent-updated-skeleton {
    display: block;
}

/* ── grouped "+N" chapter cards ─────────────────────────────── */
#recent-updated-section .rc-group {
    position: relative;
}

#recent-updated-section .rc-group:hover,
#recent-updated-section .rc-group.is-open {
    z-index: 50;
}

#recent-updated-section .rc-card {
    position: relative;
    z-index: 1;
}

/* What a tap opens: the cover and the title → the series page; the ⌄ / count pill → the popup; anywhere else on the
   card → the newest chapter. The card is not one link any more (a link around the pill let htmx open the chapter before
   the popup could): the chapter line is the link and its ::after covers the card, under the other targets. */
#recent-updated-section .rc-ch {
    text-decoration: none; /* its colour is the text-white/60 it always had */
}

#recent-updated-section .rc-ch::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}

#recent-updated-section :is(.rc-cover, .rc-title-link, .rc-side) {
    position: relative;
    z-index: 2;
}

#recent-updated-section .rc-title-link {
    color: inherit;
    text-decoration: none;
    transition: color .15s ease;
}

#recent-updated-section .rc-title-link:hover,
#recent-updated-section .rc-title-link:focus-visible {
    color: var(--zmio-accent-light, rgb(var(--c-violet-light)));
}

#recent-updated-section .rc-side {
    text-decoration: none;
}

/* a sheet of "paper" peeking out behind a multi-chapter card */
#recent-updated-section .rc-group.has-more::before {
    content: "";
    position: absolute;
    left: 7px;
    right: 7px;
    bottom: -4px;
    height: 12px;
    border-radius: 0 0 12px 12px;
    background: rgb(var(--c-peek));
    border: 1px solid rgb(var(--c-white) / .06);
    border-top: 0;
    z-index: 0;
}

#recent-updated-section .rc-more {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 16px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    color: #fff;
    /* follows the viewer's accent (--zmio-accent* are set in index.php's <head>); fallbacks = default violet */
    background: linear-gradient(135deg, var(--zmio-accent-soft, #a78bfa), var(--zmio-accent, #7c3aed));
    box-shadow: 0 1px 4px rgba(var(--zmio-accent-rgb, 124, 58, 237), .4);
    cursor: pointer;
    position: relative;
    z-index: 2;
    /* a <button>: none of the browser's own look */
    margin: 0;
    border: 0;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

/* the count pill carries a small ⌄ too, so it reads as the same dropdown as the plain chevron */
#recent-updated-section .rc-more .rc-more-ic {
    width: 8px;
    height: 8px;
    margin-left: 2px;
    transition: transform .15s ease;
}

#recent-updated-section .rc-group.is-open .rc-more .rc-more-ic {
    transform: rotate(180deg);
}

#recent-updated-section .rc-more:hover {
    filter: brightness(1.1);
}

/* no count pill (lone new chapter) but earlier chapters exist —
   a plain chevron that still opens the popup */
#recent-updated-section .rc-more.rc-more-plain {
    padding: 0 3px;
    background: rgb(var(--c-white) / .08);
    color: rgb(var(--c-white) / calc(var(--ta-b,0) + var(--ta-m,1) * .5));
    box-shadow: none;
}

#recent-updated-section .rc-more.rc-more-plain:hover {
    filter: none;
    background: rgb(var(--c-white) / .14);
    color: rgb(var(--c-white) / calc(var(--ta-b,0) + var(--ta-m,1) * .85));
}

#recent-updated-section .rc-more.rc-more-plain svg {
    width: 10px;
    height: 10px;
    transition: transform .15s ease;
}

#recent-updated-section .rc-group.is-open .rc-more-plain svg,
#recent-updated-section .rc-group:hover .rc-more-plain svg {
    transform: rotate(180deg);
}

#recent-updated-section .rc-pop {
    position: absolute;
    top: calc(100% - 6px);
    left: 0;
    right: 0;
    z-index: 40;
    padding: 8px;
    border-radius: 12px;
    background: rgb(var(--c-pop));
    border: 1px solid rgb(var(--c-white) / .1);
    box-shadow: 0 20px 44px rgba(0, 0, 0, .55);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
}

#recent-updated-section .rc-group:hover .rc-pop,
#recent-updated-section .rc-group.is-open .rc-pop {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#recent-updated-section .rc-pop-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 240px;
    overflow-y: auto;
}

#recent-updated-section .rc-pop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    font-size: 13px;
    color: rgb(var(--c-white) / calc(var(--ta-b,0) + var(--ta-m,1) * .72));
    transition: background .12s, color .12s;
}

#recent-updated-section .rc-pop-row:hover {
    background: rgb(var(--c-white) / .06);
    color: rgb(var(--c-white));
}

#recent-updated-section .rc-pop-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#recent-updated-section .rc-pop-ch {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#recent-updated-section .rc-pop-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    white-space: nowrap;
}

#recent-updated-section .rc-pop-clock {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: rgb(var(--c-white) / calc(var(--ta-b,0) + var(--ta-m,1) * .25));
}

#recent-updated-section .rc-pop-rel {
    color: rgb(var(--c-white) / calc(var(--ta-b,0) + var(--ta-m,1) * .4));
}

#recent-updated-section .rc-pop-sep {
    color: rgb(var(--c-white) / calc(var(--ta-b,0) + var(--ta-m,1) * .15));
}

#recent-updated-section .rc-pop-date {
    color: rgb(var(--c-white) / calc(var(--ta-b,0) + var(--ta-m,1) * .28));
}

#recent-updated-section .rc-pop-ic {
    width: 13px;
    height: 13px;
    display: block;
    flex-shrink: 0;
}

#recent-updated-section .rc-pop-coins {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--zmio-accent-soft, rgb(var(--c-violet-soft))); /* the price follows the viewer's accent, like the coin beside it */
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

#recent-updated-section .rc-pop-more {
    display: block;
    margin-top: 4px;
    padding: 7px 8px;
    border-top: 1px solid rgb(var(--c-white) / .06);
    font-size: 12px;
    font-weight: 600;
    color: var(--zmio-accent-soft, #a78bfa);
    text-align: center;
}

#recent-updated-section .rc-pop-more:hover {
    color: var(--zmio-accent-light, #c4b5fd);
}

/* touch: :hover sticks after a tap, so let only .is-open drive the popup */
@media (hover: none) {

    #recent-updated-section .rc-group:hover .rc-pop {
        opacity: 0;
        visibility: hidden;
        transform: translateY(-6px);
    }

    #recent-updated-section .rc-group.is-open .rc-pop {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

/* ── read: a chapter opened before is greyed out, like the old site's visited links ──
   .is-read = the signed-in reader's history (every device) or this browser's own record (assets/scripts/read-marks.js —
   chapters open through htmx, which :visited does not see); :visited = a chapter opened by a full page load. A :visited
   rule may only change colours, and the browser keeps the unvisited colour's ALPHA, so its grey differs in lightness. */
#recent-updated-section :is(.rc-ch, .rc-pop-row).is-read {
    color: rgb(113 113 122 / .75);
}

#recent-updated-section :is(.rc-ch, .rc-pop-row):visited {
    color: rgb(113 113 122);
}

/* the tier badges' tooltips (.mk-tt, global-deferred.css) open leftward from the badge's right edge, so they never stick
   out past the row: invisible until hover, they still counted as page width, and on a 390px phone they made the home
   page 408-453px wide — the browser zoomed the whole page out and it could be dragged sideways */
#recent-updated-section .rc-group .mk-tt::after {
    left: auto;
    right: -4px;
    width: max-content;
    max-width: 11rem;
    white-space: normal;
    text-align: center;
    transform: translate(0, 4px);
}

#recent-updated-section .rc-group .mk-tt:hover::after,
#recent-updated-section .rc-group .mk-tt:focus-visible::after {
    transform: translate(0, 0);
}

/* touch screens have no hover, so the tooltips could never be seen there anyway */
@media (hover: none) {
    #recent-updated-section .rc-group .mk-tt::before,
    #recent-updated-section .rc-group .mk-tt::after {
        display: none;
    }
}

/* Phones: smaller header type — title 18 → 16px, subtitle 14 → 12px, the "View all" label 12 → 11px (the eyebrow stays 10px). */
@media (max-width: 639.98px) {
    #recent-updated-section .ru-sec-head h2 { font-size: 1rem; line-height: 1.5rem; }
    /* the eyebrow and the description are desktop furniture: phones show the title alone */
    #recent-updated-section .ru-sec-head > div > p { display: none; }
    #recent-updated-section .recent-updated-controls a { font-size: 11px; }
    /* and half the section gap (mb-9 → 18px), a smaller header → content gap */
    #recent-updated-section { margin-bottom: 1.125rem; }
    #recent-updated-section .ru-sec-head { gap: .5rem; margin-bottom: .5rem; }
}
