/* =============================================================
   JSC Event Cards Grid  –  [jsc_event_cards] shortcode
   ============================================================= */

/* ---- Grid layout ------------------------------------------ */
.jsc-events-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 8px 0 32px;
}

@media (max-width: 960px) {
    .jsc-events-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
}

@media (max-width: 580px) {
    .jsc-events-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ---- Card shell ------------------------------------------- */
.jsc-event-card {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    display: flex;
    flex-direction: column;
}

/* Hover lift only where there is a real pointer — on touch the :hover state
   sticks after a tap and the card stays lifted. */
@media (hover: hover) and (pointer: fine) {
    .jsc-event-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.13);
    }

    .jsc-event-card--featured:hover {
        box-shadow: 0 10px 30px rgba(245, 158, 11, 0.30);
    }

    .jsc-event-card:hover .jsc-event-card__img {
        transform: scale(1.05);
    }
}

/* Touch feedback: a quick press-in instead of a hover lift. */
@media (hover: none) {
    .jsc-event-card:active {
        transform: scale(0.985);
        transition-duration: 0.08s;
    }
}

/* ---- Featured card ---------------------------------------- */
.jsc-event-card--featured {
    border: 2px solid #f59e0b;
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.20);
}

.jsc-event-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.jsc-event-card__link:hover {
    text-decoration: none;
    color: inherit;
}

/* ---- Flyer / image ---------------------------------------- */
.jsc-event-card__img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: linear-gradient(135deg, #1a3a6c 0%, #2d63b8 100%);
    flex-shrink: 0;
}

/* Doubled class for the same reason as the org logo below: `.elementor img
   { height: auto }` would otherwise win, and the flyer renders 1500px tall
   inside the 4:3 box, showing only a zoomed-in top-centre slice. */
.jsc-event-card .jsc-event-card__img {
    width: 100%;
    height: 100%;
    max-width: none;
    contain-intrinsic-size: none;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.jsc-event-card__img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    opacity: 0.35;
    color: #fff;
}

/* ---- Cost badge ------------------------------------------- */
.jsc-event-card__badge {
    position: absolute;
    top: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 4px 9px;
    border-radius: 6px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    line-height: 1;
}

.jsc-badge--affil {
    left: 10px;
    right: auto;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
}

.jsc-badge--free {
    right: 10px;
    background: rgba(22, 163, 74, 0.88);
    color: #fff;
}

.jsc-badge--cost {
    right: 10px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
}

.jsc-badge--featured {
    bottom: 10px;
    left: 10px;
    top: auto;
    background: rgba(217, 119, 6, 0.90);
    color: #fff;
}

/* ---- Card body -------------------------------------------- */
.jsc-event-card__body {
    padding: 15px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    flex: 1;
}

/* ---- Category tags ---------------------------------------- */
.jsc-event-card__cats {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.jsc-event-card__cat {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border-radius: 100px;
    background: #eef2ff;
    color: #3730a3;
    white-space: nowrap;
    line-height: 1.4;
}


/* ---- Event title ------------------------------------------ */
.jsc-event-card__title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.35;
    color: #111827;
    margin: -4px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Excerpt ---------------------------------------------- */
.jsc-event-card__excerpt {
    font-size: 13px;
    line-height: 1.5;
    color: #6b7280;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Meta rows -------------------------------------------- */
.jsc-event-card__meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
}

.jsc-event-card__row {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 13px;
    line-height: 1.35;
}

/* Date + venue combined row */
.jsc-event-card__date-venue {
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}

.jsc-event-card__date {
    color: #1d4ed8;
    font-weight: 600;
    white-space: nowrap;
}

/* Venue sits on its own line under the date at every width. It used to share
   the date's row behind a hard 140px cap, which truncated roughly 1 in 5 venue
   names — including on desktop, where 50-130px of the row was sitting unused
   next to the clipped text. Two lines shows ~97% of the names in full. */
.jsc-event-card__venue-group {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    flex: 1 0 100%;
    min-width: 0;
}

.jsc-event-card__venue {
    color: #4b5563;
    max-width: none;
    min-width: 0;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Keep the pin aligned to the venue's first line, not its vertical centre. */
.jsc-event-card__venue-group .jsc-meta-icon {
    margin-top: 2px;
}

/* Organizer block */
.jsc-event-card__organizer-block {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
}

.jsc-event-card__org-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.jsc-event-card__org-label {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
    line-height: 1.3;
}

.jsc-event-card__org-name {
    font-size: 14px;
    font-weight: 700;
    color: #4338ca;
    line-height: 1.3;
}

/* SVG icons */
.jsc-meta-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 1px;
    stroke: currentColor;
}

/* Organizer logo. Doubled class so it outranks Elementor's `.elementor img
   { height: auto }` (0,1,1) on Elementor-built pages like /sukkot/. Without
   that, height falls back to WP core's lazy-image placeholder
   (contain-intrinsic-size: 3000px 1500px) and the logo renders 40x1500. */
.jsc-event-card .jsc-event-card__org-logo {
    width: 40px;
    height: 40px;
    max-width: none;
    contain-intrinsic-size: 40px 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.08);
}

