@layer components {
    /* --- cafe/style.css --- */

    /* THUMBS UP ICON */
    .thumb-icon {
        position: absolute;
        bottom: 70px;
        right: 10px;
        font-size: 24px; /* Adjust size as needed */
        color: white; /* Keep it black */
        z-index: 2; /* Above image, but below badges */
        cursor: pointer; /* Indicate that the icon is clickable */
    }

    /* If the thumb is clicked/active (for future functionality) */
    .thumb-icon.active {
        color: var(--color-yellow-500); /* Gold color */
    }

    /* Transition to 'full screen' */
    .fade-out {
        opacity: 0;
        pointer-events: none; /* This ensures that the element cannot be clicked on or interacted with */
        transition: opacity 0.5s;
    }

    .translate-to-top-left {
        transform: translate(
            0,
            0
        ); /* You might need to adjust the translation values */
        z-index: 5; /* Ensures this card is above others */
        position: relative;
        transition: transform 0.5s;
    }
    /* Styles for the details view */

    .card-selected .details-view {
        display: block;
    }

    .viewColumn + .details-view {
        display: block;
    }

    .grey-out {
        color: var(--color-gray-400); /* Adjust the color as needed */
        pointer-events: none; /* Ensures the label is not clickable */
    }

    @media screen and (min-width: 1400px) {
        #gridAndMapContainer {
            height: calc(100vh - 200px);
        }
    }

    #gridContainer a:hover {
        color: unset;
        text-decoration: none;
    }

    /* Cafe grid link items - inheriting text styles */
    #cafeGrid a {
        text-decoration: none;
        color: inherit;
    }
    @media screen and (max-width: 1200px) and (min-width: 768px) {
        #cafeModal #detailsView {
            max-width: calc(100vw - 100px);
        }
    }

    .info-window__directions button:hover,
    .info-window__directions button:focus,
    .info-window__directions button {
        background-color: unset;
        color: unset;
    }

    /* CAFE SUGGESTIONS */
    .cafe-card {
        border: 1px solid black;
        margin-bottom: 1rem;
    }

    .vote-button {
        background: none;
        border: none;
        font-size: 1.2rem;
        color: black;
        transition: color 0.2s;
    }

    #cafe-suggestions {
        max-width: 600px;
        margin: 0 auto;
    }

    /* Cafe suggestions now use .cafe-card with Tailwind rounded classes */

    .vote-button:hover {
        color: var(--color-gray-600);
    }

    .vote-count {
        font-size: 1.1rem;
        font-weight: bold;
    }

    #new-cafe-suggestion input {
        margin-bottom: 0.5rem;
    }

    #new-cafe-suggestion button {
        width: 100%;
    }

    /* Suggestion voting */
    .vote-button.voted {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .vote-button.voted:hover {
        opacity: 0.5;
    }

    .wiggle {
        animation: wiggle 0.5s ease-in-out;
        animation-iteration-count: 2;
    }

    .delete-suggestion {
        cursor: pointer;
        margin-left: 0.5rem;
        opacity: 0.5;
        transition: opacity 0.2s, color 0.2s;
    }

    .delete-suggestion:hover {
        opacity: 1;
        color: var(--color-red-600);
    }

    /* --- cafe/grid.css --- */

    /* ==========================================================================
       Cafe Grid — Isotope-compatible card layout
       ========================================================================== */

    /* Container — Isotope manages positioning, we just set overflow */
    #cafeGrid {
        position: relative;
    }

    /* Responsive item widths for Isotope fitRows */
    .cafe-grid-item {
        position: relative;
        overflow: hidden;
        width: 50%;
        aspect-ratio: 1 / 1;
        cursor: pointer;
        border: 1px solid var(--bg-color, #f7f6f3);
    }

    @media (min-width: 576px) {
        .cafe-grid-item { width: 33.333%; }
    }
    @media (min-width: 992px) {
        .cafe-grid-item { width: 25%; }
    }
    @media (min-width: 1200px) {
        .cafe-grid-item { width: 20%; }
    }

    /* Card image fills the entire item */
    .custom-card-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        filter: brightness(0.9);
        transition: filter 0.3s ease;
    }

    .cafe-grid-item:hover .custom-card-img {
        filter: brightness(1);
    }

    /* Tag badge at top of card */
    .cafe-tag {
        z-index: 1;
    }

    /* ==========================================================================
       Near Me overlay
       ========================================================================== */

    .near-me .driving-time-overlay {
        display: flex;
    }

    .near-me .custom-card-img {
        filter: brightness(0.5);
    }

    .driving-time-overlay {
        display: none;
        position: absolute;
        inset: 0;
        justify-content: center;
        align-items: center;
        pointer-events: none;
    }

    .driving-time-content {
        display: flex;
        flex-direction: column;
        align-items: start;
    }

    .walking-time,
    .driving-time {
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    }

    .driving-time-icons {
        display: flex;
        justify-content: center;
        gap: 15px;
    }

    .driving-time-icons i {
        font-size: 24px;
        color: white;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    }

    /* ==========================================================================
       Promotional card
       ========================================================================== */

    .promotional-card-title {
        font-size: clamp(1rem, 2.5vw, 1.5rem);
    }

    /* ==========================================================================
       Layout containers
       ========================================================================== */

    #cafeMapContainer,
    #gridAndMapContainer {
        height: 100vh;
    }

    #gridContainer {
        height: 100%;
        overflow: scroll;
    }

    /* --- cafe/filter.css --- */

    .filterBarLogo img {
        height: 40px;
        width: auto;
    }

    .filter-menu {
        display: flex;
        overflow-x: auto;
        gap: 5px;

        width: 100%;
        border-bottom: 1px solid lightgrey;
        z-index: 2;
        transition: all 0.3s ease;
    }

    @media screen and (min-width: 1200px) {
        .filter-menu {
            gap: 40px;
        }
    }

    .filter-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 10px 10px;
        border-radius: 30px;
        /* box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); */
        cursor: pointer;
        transition: background-color 0.3s ease;
    }

    .filter-item.active {
        border-bottom: 2px solid var(--color-gray-800);
        border-radius: 0;
    }

    .filter-item:hover {
        background-color: var(--color-gray-100);
    }

    .material-icons {
        margin-bottom: 5px;
    }

    .filter-text {
        font-size: 0.7em;
        line-height: 1.2;
    }

    /* Adjustments when the admin bar is visible */
    @media screen and (min-width: 782px) {
        body.admin-bar .filter-menu:not(.sticky) {
            top: 30px; /* Adjust this value if the admin bar height changes */
        }
    }
    /* Filter Pill */
    .filter-pill {
        display: inline-flex;
        align-items: center;
        border: 1px solid var(--color-gray-800); /* dark outline */
        padding: 5px 10px;
        margin: 5px;
        cursor: pointer;
        border-radius: 5px; /* rounded corners */
        font-size: 14px; /* adjust as needed */
    }

    .filter-pill::after {
        content: "×"; /* adding the x symbol */
        margin-left: 8px; /* space between the x and the label */
    }

    /* Hidden scrollbar for Webkit browsers */
    .filter-menu::-webkit-scrollbar {
        display: none;
    }

    #cafeGridContainer {
        position: relative;
    }

    /* --- cafe/modal.css --- */

    /* Gallery layout handled by Tailwind classes in PHP */

    /* Legacy star rating - keeping for backwards compatibility */
    .star-rating {
        position: relative;
        display: inline-flex;
        font-size: 24px; /* Adjust this as needed for your design */
        color: var(--color-gray-300); /* Gray color for the base stars */
        width: 150px;
    }

    .star-rating i:not(:last-child) {
        margin-right: 3px; /* You can adjust the space between stars if needed */
    }

    .star-rating-overlay {
        position: absolute;
        top: 0;
        left: 0;
        white-space: nowrap;
        overflow: hidden;
        color: var(--color-yellow-400); /* Gold color for the overlay stars */
        display: inline-flex;
    }

    .star-rating-overlay i {
        margin-right: 3px; /* This should be the same as the base star margin for proper alignment */
    }

    /* New improved star rating system */
    .star-rating-new {
        display: inline-flex;
        align-items: center;
        font-size: 16px; /* Smaller stars */
        gap: 2px; /* Clean spacing between stars */
    }

    .star-rating-new .star-full {
        color: var(--color-yellow-400); /* Gold for full stars */
    }

    .star-rating-new .star-empty {
        color: var(--color-gray-300); /* Light gray for empty stars */
    }

    /* Half star with gradient effect */
    .star-rating-new .star-half {
        background: linear-gradient(to right, var(--color-yellow-400) 50%, var(--color-gray-300) 50%);
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
    }

    #attributes i {
        width: 30px;
    }
    /* Modal content is block flow; gallery grid handled by Tailwind */

    #map {
        width: 100%;
        max-width: 600px;
        height: 200px;
        margin: auto;
    }

    #attributes > li {
        width: 100%;
    }

    #detailsModal .topCloseButton {
        cursor: pointer;
        position: absolute;
        right: 25px;
        top: 19px;
        color: white;
        z-index: 1070;
        font-size: 1.5em;
        background: none;
        border: none;
        padding: 8px;
        user-select: none;
    }

    #detailsContent {
        width: 100%;
        max-width: 600px;
    }

    @media screen and (min-width: 768px) {
        #attributes {
            column-count: 2;
        }
    }

    #ratings {
        width: 100%;
        max-width: 600px;
    }
    #directionsUrl,
    #ratings > div {
        font-weight: 600;
    }
    /* Loading state for modal content area */
    #detailsView.loading {
        filter: blur(1px);
        opacity: 0.8;
    }
    .dummy-image {
        width: 100%;
        height: 300px;
        background-color: var(--color-gray-100);
        background-image: linear-gradient(45deg, var(--color-gray-200) 25%, transparent 25%),
            linear-gradient(-45deg, var(--color-gray-200) 25%, transparent 25%),
            linear-gradient(45deg, transparent 75%, var(--color-gray-200) 75%),
            linear-gradient(-45deg, transparent 75%, var(--color-gray-200) 75%);
        background-size: 20px 20px;
        background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    }
    .dummy-image,
    .dummy-content p {
        animation: pulse 1s infinite;
    }

    #cafeModal [type="button"] {
        border-radius: 0;
    }

    #cafeModal.loading {
        animation: blur 3s infinite;
    }

    /* --- cafe/responsive-gallery.css --- */

    .topCloseButton {
        z-index: 1070;
        position: relative;
    }

    /* Lightbox fade-in */
    .gallery-lightbox[data-open="true"] img {
        animation: lb-fade 0.2s ease;
    }
}

