/* VinesOS Events 4.0 — calendar + grid listing page.
 *
 * This file holds LAYOUT ONLY (grid, calendar, popover positioning, spacing).
 *
 * Colors and fonts come from the theme tokens exposed by
 * DefaultMgr::getCssVariablesString (--vos-primary-color,
 * --vos-accent-color, --vos-background-color, --vos-button-*,
 * --vos-table-border-color) and from the existing __vos- typography
 * classes (__vos-h1..h6, __vos-p, __vos-strong, __vos-small, __vos-btn)
 * applied in itemEventBrowser_4_0.html — no font-family or color
 * declarations are repeated here.
 */

.__vos-event-page-4_0 {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px;
    box-sizing: border-box;
}

.__vos-event-page-4_0 *,
.__vos-event-page-4_0 *::before,
.__vos-event-page-4_0 *::after {
    box-sizing: border-box;
}

/* Cancel the global #vinesos-output a color rule so that card / chip text
   nodes show whatever color their own __vos- typography class provides. */
.__vos-event-page-4_0 a {
    text-decoration: none !important;
    color: inherit !important;
}

.__vos-event-page-4_0 .__vos-event-message:empty {
    display: none;
}

/* ---- Section header ---- */
.__vos-event-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0 16px;
    gap: 12px;
}

.__vos-event-section-title {
    margin: 0;
}

/* ---- Featured grid ---- */
.__vos-event-featured-section {
    margin-bottom: 16px;
}

.__vos-event-featured-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.__vos-event-featured-card,
.__vos-event-card {
    display: flex;
    flex-direction: column;
    background: var(--vos-background-color);
    border: 1px solid var(--vos-table-border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.__vos-event-featured-card:hover,
.__vos-event-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
}

.__vos-event-featured-card__image,
.__vos-event-card__image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--vos-background-color);
    overflow: hidden;
}

.__vos-event-featured-card__image img,
.__vos-event-card__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.__vos-event-featured-card__placeholder,
.__vos-event-card__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    opacity: 0.35;
}

.__vos-event-featured-card__body,
.__vos-event-card__body {
    padding: 14px 14px 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.__vos-event-featured-card__title,
.__vos-event-card__title {
    margin: 0;
}

.__vos-event-featured-card__date,
.__vos-event-card__date {
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

/* ---- Filter bar ---- */
/* ---- View toggle bar (Grid / Calendar) — sits above the search form ---- */
.__vos-event-view-toggle-bar {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin: 24px 0 12px;
}

/* The theme's Foundation base sets `button:not(.ui-datepicker-trigger), .button`
   with `background-color: black; border-color: black` at specificity (0,1,1),
   which outranks our single-class button rules (0,1,0) and turns every <button>
   on the page black. All button selectors below are scoped under
   .__vos-event-page-4_0 so they land at (0,2,0)+ and the theme tokens win — the
   same specificity trick used for a.__vos-event-calendar-event further down. */
.__vos-event-page-4_0 .__vos-event-view-toggle {
    background: var(--vos-background-color);
    color: var(--vos-normal-font-color);
    border: 1px solid var(--vos-table-border-color);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.__vos-event-page-4_0 .__vos-event-view-toggle:hover {
    border-color: var(--vos-primary-color);
}

.__vos-event-page-4_0 .__vos-event-view-toggle--active,
.__vos-event-page-4_0 .__vos-event-view-toggle--active:hover {
    background: var(--vos-primary-color);
    color: var(--vos-background-color) !important;
    border-color: var(--vos-primary-color);
}

/* ---- Search form box ---- */
.__vos-event-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--vos-background-color);
    border: 1px solid var(--vos-table-border-color);
    border-radius: 8px;
    padding: 18px 18px 16px;
    margin: 0 0 18px;
}

.__vos-event-filter-title {
    margin: 0;
    text-align: center;
}

.__vos-event-filter-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.__vos-event-filter-field {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 160px;
    min-width: 140px;
}

.__vos-event-filter-field--search {
    flex: 2 1 240px;
    min-width: 200px;
}

.__vos-event-filter-field--search .fa {
    position: absolute;
    right: 12px;
    pointer-events: none;
    opacity: 0.6;
}

.__vos-event-filter-input,
.__vos-event-filter-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--vos-table-border-color);
    border-radius: 6px;
    background: var(--vos-background-color);
    height: 40px;
    line-height: 1.2;
    outline: none;
    transition: border-color 0.15s ease;
}

.__vos-event-filter-field--search .__vos-event-filter-input {
    padding-right: 32px;
}

.__vos-event-filter-input:focus,
.__vos-event-filter-select:focus {
    border-color: var(--vos-primary-color);
}

