/* ===========================
   Modal Overlay (glassy)
=========================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px;
    z-index: 1000;

    backdrop-filter: blur(12px) brightness(0.75);
    background: rgba(0,0,0,0.25);

    overflow-y: auto; /* <-- allow vertical scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior: contain; /* Prevent scroll chaining */
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===========================
   Modal Content Wrapper
=========================== */
.modal-content {
    width: 100%;
    max-width: 620px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-radius: 22px;
    padding: 0;
    position: relative;
    margin: auto;
    min-height: min-content; /* Prevent unnecessary height */
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}


/* Close Button */
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 2rem;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.modal-close:hover,
.modal-close:active {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* ===========================
   Card Base (glassy)
=========================== */
.modal-card {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(10px);

    padding: 24px;
    border-radius: 18px;

    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden; /* Prevent content overflow */
}

/* ===========================
   Header Card
=========================== */
.modal-title {
    font-size: 2rem;
    margin: 0;
    font-weight: 700;
}

.modal-date {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
}

.modal-description {
    color: white;
    line-height: 1.5;
}

.modal-price-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.price-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
}

.price-label {
    font-weight: 600;
    color: var(--accent);
    min-width: 70px;
}

.price-value {
    font-weight: 500;
    color: white;
}

.modal-header-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    box-sizing: border-box;
    gap: 12px;
}

.modal-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}


/* ==========================================
   Clean Glassy Gold Button (No BG Pattern)
========================================== */
.event-detail-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 14px;

    background: rgba(255, 255, 255, 0.06);
    color: #ffd86b;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.5px;

    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 215, 0, 0.35);

    overflow: hidden;
    cursor: pointer;
    box-sizing: border-box;
    max-width: 100%;
    flex-shrink: 0;
    white-space: nowrap;

    transition: transform 0.2s ease, box-shadow 0.25s ease;
}


/* ==========================================
   1) GOLD SHIMMER PASS
========================================== */
.event-detail-button::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;

    background: linear-gradient(
        120deg,
        rgba(255, 215, 0, 0),
        rgba(255, 215, 0, 0.9),
        rgba(255, 215, 0, 0)
    );

    filter: blur(8px);
    opacity: 0.8;

    animation: goldShimmer 2.8s infinite linear;
    z-index: -1; /* Ensure it stays behind the button content */
    pointer-events: none; /* Prevent interaction issues */
}

@keyframes goldShimmer {
    0%   { transform: translateX(-150%) rotate(10deg); }
    100% { transform: translateX(150%) rotate(10deg); }
}

/* ==========================================
   Hover → subtle 3D pop
========================================== */
.event-detail-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.25);
}


/* ===========================
   Timetable Card
=========================== */
.timetable-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ============================
   Timetable Redesign (Card + Line)
============================= */

.timetable-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    padding-left: 20px; /* space for the timeline line */
}

.timetable-slot-wrapper {
    display: flex;
    align-items: stretch; /* Stretch children to same height */
    gap: 12px;
    position: relative;
}

/* Vertical connecting line */
.timetable-connector {
    position: absolute;
    left: -6px;
    top: 100%;
    width: 2px;
    height: 24px;
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(4px);
    border-radius: 2px;
}

/* The main small card per slot */
.timetable-slot-card {
    flex: 1;
    padding: 12px 16px;
    border-radius: 14px;

    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(10px);

    display: flex;
    justify-content: space-between;
    align-items: stretch; /* Stretch all children to same height */
    gap: 16px;
}

/* Time on left */
.slot-time {
    font-weight: 700;
    color: var(--accent);
    width: 70px;
    display: flex;
    align-items: center; /* Center time vertically */
}

/* Event name */
.slot-event {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0; /* Allow text to wrap */
    color: white;
    font-size: 1rem;
    display: flex;
    align-items: center; /* Center event text vertically */
}

.slot-event.us {
    color: var(--accent);
    font-weight: 700;
}

/* ----------- Link Card on the Right ----------- */
.slot-links-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0; /* Don't shrink */
    width: auto;
    min-width: fit-content;
    max-width: 120px; /* Limit maximum width */
    align-self: stretch; /* Match height of sibling card */
    justify-content: flex-start; /* Stack buttons from top, don't stretch */

    padding: 12px 16px; /* Match timetable-slot-card padding */
    border-radius: 12px;

    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    align-items: stretch;
    box-sizing: border-box;
}

