/* ============================================================
   Single Webnovel Redesign
   Path: /wp-content/themes/jormuntl/assets/css/single-webnovel.css

   Extracted verbatim from the inline <style> block that single-webnovel.php
   used to print on every novel page (~9KB per request). Served as a file it's
   fetched once and reused across every novel page on the site.

   Additions at the bottom:
     - .wn-chapter-item is now visible by default and hidden via .is-hidden,
       instead of style="display:none" plus a per-row Alpine x-show. On a
       500-chapter novel that removed 500 reactive effects from Alpine's
       startup and eliminated the blank-list flash before it booted.
     - .wn-toc-footer / .wn-toc-toggle rules were already here but had no
       markup using them; the template now renders that control.
   ============================================================ */

[x-cloak] { display: none !important; }
.wn-page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }

.wn-breadcrumb {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    font-size: 13px; color: var(--secondary-text); margin-bottom: 20px;
}
.wn-breadcrumb a { color: var(--secondary-text); text-decoration: none; }
.wn-breadcrumb a:hover { color: var(--accent); }
.wn-breadcrumb .sep { opacity: .5; }
.wn-breadcrumb .current { color: var(--primary-text); font-weight: 500; }

.wn-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 40px;
    align-items: start;
}
@media (max-width: 900px) {
    .wn-layout { grid-template-columns: 1fr; gap: 28px; }
    .wn-left { max-width: 380px; margin: 0 auto; }
}

/* ---- Left column ---- */
.wn-left { display: flex; flex-direction: column; gap: 20px; }
.wn-cover {
    width: 100%; aspect-ratio: 3 / 4;
    border-radius: 12px; overflow: hidden;
    background: var(--accent-10, rgba(255,255,255,.05));
    box-shadow: 0 10px 30px rgba(0,0,0,.35);
    position: relative; cursor: pointer;
}
.wn-cover-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.55); opacity: 0;
    transition: opacity .2s ease; z-index: 2;
}
.wn-cover:hover .wn-cover-overlay { opacity: 1; }
.wn-cover-overlay span {
    display: inline-flex; align-items: center; gap: 8px;
    color: #fff; font-size: 15px; font-weight: 600;
    padding: 10px 20px; border-radius: 8px;
    background: rgba(255,255,255,.12); backdrop-filter: blur(4px);
}
.wn-cover-overlay svg { width: 18px; height: 18px; }
.wn-cover img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }

/* Cover lightbox */
.wn-lightbox {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.85); backdrop-filter: blur(6px);
    cursor: pointer; padding: 24px;
}
.wn-lightbox img {
    max-width: 90vw; max-height: 90vh;
    object-fit: contain; border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
    cursor: default;
}
.wn-lightbox-close {
    position: absolute; top: 16px; right: 20px;
    background: rgba(255,255,255,.12); border: none; cursor: pointer;
    color: #fff; width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; transition: background .15s;
}
.wn-lightbox-close:hover { background: rgba(255,255,255,.25); }

