/* ── Yeshiva Media Sync — Frontend Styles ── */
/* Design tokens matching merkaz-harav.org.il */

:root {
    --yps-gold:        #c9a068;
    --yps-gold-dark:   #9a7540;
    --yps-gold-light:  #f5ead8;
    --yps-navy:        #1e3a5f;
    --yps-navy-light:  #2c5282;
    --yps-text:        #1a1a1a;
    --yps-text-sub:    #555;
    --yps-text-muted:  #888;
    --yps-bg:          #fff;
    --yps-border:      #e8dcc8;
    --yps-radius:      4px;
}

/* ── Section wrapper ── */
.yps-section {
    margin: 2rem 0;
    direction: rtl;
    font-family: inherit;
}

/* ── Section title — gold style matching site headings ── */
.yps-section-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--yps-gold);
    margin: 0 0 1.25rem;
    text-align: right;
    letter-spacing: 0.02em;
}

/* ── Section header row: title + archive button ── */
.yps-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.yps-section-header .yps-section-title { margin-bottom: 0; }

.yps-archive-btn {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--yps-navy);
    text-decoration: none;
    border: 1.5px solid var(--yps-navy);
    padding: 5px 16px;
    border-radius: 20px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.yps-archive-btn:hover {
    background: var(--yps-navy);
    color: #fff;
}

/* ── Horizontal scroll row ── */
.yps-scroll-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.yps-scroll-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--yps-border) transparent;
    padding-bottom: 6px;
    flex: 1;
    min-width: 0;
}
.yps-scroll-row::-webkit-scrollbar { height: 4px; }
.yps-scroll-row::-webkit-scrollbar-track { background: transparent; }
.yps-scroll-row::-webkit-scrollbar-thumb { background: var(--yps-border); border-radius: 2px; }

/* Card inside scroll row — fixed width, never shrinks or grows */
.yps-scroll-row .yps-card {
    flex: 0 0 220px !important;
    width: 220px !important;
    max-width: 220px !important;
    scroll-snap-align: start;
    min-width: 0;
}

/* ── Scroll arrow buttons ── */
.yps-scroll-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1.5px solid var(--yps-border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--yps-navy);
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.yps-scroll-btn:hover { background: var(--yps-gold-light); border-color: var(--yps-gold); }
.yps-scroll-btn:disabled { opacity: 0.3; cursor: default; box-shadow: none; }

/* ── Grid (kept for backward compat) ── */
.yps-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}
.yps-grid--3 { grid-template-columns: repeat(3, 1fr); }
.yps-grid--2 { grid-template-columns: repeat(2, 1fr); }

/* ── Card — YouTube-style ── */
.yps-card {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

/* Thumbnail wrapper */
.yps-card__thumb {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #111;
    border-radius: 8px;
    margin-bottom: 8px;
}
.yps-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}
.yps-card:hover .yps-card__thumb img { transform: scale(1.04); }

