/*
 * ABIFF Lodge Events — Shortcode Styles
 * Lodge color palette: gold #aa8e4c · black #000 · white #fff
 * All classes are namespaced .abiff-* — no conflicts with WP core or themes.
 *
 * ── Easy overrides (paste into WordPress Customizer › Additional CSS) ──────
 *
 *   Card title size:
 *   .abiff-card__title { font-size: 1.5rem; }
 *
 *   Gold accent color:
 *   .abiff-card__type, .abiff-event__type,
 *   .abiff-card__detail .abiff-icon, .abiff-event__meta-row .abiff-icon,
 *   .abiff-type-icon { color: #aa8e4c; }
 *   .abiff-register-btn:hover { background: #aa8e4c; }
 *
 *   Grid column count:
 *   .abiff-events__grid { grid-template-columns: repeat(3, 1fr); }
 *
 *   Max width:
 *   .abiff-events__grid { max-width: 860px; }
 */

/* ── Shared ──────────────────────────────────────────────────────────────── */
.abiff-events {
    font-family: inherit;
    line-height: 1.5;
    color: #000;
}

.abiff-events__heading {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
    color: #000;
}

.abiff-events__empty,
.abiff-events__error {
    color: #6b7280;
    font-style: italic;
    padding: 1rem 0;
}

/* ── Badge (category pill) ───────────────────────────────────────────────── */
.abiff-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.2em 0.65em;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1.6;
}
.abiff-badge--blue   { background: #dbeafe; color: #1e40af; }
.abiff-badge--purple { background: #ede9fe; color: #5b21b6; }
.abiff-badge--gold   { background: #fef3c7; color: #92400e; }
.abiff-badge--green  { background: #d1fae5; color: #065f46; }
.abiff-badge--gray   { background: #f3f4f6; color: #374151; }

/* ── Shared icon sizing ──────────────────────────────────────────────────── */
.abiff-icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.125em;
    flex-shrink: 0;
}

.abiff-type-icon {
    width: 1.125em;
    height: 1.125em;
    display: inline-block;
    vertical-align: -0.125em;
    flex-shrink: 0;
    color: #aa8e4c;
}

/* ── Register button (shared across list + cards) ────────────────────────── */
.abiff-register-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    background: #000;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.55em 1.1em;
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    border: none;
    line-height: 1.4;
}
.abiff-register-btn:hover,
.abiff-register-btn:focus {
    background: #aa8e4c;
    color: #fff;
    text-decoration: none;
    outline: 2px solid #aa8e4c;
    outline-offset: 2px;
}

/* ── Featured hero card ──────────────────────────────────────────────────── */
.abiff-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s, transform 0.15s;
}

.abiff-hero:hover {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    transform: translateY(-1px);
}

.abiff-hero__img-wrap {
    overflow: hidden;
    background: #000;
    min-height: 260px;
}

.abiff-hero__img-wrap--empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.abiff-hero__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.3s;
}

.abiff-hero:hover .abiff-hero__img {
    transform: scale(1.03);
}

.abiff-hero__img-placeholder {
    color: #c9931a;
    opacity: 0.4;
    font-size: 3rem;
}

.abiff-hero__body {
    padding: 2rem 2rem 2rem;
    display: flex;
    flex-direction: column;
}

.abiff-hero__type {
    display: flex;
    align-items: center;
    gap: 0.35em;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #aa8e4c;
    margin-bottom: 0.4rem;
}

.abiff-hero__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #000;
    margin: 0 0 0.75rem;
    line-height: 1.25;
}

.abiff-hero__details {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
}

.abiff-hero__detail {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #374151;
}

.abiff-hero__detail .abiff-icon {
    color: #aa8e4c;
    margin-top: 0.1em;
    flex-shrink: 0;
}

.abiff-hero__detail-sub {
    display: block;
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.1em;
}

.abiff-hero__desc {
    font-size: 0.9rem;
    color: #4b5563;
    margin-bottom: 1.25rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.abiff-hero__desc p { margin: 0 0 0.4em; }
.abiff-hero__desc p:last-child { margin: 0; }

.abiff-hero__cta {
    margin-top: auto;
}

.abiff-register-btn--soon {
    background: #9ca3af;
    cursor: default;
    pointer-events: none;
    font-size: 0.8rem;
}

@media (max-width: 900px) {
    .abiff-hero {
        grid-template-columns: 1fr;
    }
    .abiff-hero__img-wrap {
        min-height: unset;
        aspect-ratio: 4 / 3;
    }
    .abiff-hero__body {
        padding: 1.25rem 1.25rem 1.5rem;
    }
    .abiff-hero__title {
        font-size: 1.4rem;
    }
}

/* ── Card grid (mode="cards") ────────────────────────────────────────────── */
.abiff-events__grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1.5rem !important;
    align-items: start !important;
    width: 100%;
    max-width: none;
}

.abiff-events--cards > .abiff-events__grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
}

@media (max-width: 640px) {
    .abiff-events__grid {
        grid-template-columns: 1fr !important;
    }
}

/* ── Single card ─────────────────────────────────────────────────────────── */
.abiff-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    transition: box-shadow 0.2s, transform 0.15s;
}

.abiff-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.11);
    transform: translateY(-1px);
}

/* Card image */
.abiff-card__img-wrap {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
    flex-shrink: 0;
}

.abiff-card__img-wrap--empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.abiff-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}

.abiff-card:hover .abiff-card__img {
    transform: scale(1.04);
}

.abiff-card__img-placeholder {
    color: #c9931a;
    opacity: 0.4;
    font-size: 2rem;
}

/* Card body */
.abiff-card__body {
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0;
}

