/* ===== DESKTOP STYLES (UNCHANGED GRID) ===== */
@media (min-width: 768px) {
    body {
        background: linear-gradient(135deg, #f5f7fa 0%, #e4e7ec 100%);
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding: 40px 20px;
        min-height: 100vh;
    }

    .container {
        max-width: 1200px;
        margin: 0 auto;
        background: var(--card);
        border-radius: 24px;
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.1);
        padding: 40px 50px 45px;
        position: relative;
        overflow-y: auto;
        max-height: calc(100vh - 80px);
    }

    .header {
        text-align: left;
        margin-bottom: 40px;
        padding-top: 10px;
    }

    .top-icons {
        justify-content: flex-end;
        gap: 15px;
        margin-bottom: 15px;
    }

    .profile-container {
        width: 100%;
        margin-bottom: 20px;
    }

    .profile-bg {
        height: 280px;
        border-radius: 24px;
    }

    .profile-banner-image {
        display: block;
        position: absolute;
        right: 50px;
        top: 25px;
        width: 350px;
        max-width: 40%;
        height: 230px;
        border-radius: 20px;
        object-fit: cover;
        border: 3px solid rgba(255, 255, 255, 0.9);
        box-shadow: var(--shadow-lg);
        transition: var(--transition);
    }

    .profile-banner-image:hover {
        transform: translateY(-8px);
        box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    }

    .profile-main {
        padding: 40px 400px 40px 50px;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 20px;
    }

    .profile-top-row {
        align-items: flex-start;
        gap: 40px;
        margin-top: 20px;
    }

    .profile-image {
        width: 140px;
        height: 140px;
        border-width: 5px;
    }

    .intro-column {
        align-items: flex-start;
    }

    .intro-name {
        font-size: 2.8rem;
    }

    .intro-role {
        font-size: 1.3rem;
        margin-top: 6px;
    }

    .social-icons {
        justify-content: flex-start;
        margin-top: 10px;
        gap: 15px;
        position: absolute;
        top: 170px;
        left: 230px;
    }

    .skills-section,
    .projects-section,
    .cta-section {
        margin-bottom: 35px;
    }

    .skills-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    /* Desktop Project Grid: UNCHANGED (3 columns uniform) */
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .project-card {
        min-height: 200px;
        /* Desktop Project Card Layout */
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: flex-start;
    }

    /* --- NEW DESKTOP CARD HEADER: Stacked Layout --- */
    .project-card .project-card-header-row {
        flex-direction: column;
        /* Stack Number and Title vertically */
        align-items: flex-start;
        /* Align Left */
        gap: 12px;
        width: 100%;
        margin-bottom: 15px;
    }

    .project-card .project-number-circle {
        width: 45px;
        /* Larger Desktop Circle */
        height: 45px;
        font-size: 1.1rem;
    }

    .project-card .project-title {
        text-align: left;
        margin-top: 0;
        font-size: 1.35rem;
        /* Slightly larger title */
    }

    .cta-section {
        text-align: left;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 30px;
        padding: 30px 30px;
    }

    .cta-text {
        margin-bottom: 0;
        flex: 1;
    }

    .cta-section p {
        max-width: 500px;
    }

    .cta-actions {
        justify-content: flex-end;
        max-width: 400px;
    }

    .cta-button {
        padding: 14px 28px;
        font-size: 1.1rem;
    }

    .footer {
        text-align: right;
        padding: 15px 0 0;
    }

    .resume-text-desktop {
        display: inline;
    }

    .resume-text-mobile {
        display: none;
    }


    .show-more-btn {
        max-width: 300px;
        height: 60px;
        margin: 0 auto;
        display: block;
    }

    .modal-content {
        max-width: 700px;
        padding: 30px;
    }

    .about-detail-content {
        max-width: 900px;
    }

    .about-profile-name {
        font-size: 3.2rem;
    }

    .contact-modal-content {
        max-width: 900px;
        padding: 40px;
    }

    .qr-codes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }
}