.jsc-event-card__org-logo--placeholder {
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jsc-event-card__org-logo--placeholder svg {
    width: 20px;
    height: 20px;
    stroke: #9ca3af;
}

/* ---- Empty state ------------------------------------------ */
.jsc-no-events {
    text-align: center;
    color: #6b7280;
    padding: 48px 20px;
    font-size: 15px;
}

/* ---- Text overflow safety --------------------------------- */
.jsc-event-card__title,
.jsc-event-card__org-name {
    overflow-wrap: anywhere;
}

/* =============================================================
   Phones
   ============================================================= */
@media (max-width: 580px) {

    .jsc-event-card {
        border-radius: 12px;
        /* One column here, so every card is within ~20px of 460 and the browser
           can skip layout/paint for the screens below the fold without the
           scroll position jumping. Deliberately not applied on the multi-column
           layouts, where real card heights vary by 150px+ and a wrong size hint
           would cause visible reflow while scrolling. */
        content-visibility: auto;
        contain-intrinsic-size: auto 460px;
    }

    /* Tighten the body so more than one card fits a screen. */
    .jsc-event-card__body {
        padding: 12px 13px 14px;
        gap: 7px;
    }

    .jsc-event-card__title {
        font-size: 17px;
        line-height: 1.3;
        margin: -2px 0 0;
    }

    /* The excerpt is the lowest-value line on a small screen — the title,
       date, venue and host already say what the event is. */
    .jsc-event-card__excerpt {
        display: none;
    }

    /* The venue's own-line layout is in the base rules now; phones just get
       slightly smaller meta text. */
    .jsc-event-card__date-venue {
        gap: 4px 8px;
        font-size: 12.5px;
    }

    /* Two chips is plenty at this width; a third wraps to a second line. */
    .jsc-event-card__cat:nth-child(n+3) {
        display: none;
    }

    .jsc-event-card__organizer-block {
        gap: 8px;
        margin-top: 6px;
        padding-top: 8px;
    }

    .jsc-event-card .jsc-event-card__org-logo {
        width: 32px;
        height: 32px;
        contain-intrinsic-size: 32px 32px;
    }

    .jsc-event-card__org-logo--placeholder svg {
        width: 16px;
        height: 16px;
    }

    .jsc-event-card__org-name {
        font-size: 13px;
    }

    /* backdrop-filter promotes every badge to its own composited layer —
       two or three per card across a long grid is a real cost on phones. */
    .jsc-event-card__badge {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .jsc-badge--affil,
    .jsc-badge--cost {
        background: rgba(15, 23, 42, 0.88);
    }

    .jsc-badge--free {
        background: #15803d;
    }

    .jsc-badge--featured {
        background: #b45309;
    }

    .jsc-no-events {
        padding: 32px 16px;
    }
}

/* ---- Reduced motion --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .jsc-event-card,
    .jsc-event-card__img {
        transition: none;
    }

    .jsc-event-card:hover,
    .jsc-event-card:active {
        transform: none;
    }

    .jsc-event-card:hover .jsc-event-card__img {
        transform: none;
    }
}

/* ---- Collapsible grid ([jsc_shabbat_cards collapsible="yes"]) ---- */
.jsc-events-more {
    margin: 0 0 8px;
}

.jsc-events-more__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 16px 20px;
    border: 1px solid #E2E8EE;
    border-radius: 12px;
    background: #F7F9FB;
    cursor: pointer;
    list-style: none;
    font-size: 19px;
    font-weight: 600;
    line-height: 1.3;
    color: #2E383F;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.jsc-events-more__summary::-webkit-details-marker {
    display: none;
}

.jsc-events-more__summary:hover {
    background: #EDF2F7;
    border-color: #92ADC5;
}

.jsc-events-more__summary:focus-visible {
    outline: 2px solid #92ADC5;
    outline-offset: 2px;
}

.jsc-events-more .jsc-events-more__chevron {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    color: #5B6770;
    transition: transform 0.2s ease;
}

.jsc-events-more[open] .jsc-events-more__chevron {
    transform: rotate(180deg);
}

.jsc-events-more[open] .jsc-events-more__summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.jsc-events-more__body .jsc-events-grid {
    padding-top: 24px;
}

@media (max-width: 580px) {
    .jsc-events-more__summary {
        padding: 14px 16px;
        font-size: 17px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .jsc-events-more .jsc-events-more__chevron {
        transition: none;
    }
}