.__vos-event-filter-date {
    min-width: 140px;
}

/* ---- Action row (Search / Reset) ---- */
.__vos-event-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.__vos-event-page-4_0 .__vos-event-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 10px 22px;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    font-weight: var(--vos-strong-font-weight, 600);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    border: 1px solid transparent;
    text-decoration: none !important;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.__vos-event-page-4_0 .__vos-event-filter-btn--primary {
    background: var(--vos-button-primary-color);
    color: var(--vos-button-font-color) !important;
    border-color: var(--vos-button-border-color, var(--vos-button-primary-color));
    margin-bottom: 0;
}

.__vos-event-page-4_0 .__vos-event-filter-btn--primary:hover,
.__vos-event-page-4_0 .__vos-event-filter-btn--primary:focus {
    background: var(--vos-button-primary-color-accent);
    color: var(--vos-button-font-color-accent) !important;
    border-color: var(--vos-button-border-color-accent, var(--vos-button-primary-color-accent));
}

.__vos-event-page-4_0 .__vos-event-filter-btn--reset {
    background: transparent;
    color: var(--vos-button-border-color, var(--vos-button-primary-color)) !important;
    border-color: var(--vos-button-border-color, var(--vos-button-primary-color));
    opacity: 0.55;
}

.__vos-event-page-4_0 .__vos-event-filter-btn--reset:hover,
.__vos-event-page-4_0 .__vos-event-filter-btn--reset:focus {
    background: var(--vos-button-primary-color);
    color: var(--vos-button-font-color) !important;
    border-color: var(--vos-button-border-color, var(--vos-button-primary-color));
    opacity: 1;
}

/* ---- Grid ---- */
.__vos-event-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 22px 18px;
}

/* ---- Badges ----
   Visual differentiation is done with the two theme palette colors:
   primary (sold out) vs accent (members only). Text comes from inherited
   color provided by the parent + the global button font color. */
.__vos-event-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    border-radius: 100px;
    background: var(--vos-primary-color);
    color: var(--vos-button-font-color) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.__vos-event-badge--soldout {
    left: auto;
    right: 10px;
}

.__vos-event-badge--members {
    background: var(--vos-accent-color);
    color: var(--vos-primary-color-dark) !important;
}

/* ---- Empty state ---- */
.__vos-event-empty {
    text-align: center;
    padding: 48px 16px;
    background: var(--vos-background-color);
    border-radius: 8px;
    border: 1px dashed var(--vos-table-border-color);
}

/* ---- Calendar ---- */
.__vos-event-calendar-section {
    margin-top: 8px;
}

.__vos-event-calendar-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 14px;
}

.__vos-event-cal-title {
    margin: 0;
    min-width: 200px;
    text-align: center;
}

.__vos-event-page-4_0 .__vos-event-cal-arrow {
    background: var(--vos-background-color);
    border: 1px solid var(--vos-table-border-color);
    width: 38px;
    height: 38px;
    border-radius: 100%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.__vos-event-page-4_0 .__vos-event-cal-arrow:hover {
    background: var(--vos-primary-color);
    color: var(--vos-button-font-color) !important;
    border-color: var(--vos-primary-color);
}

.__vos-event-page-4_0 .__vos-event-cal-arrow:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.__vos-event-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 4px;
}

.__vos-event-calendar-weekdays > div {
    text-align: center;
    padding: 8px 4px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    opacity: 0.65;
}

.__vos-event-calendar-wrap {
    position: relative;
}

.__vos-event-calendar-month {
    display: none;
}

.__vos-event-calendar-month--active {
    display: block;
}

.__vos-event-calendar-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 4px;
    position: relative;
}

.__vos-event-calendar-day {
    background: var(--vos-background-color);
    border: 1px solid var(--vos-table-border-color);
    border-radius: 6px;
    padding: 6px 6px 8px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
}

.__vos-event-calendar-day--blank {
    background: transparent;
    border: 1px dashed transparent;
}

.__vos-event-calendar-day__num {
    line-height: 1;
}

.__vos-event-calendar-day__events {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* overflow: visible — preview popover needs to escape this container */
}

.__vos-event-page-4_0 a.__vos-event-calendar-event {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #000 !important;
    border: 1px solid var(--vos-button-primary-color);
    border-radius: 4px;
    padding: 2px 5px;
    line-height: 1.25;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.__vos-event-page-4_0 a.__vos-event-calendar-event:hover {
    background: #fff;
    color: #000 !important;
    border-color: var(--vos-button-primary-color-accent);
}

.__vos-event-calendar-event__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    color: inherit !important;
}

