/* ================================================================
   STORY MODE — mobile-app-style theme for Stories/Seasons/Episodes
   Loads on top of site-mode.css (shares its CSS variables, .hbp-bottom-nav,
   .hbp-article-body typography, comments, and engagement bar styling).
================================================================ */

.hbp-story-mode-body {
    background: var(--hbp-gray-50, #F8FAFC);
}

/* ── App shell (top bar itself reuses .hbp-sm-header — same colors/search as site mode) ── */
.hbp-app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.hbp-app-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 700;
    text-decoration: none !important;
}
.hbp-app-btn-fill { background: var(--hbp-primary, #2563EB); color: #fff; }
.hbp-app-btn-fill:hover { background: var(--hbp-primary-dark, #1D4ED8); }

.hbp-app-main { flex: 1; padding-bottom: 56px; }
.hbp-app-footer {
    text-align: center; font-size: 11.5px; color: var(--hbp-gray-400, #94A3B8);
    padding: 24px 16px 90px;
}
.hbp-has-bottom-nav .hbp-app-footer { padding-bottom: 90px; }

/* ── Library home ────────────────────────────────────────────── */
.hbp-story-home { max-width: 960px; margin: 0 auto; padding: 16px; }
.hbp-story-section { margin-bottom: 28px; }
.hbp-story-section-title { font-size: 15px; font-weight: 800; color: var(--hbp-gray-700, #334155); margin: 0 0 12px; }

.hbp-genre-pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
.hbp-genre-pill {
    flex-shrink: 0; padding: 7px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
    background: #fff; color: var(--hbp-gray-500, #64748B); text-decoration: none !important;
    border: 1px solid var(--hbp-gray-100, #F1F5F9);
}
.hbp-genre-pill.is-active { background: var(--hbp-primary, #2563EB); color: #fff; border-color: var(--hbp-primary, #2563EB); }

.hbp-story-grid-home {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
@media (min-width: 560px) {
    .hbp-story-grid-home { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (min-width: 900px) {
    .hbp-story-grid-home { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1200px) {
    .hbp-story-grid-home { grid-template-columns: repeat(5, 1fr); }
}
.hbp-story-grid-home .hbp-story-card { display: flex; flex-direction: column; text-decoration: none !important; }
.hbp-story-grid-home .hbp-story-card-cover {
    display: block; width: 100%; aspect-ratio: 3/4; border-radius: 10px;
    background-size: cover; background-position: center; background-color: var(--hbp-gray-100, #F1F5F9);
}
.hbp-story-grid-home .hbp-story-card-cover-blank { display: block; width: 100%; height: 100%; background: var(--hbp-primary, #2563EB); border-radius: 10px; }
.hbp-story-grid-home .hbp-story-card-body { padding: 8px 2px 0; }
.hbp-story-grid-home .hbp-story-card-title { display: block; font-size: 13px; font-weight: 700; color: var(--hbp-gray-700, #334155); line-height: 1.3; }
.hbp-story-grid-home .hbp-story-card-meta { display: block; font-size: 11px; color: var(--hbp-gray-400, #94A3B8); margin-top: 2px; }

.hbp-browse-search {
    display: flex; align-items: center; gap: 10px; background: #fff;
    border: 1px solid var(--hbp-gray-100, #F1F5F9); border-radius: 10px;
    padding: 10px 14px; margin-bottom: 20px; color: var(--hbp-gray-400, #94A3B8);
}
.hbp-browse-search input { border: none; outline: none; flex: 1; font-size: 14px; color: var(--hbp-gray-700, #334155); background: transparent; }

/* ── Story detail page ───────────────────────────────────────── */
.hbp-story-detail { max-width: 720px; margin: 0 auto; }
.hbp-story-hero { position: relative; background-size: cover; background-position: center; background-color: var(--hbp-gray-800, #1E293B); }
.hbp-story-hero-tint { position: absolute; inset: 0; background: rgba(15,23,42,.72); backdrop-filter: blur(20px); }
.hbp-story-hero-content { position: relative; display: flex; gap: 16px; padding: 24px 16px; align-items: flex-end; }
.hbp-story-hero-cover {
    flex-shrink: 0; width: 108px; height: 144px; border-radius: 10px;
    background-size: cover; background-position: center; background-color: var(--hbp-gray-100, #F1F5F9);
}
.hbp-story-hero-info { padding-bottom: 4px; }
.hbp-story-hero-title { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.25; margin: 0 0 6px; }
.hbp-story-hero-synopsis { font-size: 12.5px; line-height: 1.5; color: rgba(255,255,255,.85); margin: 0 0 8px; max-width: 340px; }
.hbp-story-hero-meta { font-size: 12.5px; color: rgba(255,255,255,.8); margin: 0 0 4px; }
.hbp-story-hero-genre-link { color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(255,255,255,.4); }
.hbp-story-hero-genre-link:hover { text-decoration-color: #fff; }
.hbp-story-hero-author { font-size: 12px; color: rgba(255,255,255,.6); margin: 0; }
.hbp-story-hero-author-link { color: inherit; text-decoration: none; }
.hbp-story-hero-author-link:hover { text-decoration: underline; }

.hbp-season-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 16px 16px 4px; -webkit-overflow-scrolling: touch; }
.hbp-season-tab {
    flex-shrink: 0; padding: 7px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
    background: #fff; color: var(--hbp-gray-500, #64748B); text-decoration: none !important;
    border: 1px solid var(--hbp-gray-100, #F1F5F9);
}
.hbp-season-tab.is-active { background: var(--hbp-primary, #2563EB); color: #fff; border-color: var(--hbp-primary, #2563EB); }

.hbp-episode-list { padding: 8px 16px 32px; }
.hbp-episode-row {
    display: flex; align-items: center; gap: 12px; padding: 14px 0;
    border-bottom: 1px solid var(--hbp-gray-100, #F1F5F9);
    text-decoration: none !important;
}
.hbp-episode-row:last-child { border-bottom: none; }
.hbp-episode-row-num { flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--hbp-primary, #2563EB); width: 56px; }
.hbp-episode-row-title { flex: 1; font-size: 14px; font-weight: 600; color: var(--hbp-gray-700, #334155); }
.hbp-episode-row-lock { flex-shrink: 0; color: var(--hbp-gray-300, #CBD5E1); }
.hbp-episode-row-arrow { flex-shrink: 0; color: var(--hbp-gray-300, #CBD5E1); }

/* ── Episode reader ──────────────────────────────────────────── */
.hbp-reader-body { background: #fff; }
.hbp-reader-bar {
    position: sticky; top: 0; z-index: 500;
    display: flex; align-items: center; gap: 12px;
    height: 52px; padding: 0 8px 0 4px;
    background: var(--hbp-header-bg, #fff);
    border-bottom: 1px solid var(--hbp-gray-100, #F1F5F9);
}
/* The reading progress bar is defined once in site-mode.css at
   top:64px, which matches the standard 64px (h-16) sticky header used
   on posts/pages/story-hub. The episode reader has its own, shorter
   .hbp-reader-bar (52px) instead of that header, so it needs its own
   offset here rather than a second top-level rule in site-mode.css. */
.hbp-reader-body .hbp-read-progress {
    top: 52px;
    z-index: 501;
}
.hbp-reader-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex-shrink: 0; color: var(--hbp-header-text, var(--hbp-gray-600, #475569));
    text-decoration: none !important;
}
.hbp-reader-logo { display: inline-flex; align-items: center; flex-shrink: 0; text-decoration: none !important; margin-right: 2px; }
.hbp-reader-logo img { height: 20px; width: auto; display: block; }
.hbp-reader-logo span { font-size: 13px; font-weight: 800; color: var(--hbp-primary, #2563EB); }
.hbp-reader-bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.hbp-reader-bar-story { font-size: 12px; font-weight: 700; color: var(--hbp-gray-400, #94A3B8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbp-reader-bar-ep { font-size: 13.5px; font-weight: 700; color: var(--hbp-header-text, var(--hbp-gray-700, #334155)); }
.hbp-reader-eplist-btn {
    flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px; border: none;
    background: transparent; color: var(--hbp-header-text, var(--hbp-gray-500, #64748B)); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.hbp-reader-eplist-btn:hover { background: var(--hbp-gray-50, #F8FAFC); }

.hbp-reader-main { max-width: 680px; margin: 0 auto; padding: 8px 20px calc(88px + env(safe-area-inset-bottom, 0px)); }
.hbp-reader-ep-kicker { font-size: 12px; font-weight: 700; color: var(--hbp-primary, #2563EB); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 8px; }
.hbp-reader-title { font-size: 24px; font-weight: 800; color: var(--hbp-gray-800, #1E293B); line-height: 1.3; margin: 0 0 24px; }
.hbp-reader-body-text { font-size: 17px; line-height: 1.75; }
.hbp-reader-body-text p { margin: 0 0 14px; }

.hbp-reader-nextprev { display: flex; gap: 10px; margin: 36px 0 20px; }
.hbp-reader-nav-btn {
    flex: 1; display: flex; align-items: center; gap: 8px;
    padding: 14px 16px; border-radius: 12px; background: var(--hbp-gray-50, #F8FAFC);
    text-decoration: none !important; color: var(--hbp-gray-700, #334155);
    font-size: 13.5px; font-weight: 700; line-height: 1.3;
}
.hbp-reader-nav-next { justify-content: flex-end; text-align: right; }
.hbp-reader-nav-btn span { display: flex; flex-direction: column; overflow: hidden; }
.hbp-reader-nav-next span { align-items: flex-end; }
.hbp-reader-nav-btn small { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--hbp-gray-400, #94A3B8); }
.hbp-reader-nav-btn:hover { background: var(--hbp-primary-light, #DBEAFE); color: var(--hbp-primary-dark, #1D4ED8); }
.hbp-reader-nav-disabled { color: var(--hbp-gray-300, #CBD5E1); cursor: default; font-weight: 600; font-size: 12.5px; }

/* ── Sticky episode-number nav (single-episode.php only) ────── */
.hbp-reader-epnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 520;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--hbp-header-bg, #fff) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--hbp-gray-100, #F1F5F9);
    box-shadow: 0 -6px 20px rgba(15, 23, 42, .06);
}
.hbp-reader-epnav-arrow {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--hbp-gray-50, #F8FAFC); color: var(--hbp-gray-600, #475569);
    text-decoration: none !important; transition: background .15s ease, color .15s ease;
}
.hbp-reader-epnav-arrow:hover { background: var(--hbp-primary-light, #DBEAFE); color: var(--hbp-primary-dark, #1D4ED8); }
.hbp-reader-epnav-arrow.is-disabled { opacity: .35; pointer-events: none; }
.hbp-reader-epnav-nums { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.hbp-reader-epnav-num {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px; padding: 0 8px; border-radius: 9px;
    font-size: 13px; font-weight: 700; color: var(--hbp-gray-400, #94A3B8);
    text-decoration: none !important; transition: background .15s ease, color .15s ease;
}
.hbp-reader-epnav-num:hover { background: var(--hbp-gray-50, #F8FAFC); color: var(--hbp-gray-700, #334155); }
.hbp-reader-epnav-num.is-active { background: var(--hbp-primary, #2563EB); color: #fff; }
.hbp-reader-epnav-dot { color: var(--hbp-gray-300, #CBD5E1); font-size: 13px; line-height: 1; }

.hbp-eplist-overlay {
    position: fixed; inset: 0; z-index: 950; background: rgba(15,23,42,.5);
    display: none; align-items: flex-end;
}
.hbp-eplist-overlay.is-open { display: flex; }
.hbp-eplist-sheet {
    background: #fff; width: 100%; max-height: 72vh; border-radius: 18px 18px 0 0;
    overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 0);
}
.hbp-eplist-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--hbp-gray-100, #F1F5F9); position: sticky; top: 0; background: #fff; }
.hbp-eplist-title { font-size: 15px; font-weight: 800; color: var(--hbp-gray-700, #334155); margin: 0; }
.hbp-eplist-body { padding: 4px 20px 16px; }
.hbp-eplist-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; text-decoration: none !important; border-bottom: 1px solid var(--hbp-gray-100, #F1F5F9); }
.hbp-eplist-row:last-child { border-bottom: none; }
.hbp-eplist-row-num { flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--hbp-primary, #2563EB); width: 56px; }
.hbp-eplist-row-title { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--hbp-gray-700, #334155); }
.hbp-eplist-row.is-active .hbp-eplist-row-title { color: var(--hbp-primary, #2563EB); }
.hbp-eplist-row-current { flex-shrink: 0; font-size: 10.5px; font-weight: 700; color: var(--hbp-primary, #2563EB); text-transform: uppercase; letter-spacing: .04em; }

/* ── Plain Page + 404 ─────────────────────────────────────────── */
.hbp-story-page { max-width: 680px; margin: 0 auto; padding: 24px 20px 60px; }
.hbp-story-page-title { font-size: 22px; font-weight: 800; color: var(--hbp-gray-800, #1E293B); margin: 0 0 20px; }
.hbp-story-page-content { font-size: 15px; line-height: 1.8; color: var(--hbp-gray-600, #475569); }

.hbp-story-404 { text-align: center; padding: 80px 24px; }
.hbp-story-404-code { font-size: 48px; font-weight: 800; color: var(--hbp-gray-200, #E2E8F0); margin: 0; }
.hbp-story-404-msg { font-size: 14px; color: var(--hbp-gray-500, #64748B); margin: 8px 0 24px; }

@media (max-width: 640px) {
    .hbp-reader-nextprev { flex-direction: column; }
    .hbp-reader-nav-next { justify-content: flex-start; text-align: left; }
    .hbp-reader-nav-next span { align-items: flex-start; }
}
