/*
 * listen_home.css — sermonwave.com/ home page (listen/index.php 'home' mode, listen/js/listen_home.js).
 * Built on listener.css: its theme tokens (--listener-*) drive dark and light.
 * Phones: one column with 16px gutters (Listen, then Bible trivia); tablets: map on top, Listen beside Bible trivia;
 * desktop: map + Listen side by side, Sermons (an infinite list scrolling inside the card) beside Bible trivia (right
 * under Listen) and Stories.
 */

/* ---------- hero ---------- */
.listen-home__hero {
    position: relative;
    text-align: center;
    padding: 40px 16px 60px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background-size: cover;
    background-position: center;
    color: #fff;
    overflow: hidden;
}
.listen-home__hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.6) 65%, rgba(0, 0, 0, 0.78) 100%);
    z-index: 1;
}
.listen-home__hero-inner {
    position: relative;
    z-index: 2;
    max-width: 760px;
    margin: 0 auto;
}
.listen-home__eyebrow {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}
.listen-home__title {
    font-size: clamp(1.75rem, 4.6vw, 2.75rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 10px 0 12px;
    color: #fff;
    text-wrap: balance;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
.listen-home__subtitle {
    font-size: 1.0625rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.82);
    max-width: 560px;
    margin: 0 auto 26px;
}
.listen-home__learn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 56px;
    padding: 14px 32px;
    border-radius: var(--listener-radius-full);
    background: var(--listener-accent);
    color: #14110a;
    font-size: 1.125rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.listen-home__learn:hover { color: #14110a; filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4); }
.listen-home__learn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.listen-home__stats {
    margin: 18px 0 0;
    min-height: 1.4em;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}
.listen-home__stats-live { display: inline-flex; align-items: center; gap: 6px; color: #fff; font-weight: 600; }
.listen-home__credit { z-index: 2; bottom: 40px; }
@media (max-width: 767.98px) { .listen-home__credit { bottom: 36px; } }

/* ---------- grid ---------- */
.listen-home__grid {
    position: relative;
    z-index: 3;
    max-width: 1200px;
    margin: -32px auto 0;
    padding: 0 16px 48px;
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "listen" "trivia" "map" "recorded" "stories";
}
.listen-home__card--listen { grid-area: listen; }
.listen-home__card--listen > .listen-home__more { margin-top: auto; }
.listen-home__card--map { grid-area: map; }
.listen-home__card--recorded { grid-area: recorded; }
.listen-home__card--stories { grid-area: stories; }
.listen-home__card--trivia { grid-area: trivia; }

@media (min-width: 768px) {
    .listen-home__hero { padding: 52px 24px 72px; }
    .listen-home__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas: "map map" "listen trivia" "recorded stories";
        padding: 0 24px 56px;
    }
}
@media (min-width: 1024px) {
    .listen-home__grid {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        grid-template-areas: "map listen" "recorded trivia" "recorded stories";
        gap: 20px;
    }
}

/* ---------- card ---------- */
.listen-home__card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border-radius: var(--listener-radius-lg);
    background: var(--listener-bg-card);
    border: 1px solid var(--listener-border-strong);
    box-shadow: var(--listener-shadow-md);
}
.listen-home__card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.listen-home__card-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--listener-text);
}
.listen-home__card-sub,
.listen-home__card-note {
    margin: -6px 0 0;
    font-size: var(--listener-font-size-sm);
    color: var(--listener-text-muted);
}
.listen-home__card-note { margin: auto 0 0; font-size: var(--listener-font-size-xs); color: var(--listener-text-faint); }
.listen-home__empty {
    margin: 0;
    padding: 14px 4px;
    font-size: var(--listener-font-size-sm);
    color: var(--listener-text-muted);
    list-style: none;
}
.listen-home__more {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    font-size: var(--listener-font-size-sm);
    font-weight: 600;
    color: var(--listener-accent);
    text-decoration: none;
}
.listen-home__more:hover { text-decoration: underline; color: var(--listener-accent); }
.listen-home__more--head { align-self: center; }
.listen-home__chip-btn {
    min-height: 32px;
    padding: 6px 14px;
    border-radius: var(--listener-radius-full);
    border: 1px solid var(--listener-border-strong);
    background: transparent;
    color: var(--listener-text-muted);
    font: inherit;
    font-size: var(--listener-font-size-xs);
    font-weight: 600;
    cursor: pointer;
}
.listen-home__chip-btn:hover { color: var(--listener-text); border-color: var(--listener-text-faint); background: var(--listener-bg-card-hover); }

