* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    position: relative;
    z-index: 0;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: #2c3e50;

    position: sticky;
    width: 100%;
    top: 0;
    z-index: 10000;
    overflow: hidden;
    overflow-x: auto;
    white-space: nowrap;
}

.logo {
    flex-shrink: 0;
    margin-right: 1rem;
}

.nav-list {
    display: flex;
    flex-grow: 1;
    justify-content: flex-start;
    list-style: none;
    gap: 1rem;
    padding: 0 1rem;
    transition: transform 0.3s ease;
}

.nav-item {
    cursor: pointer;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

.nav-item.active {
    background: rgb(55, 124, 160);
    border: 2px solid rgb(65, 148, 191);
    border-radius: 10px;
}

.nav-item:hover {
    background: #035767;
    border: 2px solid rgb(55, 124, 160);
    border-radius: 10px;
}

.logo {
    position: absolute;
    top: 1vh;
    left: 1vw;
    display: inline-flex;
    align-items: center;
    padding-right: 1rem;
    z-index: 10001;
}

.logo img {
    height: 2rem;
    max-width: 100%;
    object-fit: contain;
}

.logo:hover::after {
    content: "AI Tools Directory";
    position: fixed;
    top: 60px;
    left: 10px;
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 100000; /* Higher than .logo */
}

.nav .logo {
    position: relative;
    left: 0;
    display: inline-flex;
    align-items: center;
    padding-right: 1rem;
    z-index: 10001;
}

.nav .logo img {
    height: 5rem;
    max-width: 100%;
    object-fit: contain;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 3.5rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative; /* Create a new stacking context */
}

.flip-box {
    background-color: transparent;
    perspective: 1000px;
    height: 200px;
}

.flip-box-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.flip-box:hover .flip-box-inner,
.flip-box:focus-within .flip-box-inner {
    transform: rotateY(180deg);
}

.flip-box-front,
.flip-box-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.flip-box-front {
    background: white;
}

.flip-box-back {
    background: #3498db;
    color: white;
    transform: rotateY(180deg);
}

.icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.icon-image {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.label {
    font-size: 1.2rem;
    font-weight: 600;
}

.description {
    margin-bottom: 1rem;
}

.link-button {
    background: white;
    color: #3498db;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.3s;
}

.link-button:hover {
    background: #f8f9fa;
}

.loading {
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: #666;
}

.error {
    text-align: center;
    padding: 2rem;
    color: #e74c3c;
    background: #fde8e7;
    border-radius: 8px;
    margin: 2rem;
}

@media (max-width: 768px) {
    .nav-list {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .grid-container {
        padding: 3rem;
    }

    .nav-arrow {
        display: none !important;
    }
}

.flip-box:focus-within {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .flip-box-inner {
        transition: none;
    }

    body::after {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        pointer-events: none;
        z-index: 99999;
    }
}