/* Text body */
.yps-card__body {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Title — YouTube style: 14px semibold, 2 lines max */
.yps-card__title {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
    color: var(--yps-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.yps-card__title a {
    color: var(--yps-text);
    text-decoration: none;
}
.yps-card__title a:hover { color: var(--yps-gold-dark); }

/* Sub-line: rabbi name / series — small gray */
.yps-card__sub {
    font-size: 0.75rem;
    color: var(--yps-text-muted);
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hide excerpt inside scroll cards — not enough space */
.yps-scroll-row .yps-card__excerpt { display: none; }

/* Excerpt shown only in standalone grids */
.yps-card__excerpt {
    font-size: 0.78rem;
    color: var(--yps-text-sub);
    margin: 2px 0 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.yps-card__date {
    font-size: 0.7rem;
    color: var(--yps-text-muted);
    margin-top: 2px;
}

/* ── Live badge ── */
.yps-live-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #d32f2f;
    color: #fff;
    font-size: 0.70rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 2px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── Current content section — פרשת השבוע panel ── */
.yps-current-content .yps-section-title {
    font-size: 1.8rem;
    text-align: center;
    color: var(--yps-gold);
    border-bottom: 2px solid var(--yps-border);
    padding-bottom: 0.6rem;
    margin-bottom: 1.25rem;
}


/* ── Mishmar section ── */
.yps-mishmar {
    background: var(--yps-gold-light);
    border-top: 3px solid var(--yps-gold);
    padding: 1.25rem 1.5rem;
}
.yps-mishmar-header {
    text-align: center;
    margin-bottom: 1.1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--yps-border);
}
.yps-mishmar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--yps-gold-dark);
    margin: 0;
    letter-spacing: 0.03em;
}
.yps-mishmar-sub {
    font-size: 0.8rem;
    color: var(--yps-gold-dark);
    margin: 0.2rem 0 0;
    opacity: 0.75;
}
.yps-card--mishmar .yps-card__title a { color: var(--yps-gold-dark); }

/* ── Livestream section ── */
.yps-livestreams {
    background: var(--yps-navy);
    color: #fff;
    padding: 1.5rem;
    border-radius: var(--yps-radius);
}
.yps-livestreams .yps-section-title {
    color: #fff;
    font-size: 1.3rem;
    border-bottom: 1px solid rgba(255,255,255,0.25);
    padding-bottom: 0.5rem;
}
.yps-live-now h2 {
    color: #fff;
    font-size: 1.1rem;
    margin: 0 0 0.75rem;
}
.yps-live-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: #f44336;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    animation: yps-pulse 1.4s ease-in-out infinite;
}
@keyframes yps-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.85); }
}
.yps-upcoming-list h3 {
    color: rgba(255,255,255,0.75);
    font-size: 0.85rem;
    margin: 1rem 0 0.4rem;
}
.yps-upcoming-list ul { list-style: none; padding: 0; margin: 0; }
.yps-upcoming-list li {
    font-size: 0.85rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.9);
}
.yps-upcoming-list a { color: #90cdf4; text-decoration: none; }
.yps-upcoming-list a:hover { text-decoration: underline; }

.yps-upcoming-notice,
.yps-live-badge-inline {
    background: #fff8e1;
    border-right: 3px solid var(--yps-gold);
    padding: 0.5rem 0.9rem;
    font-size: 0.88rem;
    color: #5a3e00;
    margin-bottom: 0.75rem;
    border-radius: 0 var(--yps-radius) var(--yps-radius) 0;
}

/* ── Video embed ── */
.yps-video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}
/* Shorts: vertical 9:16 ratio, max 400px wide so it doesn't stretch */
.yps-video-wrapper--short {
    aspect-ratio: 9 / 16;
    max-width: 400px;
    margin: 0 auto;
}
.yps-video-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ── PDF embed ── */
.yps-pdf-wrapper { margin: 1rem 0; }
.yps-pdf-download {
    margin-top: 0.5rem;
    font-size: 0.88rem;
}
.yps-pdf-download a {
    color: var(--yps-navy-light);
    text-decoration: none;
    font-weight: 600;
}
.yps-pdf-download a:hover { text-decoration: underline; }

/* ── PDF ↔ Stream cross-links ── */
.yps-related-stream {
    margin: 1.2rem 0 0;
    padding: 0.55rem 1rem;
    background: #eaf3ff;
    border-right: 3px solid var(--yps-navy-light);
    font-size: 0.88rem;
    color: var(--yps-navy);
    border-radius: 0 var(--yps-radius) var(--yps-radius) 0;
}
.yps-related-stream a { color: var(--yps-navy); font-weight: 700; }
.yps-stream-pdf {
    margin: 1.2rem 0 0;
    padding: 0.55rem 1rem;
    background: #f0fff4;
    border-right: 3px solid #38a169;
    font-size: 0.88rem;
    color: #276749;
    border-radius: 0 var(--yps-radius) var(--yps-radius) 0;
}
.yps-stream-pdf a { color: #276749; font-weight: 700; }

/* ── Shorts section ─────────────────────────────────────────────────────── */

/* Dark container — mirrors YouTube Shorts shelf */
.yps-section.yps-shorts {
    background: #0f0f0f;
    border-radius: 10px;
    padding: 1.25rem 1.25rem 1.5rem;
}

/* Heading row: bolt icon + "Shorts" white title */
.yps-shorts-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    direction: rtl;
}
.yps-shorts-icon {
    fill: #ff0033;
    flex-shrink: 0;
}
.yps-shorts .yps-section-title {
    color: #fff;
    font-size: 1.3rem;
    margin-bottom: 0;
}

/* Arrow buttons on dark bg */
.yps-shorts .yps-scroll-btn {
    background: #2a2a2a;
    border-color: #444;
    color: #fff;
    box-shadow: none;
}
.yps-shorts .yps-scroll-btn:hover {
    background: #3a3a3a;
    border-color: #666;
}
.yps-shorts .yps-scroll-btn:disabled {
    opacity: 0.25;
}

/* Shorts scroll row — portrait cards, narrower gap */
.yps-scroll-row--shorts {
    gap: 10px;
}
.yps-scroll-row--shorts .yps-card {
    flex: 0 0 130px !important;
    width: 130px !important;
    max-width: 130px !important;
}

/* Portrait thumbnail (9:16) */
.yps-card--short .yps-card__thumb {
    aspect-ratio: 9 / 16;
    border-radius: 10px;
    margin-bottom: 7px;
}

