/* --- Base Reset & Typography --- */
:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --accent-color: #0056b3;
    --hover-bg: #ffffff;
    --mobile-padding: 10px; /* New: Padding for screen edges */
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    /* Removed padding from body, now handled by main container for control */
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

h1 {
    margin-bottom: 2rem;
    font-size: 2.5rem;
    text-align: center;
    padding: 0;
    width: 100%;
    color: #003399;
}

/* --- The Navigation Grid --- */
.nav-grid {
    display: grid;
    /* CHANGE: Explicitly force 3 equal columns (1fr) */
    grid-template-columns: repeat(3, 1fr); 
    gap: 20px;
    max-width: 600px;
    width: 100%;
}

/* --- The Link "Card" --- */
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
    padding: 15px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    text-align: center;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    position: relative; /* Needed for absolute positioning of label */
}

.nav-item:hover, .nav-item:focus {
    background-color: var(--hover-bg);
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
}

.nav-item img {
    width: 64px;
    height: auto;
    margin-bottom: 0; /* Removed margin here */
    display: block;
}

/* --- The Hidden Label (The Mystery!) --- */
.nav-label {
    /* Hide the text label by default */
    opacity: 0;
    height: 0;
    overflow: hidden;
    /* The rest of the styling is for desktop hover */
    font-size: 0.9rem;
    line-height: 1.2;
    padding-top: 5px; /* Visual separation from the icon */
    transition: opacity 0.3s ease;
}

/* --- Media Queries --- */

/* 1. Mobile Fixes (applies to screens 600px wide or less) */
@media (max-width: 600px) {
    
    /* External Padding Fix: Apply margin to the entire page */
    body {
        padding-left: var(--mobile-padding);
        padding-right: var(--mobile-padding);
        width: 100%; 
        box-sizing: border-box;
    }
    
    /* Reset the grid container's size to respect body padding */
    .nav-grid {
        margin-left: 0;
        margin-right: 0;
        max-width: 100%; /* Important: Let the body padding define the width */
        width: auto;
    }

    /* Reset the header padding */
    h1 {
        padding-left: 0;
        padding-right: 0;
    }

    /* Adjust internal icon padding for tight screens */
    .nav-item { 
        padding: 10px 5px; 
    }
}

/* 2. Desktop/Hover (applies to screens 601px wide and up) */
@media (min-width: 601px) {
    
    /* Reset mobile padding/margins */
    body { 
        padding: 0; 
    }
    
    .nav-grid { 
        margin: 0 auto; /* Re-center on desktop */
    }
    
    /* Revert internal icon padding */
    .nav-item { 
        padding: 15px; 
    }

    /* Enable the hover effect */
    .nav-item:hover .nav-label {
        opacity: 1;
        height: auto;
    }
}

/* --- The Search Modal (No change needed) --- */

#search-modal {
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-width: 90%;
}

#search-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

.sl_search_box {
    display: flex;
    gap: 10px;
}

.sl_search_box input[type="text"] {
    flex-grow: 1;
    padding: 8px;
    font-size: 1rem;
}

.sl_search_box button {
    padding: 8px 16px;
    font-size: 1rem;
    cursor: pointer;
}

.close-btn {
    display: block;
    margin-top: 15px;
    cursor: pointer;
    font-size: 0.9rem;
    background: none;
    border: none;
    text-decoration: underline;
    color: var(--text-color);
    width: 100%;
    text-align: right;
}
