/* Recently Updated page (/recently-updated) — markup: components/recently-updated/index.php.
   Colours come from the theme tokens (--c-white = ink, --c-surface …) and the viewer-accent variables
   (--zmio-accent*, set in index.php's <head>), so dark, light and every colour scheme work without extra rules.
   Text tiers use the same `--ta-b / --ta-m` formula as the rest of the site: light themes lift low-alpha text. */

.ru-page-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    /* The gate tooltips (.mk-tt::after) are invisible until hover but still count as scrollable overflow — on a narrow phone
       they made the whole page wider than the screen. Clip sideways overflow here (vertical stays visible for the tooltips). */
    overflow-x: clip;
}

/* ── heading ───────────────────────────────────────────────── */
.ru-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.ru-head-text {
    min-width: 0;
}

.ru-head .ru-seg {
    flex: none;
}

.ru-eyebrow {
    margin: 0;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgb(var(--c-violet-light) / .7);
}

.ru-h1 {
    margin: 2px 0 0;
    font-size: 1.5rem;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.02em;
    color: rgb(var(--c-white));
}

.ru-sub {
    margin: 4px 0 0;
    font-size: .875rem;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .4));
}

@media (min-width: 640px) {
    .ru-h1 {
        font-size: 1.875rem;
    }
}

/* ── grid: 1 → 2 → 3 → 4 columns ───────────────────────────── */
.ru-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

@media (min-width: 640px) {
    .ru-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .ru-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .ru-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ── card: cover on the left, series + chapters on the right ── */
/* No overflow:hidden / transform here on purpose — the gate tooltips (.mk-tt) must be able to spill out of the card. */
.ru-card {
    position: relative;
    display: flex;
    min-width: 0;
    gap: 12px;
    padding: 8px;
    border-radius: 14px;
    background: rgb(var(--c-surface));
    border: 1px solid rgb(var(--c-white) / .06);
    box-shadow: 0 4px 20px rgba(0, 0, 0, .3);
    transition: border-color .2s ease;
}

html[data-theme="light"] .ru-card {
    box-shadow: 0 2px 14px rgb(var(--c-white) / .08);
}

.ru-card:hover,
.ru-card:focus-within {
    border-color: rgba(var(--zmio-accent-rgb, 167, 139, 250), .38);
}

/* the poster: inset in the card, rounded on every corner, with the tags and the green bar laid over it */
.ru-media {
    position: relative;
    flex: 0 0 7rem;
    align-self: stretch;
    min-height: 10.5rem; /* 2:3 at minimum — taller when the chapter list is */
    overflow: hidden;
    border-radius: 10px;
    background: rgb(var(--c-white) / .05);
}

.ru-cover {
    position: absolute;
    inset: 0;
    display: block;
}

.ru-cover-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* status tag on the cover (Hiatus / Completed / Dropped) */
.ru-chips {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: calc(100% - 12px);
    pointer-events: none;
}

.ru-chip {
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid rgb(255 255 255 / .14);
    background: rgb(12 12 16 / .68);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .01em;
}

.ru-chip--hiatus,
.ru-chip--done,
.ru-chip--dropped {
    border-color: transparent;
}

.ru-chip--hiatus {
    background: #2563eb;
}

.ru-chip--done {
    background: #15803d;
}

.ru-chip--dropped {
    background: #b91c1c;
}

/* "✦ New Chapter": solid green bar across the bottom of the poster while the series' newest chapter is under a day old.
   White on a fixed green (a brand-style surface), so every theme and colour scheme reads it the same way. */
.ru-newbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 24px;
    background: #1f9e70;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .01em;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s ease;
}

.ru-newbar:hover,
.ru-newbar:focus-visible {
    background: #1a8a61;
}

.ru-newbar-ic {
    width: 13px;
    height: 13px;
    flex: none;
}

/* ── body ──────────────────────────────────────────────────── */
.ru-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 4px 4px 0;
}

