/* ============================================================
 * Masons Events & Calendar Widget
 * ============================================================ */

.masons-ec-widget {
    position: relative;
}

.masons-ec-widget.masons-ec-loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* Two-column container. Inline grid-template-columns is set by the widget
 * (e.g. "1fr 2fr") when both modules are visible. */
.masons-ec-container {
    display: grid;
    gap: 60px;
    align-items: start;
}

/* When only one module is visible, it spans full width. */
.masons-ec-events-only .masons-ec-container,
.masons-ec-calendar-only .masons-ec-container {
    grid-template-columns: 1fr;
}

/* ==================== CALENDAR MODULE ==================== */
.masons-calendar-widget {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.masons-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.masons-calendar-nav-button {
    width: 50px;
    height: 50px;
    border: 2px solid #333;
    border-radius: 25px;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    color: #333;
}

.masons-calendar-nav-button:hover {
    background: #f0f0f0;
}

.masons-calendar-month-label {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.masons-calendar-grid {
    border: 1px solid #ddd;
    border-collapse: collapse;
    background: #fff;
    width: 100%;
    table-layout: fixed;
}

.masons-calendar-grid th {
    background: #fff;
    padding: 15px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid #ddd;
    color: #333;
}

.masons-calendar-grid td {
    width: calc(100% / 7);
    height: 80px;
    padding: 0;
    border: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
    position: relative;
}

.masons-calendar-grid-date {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 0; /* stacking context so the ::before pill sits behind the number */
    width: 100%;
    height: 100%;
    font-size: 16px;
    color: #333;
    transition: color 0.15s ease;
}

/* Circular "pill" drawn behind the day number — the day states colour this,
 * not the whole square cell, for a lighter, more legible calendar. */
.masons-calendar-grid-date[data-day]::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 68%;
    max-width: 44px;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background-color: transparent;
    transition: background-color 0.15s ease, transform 0.15s ease;
    z-index: -1;
}

.masons-calendar-grid-date[data-day] {
    cursor: pointer;
}

/* Days that have an event: soft tinted circle around the number only. */
.masons-calendar-grid-date.has-event {
    font-weight: 600;
}

.masons-calendar-grid-date.has-event::before {
    background-color: #f0d4e1;
}

/* Hover: a solid accent circle with a white number — high contrast, legible. */
.masons-calendar-grid-date[data-day]:hover,
.masons-calendar-grid-date[data-day]:focus-visible {
    color: #fff;
}

.masons-calendar-grid-date[data-day]:hover::before,
.masons-calendar-grid-date[data-day]:focus-visible::before {
    background-color: #8b1838;
}

/* Selected/active day: the whole cell is tinted AND a solid accent circle
 * sits around the white number. */
.masons-calendar-grid-date.is-selected {
    background-color: #f0d4e1;
    color: #fff;
    font-weight: 700;
}

.masons-calendar-grid-date.is-selected::before,
.masons-calendar-grid-date.is-selected:hover::before,
.masons-calendar-grid-date.is-selected:focus-visible::before {
    background-color: #8b1838;
    transform: translate(-50%, -50%) scale(1.04);
}

/* Empty padding cells are not interactive. */
.masons-calendar-grid-date.is-empty,
.masons-calendar-grid-date.is-empty:hover {
    cursor: default;
}

.masons-calendar-grid-date.is-empty::before {
    display: none;
}

.masons-calendar-grid-date:focus-visible {
    outline: none;
}

.masons-calendar-grid-date.is-selected:focus-visible::before {
    box-shadow: 0 0 0 2px #333;
}

/* ==================== CALENDAR LEGEND ==================== */
.masons-calendar-legend {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.masons-calendar-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #888;
}

/* Each swatch mirrors a real day state (see the calendar day pills above). */
.masons-calendar-legend-swatch {
    position: relative;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    box-sizing: border-box;
    background-color: transparent;
}

/* Event day: tinted circle. */
.masons-calendar-legend-swatch--event {
    background-color: #f0d4e1;
}

/* Selected day: tinted cell (rounded square) with a solid accent circle inside. */
.masons-calendar-legend-swatch--selected {
    border-radius: 5px;
    background-color: #f0d4e1;
}

.masons-calendar-legend-swatch--selected::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background-color: #8b1838;
}