.__vos-event-calendar-event__img {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    overflow: hidden;
    background: var(--vos-background-color);
}

.__vos-event-calendar-event__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---- Hover preview popover for calendar chips ---- */
.__vos-event-calendar-event__preview {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    width: 260px;
    background: var(--vos-background-color);
    border: 1px solid var(--vos-table-border-color);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
    display: flex;
    flex-direction: column;
    text-align: left;
    white-space: normal;
}

/* Invisible bridge so the cursor can travel from chip → popover without losing :hover. */
.__vos-event-calendar-event__preview::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
}

.__vos-event-calendar-event:hover .__vos-event-calendar-event__preview,
.__vos-event-calendar-event:focus .__vos-event-calendar-event__preview,
.__vos-event-calendar-event:focus-visible .__vos-event-calendar-event__preview {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0s;
}

.__vos-event-calendar-event__preview-img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--vos-background-color);
    overflow: hidden;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.__vos-event-calendar-event__preview-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.__vos-event-calendar-event__preview-img--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    opacity: 0.35;
}

.__vos-event-calendar-event__preview-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px 14px;
}

.__vos-event-calendar-event__preview-title,
.__vos-event-calendar-event__preview-date {
    display: block;
}

/* CTA visuals come from .__vos-btn; we only handle layout inside the column. */
.__vos-event-calendar-event__preview-cta {
    align-self: flex-start;
    margin-top: 6px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
}

/* Edge-aware popover positioning: anchor right edge for chips in cols 6-7,
   left edge for chips in cols 1-2, so the popover never runs off-screen. */
.__vos-event-calendar-week > .__vos-event-calendar-day:nth-child(6) .__vos-event-calendar-event__preview,
.__vos-event-calendar-week > .__vos-event-calendar-day:nth-child(7) .__vos-event-calendar-event__preview {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(-4px);
}

.__vos-event-calendar-week > .__vos-event-calendar-day:nth-child(6) .__vos-event-calendar-event:hover .__vos-event-calendar-event__preview,
.__vos-event-calendar-week > .__vos-event-calendar-day:nth-child(7) .__vos-event-calendar-event:hover .__vos-event-calendar-event__preview {
    transform: translateX(0) translateY(0);
}

.__vos-event-calendar-week > .__vos-event-calendar-day:nth-child(1) .__vos-event-calendar-event__preview,
.__vos-event-calendar-week > .__vos-event-calendar-day:nth-child(2) .__vos-event-calendar-event__preview {
    left: 0;
    transform: translateX(0) translateY(-4px);
}

.__vos-event-calendar-week > .__vos-event-calendar-day:nth-child(1) .__vos-event-calendar-event:hover .__vos-event-calendar-event__preview,
.__vos-event-calendar-week > .__vos-event-calendar-day:nth-child(2) .__vos-event-calendar-event:hover .__vos-event-calendar-event__preview {
    transform: translateX(0) translateY(0);
}

/* Touch devices: no hover, hide the preview to avoid stuck-open popovers. */
@media (hover: none) {
    .__vos-event-calendar-event__preview {
        display: none !important;
    }
}

/* Hidden card via JS filter */
.__vos-event-card--hidden,
.__vos-event-featured-card--hidden {
    display: none !important;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .__vos-event-featured-grid,
    .__vos-event-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .__vos-event-page-4_0 {
        padding: 12px;
    }

    .__vos-event-featured-grid,
    .__vos-event-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .__vos-event-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .__vos-event-filter-views {
        justify-content: center;
    }

    .__vos-event-view-toggle {
        flex: 1;
        justify-content: center;
    }

    .__vos-event-filter-fields {
        justify-content: stretch;
    }

    .__vos-event-filter-field {
        flex: 1 1 100%;
        min-width: 100%;
        max-width: 100%;
    }

    .__vos-event-filter-field--search {
        max-width: 100%;
    }

    .__vos-event-filter-clear {
        align-self: center;
    }

    .__vos-event-calendar-day {
        min-height: 70px;
        padding: 4px;
    }

    .__vos-event-calendar-event__title {
        display: none;
    }

    .__vos-event-calendar-event {
        justify-content: center;
        padding: 2px 4px;
    }

    .__vos-event-calendar-event__img {
        flex: 0 0 14px;
        width: 14px;
        height: 14px;
    }

    .__vos-event-calendar-weekdays > div {
        padding: 6px 2px;
    }
}

@media (max-width: 480px) {
    .__vos-event-featured-grid,
    .__vos-event-grid {
        grid-template-columns: 1fr 1fr;
    }

    .__vos-event-calendar-day {
        min-height: 48px;
    }
}