.ru-title {
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: .875rem;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -.005em;
    color: rgb(var(--c-white));
}

.ru-title a {
    color: inherit;
    text-decoration: none;
    transition: color .15s ease;
}

.ru-title a:hover {
    color: rgb(var(--c-violet-light));
}

/* ── chapter rows ──────────────────────────────────────────── */
.ru-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ru-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 0 -6px;
    padding: 5px 6px;
    border-radius: 7px;
    font-size: 12px;
    line-height: 1.2;
    text-decoration: none;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .72));
    transition: background-color .15s ease, color .15s ease;
}

.ru-row:hover,
.ru-row:focus-visible {
    background: rgb(var(--c-white) / .06);
    color: rgb(var(--c-white));
}

.ru-ch {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.ru-row--paid .ru-ch {
    font-weight: 600;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .88));
}

.ru-time {
    flex: none;
    margin-left: auto;
    padding-left: 4px;
    font-size: 10.5px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .38));
}

.ru-ic {
    display: block;
    flex: none;
    width: 14px;
    height: 14px;
}

.ru-gate {
    display: inline-flex;
    align-items: center;
    flex: none;
    gap: 2px;
}

.ru-tier {
    font-size: 10px;
    font-weight: 700;
}

/* tooltips wrap at a phone-safe width instead of one long line */
.ru-gate.mk-tt::after {
    width: max-content;
    max-width: 11rem;
    white-space: normal;
    text-align: center;
}

.ru-new {
    flex: none;
    padding: 2px 5px;
    border-radius: 5px;
    font-size: 9.5px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .02em;
    color: rgb(var(--c-violet-light));
    background: rgba(var(--zmio-accent-rgb, 167, 139, 250), .14);
}

/* paid ↔ free divider: a hairline with a small "Free" label */
.ru-sep {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 3px 0;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .3));
}

.ru-sep::before,
.ru-sep::after {
    content: "";
    flex: 1 1 0;
    height: 1px;
    background: rgb(var(--c-white) / .1);
}

/* ── pager ─────────────────────────────────────────────────── */
.ru-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
}

.ru-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid rgb(var(--c-white) / .1);
    background: rgb(var(--c-white) / .05);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .6));
    transition: background-color .15s ease, color .15s ease;
}

a.ru-page:hover,
a.ru-page:focus-visible {
    background: rgb(var(--c-white) / .1);
    color: rgb(var(--c-white));
}

.ru-page.is-current {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--zmio-accent-soft, #a78bfa), var(--zmio-accent, #7c3aed));
}

.ru-page.is-disabled {
    opacity: .35;
}

.ru-arrow {
    width: 16px;
    height: 16px;
}

.ru-gap {
    min-width: 20px;
    text-align: center;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .35));
}

/* ── empty / error ─────────────────────────────────────────── */
.ru-empty {
    padding: 64px 0;
    text-align: center;
    font-size: .875rem;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .4));
}

.ru-empty a {
    color: rgb(var(--c-violet-light));
}

/* ── infinite scroll: sentinel, loading skeleton, retry, end ─ */
.ru-more[hidden],
.ru-retry[hidden],
.ru-end[hidden] {
    display: none;
}

.ru-more {
    margin-top: 14px;
}

/* load-more placeholders: only while a page is loading (.is-loading, set by recently-updated.js), and only the
   ones of the layout in use */
.ru-more .ru-skeletons,
.ru-more .ru-list-skeleton {
    display: none;
}

#recent-updated-section[data-layout="cards"] .ru-more.is-loading .ru-skeletons,
#recent-updated-section[data-layout="list"] .ru-more.is-loading .ru-list-skeleton {
    display: grid;
}

.ru-sentinel {
    height: 1px;
}

/* the loading cards use the grid's columns; only as many as fit one row are shown */
.ru-skeletons .ru-card--skel:nth-child(n+2) {
    display: none;
}

@media (min-width: 640px) {
    .ru-skeletons .ru-card--skel:nth-child(-n+2) {
        display: flex;
    }
}