/* Hover: solid accent circle. */
.masons-calendar-legend-swatch--hover {
    background-color: #8b1838;
}

/* ==================== CLEAR FILTER ==================== */
/* Shown only after a day is selected (toggled by JS). Reverts the list to the
 * currently displayed month. */
.masons-calendar-clear-filter {
    margin-top: 4px;
}

.masons-clear-filter-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #8b1838;
    border-radius: 20px;
    color: #8b1838;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.masons-clear-filter-button:hover,
.masons-clear-filter-button:focus-visible {
    background: #8b1838;
    color: #fff;
    outline: none;
}

/* ==================== EVENT LIST MODULE ==================== */
.masons-events-widget {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.masons-events-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.masons-events-title {
    font-size: 42px;
    font-weight: 300;
    letter-spacing: 1px;
    color: #333;
    margin: 0;
}

.masons-events-filter {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    font-size: 14px;
    color: #333;
}

.masons-events-filter-label {
    font-weight: 500;
}

.masons-events-filter-dropdown {
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    min-width: 150px;
}

.masons-events-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.masons-events-empty {
    color: #888;
    font-size: 15px;
}

/* ==================== EVENT CARD ==================== */
.masons-event-card {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
    transition: box-shadow 0.2s ease;
}

.masons-event-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Clickable event cards (JetPopup trigger). */
.masons-event-card.masons-event-clickable {
    cursor: pointer;
}

.masons-event-card.masons-event-clickable:hover {
    box-shadow: 0 4px 14px rgba(139, 24, 56, 0.14);
    transform: translateY(-1px);
}

.masons-event-card.masons-event-clickable:focus-visible {
    outline: 2px solid #8b1838;
    outline-offset: 2px;
}

.masons-event-date-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f5f0e8;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    min-height: 80px;
}

.masons-event-date-month {
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.masons-event-date-day {
    font-size: 32px;
    font-weight: 300;
    color: #333;
    line-height: 1;
}

/* Multi-day events: the badge shows the end date so a card that started in a
 * previous month reads as an ongoing range, not a misplaced entry. */
.masons-event-date-end {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #8b1838;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.1;
}

/* Dedicated date-range line in the card body (calendar-range icon). */
.masons-event-meta-daterange {
    font-weight: 600;
    color: #333;
}

.masons-event-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
}

.masons-event-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.masons-event-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.masons-event-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 4px 0 0;
}

.masons-event-status-badge {
    padding: 4px 12px;
    background: #f0f0e8;
    border-radius: 4px;
    font-size: 12px;
    color: #a89968;
    font-weight: 500;
    white-space: nowrap;
}

.masons-event-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: #666;
    flex-wrap: wrap;
}

.masons-event-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.masons-event-meta-icon {
    font-size: 16px;
    color: #666;
    line-height: 1;
}

/* ==================== LOAD MORE ==================== */
.masons-events-load-more {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.masons-load-more-button {
    padding: 14px 40px;
    background: linear-gradient(135deg, #8b1838 0%, #a01f47 100%);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.masons-load-more-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 24, 56, 0.3);
}

.masons-load-more-button:active {
    transform: translateY(0);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    /* Force a single column when the viewport is narrow, overriding the
     * inline grid-template-columns set for the two-module layout. */
    .masons-ec-container {
        grid-template-columns: 1fr !important;
        gap: 40px;
    }

    .masons-events-title {
        font-size: 32px;
    }
}

@media (max-width: 640px) {
    .masons-ec-container {
        gap: 24px;
    }

    .masons-events-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .masons-events-filter {
        align-items: flex-start;
        width: 100%;
    }

    .masons-events-filter-dropdown {
        width: 100%;
    }

    .masons-event-card {
        grid-template-columns: 1fr;
    }

    .masons-event-date-badge {
        min-height: auto;
        padding: 8px;
        flex-direction: row;
        gap: 8px;
    }

    .masons-event-date-day {
        font-size: 24px;
    }

    .masons-event-header {
        flex-direction: column;
    }
}