/* Shorts badge — bottom-right of thumbnail */
.yps-shorts-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    backdrop-filter: blur(2px);
}

/* Text colours on dark bg */
.yps-card--short .yps-card__title {
    font-size: 0.8rem;
    -webkit-line-clamp: 3;
}
.yps-card--short .yps-card__title a {
    color: #f1f1f1;
}
.yps-card--short .yps-card__title a:hover { color: #fff; }
.yps-card--short .yps-card__sub {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.7rem;
}
.yps-card--short .yps-card__excerpt { display: none; }

/* Responsive Shorts */
@media (max-width: 768px) {
    .yps-scroll-row--shorts .yps-card {
        flex: 0 0 110px !important;
        width: 110px !important;
        max-width: 110px !important;
    }
}
@media (max-width: 480px) {
    .yps-scroll-row--shorts .yps-card {
        flex: 0 0 95px !important;
        width: 95px !important;
        max-width: 95px !important;
    }
    .yps-section.yps-shorts { padding: 1rem; }
}

/* ── Autoload spinner card (shown at left end while fetching) ── */
.yps-card--spinner {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    min-height: 120px;
    flex: 0 0 60px !important;
    width: 60px !important;
    max-width: 60px !important;
}
.yps-spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--yps-border);
    border-top-color: var(--yps-gold);
    border-radius: 50%;
    animation: yps-spin 0.7s linear infinite;
}
@keyframes yps-spin {
    to { transform: rotate(360deg); }
}

/* ── Archive page ── */
.yps-archive {
    font-family: inherit;
    margin: 1.5rem 0;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.yps-archive-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1.5rem;
}

/* Reuse .yps-filter-tab from admin, but define standalone here too */
.yps-filter-tab {
    display: inline-block;
    padding: 6px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--yps-navy);
    background: transparent;
    border: 1.5px solid var(--yps-border);
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.yps-filter-tab:hover,
.yps-filter-tab.is-active {
    background: var(--yps-navy);
    color: #fff;
    border-color: var(--yps-navy);
}

.yps-archive-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem 1rem;
    width: 100%;
    box-sizing: border-box;
}

/* Archive cards: hide excerpt (80 items / page — keep compact) */
.yps-archive-grid .yps-card__excerpt { display: none; }

/* Archive card — slightly tighter thumbnail */
.yps-archive-grid .yps-card__thumb {
    border-radius: 6px;
    margin-bottom: 6px;
}

/* Archive card title: one extra line allowed */
.yps-archive-grid .yps-card__title {
    font-size: 0.82rem;
    -webkit-line-clamp: 2;
}

/* Archive card sub-line */
.yps-archive-grid .yps-card__sub {
    font-size: 0.72rem;
}

/* Archive card date */
.yps-archive-grid .yps-card__date {
    font-size: 0.68rem;
    color: var(--yps-text-muted);
    margin-top: 2px;
}

.yps-archive-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2.5rem;
    justify-content: center;
    direction: rtl;
}

.yps-page-btn {
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 1.5px solid var(--yps-border);
    text-decoration: none;
    color: var(--yps-navy);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.yps-page-btn:hover,
.yps-page-btn.is-active {
    background: var(--yps-navy);
    color: #fff;
    border-color: var(--yps-navy);
}
.yps-page-ellipsis {
    align-self: center;
    color: var(--yps-text-muted);
    font-size: 0.85rem;
    padding: 0 4px;
}

.yps-archive-empty {
    text-align: center;
    color: var(--yps-text-muted);
    padding: 3rem 0;
    font-size: 1rem;
}

/* ── Responsive ── */

/* Very wide screens: 5 columns for archive (fits more content) */
@media (min-width: 1400px) {
    .yps-archive-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    .yps-grid          { grid-template-columns: repeat(3, 1fr); }
    .yps-archive-grid  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
    .yps-grid          { grid-template-columns: repeat(2, 1fr); }
    .yps-archive-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 0.75rem; }
    .yps-section-title { font-size: 1.3rem; }
    .yps-scroll-row .yps-card { flex: 0 0 168px; width: 168px; }
    .yps-scroll-btn { width: 26px; height: 26px; font-size: 1rem; }
}
@media (max-width: 480px) {
    .yps-grid          { grid-template-columns: 1fr; }
    .yps-archive-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 0.6rem; }
    .yps-section-header { flex-wrap: wrap; gap: 0.5rem; }
    .yps-scroll-row .yps-card { flex: 0 0 148px; width: 148px; }
    .yps-archive-filters { gap: 6px; }
    .yps-filter-tab { font-size: 0.75rem; padding: 5px 12px; }
    .yps-archive-grid .yps-card__title { font-size: 0.78rem; }
}