/* ===== MOBILE SPECIFIC (BENTO GRID IMPLEMENTATION) ===== */
@media (max-width: 767px) {
    .resume-text-desktop {
        display: none;
    }

    .pad-10 {
        padding: 0 10px;
    }

    .resume-text-mobile {
        display: inline;
    }

    .contact-body {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .qr-codes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .qr-code-card {
        padding: 20px 15px;
    }

    .qr-code-image {
        width: 120px;
        height: 120px;
    }

    .show-more-btn {
        width: 100%;
        max-width: none;
        margin: 0 auto;
    }

    /* >>> BENTO GRID LOGIC START <<< */
    .projects-grid {
        display: grid !important;
        /* Force 2 columns on mobile to create Bento effect */
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        grid-auto-flow: dense;
        /* Helps pack items tightly */
    }

    /* === UPDATED: SMALL CARDS (Default State - CLEAN TILE LOOK) === */
    .project-card {
        min-height: auto;
        /* Let aspect ratio decide height */
        aspect-ratio: 1 / 1;
        /* Force square tile shape */
        padding: 15px;
        display: flex;
        flex-direction: column;
        align-items: center;
        /* Center horizontally */
        justify-content: center;
        /* Center vertically */
        text-align: center;
    }

    /* HIDE TAGS ON SMALL CARDS FOR CLEANER UI */
    .project-card .project-tags-preview {
        display: none;
    }

    .project-card .project-card-header-row {
        flex-direction: column;
        /* STACK Number and Title */
        justify-content: center;
        align-items: center;
        width: 100%;
        gap: 10px;
        margin-bottom: 0;
        /* No margin needed as tags are hidden */
    }

    .project-card .project-number-circle {
        width: 50px;
        /* Much Larger Circle for emphasis */
        height: 50px;
        font-size: 1.2rem;
    }

    .project-card .project-title {
        font-size: 1rem;
        /* Slightly smaller title for balance */
        text-align: center;
        width: 100%;
        margin-top: 0;
        line-height: 1.3;
    }

    /* === UPDATED: LARGE CARDS (Override: Every 3rd item) === */
    /* BENTO PATTERN: Every 3rd item spans 2 columns and shows tags */
    .project-card:nth-child(3n+1) {
        grid-column: span 2;
        aspect-ratio: auto;
        /* Reset aspect ratio */
        min-height: 180px;
        /* Fixed height for banner feel */

        /* Revert to Left Align structure for Big Cards */
        justify-content: space-between;
        align-items: flex-start;
        text-align: left;
        padding: 20px;
    }

    /* SHOW TAGS ONLY ON LARGE CARDS */
    .project-card:nth-child(3n+1) .project-tags-preview {
        display: flex;
        justify-content: flex-start;
    }

    .project-card:nth-child(3n+1) .project-card-header-row {
        flex-direction: row;
        /* Side by side for big cards */
        justify-content: flex-start;
        align-items: center;
        gap: 15px;
        margin-bottom: 15px;
    }

    /* Increase Number size on Featured Cards as requested */
    .project-card:nth-child(3n+1) .project-number-circle {
        width: 45px;
        /* Bigger than standard 32px */
        height: 45px;
        font-size: 1.1rem;
    }

    .project-card:nth-child(3n+1) .project-title {
        font-size: 1.3rem;
        /* Larger title */
        text-align: left;
    }

    /* Mobile Contact Header Fix */
    .contact-detail-header,
    .about-detail-header {
        padding-top: 20px;
        min-height: auto;
        padding-bottom: 20px;
    }

    .back-button {
        position: relative;
        top: 0;
        left: 0;
        margin-bottom: 10px;
    }

    /* iOS specific adjustments */
    @supports (-webkit-touch-callout: none) {
        .container {
            padding: 15px;
        }

        .profile-bg {
            height: 200px;
        }

        .profile-top-row {
            gap: 15px;
        }

        .profile-image {
            width: 80px;
            height: 80px;
        }

        .intro-name {
            font-size: 1.6rem;
        }

        .intro-role {
            font-size: 0.9rem;
        }

        .skills-grid {
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
        }

        /* Ensure iOS also respects the Bento Grid */
        .projects-grid {
            grid-template-columns: repeat(2, 1fr);
            gap: 15px;
        }

        .cta-section {
            padding: 20px 15px;
        }

        .cta-title {
            font-size: 1.4rem;
        }

        .cta-actions {
            flex-direction: column;
        }
    }
}

/* Small mobile devices */
@media (max-width: 360px) {
    .container {
        padding: 10px;
    }

    .profile-bg {
        height: 180px;
    }

    .profile-top-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }

    .intro-column {
        align-items: center;
    }

    .social-icons {
        gap: 8px;
    }

    .social-icon {
        min-width: 42px;
        min-height: 42px;
        font-size: 18px;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }

    .about-detail-body,
    .contact-detail-body {
        padding: 20px 15px;
    }

    .about-detail-title,
    .contact-detail-title {
        font-size: 1.6rem;
    }

    .qr-codes-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* =========================================
   MOBILE DEVICES (Portrait)
   Breakpoint: < 768px
   ========================================= */
@media (max-width: 767px) {
    /* Styles are merged in the block above for cleaner code */

    .contact-detail-header,
    .about-detail-header {
        padding-top: 20px;
        min-height: auto;
        padding-bottom: 20px;
    }

    .back-button {
        position: relative;
        top: 0;
        left: 0;
        margin-bottom: 10px;
    }

    .contact-body {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .qr-codes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .qr-code-card {
        padding: 20px 15px;
    }

    .qr-code-image {
        width: 120px;
        height: 120px;
    }

    .show-more-btn {
        width: 100%;
        max-width: none;
        margin: 0 auto;
    }

    .profile-banner-image {
        display: none;
    }
}

/* =========================================
   SMALL MOBILE (iPhone SE, Older Androids)
   Breakpoint: < 360px
   ========================================= */
@media (max-width: 360px) {
    .container {
        padding: 10px;
    }

    .profile-bg {
        height: 180px;
    }

    .profile-top-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }

    .intro-column {
        align-items: center;
    }

    .social-icons {
        gap: 8px;
    }

    .social-icon {
        min-width: 42px;
        min-height: 42px;
        font-size: 18px;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }

    .about-detail-body,
    .contact-detail-body {
        padding: 20px 15px;
    }

    .qr-codes-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* =========================================
   TABLETS & iPADS (Portrait & Landscape)
   Breakpoint: 768px - 1023px
   ========================================= */
@media (min-width: 768px) and (max-width: 1023px) {
    body {
        padding: 20px;
    }

    .container {
        padding: 30px;
    }

    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .project-card {
        min-height: 220px;
    }

    .profile-banner-image {
        display: block;
        width: 280px;
        height: 180px;
        top: 20px;
        right: 20px;
    }

    .profile-main {
        padding-right: 320px;
        align-items: flex-start;
        text-align: left;
    }

    .intro-column {
        align-items: flex-start;
    }

    .social-icons {
        justify-content: flex-start;
    }

    .qr-codes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* =========================================
   DESKTOP & LAPTOPS
   Breakpoint: >= 1024px
   ========================================= */
@media (min-width: 1024px) {
    body {
        background: linear-gradient(135deg, #f5f7fa 0%, #e4e7ec 100%);
        justify-content: center;
        align-items: flex-start;
        padding-top: 40px;
    }

    .container {
        max-width: 1200px;
        margin: 0 auto;
        border-radius: 24px;
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.1);
        padding: 40px;
    }

    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
    }

    .project-card:nth-child(3n + 1) {
        grid-column: auto;
    }

    .profile-bg {
        height: 280px;
    }

    .profile-banner-image {
        display: block;
        position: absolute;
        right: 40px;
        top: 30px;
        width: 400px;
        height: 220px;
        border-radius: 16px;
        border: 4px solid rgba(255, 255, 255, 0.8);
        object-fit: cover;
    }

    .profile-main {
        padding-right: 400px;
        padding-left: 40px;
        align-items: flex-start;
        text-align: left;
    }

    .profile-top-row {
        gap: 30px;
    }

    .profile-image {
        width: 130px;
        height: 130px;
        border-width: 5px;
    }

    .intro-name {
        font-size: 2.5rem;
    }

    .intro-role {
        font-size: 1.2rem;
    }

    .intro-column {
        align-items: flex-start;
    }

    .social-icons {
        margin-top: 15px;
    }

    .skills-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .cta-section {
        text-align: left;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 40px;
    }

    .cta-actions {
        margin-top: 0;
    }

    .cta-button {
        padding: 14px 28px;
        font-size: 1.1rem;
    }

    .resume-text-desktop {
        display: inline;
    }

    .resume-text-mobile {
        display: none;
    }

    .show-more-btn {
        max-width: 300px;
        margin: 30px auto 0;
    }

    .contact-modal-content {
        max-width: 900px;
        padding: 40px;
    }

    .qr-codes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }
}