.slot-links-card button {
    background: var(--accent);
    border: none;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    color: #0f1724;
    white-space: nowrap;
    width: 100%;
    min-width: fit-content;
    flex: 0 0 auto; /* Don't stretch buttons, use natural height */

    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.slot-links-card button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}


.modal-venue-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(10px);
    border-radius: 18px;
}

/* Header row with top-right buttons */
.venue-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    gap: 12px;
    flex-wrap: wrap;
    box-sizing: border-box;
    width: 100%;
}

.venue-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    word-wrap: break-word;
}

.venue-buttons-card {
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    padding: 6px 12px;
    border-radius: 12px;
    transform: translateY(-5px);
    box-sizing: border-box;
    flex-wrap: wrap;
    max-width: 100%;
    flex-shrink: 0;
}

.venue-buttons-card button {
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    white-space: nowrap;
    flex-shrink: 0;
}

.venue-buttons-card button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.venue-website {
    background: var(--accent);
    color: #0f1724;
}

.venue-maps {
    background: #4caf50;
    color: white;
}

.venue-calendar {
    background: #ff9800;
    color: #0f1724;
}


.venue-website {
    background: var(--accent);
    color: #0f1724;
}

.venue-maps {
    background: #4caf50;
    color: white;
}

/* Address */
.venue-address {
    font-size: 1rem;
    color: white;
    margin: 0;
}

/* Image */
.venue-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

/* Map */
.modal-map {
    width: 100%;
    max-width: 100%;
    height: 200px;
    border-radius: 14px;
    border: none;
    margin-top: 12px;
    box-sizing: border-box;
}


/* Calendar button standalone */
.modal-calendar {
    margin: 0 auto;
    display: block;
    margin-top: 12px;
    background: var(--accent);
    color: #0f1724;
    width: fit-content;
    padding: 12px 20px;
    font-size: 1.1rem;
}


#events-container {
    display: flex;
    flex-direction: column; /* vertical stacking */
    gap: 16px; /* vertical space between cards */
}

/* ============================================
   Mobile Responsive Styles
   ============================================ */