/* Event type row */
.abiff-card__type {
    display: flex;
    align-items: center;
    gap: 0.35em;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #aa8e4c;
    margin-bottom: 0.3rem;
}

/* Title */
.abiff-card__title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #000;
    margin: 0 0 0.6rem;
    line-height: 1.3;
}

/* Date / location detail rows */
.abiff-card__details {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}

.abiff-card__detail {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #374151;
}

.abiff-card__detail .abiff-icon {
    color: #aa8e4c;
    margin-top: 0.1em;
    flex-shrink: 0;
}

.abiff-card__detail-sub {
    display: block;
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.1em;
}

/* Description (clamped to 4 lines) */
.abiff-card__desc {
    font-size: 0.875rem;
    color: #4b5563;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.abiff-card__desc p { margin: 0 0 0.4em; }
.abiff-card__desc p:last-child { margin: 0; }

/* CTA — pinned to bottom */
.abiff-card__cta {
    margin-top: auto;
    padding-top: 0.5rem;
}

.abiff-card__flyers {
    margin-top: 0.55rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.abiff-card__flyers a {
    font-size: 0.78rem;
    color: #6b7280;
    text-decoration: underline;
}

.abiff-card__flyers a:hover,
.abiff-card__flyers a:focus {
    color: #aa8e4c;
}

/* ── List mode ───────────────────────────────────────────────────────────── */
.abiff-events__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: 760px;
}

/* Single list item */
.abiff-event {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s;
}

.abiff-event:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

/* List item image — full width banner */
.abiff-event__img-wrap {
    aspect-ratio: 21 / 6;
    overflow: hidden;
    background: #000;
}

@media (max-width: 768px) {
    .abiff-event__img-wrap {
        aspect-ratio: 16 / 6;
    }
}

@media (max-width: 480px) {
    .abiff-event__img-wrap {
        aspect-ratio: 16 / 9;
    }
}

.abiff-event__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
    display: block;
}

/* List item body */
.abiff-event__body {
    padding: 1rem 1.25rem 1.25rem;
}

.abiff-event__type {
    display: flex;
    align-items: center;
    gap: 0.35em;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #aa8e4c;
    margin-bottom: 0.35rem;
}

.abiff-event__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.abiff-event__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #000;
    margin: 0;
    line-height: 1.35;
    flex: 1;
    min-width: 0;
}

.abiff-event__meta {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #374151;
    margin-bottom: 0.6rem;
}

.abiff-event__meta-row {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
}

.abiff-event__meta-row .abiff-icon {
    color: #aa8e4c;
    margin-top: 0.1em;
    flex-shrink: 0;
}

.abiff-event__meta-sub {
    font-size: 0.78rem;
    color: #6b7280;
    display: block;
}

.abiff-event__desc {
    font-size: 0.875rem;
    color: #4b5563;
    margin: 0.5rem 0 0.75rem;
}

.abiff-event__desc p { margin: 0 0 0.4em; }
.abiff-event__desc p:last-child { margin: 0; }

@media (max-width: 480px) {
    .abiff-event__header {
        flex-direction: column;
    }
}

/* ── Modal overlay ───────────────────────────────────────────────────────── */
#abiff-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#abiff-modal[aria-hidden="false"] {
    display: flex;
}

.abiff-modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    animation: abiffFadeIn 0.2s ease;
}

.abiff-modal__box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 980px;
    height: 92vh;
    height: calc(100dvh - 2rem);
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
    animation: abiffSlideUp 0.25s ease;
}

.abiff-modal__media {
    flex: 1;
    min-height: 0;
    position: relative;
    background: #000;
    overflow: hidden;
    overscroll-behavior: contain;
}

/* Header bar — houses the close button, keeps it off the form content */
.abiff-modal__header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.55rem 0.75rem 0.55rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
    min-height: 48px;
    position: relative;
    z-index: 2;
}

.abiff-modal__close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #374151;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    touch-action: manipulation;
}

.abiff-modal__close:hover {
    background: #000;
    color: #fff;
    border-color: #000;
}

.abiff-modal__loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #000;
    z-index: 2;
}

.abiff-modal__loader.is-hidden {
    display: none;
}

.abiff-modal__loader span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #aa8e4c;
    animation: abiff-bounce 1.2s ease-in-out infinite;
}

.abiff-modal__loader span:nth-child(2) { animation-delay: 0.2s; }
.abiff-modal__loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes abiff-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1;   }
}

#abiff-modal-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: #fff;
    min-height: 0; /* prevents flex overflow on some browsers */
}

#abiff-modal-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    background: #000;
}

/* Prevent body scroll when modal is open */
body.abiff-modal-open {
    overflow: hidden;
}

@keyframes abiffFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes abiffSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Responsive tweaks ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
    #abiff-modal {
        padding: 0;
    }

    .abiff-modal__box {
        height: 100dvh;
        max-height: 100dvh;
        width: 100vw;
        max-width: none;
        border-radius: 0;
        align-self: stretch;
        margin: 0;
        animation: abiffSlideUpMobile 0.25s ease;
    }

    .abiff-modal__header {
        padding: calc(0.45rem + env(safe-area-inset-top)) calc(0.6rem + env(safe-area-inset-right)) 0.45rem calc(1rem + env(safe-area-inset-left));
        min-height: 52px;
        position: sticky;
        top: 0;
    }

    .abiff-modal__close {
        width: 44px;
        height: 44px;
    }

    #abiff-modal-frame,
    #abiff-modal-image {
        min-height: 0;
    }
}

@media (max-width: 480px) {
    .abiff-modal__box {
        animation: abiffSlideUpMobile 0.25s ease;
    }
    @keyframes abiffSlideUpMobile {
        from { opacity: 0; transform: translateY(100%); }
        to   { opacity: 1; transform: translateY(0);    }
    }
}