/* ---------- rows (live now, search results, recorded) ---------- */
.listen-home__list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.listen-home__list[hidden] { display: none; }
.listen-home__row,
.listen-home__sermon {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 8px 10px;
    border-radius: var(--listener-radius-md);
    border: 1px solid var(--listener-border);
    background: var(--listener-bg-elevated);
    color: var(--listener-text);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.listen-home__row:hover,
.listen-home__sermon:hover { background: var(--listener-bg-card-hover); border-color: var(--listener-border-strong); color: var(--listener-text); }
.listen-home__row:focus-visible,
.listen-home__sermon:focus-within { outline: 2px solid var(--listener-accent); outline-offset: 1px; }
.listen-home__row--live { border-color: rgba(239, 68, 68, 0.35); }
.listen-home__logo {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: var(--listener-radius-sm);
    object-fit: contain;
    background: #fff;
}
.listen-home__logo--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--listener-accent-subtle);
    color: var(--listener-accent);
    font-weight: 700;
}
.listen-home__row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.listen-home__row-name,
.listen-home__sermon-link {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--listener-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.listen-home__row-meta {
    font-size: var(--listener-font-size-xs);
    color: var(--listener-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.listen-home__live-badge {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--listener-radius-full);
    background: var(--listener-live-red);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.listen-home__live-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: listener-pulse-dot 1s ease infinite; }

/* recorded: the title link covers the row (opens the sermon); the church name is its own link above it */
.listen-home__sermons { counter-reset: none; }
.listen-home__sermon-link { text-decoration: none; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.listen-home__sermon-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.listen-home__sermon-link:focus-visible { outline: none; }
.listen-home__sermon .listen-home__row-meta { position: relative; z-index: 1; display: flex; gap: 6px; align-items: baseline; }
.listen-home__church-link { position: relative; z-index: 2; flex: 0 1 auto; min-width: 0; max-width: 62%; color: var(--listener-accent); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listen-home__sermon-when { flex: 0 0 auto; white-space: nowrap; }
.listen-home__story-cite .listen-home__church-link { max-width: none; }
.listen-home__church-link:hover { text-decoration: underline; color: var(--listener-accent); }
.listen-home__sermon-play { flex: none; color: var(--listener-text-faint); }
.listen-home__sermon:hover .listen-home__sermon-play { color: var(--listener-accent); }

/* sermons card: every public sermon in a fixed-height box that scrolls inside the card (infinite list, listen_home.js).
   Shorter than the viewport on phones so a swipe beside it still scrolls the page, and scroll chaining is left on:
   at either end of the list, the page carries on scrolling (nothing is trapped). */
.listen-home__scroll {
    position: relative;
    height: min(62vh, 460px);
    min-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: none;
    scrollbar-width: thin;
    scrollbar-color: var(--listener-border-strong) transparent;
    margin: 0 -6px;
    padding: 2px 6px;
    border-radius: var(--listener-radius-md);
}
.listen-home__scroll:focus { outline: none; }
.listen-home__scroll:focus-visible { outline: 2px solid var(--listener-accent); outline-offset: 2px; }
.listen-home__scroll::-webkit-scrollbar { width: 8px; }
.listen-home__scroll::-webkit-scrollbar-thumb { background: var(--listener-border-strong); border-radius: 8px; }
.listen-home__scroll::-webkit-scrollbar-track { background: transparent; }
.listen-home__scroll .listen-home__sermon:focus-within { outline-offset: -2px; }
.listen-home__scroll-status {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 48px;
    padding: 10px 8px 6px;
    font-size: var(--listener-font-size-xs);
    color: var(--listener-text-muted);
    text-align: center;
}
.listen-home__scroll-status[hidden] { display: none; }
.listen-home__spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--listener-border-strong);
    border-top-color: var(--listener-accent);
    animation: listen-home-spin 0.8s linear infinite;
}
.listen-home__scroll-status:not([data-state="loading"]) .listen-home__spinner { display: none; }
.listen-home__scroll-status[data-state="end"]::before,
.listen-home__scroll-status[data-state="end"]::after { content: ''; flex: 0 1 40px; height: 1px; background: var(--listener-border-strong); }
.listen-home__retry[hidden] { display: none; }
.listen-home__scroll-sentinel { height: 1px; }
@keyframes listen-home-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .listen-home__spinner { animation-duration: 2.4s; } }
@media (min-width: 768px) { .listen-home__scroll { height: 460px; } }
/* desktop: the card spans the Bible trivia + Stories rows; its list fills that height (never below 420px), but stays
   shorter than the viewport so a wheel / swipe beside it still scrolls the page */
@media (min-width: 1024px) {
    .listen-home__card--recorded .listen-home__scroll { flex: 1 1 0; height: auto; min-height: 420px; max-height: calc(100vh - 64px); }
    .listen-home__card--stories .listen-home__story-text { -webkit-line-clamp: 3; }
}

/* ---------- search ---------- */
.listen-home__search { position: relative; }
.listen-home__search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--listener-text-faint); pointer-events: none; }
.listen-home__search-input {
    width: 100%;
    min-height: 46px;
    padding: 10px 42px 10px 40px;
    border-radius: var(--listener-radius-full);
    border: 1px solid var(--listener-border-strong);
    background: var(--listener-bg-elevated);
    color: var(--listener-text);
    font: inherit;
    font-size: 16px; /* no zoom on iOS */
    -webkit-appearance: none;
    appearance: none;
}
.listen-home__search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.listen-home__search-input::placeholder { color: var(--listener-text-faint); }
.listen-home__search-input:focus { outline: none; border-color: var(--listener-accent); box-shadow: 0 0 0 3px var(--listener-accent-glow); }
.listen-home__search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--listener-text-muted);
    cursor: pointer;
}
.listen-home__search-clear[hidden] { display: none; }
.listen-home__search-clear:hover { background: var(--listener-bg-card-hover); color: var(--listener-text); }