@media (max-width: 768px) {
    /* Modal overlay adjustments */
    .modal-overlay {
        padding: 0;
        align-items: flex-end; /* Align to bottom for mobile sheet-like appearance */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        gap: 16px;
        padding: 0;
        border-radius: 20px 20px 0 0;
        margin-top: auto;
        margin-bottom: 0;
        padding-top: calc(16px + env(safe-area-inset-top, 0));
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
        padding-left: 12px;
        padding-right: 12px;
        max-height: 95vh;
        max-height: 95dvh; /* Dynamic viewport height for mobile */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        animation: slideUp 0.3s ease-out;
    }

    .modal-close {
        top: calc(16px + env(safe-area-inset-top, 0));
        right: 12px;
        width: 44px; /* Better touch target */
        height: 44px;
        font-size: 1.8rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }


    /* Modal cards */
    .modal-card {
        padding: 18px;
        border-radius: 14px;
        gap: 10px;
        margin: 0;
    }

    .modal-title {
        font-size: 1.5rem;
        line-height: 1.3;
        word-wrap: break-word;
    }

    .modal-date {
        font-size: 1rem;
        margin-top: 4px;
    }

    .modal-description {
        font-size: 0.9rem;
        line-height: 1.6;
        word-wrap: break-word;
    }

    /* Header row */
    .modal-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
        box-sizing: border-box;
    }

    .modal-header-left {
        width: 100%;
        padding-right: 50px; /* Space for close button */
        box-sizing: border-box;
    }

    .event-detail-button {
        width: 100%;
        max-width: 100%;
        text-align: center;
        padding: 14px 18px;
        font-size: 0.95rem;
        min-height: 44px; /* Better touch target */
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        white-space: nowrap;
    }

    /* Timetable */
    .timetable-container {
        padding-left: 16px;
        gap: 16px;
    }

    .timetable-slot-wrapper {
        gap: 10px;
    }

    .timetable-slot-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 12px;
        gap: 10px;
    }

    .slot-time {
        width: auto;
        font-size: 0.95rem;
    }

    .slot-event {
        font-size: 0.9rem;
        width: 100%;
    }

    .slot-links-card {
        width: auto;
        max-width: 110px;
        flex-direction: column;
        padding: 10px 12px; /* Match timetable-slot-card padding */
        gap: 6px;
        flex-shrink: 0;
        align-self: flex-start; /* On mobile, align to start since card is column */
        justify-content: flex-start; /* Stack buttons from top */
    }

    .slot-links-card button {
        padding: 8px 10px;
        font-size: 0.8rem;
        width: 100%;
        min-height: 36px; /* Compact but still touchable */
        flex: 0 0 auto; /* Don't grow on mobile */
    }

    /* Venue card */
    .modal-venue-card {
        padding: 18px;
        gap: 10px;
    }

    .venue-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .venue-title {
        font-size: 1.3rem;
        width: 100%;
    }

    .venue-buttons-card {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        transform: none;
        padding: 8px 12px;
        gap: 8px;
        box-sizing: border-box;
        max-width: 100%;
    }

    .venue-buttons-card button {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 100%;
        padding: 12px 10px;
        font-size: 0.85rem;
        min-height: 44px; /* Better touch target */
        box-sizing: border-box;
    }

    .venue-address {
        font-size: 0.9rem;
    }

    .venue-image {
        max-height: 250px;
    }

    .modal-map {
        height: 180px;
        border-radius: 10px;
    }

    .modal-calendar {
        width: 100%;
        padding: 14px 20px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 0;
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .modal-content {
        gap: 12px;
        padding-top: calc(16px + env(safe-area-inset-top, 0));
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
        padding-left: 10px;
        padding-right: 10px;
        border-radius: 18px 18px 0 0;
        max-height: 96vh;
        max-height: 96dvh;
    }

    .modal-close {
        top: calc(16px + env(safe-area-inset-top, 0));
        right: 10px;
        width: 44px; /* Maintain good touch target */
        height: 44px;
        font-size: 1.6rem;
    }

    .modal-card {
        padding: 14px;
        border-radius: 12px;
    }

    .modal-title {
        font-size: 1.3rem;
    }

    .modal-date {
        font-size: 0.95rem;
    }

    .modal-description {
        font-size: 0.85rem;
    }

    .event-detail-button {
        padding: 12px 16px;
        font-size: 0.9rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .timetable-container {
        padding-left: 12px;
        gap: 12px;
    }

    .timetable-slot-card {
        padding: 8px 10px;
    }

    .slot-time {
        font-size: 0.9rem;
    }

    .slot-event {
        font-size: 0.85rem;
    }

    .slot-links-card {
        padding: 8px 10px; /* Match timetable-slot-card padding */
        gap: 5px;
        max-width: 100px;
        align-self: flex-start;
        justify-content: flex-start;
    }

    .slot-links-card button {
        padding: 7px 8px;
        font-size: 0.75rem;
        min-height: 34px; /* Compact but still touchable */
        flex: 0 0 auto; /* Don't grow on mobile */
    }

    .modal-venue-card {
        padding: 14px;
    }

    .venue-title {
        font-size: 1.2rem;
    }

    .venue-buttons-card {
        padding: 6px 10px;
        box-sizing: border-box;
        max-width: 100%;
    }

    .venue-buttons-card button {
        padding: 10px 8px;
        font-size: 0.8rem;
        min-height: 44px; /* Better touch target */
        box-sizing: border-box;
        flex: 1 1 auto;
        min-width: 0;
    }

    .venue-address {
        font-size: 0.85rem;
    }

    .venue-image {
        max-height: 200px;
    }

    .modal-map {
        height: 160px;
    }

    .modal-calendar {
        padding: 14px 18px;
        font-size: 0.95rem;
        min-height: 44px; /* Better touch target */
    }
}

/* Additional mobile optimizations */
@media (max-width: 768px) {
    /* Prevent body scroll when modal is open */
    body.modal-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    /* Improve scrolling performance */
    .modal-overlay {
        will-change: scroll-position;
    }

    /* Better text rendering on mobile */
    .modal-card {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Ensure images don't overflow */
    .venue-image {
        width: 100%;
        height: auto;
        object-fit: cover;
    }

    /* Improve map visibility on small screens */
    .modal-map {
        width: 100%;
        min-height: 180px;
    }
}


