/* style.css */
/* --------------- Global Resets and Base Styles -----------------*/
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px; /* Base font size */
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

body {
    /* Background, text color, and font-family are set dynamically via inline <style> in index.php */
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 10px; /* Small border around the entire page */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* --------------- Typography -------------------------------------*/
.page-title {
    /* Font family and color set dynamically */
    text-align: center;
    font-size: clamp(2rem, 6vw, 2.8rem); /* Responsive font size */
    margin-block: 20px 30px; /* More space below title */
    font-weight: normal; /* Gabriela is decorative, normal weight is often best */
}

/* --------------- Layout and Containers --------------------------*/
.container {
    width: 100%;
    max-width: 1200px; /* Max width for very large screens, content will center */
    margin-inline: auto; /* Horizontal centering */
    padding-inline: 10px; /* Padding within container, smaller than body padding */
}

.tools-grid {
    display: grid;
    /* MODIFIED: Increased minmax for larger buttons. Was minmax(110px, 1fr) */
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: clamp(18px, 3.5vw, 30px); /* MODIFIED: Slightly increased gap for larger items */
    justify-content: center;
}

/* --------------- Tool Item Styling ------------------------------*/
.tool-item {
    /* background-color, border-radius, color set dynamically */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    /* MODIFIED: Adjusted padding clamp for potentially larger items. Was clamp(10px, 2vw, 15px) */
    padding: clamp(12px, 2.5vw, 18px);
    text-decoration: none;
    text-align: center;
    aspect-ratio: 1 / 1; /* Make items square */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease-out, background-color 0.2s ease-out, box-shadow 0.2s ease-out;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.tool-item:hover {
    /* hover background-color set dynamically */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    transform: translateY(-5px); /* Slight lift on hover */
}

.tool-item:active, .tool-item.active-touch { /* For JS-added class on touch */
    transform: translateY(2px) scale(0.97); /* Click animation */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.tool-item img {
    /* border-radius set dynamically */
    /* MODIFIED: Increased width and max-height for more prominent image. Was 65% / 60% */
    width: 75%;
    max-height: 70%;
    object-fit: contain;
    /* MODIFIED: Slightly increased margin-bottom. Was 8px */
    margin-bottom: 10px;
    pointer-events: none;
    transition: transform 0.2s ease-out;
}
.tool-item:hover img {
    transform: scale(1.05);
}

.tool-name {
    /* MODIFIED: Increased font size by ~50%. Was clamp(0.8rem, 2.2vw, 0.95rem) */
    font-size: clamp(1.2rem, 3.3vw, 1.4rem);
    line-height: 1.25;
    max-height: 2.5em; /* Approx 2 lines (1.25em * 2). May need adjustment if text overflows too much. */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    width: 100%;
}

/* --------------- Tooltip Styling --------------------------------*/
#tooltip {
    position: fixed;
    /* background-color, color, border-radius set dynamically */
    padding: 8px 12px;
    font-size: clamp(0.8rem, 2vw, 0.9rem); /* Tooltip font size remains the same */
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    z-index: 9999;
    max-width: 280px;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    white-space: pre-wrap;
    will-change: transform, opacity;
}

#tooltip.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* --------------- Accessibility ----------------------------------*/
/* Focus styles are set dynamically in index.php <style> for color */

/* --------------- Responsive Adjustments -------------------------*/
@media (max-width: 600px) {
    body {
        padding: 5px;
    }
    .container {
        padding-inline: 5px;
    }
    .tools-grid {
        /* MODIFIED: Increased minmax for larger buttons on mobile. Was minmax(100px, 1fr) */
        grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
        /* MODIFIED: Slightly increased gap. Was 10px */
        gap: 12px;
    }
    .tool-item {
        /* MODIFIED: Adjusted padding for mobile. Was 8px */
        padding: 10px;
    }
    .tool-item img {
        /* MODIFIED: Adjusted image size for mobile context. Was 60% / 55% */
        width: 70%;
        max-height: 65%;
        margin-bottom: 8px; /* Slightly less margin for smaller items overall */
    }
    /* Tool name font size uses the general clamp which should adapt well */
    #tooltip {
        max-width: 85vw;
    }
}

/* --------------- Message Styling ------------------------------*/
.info-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 25px 15px;
    font-size: 1.05rem;
    color: #a0a0a0;
    border: 1px dashed #444;
    border-radius: 8px;
    background-color: rgba(0,0,0,0.1);
}
/* style.css */