/*
 * AGOOGI PACK C1 v1.2 — Homepage recommendation + calendar modal layer
 * Surgical scope: homepage recommendation section, homepage upcoming calendar,
 * and #agoogiPackC1Dialog only.
 *
 * No global .card, .btn, .agoogi-event-card or shared calendar rules are replaced.
 */

/* ---------------------------------------------------------------
   HOMEPAGE DISPLAY LIMITS
   Recommendations are ranked first by the existing recommendations.js.
   The homepage then exposes the top SIX recommendations in a 3 x 2 desktop
   grid. Upcoming at Agoogi remains capped at THREE live calendar events.
   --------------------------------------------------------------- */
.home-recommendations #agoogiRecommendations > .recommendation-card:nth-child(n + 7) {
    display: none !important;
}

.home-upcoming .home-event-grid > .agoogi-event-card:nth-child(n + 4) {
    display: none !important;
}

/* Explicitly preserve the agreed recommendation model: 3 x 2 on desktop,
   then the existing responsive pattern collapses cleanly on smaller screens. */
.home-recommendations #agoogiRecommendations {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
    .home-recommendations #agoogiRecommendations {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .home-recommendations #agoogiRecommendations {
        grid-template-columns: 1fr;
    }
}

/* ---------------------------------------------------------------
   GRACEFUL ENHANCEMENT
   The compact/modal appearance turns on only after JS successfully initialises.
   Without JS, the original summaries/actions remain visible and usable.
   --------------------------------------------------------------- */
.agoogi-c1-card-open,
.agoogi-c1-card-prompt {
    display: none;
}

body.agoogi-pack-c1-ready .home-recommendations .recommendation-card,
body.agoogi-pack-c1-ready .home-upcoming .agoogi-event-card {
    position: relative;
    cursor: pointer;
    isolation: isolate;
    overflow: hidden;
}

body.agoogi-pack-c1-ready .home-recommendations .agoogi-c1-card-details {
    display: none;
}

body.agoogi-pack-c1-ready .home-recommendations .agoogi-c1-card-prompt,
body.agoogi-pack-c1-ready .home-upcoming .agoogi-c1-card-prompt {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-top: .75rem;
    font-size: .9rem;
    font-weight: 700;
    color: var(--cyan, #0891b2);
}

/* Keep useful date/location context on the small calendar card, but move
   long summaries and the action buttons into the expanded modal clone. */
body.agoogi-pack-c1-ready .home-upcoming .agoogi-event-card > .agoogi-event-copy > p:not(.agoogi-event-when):not(.agoogi-event-location),
body.agoogi-pack-c1-ready .home-upcoming .agoogi-event-card .agoogi-event-actions {
    display: none;
}

body.agoogi-pack-c1-ready .home-upcoming .agoogi-event-card .agoogi-c1-card-prompt {
    grid-column: 1 / -1;
}

body.agoogi-pack-c1-ready .agoogi-c1-card-open {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: inherit;
    background: transparent;
    cursor: pointer;
}

body.agoogi-pack-c1-ready .agoogi-c1-card-open:focus-visible {
    outline: 3px solid #0891b2;
    outline-offset: -4px;
}

body.agoogi-pack-c1-ready .home-recommendations .recommendation-card.is-c1-open,
body.agoogi-pack-c1-ready .home-upcoming .agoogi-event-card.is-c1-open {
    visibility: hidden;
}

/* ---------------------------------------------------------------
   SHARED NATIVE DIALOG
   --------------------------------------------------------------- */
#agoogiPackC1Dialog {
    --agoogi-c1-overlay-alpha: 100%;
    box-sizing: border-box;
    position: fixed;
    inset: 0;
    z-index: 10050;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: clamp(1rem, 4vw, 3rem);
    border: 0;
    background: rgba(2, 6, 23, .66);
    background-color: color-mix(in srgb, #020617, transparent var(--agoogi-c1-overlay-alpha));
    overflow: auto;
    align-items: center;
    justify-content: center;
}

#agoogiPackC1Dialog[open] {
    --agoogi-c1-overlay-alpha: 34%;
    display: flex;
}

#agoogiPackC1Dialog::backdrop {
    background: transparent;
}

#agoogiPackC1Dialog .agoogi-c1-dialog__slot {
    width: min(46rem, 100%);
    margin: auto;
}

#agoogiPackC1Dialog .recommendation-card,
#agoogiPackC1Dialog .agoogi-event-card {
    position: relative;
    width: 100%;
    max-height: calc(100dvh - 4rem);
    overflow: auto;
    margin: 0;
    cursor: default;
    box-shadow: 0 28px 80px rgba(2, 6, 23, .35);
}

#agoogiPackC1Dialog .recommendation-card {
    padding: clamp(1.25rem, 3vw, 2rem);
}

#agoogiPackC1Dialog .agoogi-event-card {
    padding: clamp(1.1rem, 3vw, 1.7rem);
}

#agoogiPackC1Dialog .agoogi-c1-card-open,
#agoogiPackC1Dialog .agoogi-c1-card-prompt {
    display: none !important;
}

#agoogiPackC1Dialog .agoogi-c1-card-details,
#agoogiPackC1Dialog .agoogi-event-card > .agoogi-event-copy > p,
#agoogiPackC1Dialog .agoogi-event-actions {
    display: block;
}

#agoogiPackC1Dialog .agoogi-c1-card-details {
    margin-top: 1rem;
}

#agoogiPackC1Dialog .agoogi-c1-card-details .actions,
#agoogiPackC1Dialog .agoogi-event-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1rem;
}

#agoogiPackC1Dialog .agoogi-c1-dialog__close {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
    z-index: 3;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 999px;
    background: rgba(15,23,42,.82);
    color: #fff;
    font: inherit;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

#agoogiPackC1Dialog .agoogi-c1-dialog__close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

@media (max-width: 640px) {
    #agoogiPackC1Dialog {
        padding: 1rem;
        align-items: flex-end;
    }

    #agoogiPackC1Dialog .recommendation-card,
    #agoogiPackC1Dialog .agoogi-event-card {
        max-height: calc(100dvh - 2rem);
        border-radius: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    #agoogiPackC1Dialog,
    #agoogiPackC1Dialog * {
        scroll-behavior: auto !important;
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* ---------------------------------------------------------------
   PUBLIC /calendar/ INTEGRATION — PACK C1
   The dynamic public calendar is server-paginated at three items. This guard
   keeps the visual contract intact if its PHP limit is ever changed later.
   --------------------------------------------------------------- */
.agoogi-public-calendar-page .agoogi-event-grid > .agoogi-event-card:nth-child(n + 4) {
    display: none;
}

body.agoogi-pack-c1-ready .agoogi-public-calendar-page .agoogi-event-card {
    position: relative;
    cursor: pointer;
    isolation: isolate;
    overflow: hidden;
}

body.agoogi-pack-c1-ready .agoogi-public-calendar-page .agoogi-c1-card-prompt {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-top: .75rem;
    font-size: .9rem;
    font-weight: 700;
    color: var(--cyan, #0891b2);
}

body.agoogi-pack-c1-ready .agoogi-public-calendar-page .agoogi-event-card > .agoogi-event-copy > p:not(.agoogi-event-when):not(.agoogi-event-location),
body.agoogi-pack-c1-ready .agoogi-public-calendar-page .agoogi-event-card .agoogi-event-actions {
    display: none;
}

body.agoogi-pack-c1-ready .agoogi-public-calendar-page .agoogi-event-card.is-c1-open {
    visibility: hidden;
}

.agoogi-public-calendar-page .agoogi-calendar-pagination {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}