/* ---------- map ---------- */
.listen-home__legend { display: inline-flex; gap: 12px; font-size: var(--listener-font-size-xs); color: var(--listener-text-muted); }
.listen-home__legend-item { display: inline-flex; align-items: center; gap: 6px; }
.listen-home__legend-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--listener-accent); box-shadow: 0 0 0 2px var(--listener-bg-card); }
.listen-home__legend-dot--live { background: var(--listener-live-red); animation: listener-pulse-dot 1.2s ease infinite; }
.listen-home__map {
    position: relative;
    height: 300px;
    border-radius: var(--listener-radius-md);
    overflow: hidden;
    background: var(--listener-bg-elevated);
    border: 1px solid var(--listener-border);
    z-index: 0;
}
@media (min-width: 768px) { .listen-home__map { height: 380px; } }
/* desktop: the map grows to the height of the Listen card beside it (live now + recently live), never below 340px,
   so neither card is left with a big empty space */
@media (min-width: 1024px) { .listen-home__card--map .listen-home__map { flex: 1 1 auto; min-height: 340px; height: auto; } }
.listen-home__map-note { margin: 0; min-height: 1.2em; font-size: var(--listener-font-size-xs); color: var(--listener-text-muted); }

.listen-home-pin { background: none; border: 0; }
.listen-home-pin__dot {
    position: absolute;
    left: 5px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--listener-accent);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.listen-home-pin__ring { display: none; }
.listen-home-pin--live .listen-home-pin__dot { background: var(--listener-live-red); animation: listen-home-blink 1.2s ease-in-out infinite; }
.listen-home-pin--live .listen-home-pin__ring {
    display: block;
    position: absolute;
    left: -3px;
    top: -3px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--listener-live-red);
    animation: listen-home-pulse 1.6s ease-out infinite;
}
@keyframes listen-home-pulse {
    0%   { transform: scale(0.45); opacity: 0.95; }
    100% { transform: scale(1.5); opacity: 0; }
}
@keyframes listen-home-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}
@media (prefers-reduced-motion: reduce) {
    .listen-home-pin--live .listen-home-pin__ring { animation: none; transform: scale(1); opacity: 0.6; }
    .listen-home-pin--live .listen-home-pin__dot,
    .listen-home__legend-dot--live,
    .listen-home__live-badge-dot { animation: none; }
}
.listen-home-popup { display: flex; flex-direction: column; gap: 3px; min-width: 160px; }
.listen-home-popup__name { font-size: 0.9rem; }
.listen-home-popup__place { font-size: 0.75rem; opacity: 0.75; }
.listen-home-popup__live { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 700; color: var(--listener-live-red); }
.listen-home-popup__link { margin-top: 4px; font-weight: 600; color: var(--listener-accent); text-decoration: none; }
.listen-home-popup__link:hover { text-decoration: underline; }

