/* ============================================ */
/* HERO & DIRECTORY HEADER                      */
/* ============================================ */
.hero-directory {
    position: relative;
    width: 100%;
    background-color: var(--primary) !important;
    background: linear-gradient(
        rgba(0, 0, 0, 0.04), 
        rgba(0, 0, 0, 0.9)
    ), 
    url("../../images/banners/main2.webp") no-repeat center center/cover;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--ink);
    padding: 2rem;
    overflow: hidden;
}

/* ============================================ */
/* VIEW SWITCHER MENU                        */
/* ============================================ */

/* Hides the toggle buttons on mobile by default */
.view-toggle {
    display: none;
} 

.menu {
    margin: 1rem auto;
    padding: 0.5rem;
    text-align: center;
}

.menu button {
    padding: 0.5rem 1rem;
    font-weight: 700;
    cursor: pointer;
    background-color: var(--ink);
    border: 1px solid var(--primary);
    margin: 0 5px;
    transition: all 0.3s ease;
    color: var(--accent3);
}

.menu button:hover {
    background-color: var(--primary);
    color: white;
}

/* ============================================ */
/*  LAYOUT TOGGLE                               */
/* ============================================ */

/* Base container - shared properties */
#cards {
    padding: 2rem;
    max-width: var(--maxw);
    margin: 0 auto;
    width: 100%;
}

/* GRID MODE */
#cards.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 2rem;
}

#cards.grid section h2 {
    display: none; /* hides title*/
}


/* ============================================ */
/*  INDIVIDUAL CARD STYLING                     */
/* ============================================ */
#cards section {
    background-color: var(--ink);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    max-width: 100%; 
}

#cards section:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* CARD IMAGE/LOGO */
#cards section img {
    width: 80%;
    height: auto;
    max-height: 150px;
    object-fit: cover;
    border-radius: var(--radius2);
    display: block;
    filter: grayscale(20%);
    transition: filter 0.3s ease;
}

#cards section:hover img {
    scale: 105%;
}

/* CARD TEXT STYLING */
#cards section h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--ink2);
    margin: 0.5rem 0;
    line-height: 1.2;
}

#cards section p {
    font-size: 0.9rem;
    margin: 0.25rem 0;
    color: #555;
    overflow-wrap: break-word;
    word-break: break-all;
}

/* CONTACT LINK STYLE (WEBSITE) */
#cards section a {
    margin-top: auto;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent3);
    text-decoration: underline;
}

#cards section a:hover {
    background-color: var(--accent3);
    color: var(--ink);
}

/* ============================================ */
/*  BADGES & RESPONSIVENESS                     */
/* ============================================ */
@media (min-width: 768px) {
    .view-toggle {
        display: block;
        margin: 1rem auto;
        text-align: center;
    }

    #cards section {
    background-color: var(--ink);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: none; /* This removes the shadow from the list view*/
    }
    
    #cards.grid {
        gap: 2.5rem;
    }

    /* LIST MODE - Changes layout to a vertical stack */
    #cards.list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem; /* Tighter gap for list view */
    }

    /* Individual Section Adjustments for LIST VIEW */
    #cards.list section {
        display: grid;
        /* This creates 5 distinct columns: Name, Address, Phone, emails, Website */
        grid-template-columns: 1fr 1.5fr 1fr 1.5fr 1fr; 
        align-items: center;
        text-align: left;
        padding: 0.75rem 1rem;
        border-radius: 0; /* Flat rows look better in lists */
        border: none;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }

    /* Zebra Striping for better readability */
    #cards.list section:nth-child(even) {
        background-color: #f9f9f9;
    }

    #cards.list section img {
        display: none; /* Hide logos in list view to save space */
    }

    #cards.list section h2 {
        font-size: 1rem;
        margin: 0;
        flex: 1; /* Give name some space */
    }

    #cards.list section p {
        margin: 0 10px;
        flex: 1;
    }

    #cards section:hover {
    transform: none;
    }

}

@media (max-width: 767px) {
    /* Force Grid View on mobile even if the "list" class is somehow added */
    /* I learnt this from the internet */
    
    #cards {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }
}
