/*
 * FFSA Event Calendar — front-end styles.
 *
 * Scoped under .ffsa-ec* so nothing leaks into the theme, and built on custom
 * properties so a theme can retint it without overriding rule by rule:
 *
 *   .ffsa-ec { --ffsa-ec-accent: #61bb46; --ffsa-ec-radius: 4px; }
 */

/*
 * The custom properties are declared on both roots. Shortcode and block output is
 * wrapped in .ffsa-ec, but the single event page's root element is .ffsa-ec-single and
 * is not nested inside it — so declaring them on .ffsa-ec alone left every var() on
 * that page resolving to nothing: no panel borders, no corner radius, category links
 * falling back to the theme's body colour.
 */
.ffsa-ec,
.ffsa-ec-single {
    --ffsa-ec-accent: #2b6cb0;
    --ffsa-ec-ink: #16202c;
    --ffsa-ec-muted: #5b6b7f;
    --ffsa-ec-line: rgba(22, 32, 44, 0.12);
    --ffsa-ec-surface: #fff;
    --ffsa-ec-surface-2: #f4f6f9;
    --ffsa-ec-radius: 10px;
    --ffsa-ec-gap: 24px;
    --ffsa-ec-cols: 3;

    /* How tall the featured image on a single event page may get. */
    --ffsa-ec-hero-max: clamp(200px, 30vw, 380px);
}

/* Typography is set only on .ffsa-ec: the single page runs the_content(), and the
   theme's own body type should win there. */
.ffsa-ec {
    color: var(--ffsa-ec-ink);

    /* Block themes often set a large body font-size (20px+). Inheriting it makes the
       cards read as oversized and wraps button labels, so the component states its
       own base and scales with the root instead. */
    font-size: 1rem;
    line-height: 1.5;
}

.ffsa-ec *,
.ffsa-ec *::before,
.ffsa-ec *::after,
.ffsa-ec-single *,
.ffsa-ec-single *::before,
.ffsa-ec-single *::after { box-sizing: border-box; }

/* ---------------------------------------------------------------- filter bar */
.ffsa-ec-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: var(--ffsa-ec-gap);
}

.ffsa-ec-filter { flex: 1 1 180px; min-width: 0; }

.ffsa-ec-filters input,
.ffsa-ec-filters select {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--ffsa-ec-line);
    border-radius: var(--ffsa-ec-radius);
    background: var(--ffsa-ec-surface);
    color: inherit;
    font-family: inherit;
    font-size: 0.92rem;
}

/* ------------------------------------------------------------------- buttons */
.ffsa-ec-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.55rem 0.95rem;
    border: 1px solid var(--ffsa-ec-line);
    border-radius: var(--ffsa-ec-radius);
    background: var(--ffsa-ec-surface);
    color: inherit;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.25;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ffsa-ec-btn:hover { background: var(--ffsa-ec-surface-2); color: inherit; }

.ffsa-ec-btn.is-primary {
    background: var(--ffsa-ec-accent);
    border-color: var(--ffsa-ec-accent);
    color: #fff;
}

.ffsa-ec-btn.is-primary:hover { filter: brightness(0.94); color: #fff; }
.ffsa-ec-btn.is-ghost { background: transparent; }

/* -------------------------------------------------------------------- badges */
.ffsa-ec-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: var(--ffsa-ec-surface-2);
    color: var(--ffsa-ec-muted);
}

.ffsa-ec-badge.is-ended { background: #e6e8ec; color: #55606e; }
.ffsa-ec-badge.is-now { background: #d8f3dc; color: #1b5e20; }
.ffsa-ec-badge.is-today { background: #fff3cd; color: #7a5b00; }
.ffsa-ec-badge.is-featured { background: #e7edff; color: #23408e; }

/* A finished event is dimmed, but stays legible — it is still information. */
.ffsa-ec-card.is-past,
.ffsa-ec-row.is-past,
.ffsa-ec-single.is-past .ffsa-ec-single-hero { opacity: 0.62; }

.ffsa-ec-card.is-past img,
.ffsa-ec-row.is-past img { filter: grayscale(0.85); }

.ffsa-ec-cat {
    display: inline-block;
    margin: 0 0.35rem 0.35rem 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ffsa-ec-accent);
}

.ffsa-ec-meta {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    margin: 0.3rem 0;
    font-size: 0.9rem;
    color: var(--ffsa-ec-muted);
}

.ffsa-ec-ico { flex: 0 0 auto; opacity: 0.75; }
.ffsa-ec-excerpt { margin: 0.6rem 0 0.9rem; font-size: 0.94rem; }

/* ---------------------------------------------------------------- grid cards */
.ffsa-ec-grid {
    display: grid;
    grid-template-columns: repeat(var(--ffsa-ec-cols), minmax(0, 1fr));
    gap: var(--ffsa-ec-gap);
}

@media (max-width: 991.98px) { .ffsa-ec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .ffsa-ec-grid { grid-template-columns: 1fr; } }

.ffsa-ec-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--ffsa-ec-line);
    border-radius: var(--ffsa-ec-radius);
    background: var(--ffsa-ec-surface);
    height: 100%;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ffsa-ec-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 34px -18px rgba(16, 24, 40, 0.4);
}

.ffsa-ec-card.is-featured { border-color: var(--ffsa-ec-accent); }

.ffsa-ec-card-media {
    position: relative;
    display: block;
    aspect-ratio: 16 / 10;
    background: var(--ffsa-ec-surface-2);
    overflow: hidden;
}

.ffsa-ec-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ffsa-ec-card-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 2rem;
    color: var(--ffsa-ec-line);
}