/* ---------- stories ---------- */
.listen-home__stories { display: flex; flex-direction: column; gap: 10px; }
.listen-home__story {
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--listener-radius-md);
    background: var(--listener-bg-elevated);
    border-left: 3px solid var(--listener-accent);
}
.listen-home__story-text {
    margin: 0 0 8px;
    font-size: var(--listener-font-size-sm);
    line-height: 1.55;
    color: var(--listener-text);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.listen-home__story-cite { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--listener-font-size-xs); color: var(--listener-text-muted); }
.listen-home__story-link { color: var(--listener-text-muted); text-decoration: none; overflow-wrap: anywhere; }
.listen-home__story-link:hover { color: var(--listener-text); text-decoration: underline; }

/* ---------- Listen card: recently live (under the live list) ---------- */
.listen-home__recent-live[hidden] { display: none; }
.listen-home__recent-live { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--listener-border); }
.listen-home__subhead { margin: 0; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--listener-text-faint); }
.listen-home__row--compact { min-height: 48px; padding: 6px 10px; }
.listen-home__row--compact .listen-home__logo { width: 32px; height: 32px; }

/* ---------- Bible trivia card: quick play (listen/css/listen_trivia.css) + score, streak and the game buttons ---------- */
.listen-home__trivia-stats { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.listen-home__trivia-stat {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--listener-radius-full);
    background: var(--listener-bg-elevated);
    border: 1px solid var(--listener-border);
    font-size: var(--listener-font-size-xs);
    color: var(--listener-text-muted);
    font-variant-numeric: tabular-nums;
}
.listen-home__trivia-stat strong { color: var(--listener-text); font-size: 0.8125rem; }
.listen-home__trivia-stat--streak { align-items: center; }
.listen-home__trivia-flame { color: var(--listener-text-faint); align-self: center; }
.listen-home__trivia-stat--streak.is-hot { border-color: var(--listener-verse-border); background: var(--listener-accent-subtle); }
.listen-home__trivia-stat--streak.is-hot .listen-home__trivia-flame { color: var(--listener-accent); }
.listen-home__trivia-gain {
    position: absolute;
    right: 6px;
    top: -4px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--listener-success);
    opacity: 0;
    pointer-events: none;
}
[data-bs-theme="light"] .listen-home__trivia-gain { color: #15803d; }
.listen-home__trivia-gain.is-on { animation: listen-home-gain 1.1s ease-out; }
@keyframes listen-home-gain {
    0%   { opacity: 0; transform: translateY(4px); }
    20%  { opacity: 1; transform: translateY(-6px); }
    100% { opacity: 0; transform: translateY(-18px); }
}
.listen-home__trivia-cta { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.listen-home__trivia-play {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 10px 18px;
    border: 0;
    border-radius: var(--listener-radius-md);
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
    color: #1a1206;
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(234, 88, 12, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.listen-home__trivia-play:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(234, 88, 12, 0.36); }
.listen-home__trivia-play:focus-visible { outline: 3px solid var(--listener-text); outline-offset: 2px; }
.listen-home__trivia-play-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.listen-home__trivia-play-label { font-size: 1.0625rem; font-weight: 800; letter-spacing: -0.01em; }
.listen-home__trivia-play-sub { font-size: 0.75rem; font-weight: 600; opacity: 0.8; }
.listen-home__trivia-daily {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 14px;
    border-radius: var(--listener-radius-md);
    border: 1px solid var(--listener-border-strong);
    background: var(--listener-bg-elevated);
    color: var(--listener-text);
    font: inherit;
    font-size: var(--listener-font-size-sm);
    font-weight: 700;
    cursor: pointer;
}
.listen-home__trivia-daily:hover { border-color: var(--listener-accent); color: var(--listener-accent); }
.listen-home__trivia-daily:focus-visible { outline: 2px solid var(--listener-accent); outline-offset: 2px; }
.listen-home__trivia-daily.is-done { color: var(--listener-text-muted); }
.listen-home__trivia-daily.is-done svg { color: var(--listener-success); }
.listen-home__trivia-play[hidden], .listen-home__trivia-daily[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
    .listen-home__trivia-gain.is-on { animation: none; opacity: 0; }
    .listen-home__trivia-play { transition: none; }
}

@media (max-width: 480px) {
    .listen-home__hero { padding: 36px 16px 56px; }
    .listen-home__learn { display: flex; width: 100%; padding: 14px 20px; font-size: 1.0625rem; }
    .listen-home__card { padding: 16px 14px; }
}
