/* Bento Grid Layout System */

.bento-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Base Tile Styles */
.bento-tile {
    background: var(--card-bg);
    border-radius: 1.5rem;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 153, 0, 0.1);
}

.bento-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 1.5rem;
    padding: 2px;
    background: linear-gradient(135deg,
        var(--aws-orange) 0%,
        var(--aws-blue) 25%,
        var(--aws-orange) 50%,
        var(--aws-blue) 75%,
        var(--aws-orange) 100%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.3;
    animation: borderGlow 3s linear infinite;
    background-size: 200% 200%;
}

.bento-tile:hover::before {
    opacity: 0.6;
}

.bento-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(255, 153, 0, 0.2);
}

.tile-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Override for intro tile with photo */
.tile-2x2 .tile-content {
    justify-content: flex-start;
    padding-top: 0;
}

/* Tile Size Classes */

/* 2x2 Large Tile */
.tile-2x2 {
    grid-column: span 2;
    grid-row: span 2;
    min-height: 500px;
    max-height: 100vh;
    overflow-y: auto;
}

/* 1x2 Tall Tile */
.tile-1x2 {
    grid-column: span 1;
    grid-row: span 2;
    min-height: 500px;
    max-height: 100vh;
    overflow-y: auto;
}

/* 2x1 Medium Tile */
.tile-2x1 {
    grid-column: span 2;
    grid-row: span 1;
    min-height: calc((100vh - 4rem - 1.5rem) / 2);
}

/* 1x1 Small Tile */
.tile-1x1 {
    grid-column: span 1;
    grid-row: span 1;
    min-height: calc((100vh - 4rem - 1.5rem) / 2);
}

.tile-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--aws-orange);
    margin-bottom: 1.5rem;
    letter-spacing: 0.5px;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.project-tile {
    background: var(--card-bg);
    border-radius: 1.5rem;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 153, 0, 0.1);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 1.5rem;
    padding: 2px;
    background: linear-gradient(135deg,
        var(--aws-orange) 0%,
        var(--aws-blue) 50%,
        var(--aws-orange) 100%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.3;
    animation: borderGlow 3s linear infinite;
    background-size: 200% 200%;
}

.project-tile:hover::before {
    opacity: 0.7;
}

.project-tile.expanded {
    grid-column: 1 / -1;
    transform: scale(1);
    z-index: 10;
}

.project-tile.expanded .project-preview {
    display: none;
}

.project-tile.expanded .project-expanded {
    display: block;
}

.project-preview {
    position: relative;
    z-index: 1;
}

.project-expanded {
    display: none;
    padding: 3rem;
    position: relative;
    z-index: 1;
    animation: fadeIn 0.4s ease;
}

/* Responsive Design */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .bento-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
        padding: 1.5rem;
    }

    .tile-2x2 {
        grid-column: span 2;
        grid-row: span 2;
        min-height: 450px;
        max-height: 100vh;
        overflow-y: auto;
    }

    .tile-1x2 {
        grid-column: span 1;
        grid-row: span 2;
        min-height: 450px;
        max-height: 100vh;
        overflow-y: auto;
    }

    .tile-2x1 {
        grid-column: span 3;
        grid-row: span 1;
        min-height: calc((100vh - 3rem - 1.25rem) / 2);
    }

    .tile-1x1 {
        grid-column: span 1;
        grid-row: span 1;
        min-height: calc((100vh - 3rem - 1.25rem) / 2);
    }

    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 1.5rem;
        padding: 1.5rem;
    }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    .bento-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .tile-2x2,
    .tile-1x2,
    .tile-2x1,
    .tile-1x1 {
        grid-column: span 1;
        grid-row: span 1;
        min-height: 280px;
    }

    .tile-2x2 {
        min-height: 350px;
        max-height: 100vh;
        overflow-y: auto;
    }

    .bento-tile {
        padding: 1.5rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .project-tile.expanded {
        grid-column: 1;
    }

    .project-expanded {
        padding: 2rem;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 480px) {
    .bento-container {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .bento-tile {
        padding: 1.25rem;
        border-radius: 1rem;
    }

    .tile-title {
        font-size: 1.1rem;
    }

    .projects-grid {
        padding: 0.75rem;
        gap: 0.75rem;
    }
}

/* Animation for border glow */
@keyframes borderGlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
