/* Preach! Public Styles */
:root {
    --preach-primary:    #00226F;
    --preach-primary-h:  #41679C;
    --preach-text:       #1a2340;
    --preach-muted:      #5c6f8a;
    --preach-border:     #cdd5e2;
    --preach-bg:         #f3f6fb;
    --preach-card-bg:    #ffffff;
    --preach-radius:     10px;
    --preach-shadow:     0 1px 3px rgba(0,34,111,.07), 0 4px 12px rgba(0,34,111,.05);
    --preach-shadow-h:   0 4px 12px rgba(0,34,111,.13), 0 8px 24px rgba(0,34,111,.09);
}

#preach-app {
    font-family: inherit;
    color: var(--preach-text);
}

/* ---- Toolbar ---- */
.preach-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.preach-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.preach-search {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 14px;
    border: 1px solid var(--preach-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.preach-search:focus {
    border-color: var(--preach-primary);
    box-shadow: 0 0 0 3px rgba(0,34,111,.15);
}

.preach-filters select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--preach-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235c6f8a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
    outline: none;
    transition: border-color .15s;
    flex: 1 1 0;
    min-width: 0;
}
.preach-filters select:focus {
    border-color: var(--preach-primary);
}

.preach-view-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.preach-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--preach-border);
    border-radius: 6px;
    background: #fff;
    color: var(--preach-muted);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    margin-bottom: 20px;
}
.preach-view-btn:hover,
.preach-view-btn.is-active {
    background: var(--preach-primary);
    border-color: var(--preach-primary);
    color: #fff;
}

/* ---- Grid View ---- */
.preach-grid {
    display: grid;
    grid-template-columns: repeat(var(--preach-grid-cols, 3), 1fr);
    gap: 20px;
}

#preach-app.is-list .preach-grid {
    grid-template-columns: 1fr;
    gap: 12px;
}

/* ---- Card ---- */
.preach-card {
    background: var(--preach-card-bg);
    border: 1px solid var(--preach-border);
    border-radius: var(--preach-radius);
    box-shadow: var(--preach-shadow);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
    display: flex;
    flex-direction: column;
}
.preach-card:hover {
    box-shadow: var(--preach-shadow-h);
    transform: translateY(-2px);
}

.preach-card-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    background: var(--preach-bg);
}

.preach-card-thumb-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #dce6f5 0%, #c8d8ee 100%);
}

.preach-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preach-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.preach-card-date {
    font-size: 12px;
    font-weight: 500;
    color: var(--preach-primary);
}

.preach-card-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--preach-text);
    margin: 0;
}

.preach-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 13px;
    color: var(--preach-muted);
}

.preach-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
    text-decoration: none;
}

.preach-tag-preacher {
    background: #e6edf9;
    color: #00226F;
}
.preach-tag-preacher:hover { background: #d0dcf0; }

.preach-tag-service {
    background: #fef5e0;
    color: #8a6010;
}
.preach-tag-service:hover { background: #fdecc4; }

.preach-tag-series {
    background: #dfe9f5;
    color: #41679C;
}
.preach-tag-series:hover { background: #c8d8ec; }

#preach-app.is-grid .preach-tag-series { display: none; }

.preach-card-duration {
    font-size: 12px;
    font-weight: 500;
    color: var(--preach-muted);
}

.preach-card-citations {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

#preach-app .preach-tag-citation {
    background: transparent;
    color: #4a5568;
    border: 1px solid #9aa3b0;
    text-decoration: none;
}
#preach-app .preach-tag-citation:hover { background: #f3f6fb; }

/* ---- Card footer (audio + video actions) ---- */
.preach-card-footer {
    padding-top: 10px;
    border-top: 1px solid var(--preach-border);
    margin-top: 8px;
}

#preach-app.is-grid .preach-card-footer {
    margin-top: auto;
}

/* ---- Audio Player ---- */
.preach-audio-player {
    margin-top: 0;
}

.preach-audio-player audio {
    width: 100%;
    height: 36px;
    outline: none;
    border-radius: 4px;
    accent-color: var(--preach-primary);
}

.preach-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.preach-btn-video {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: var(--preach-primary);
    color: #fff;
    transition: background .15s;
}
.preach-btn-video:hover {
    background: var(--preach-primary-h);
}

/* ---- Grid View extras ---- */
#preach-app.is-grid .preach-card-title {
    border-bottom: 1px solid var(--preach-border);
    padding-bottom: 8px;
    margin-bottom: 2px;
}

/* ---- List View ---- */
#preach-app.is-list .preach-card {
    flex-direction: row;
    align-items: stretch;
}

#preach-app.is-list .preach-card-thumb,
#preach-app.is-list .preach-card-thumb-placeholder {
    width: 320px;
    min-width: 320px;
    aspect-ratio: unset;
    height: auto;
    align-self: stretch;
}

#preach-app.is-list .preach-card-body {
    padding: 14px 16px;
}

#preach-app.is-list .preach-audio-player audio {
    height: 32px;
}

#preach-app.is-list .preach-card-footer {
    width: 100%;
}

/* ---- Pagination ---- */
.preach-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.preach-page-btn {
    padding: 7px 14px;
    border: 1px solid var(--preach-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: var(--preach-text);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.preach-page-btn:hover:not(:disabled) {
    background: var(--preach-primary);
    border-color: var(--preach-primary);
    color: #fff;
}
.preach-page-btn.is-current {
    background: var(--preach-primary);
    border-color: var(--preach-primary);
    color: #fff;
    cursor: default;
}
.preach-page-btn:disabled {
    opacity: .4;
    cursor: default;
}

.preach-page-ellipsis {
    padding: 0 4px;
    color: #8899b0;
    line-height: 36px;
}

/* ---- Login notice ---- */
.preach-login-notice {
    padding: 24px;
    margin-top: 4em;
    margin-bottom: 12em;
    text-align: center;
    color: var(--preach-muted);
    font-size: 15px;
}

.preach-login-notice a {
    color: var(--preach-primary);
    text-decoration: underline;
}

/* ---- Loading / Empty ---- */
.preach-loading,
.preach-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--preach-muted);
    font-size: 15px;
    width: 100%;
    grid-column: 1 / -1;
}

.preach-loading::before {
    content: '';
    display: block;
    width: 36px;
    height: 36px;
    margin: 0 auto 14px;
    border: 3px solid var(--preach-border);
    border-top-color: var(--preach-primary);
    border-radius: 50%;
    animation: preachSpin .7s linear infinite;
}

@keyframes preachSpin { to { transform: rotate(360deg); } }

/* ---- Video Modal ---- */
.preach-video-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preach-video-modal[hidden] { display: none !important; }

.preach-video-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.75);
}

.preach-video-container {
    position: relative;
    z-index: 1;
    width: min(90vw, 900px);
    background: #000;
    border-radius: var(--preach-radius);
    overflow: hidden;
}

.preach-video-player {
    width: 100%;
    aspect-ratio: 16/9;
    display: block;
}

.preach-video-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    background: rgba(0,0,0,.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.preach-video-close:hover { background: rgba(0,0,0,.9); }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .preach-toolbar { flex-direction: column; align-items: stretch; }
    .preach-view-controls { justify-content: flex-end; }

    .preach-grid { grid-template-columns: 1fr; }

    #preach-app.is-list .preach-card { flex-direction: column; }
    #preach-app.is-list .preach-card-thumb,
    #preach-app.is-list .preach-card-thumb-placeholder {
        width: 100%;
        aspect-ratio: 16/9;
    }
}

@media (min-width: 641px) and (max-width: 900px) {
    .preach-grid { grid-template-columns: repeat(2, 1fr); }
}