/* The date pill sits on the image, top-left. */
.ffsa-ec-pill {
    position: absolute;
    top: 0;
    left: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 3.2rem;
    padding: 0.4rem 0.55rem 0.5rem;
    background: rgba(20, 24, 31, 0.9);
    color: #fff;
    line-height: 1.1;
}

.ffsa-ec-pill-day { font-size: 1.15rem; font-weight: 800; }
.ffsa-ec-pill-month { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }

.ffsa-ec-card-media .ffsa-ec-badge { position: absolute; top: 10px; right: 10px; }

.ffsa-ec-card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 1rem 1.1rem 1.1rem;
}

.ffsa-ec-card-title { margin: 0.2rem 0 0.5rem; font-size: 1.08rem; line-height: 1.3; }
.ffsa-ec-card-title a { color: inherit; text-decoration: none; }
.ffsa-ec-card-title a:hover { text-decoration: underline; }

.ffsa-ec-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
}

/* ------------------------------------------------------------------- masonry */
/* CSS columns, so there is no layout library and nothing to re-run on load. */
.ffsa-ec-masonry {
    column-count: var(--ffsa-ec-cols);
    column-gap: var(--ffsa-ec-gap);
}

@media (max-width: 991.98px) { .ffsa-ec-masonry { column-count: 2; } }
@media (max-width: 575.98px) { .ffsa-ec-masonry { column-count: 1; } }

.ffsa-ec-masonry-item {
    /* Stops a card being split across two columns. */
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: var(--ffsa-ec-gap);
}

/* ---------------------------------------------------------------- list rows */
.ffsa-ec-list { display: flex; flex-direction: column; gap: 14px; }

.ffsa-ec-row {
    display: grid;
    grid-template-columns: 7.5rem 1fr auto;
    gap: 1rem;
    border: 1px solid var(--ffsa-ec-line);
    border-radius: var(--ffsa-ec-radius);
    background: var(--ffsa-ec-surface);
    overflow: hidden;
}

.ffsa-ec-row-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    padding: 1.4rem 0.75rem;
    background: var(--ffsa-ec-surface-2);
    text-align: center;
}

.ffsa-ec-row-day { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.ffsa-ec-row-month { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.85rem; }
.ffsa-ec-row-year { font-size: 0.82rem; color: var(--ffsa-ec-muted); }

.ffsa-ec-row-body { padding: 1.1rem 0.25rem 1.1rem 0; min-width: 0; }
.ffsa-ec-row-title { margin: 0.35rem 0 0.5rem; font-size: 1.2rem; line-height: 1.3; }
.ffsa-ec-row-title a { color: inherit; text-decoration: none; }
.ffsa-ec-row-title a:hover { text-decoration: underline; }

.ffsa-ec-row-action {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    justify-content: center;
    padding: 1.1rem;
}

@media (max-width: 767.98px) {
    .ffsa-ec-row { grid-template-columns: 1fr; }
    .ffsa-ec-row-date { flex-direction: row; gap: 0.5rem; padding: 0.7rem; }
    .ffsa-ec-row-day { font-size: 1.2rem; }
    .ffsa-ec-row-body { padding: 0 1rem; }
    .ffsa-ec-row-action { padding: 0 1rem 1rem; }
}

/* ------------------------------------------------------------------ calendar */
.ffsa-ec-cal {
    border: 1px solid var(--ffsa-ec-line);
    border-radius: var(--ffsa-ec-radius);
    overflow: hidden;
    background: var(--ffsa-ec-surface);
}

.ffsa-ec-cal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--ffsa-ec-line);
}

.ffsa-ec-cal-title { font-size: 1.05rem; }

.ffsa-ec-cal-nav {
    width: 44px;
    height: 44px;
    border: 1px solid var(--ffsa-ec-line);
    border-radius: 50%;
    background: var(--ffsa-ec-surface);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.ffsa-ec-cal-nav:hover { background: var(--ffsa-ec-surface-2); }

.ffsa-ec-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }

.ffsa-ec-cal-dow {
    padding: 0.5rem 0.35rem;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ffsa-ec-muted);
    border-bottom: 1px solid var(--ffsa-ec-line);
}