/* --- Unlayered rules (keyframes, third-party overrides) --- */

/* cafe/style.css — Google Places Autocomplete — unlayered to beat third-party z-index */
.pac-container {
    z-index: 1051;
    border-radius: 0.25rem;
    margin-top: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* cafe/style.css */
@keyframes wiggle {
    0%   { transform: rotate(0deg); }
    25%  { transform: rotate(-1deg); }
    50%  { transform: rotate(0deg); }
    75%  { transform: rotate(1deg); }
    100% { transform: rotate(0deg); }
}

/* cafe/modal.css */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.01);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes blur {
    0% {
        filter: blur(0px);
    }
    100% {
        filter: blur(8px);
    }
}

/*
 * Gallery grid fix — explicit rules to survive Tailwind v4 @layer cascade.
 * Tailwind utilities live in @layer, but this file is unlayered (higher priority).
 * Without these, innerHTML-injected gallery grids lose their display:grid.
 */
#detailview-gallery {
    display: grid;
    gap: 0.25rem;
    overflow: hidden;
    border-radius: 0.5rem;
    height: 360px;
}
@media (max-width: 767px) {
    #detailview-gallery { height: 250px; }
}
#detailview-gallery.grid-cols-1 {
    grid-template-columns: 1fr;
}
#detailview-gallery.grid-cols-\[3fr_2fr\] {
    grid-template-columns: 3fr 2fr;
}
#detailview-gallery.grid-rows-2 {
    grid-template-rows: repeat(2, minmax(0, 1fr));
}
#detailview-gallery > .row-span-2 {
    grid-row: span 2 / span 2;
}
#detailview-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
#detailview-gallery .grid {
    display: grid;
}
#detailview-gallery .grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
#detailview-gallery .gap-1 {
    gap: 0.25rem;
}

/* cafe/responsive-gallery.css */
@keyframes lb-fade {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}
