/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: 0;
}

body {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    font-family: 'Apercu Pro', serif;
    margin: 0;
    padding: 0;
}

/* Navbar */
nav {
    position: fixed; /* Change to fixed */
    top: 20px; /* Adjust top position */
    right: 20px; /* Adjust right position */
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 1rem;
    padding: 16px 35px;
    background: linear-gradient(96.85deg, rgba(255, 185, 40, 0.64) 6.09%, rgba(255, 57, 180, 0.64) 37.92%, rgba(95, 196, 236, 0.64) 65.58%);
    border-radius: 50px; /* Optional: Add border-radius for rounded corners */
    z-index: 1000; /* Ensure the navbar is always on top */
}

.nav-links {
    display: grid;
    grid-auto-flow: column;
    gap: 2rem;
    justify-content: end;
}

nav a {
    color: white;
    font-weight: bold;
    font-size: 14px;
    margin-left: 20px; /* Add margin between links */
}

/* Hamburger Menu Improvements */
.hamburger-menu {
    display: none;
    cursor: pointer;
    padding: 12px;  /* Increased padding for better touch target */
    scale: 1;       /* Remove scale transformation */
    margin-right: -8px; /* Adjust position */
}

.bar {
    display: block;
    width: 24px;    /* Increased width */
    height: 2px;
    margin: 5px auto;
    background-color: white;
    transition: all 0.3s ease-in-out;
}

a {
    text-decoration: none;
}

/* Back button positioning */
.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

/* Responsive styles */
@media screen and (max-width: 768px) {
    nav {
        grid-template-columns: 1fr auto;
        padding: 8px 16px;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: calc(100% + 5px); /* Add small gap between menu and dropdown */
        left: 0;
        width: 100%;
        grid-auto-flow: row;
        gap: 1rem;
        background: linear-gradient(96.85deg, rgba(255, 185, 40, 0.9) 6.09%, rgba(255, 57, 180, 0.9) 37.92%, rgba(95, 196, 236, 0.9) 65.58%);
        padding: 1rem;
        border-radius: 0 0 15px 15px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* Add shadow for better visibility */
    }

    nav.active .nav-links {
        display: grid;
    }

    .nav-links a {
        padding: 12px 0; /* Increase touch target */
        display: block;  /* Full width for better tapping */
        font-size: 16px; /* Larger font size */
        margin: 10px 0; /* Add margin between links */
    }

    .hamburger-menu {
        min-width: 44px;    /* Minimum touch target size */
        min-height: 44px;   /* Minimum touch target size */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    /* Improved animation for better visibility */
    .hamburger-menu.active .bar:nth-child(1) {
        transform: rotate(-45deg) translate(-6px, 6px);
    }
    
    .hamburger-menu.active .bar:nth-child(3) {
        transform: rotate(45deg) translate(-6px, -6px);
    }
    
    .hamburger-menu.active .bar:nth-child(2) {
        opacity: 0;
    }

    .back-button {
        top: 10px;
        left: 10px;
    }

    .back-button button {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

/* Mobile adjustments */
@media screen and (max-width: 480px) {
    main {
        padding: 4rem 1rem 1rem;
    }

    .card-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.3));
    }

    .view-button {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 14px;
    }

    .back-button {
        top: 10px;
        left: 10px;
    }

    .back-button button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    nav {
        padding: 8px 12px;
        right: 10px;
        top: 10px;
    }

    .nav-links a {
        font-size: 13px;
    }

    .bar {
        width: 18px; /* Even smaller on mobile */
        height: 2px;
        margin: 3px auto;
    }

    .hamburger-menu {
        padding: 6px;
        scale: 0.7;
        margin-right: -4px;
    }

    .courts-grid {
        padding: 0.5rem;
        gap: 1rem;
    }

    .court-card {
        aspect-ratio: 3/4;
    }
}

/* Back Button */
.back-button button {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    background-color: #FFB928;
    font-family: monospace;
    font-weight: bold;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.back-button button:hover {
    background-color: #555;
}

/* Heading styles */

h1{
    font-family: 'Druk Wide Trial', sans-serif;
}

.h1-color {
    font-size: clamp(1.8rem, 4vw, 4rem);
    font-family: 'Druk Wide Trial', sans-serif;
    background: linear-gradient(96.85deg, #FFB928 6.09%, #FF39B4 37.92%, #5FC4EC 65.58%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

main {
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 2rem;
    padding: 6rem 2rem 2rem;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

main h1 {
    font-size: clamp(1.8rem, 4vw, 4rem);
    text-align: center;
    line-height: 1.2;
    padding: 0 1rem;
    margin-top: 50px; /* Add top margin */
}

.filter-container {
    justify-self: center;
    width: calc(100% - 2rem);
    max-width: 300px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

#courtFilter {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #FFB928;
    border-radius: 25px;
    font-size: clamp(14px, 3vw, 1rem);
    background: white;
    cursor: pointer;
    outline: none;
}

.courts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
}

.court-card {
    width: 100%;
    max-width: 320px; /* Set maximum width for the card */
    aspect-ratio: 4/5;
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    justify-self: center; /* Center the card in its grid cell */
    cursor: pointer;
}

/* Single card display fix */
@media (min-width: 768px) {
    .courts-grid:has(.court-card:only-child) {
        grid-template-columns: minmax(300px, 360px);
        justify-content: center;
    }
}

.court-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 2rem;
    gap: 1rem;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    opacity: 0;
    transition: all 0.3s ease;
}

.court-card h3 {
    color: white;
    font-family: 'Druk Wide Trial', sans-serif;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    margin-bottom: 1rem;
    text-align: center;
}

/* Mobile styles */
@media screen and (max-width: 768px) {
    .card-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.3));
        justify-content: center;
        gap: 1.5rem;
    }

    .court-card h3 {
        margin-bottom: 0.5rem;
    }

    .view-button {
        position: static; /* Remove absolute positioning */
        transform: none;  /* Remove transform */
        margin-top: 0.5rem;
    }
}

.view-button {
    padding: 0.6rem 1.2rem;
    background: #FFB928;
    color: white;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    transition: transform 0.3s ease;
    font-size: clamp(14px, 2.5vw, 1rem);
}

/* Desktop hover effects */
@media (hover: hover) {
    .court-card:hover {
        transform: translateY(-10px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    }

    .court-card:hover img {
        transform: scale(1.05);
    }

    .court-card:hover .card-overlay {
        opacity: 1;
    }

    .view-button:hover {
        transform: translateY(-2px);
        background: #e69f23;
    }
}

/* Tablet styles */
@media screen and (min-width: 481px) and (max-width: 768px) {
    main {
        padding: 5rem 1.5rem 1.5rem;
    }

    .courts-grid {
        gap: 1.5rem;
    }

    .court-card {
        max-width: 340px;
    }
}

/* Additional layout fixes */
@supports (-webkit-touch-callout: none) {
    .court-card {
        /* Fixes safari aspect-ratio issues */
        height: 0;
        padding-bottom: 133.33%;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .courts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}