.ffsa-ec-cal-cell {
    min-height: 6.2rem;
    padding: 0.3rem 0.35rem;
    border-right: 1px solid var(--ffsa-ec-line);
    border-bottom: 1px solid var(--ffsa-ec-line);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ffsa-ec-cal-cell:nth-child(7n + 7) { border-right: 0; }
.ffsa-ec-cal-cell.is-outside { background: var(--ffsa-ec-surface-2); color: var(--ffsa-ec-muted); }

.ffsa-ec-cal-daynum {
    width: 1.6rem;
    height: 1.6rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 700;
}

.ffsa-ec-cal-cell.is-today .ffsa-ec-cal-daynum { background: var(--ffsa-ec-accent); color: #fff; }

.ffsa-ec-cal-event {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.12rem 0.3rem;
    border-radius: 4px;
    background: #e7edff;
    color: #23408e;
    font-size: 0.74rem;
    text-decoration: none;
    overflow: hidden;
}

.ffsa-ec-cal-event:hover { text-decoration: underline; }
.ffsa-ec-cal-event.is-past { background: #eceef1; color: #6a7583; }
.ffsa-ec-cal-time { font-weight: 700; flex: 0 0 auto; }
.ffsa-ec-cal-name { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.ffsa-ec-cal-more { font-size: 0.7rem; color: var(--ffsa-ec-muted); padding-left: 0.3rem; }
.ffsa-ec-cal-count { margin: 0; padding: 0.6rem 0.9rem; font-size: 0.85rem; color: var(--ffsa-ec-muted); }

/* On a phone a 7-column month grid is unusable, so the cells shrink and the event
   chips become dots with the title hidden. */
@media (max-width: 575.98px) {
    .ffsa-ec-cal-cell { min-height: 3.6rem; padding: 0.2rem; }
    .ffsa-ec-cal-name, .ffsa-ec-cal-time { display: none; }
    .ffsa-ec-cal-event { height: 6px; padding: 0; border-radius: 999px; }
    .ffsa-ec-cal-more { font-size: 0.62rem; }
}

/* ---------------------------------------------------------------- pagination */
.ffsa-ec-pager {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
    margin-top: var(--ffsa-ec-gap);
}

.ffsa-ec-page {
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.7rem;
    border: 1px solid var(--ffsa-ec-line);
    border-radius: var(--ffsa-ec-radius);
    background: var(--ffsa-ec-surface);
    font: inherit;
    cursor: pointer;
}

.ffsa-ec-page.is-current {
    background: var(--ffsa-ec-accent);
    border-color: var(--ffsa-ec-accent);
    color: #fff;
    font-weight: 700;
}

.ffsa-ec-page[disabled] { opacity: 0.45; cursor: default; }

/* ---------------------------------------------------------- empty + loading */
.ffsa-ec-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    border: 1px dashed var(--ffsa-ec-line);
    border-radius: var(--ffsa-ec-radius);
    background: var(--ffsa-ec-surface-2);
}

.ffsa-ec-empty-title { margin: 0 0 0.3rem; font-weight: 700; }
.ffsa-ec-empty-hint { margin: 0; color: var(--ffsa-ec-muted); font-size: 0.9rem; }

.ffsa-ec-results.is-loading { opacity: 0.55; transition: opacity 0.15s ease; }

/* ------------------------------------------------------------- single event */
/* Width and page padding come from the theme now: the event details are injected into
   the_content(), so they sit inside the theme's own content wrapper. Setting them here
   as well double-padded the column and fought the theme's measure. */
.ffsa-ec-single { margin: 0; }
.ffsa-ec-single-title { margin: 0.2rem 0 0.5rem; line-height: 1.2; }
.ffsa-ec-single-hero { margin: 1.2rem 0; }

/* A portrait featured image used to render at its full scaled height — 1774px on a
   1140px page, two screensful of photo before the first line of copy. Capped and
   centre-cropped instead; raise --ffsa-ec-hero-max if you want it taller. */
.ffsa-ec-single-hero img {
    display: block;
    width: 100%;
    height: auto;
    max-height: var(--ffsa-ec-hero-max);
    object-fit: cover;
    object-position: center;
    border-radius: var(--ffsa-ec-radius);
}
.ffsa-ec-repeat { font-style: italic; }

.ffsa-ec-single-cols {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 2rem;
}

@media (max-width: 991.98px) { .ffsa-ec-single-cols { grid-template-columns: 1fr; } }

.ffsa-ec-panel {
    border: 1px solid var(--ffsa-ec-line);
    border-radius: var(--ffsa-ec-radius);
    padding: 1.1rem;
    margin-bottom: 1.2rem;
    background: var(--ffsa-ec-surface);
}

.ffsa-ec-h2 { margin: 1.8rem 0 0.8rem; }
.ffsa-ec-h3 { margin: 0 0 0.7rem; font-size: 1.05rem; }
.ffsa-ec-dl { margin: 0 0 1rem; }
.ffsa-ec-dl dt { font-weight: 700; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ffsa-ec-muted); }
.ffsa-ec-dl dd { margin: 0 0 0.7rem; }

.ffsa-ec-map { position: relative; aspect-ratio: 4 / 3; margin-bottom: 0.8rem; }
.ffsa-ec-map iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }

.ffsa-ec-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.ffsa-ec-gallery-item img {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    .ffsa-ec-card, .ffsa-ec-btn, .ffsa-ec-results { transition: none; }
    .ffsa-ec-card:hover { transform: none; }
}