@media (min-width: 1024px) {
    .ru-skeletons .ru-card--skel:nth-child(3) {
        display: flex;
    }
}

@media (min-width: 1280px) {
    .ru-skeletons .ru-card--skel:nth-child(4) {
        display: flex;
    }
}

.ru-card--skel {
    pointer-events: none;
    box-shadow: none;
}

.ru-skel {
    height: 12px;
    width: 88%;
    margin: 6px 0;
    border-radius: 6px;
    background: rgb(var(--c-white) / .07);
}

.ru-skel--title {
    height: 15px;
    width: 70%;
    margin-bottom: 14px;
}

.ru-skel--short {
    width: 62%;
}

.ru-card--skel .ru-media,
.ru-skel {
    animation: ru-pulse 1.4s ease-in-out infinite;
}

@keyframes ru-pulse {
    50% {
        opacity: .45;
    }
}

@media (prefers-reduced-motion: reduce) {

    .ru-card--skel .ru-media,
    .ru-skel {
        animation: none;
    }
}

.ru-retry {
    display: block;
    margin: 4px auto 0;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid rgb(var(--c-white) / .12);
    background: rgb(var(--c-white) / .06);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .75));
    transition: background-color .15s ease, color .15s ease;
}

.ru-retry:hover,
.ru-retry:focus-visible {
    background: rgb(var(--c-white) / .11);
    color: rgb(var(--c-white));
}

.ru-end {
    margin: 28px 0 0;
    text-align: center;
    font-size: 13px;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .35));
}

/* screen-reader-only live region (announces loading / errors) */
.ru-status {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.ru-back {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: rgb(var(--c-violet-light));
}

.ru-back:hover {
    text-decoration: underline;
}

/* ── home page: "Recently Updated" list ↔ cards toggle (components/recent-chapters/index.php, assets/scripts/recent-layout.js) ─ */
/* Both layouts are in the markup; the section's data-layout picks the one that shows. */
#recent-updated-section[data-layout="list"] .recent-updated-cards,
#recent-updated-section[data-layout="cards"] .recent-updated-content,
#recent-updated-section .ru-cards-skeleton {
    display: none;
}

/* while a page is being fetched (HTMX pagination) the placeholders of the layout in use take over */
#recent-updated-section.is-loading[data-layout="cards"] .ru-cards-skeleton {
    display: grid;
}

#recent-updated-section.is-loading .recent-updated-cards,
#recent-updated-section.is-loading[data-layout="cards"] .recent-updated-skeleton {
    display: none;
}

/* the two-button switch, same height as its neighbours */
.ru-seg {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 36px;
    box-sizing: border-box;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid rgb(var(--c-white) / .1);
    background: rgb(var(--c-white) / .05);
}

.ru-seg button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    color: rgb(var(--c-white) / calc(var(--ta-b, 0) + var(--ta-m, 1) * .5));
    transition: background-color .15s ease, color .15s ease;
}

.ru-seg button svg {
    width: 16px;
    height: 16px;
}

.ru-seg button:hover,
.ru-seg button:focus-visible {
    color: rgb(var(--c-white));
}

.ru-seg button[aria-pressed="true"] {
    color: rgb(var(--c-violet-light));
    background: rgba(var(--zmio-accent-rgb, 167, 139, 250), .18);
}

/* phones: title block and all the controls don't fit side by side — the controls drop under the title */
@media (max-width: 639px) {
    #recent-updated-section .ru-sec-head {
        flex-wrap: wrap;
    }

    #recent-updated-section .ru-sec-head .recent-updated-controls {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Touch screens have no hover, so the gate tooltips (.mk-tt::after) can never be seen there — but, invisible, they still
   widen the page when a badge sits near the edge. Drop them. */
@media (hover: none) {

    .ru-gate.mk-tt::before,
    .ru-gate.mk-tt::after {
        display: none;
    }
}