.wn-actions { display: flex; flex-direction: column; gap: 10px; }
.wn-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 16px; border-radius: 10px;
    font-weight: 600; font-size: 14px; cursor: pointer;
    border: 1px solid var(--border, #333);
    background: rgba(255,255,255,.04); color: var(--primary-text);
    text-decoration: none; transition: all .18s ease;
    width: 100%;
}
.wn-btn:hover { background: rgba(255,255,255,.08); transform: translateY(-1px); }
.wn-btn.primary {
    background: var(--primary-text, #fff); color: var(--bg, #111);
    border-color: transparent;
}
.wn-btn.primary:hover { background: var(--accent, #fff); }
.wn-btn[disabled] { opacity: .5; cursor: not-allowed; }
.wn-btn svg, .wn-btn i { width: 18px; height: 18px; }

.wn-meta { display: flex; flex-direction: column; gap: 2px; }
.wn-meta-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 2px; border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
    font-size: 14px;
}
.wn-meta-row:last-child { border-bottom: none; }
.wn-meta-label {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--secondary-text);
}
.wn-meta-label svg { width: 16px; height: 16px; opacity: .8; }
.wn-meta-value { color: var(--primary-text); font-weight: 500; text-align: right; }
.wn-meta-value a { color: var(--accent); text-decoration: none; }
.wn-meta-value a:hover { text-decoration: underline; }
.wn-status-pill {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    background: var(--accent-15, rgba(127, 127, 127, .18));
    color: var(--primary-text);
    border: 1px solid var(--border, rgba(127, 127, 127, .2));
    font-size: 12px; font-weight: 600;
}

.wn-genres-title {
    font-size: 15px; font-weight: 700; margin: 4px 0 10px;
    color: var(--primary-text);
}
.wn-genre-list { display: flex; flex-wrap: wrap; gap: 8px; }
.wn-genre {
    display: inline-block; padding: 6px 12px; border-radius: 999px;
    background: var(--accent-15, rgba(127, 127, 127, .15));
    color: var(--primary-text);
    border: 1px solid var(--border, rgba(127, 127, 127, .2));
    font-size: 12px; font-weight: 600; text-decoration: none;
    transition: all .15s ease;
}
.wn-genre:hover {
    background: var(--accent, #6bb6ff);
    color: var(--bg, #fff);
    border-color: transparent;
}

.wn-dmca {
    margin-top: 6px; font-size: 12px; color: var(--secondary-text);
    display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.wn-dmca:hover { color: var(--error, #e55); }
.wn-dmca svg { width: 14px; height: 14px; }

/* ---- Right column ---- */
.wn-right { min-width: 0; }
.wn-title { font-size: 32px; font-weight: 800; line-height: 1.15; margin: 0 0 8px; color: var(--primary-text); }
.wn-tagline { font-size: 16px; font-weight: 600; color: var(--secondary-text); margin: 0 0 18px; }
.wn-alt-title { font-size: 14px; font-style: italic; color: var(--secondary-text); margin: -4px 0 14px; }

.wn-stats-row {
    display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 18px;
    font-size: 13px; color: var(--secondary-text);
}
.wn-stats-row .stat { display: inline-flex; align-items: center; gap: 6px; }
.wn-stats-row .stat strong { color: var(--primary-text); font-weight: 700; }
.wn-stats-row svg { width: 16px; height: 16px; }
.wn-release-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(100,180,255,.12); color: #6bb6ff;
    font-size: 12px; font-weight: 600;
}

.wn-synopsis { font-size: 15px; line-height: 1.65; color: var(--secondary-text); margin-bottom: 16px; }
.wn-synopsis.clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.wn-see-more {
    display: inline-flex; align-items: center; gap: 4px;
    background: none; border: none; cursor: pointer;
    color: var(--primary-text); font-weight: 600; font-size: 14px; padding: 4px 0;
}
.wn-see-more svg { width: 14px; height: 14px; transition: transform .2s; }
.wn-see-more.open svg { transform: rotate(180deg); }

/* ---- Tabs ---- */
.wn-tabs {
    display: flex; gap: 24px; border-bottom: 1px solid var(--border, rgba(255,255,255,.1));
    margin: 24px 0 20px;
}
.wn-tab {
    background: none; border: none; cursor: pointer;
    padding: 12px 2px; font-size: 16px; font-weight: 700;
    color: var(--secondary-text); position: relative; transition: color .15s;
}
.wn-tab:hover { color: var(--primary-text); }
.wn-tab.active { color: var(--primary-text); }
.wn-tab.active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
    background: var(--primary-text);
}

.wn-toc-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
}
.wn-toc-count { font-size: 14px; color: var(--secondary-text); font-weight: 500; }
.wn-sort-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: none; cursor: pointer;
    color: var(--secondary-text); font-size: 13px; font-weight: 600;
    padding: 6px 10px; border-radius: 6px; transition: background .15s;
}
.wn-sort-btn:hover { background: rgba(255,255,255,.05); color: var(--primary-text); }
.wn-sort-btn svg { width: 14px; height: 14px; transition: transform .2s; }
.wn-sort-btn.is-reversed svg { transform: rotate(180deg); }

.wn-toc-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.wn-search-wrap {
    position: relative; display: flex; align-items: center;
}
.wn-search-wrap svg {
    position: absolute; left: 10px; width: 14px; height: 14px;
    color: var(--secondary-text); pointer-events: none;
}
.wn-search-input {
    padding: 7px 10px 7px 30px;
    border-radius: 8px;
    border: 1px solid var(--border, rgba(127,127,127,.25));
    background: transparent; color: var(--primary-text);
    font-size: 13px; font-weight: 500;
    width: 180px; transition: border-color .15s, width .2s;
    outline: none;
}
.wn-search-input:focus {
    border-color: var(--accent, #6bb6ff);
    width: 220px;
}
.wn-search-input::placeholder { color: var(--secondary-text); opacity: .7; }
.wn-premium-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 600; color: var(--secondary-text);
    cursor: pointer; user-select: none;
}
.wn-toggle-track {
    position: relative; width: 36px; height: 20px;
    background: rgba(255,255,255,.12); border-radius: 999px;
    transition: background .2s;
}
.wn-toggle-track.on { background: var(--accent, #6bb6ff); }
.wn-toggle-knob {
    position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; transition: transform .2s;
}
.wn-toggle-track.on .wn-toggle-knob { transform: translateX(16px); }

/* ---- Chapter list ---- */
.wn-chapter-list {
    display: flex; flex-direction: column;
    max-height: 600px; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
    /* Keeps the browser from laying out thousands of off-screen rows at once. */
    content-visibility: auto;
    contain-intrinsic-size: auto 600px;
}
.wn-chapter-list::-webkit-scrollbar { width: 6px; }
.wn-chapter-list::-webkit-scrollbar-track { background: transparent; }
.wn-chapter-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.wn-chapter-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); }
.wn-chapter-list.reverse-order { flex-direction: column-reverse; }
.wn-chapter-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 4px;
    border-bottom: 1px solid rgba(255,255,255,.04);
    text-decoration: none; color: inherit;
    transition: background .15s;
    /* Fixed row height lets the browser skip layout for off-screen rows. */
    content-visibility: auto;
    contain-intrinsic-size: auto 59px;
}
.wn-chapter-item:last-child { border-bottom: none; }
.wn-chapter-item:hover { background: rgba(255,255,255,.03); }
.wn-chapter-item.is-hidden { display: none; }
.wn-chapter-thumb {
    width: 38px; height: 38px; flex-shrink: 0;
    border-radius: 6px; overflow: hidden;
    background: var(--accent-10, rgba(255,255,255,.05));
}
.wn-chapter-thumb img { width: 100%; height: 100%; object-fit: cover; }
.wn-chapter-info { flex: 1; min-width: 0; }
.wn-chapter-title {
    font-size: 14px; font-weight: 600; color: var(--primary-text);
    margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wn-chapter-meta {
    font-size: 11px; color: var(--secondary-text);
    display: flex; align-items: center; gap: 6px;
}

/* See More toggle for chapter list */
.wn-toc-footer {
    display: flex; justify-content: center;
    margin-top: 16px; padding-top: 12px;
    border-top: 1px solid var(--border, rgba(255,255,255,.06));
}
.wn-toc-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: none; cursor: pointer;
    color: var(--primary-text); font-weight: 600; font-size: 14px;
    padding: 8px 16px; border-radius: 8px;
    transition: background .15s;
}
.wn-toc-toggle:hover { background: rgba(255,255,255,.06); }
.wn-toc-toggle svg { width: 14px; height: 14px; transition: transform .2s; }
.wn-toc-toggle.open svg { transform: rotate(180deg); }
.wn-chapter-meta .dot { opacity: .5; }
.wn-chapter-lock {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--warning, #e5a94a); font-size: 11px; font-weight: 600;
    flex-shrink: 0; white-space: nowrap;
}
.wn-chapter-lock svg { width: 13px; height: 13px; }
.wn-free-date { opacity: .85; }

.wn-toc-empty-search {
    padding: 24px 8px; text-align: center;
    color: var(--secondary-text); font-size: 14px;
}

.wn-empty { text-align: center; padding: 48px 20px; color: var(--secondary-text); }
.wn-empty h3 { color: var(--primary-text); margin: 12px 0 4px; }
