/* ============================================
   TABLET BREAKPOINT (768px - 1024px)
   ============================================ */
@media only screen and (max-width: 1024px) {
    :root {
        --font-size-3xl: 2.5rem;
        --font-size-2xl: 2rem;
        --spacing-xl: 4rem;
    }

    .container_home {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
        text-align: center;
    }

    .container_text {
        align-items: center;
    }

    .container_text p {
        max-width: 100%;
    }

    .container_img {
        order: -1;
    }

    .container_left {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .container_left>span {
        align-items: center;
    }

    .container_work_card {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* ============================================
   MOBILE BREAKPOINT (< 768px)
   ============================================ */
@media only screen and (max-width: 768px) {
    :root {
        --font-size-3xl: 2rem;
        --font-size-2xl: 1.75rem;
        --font-size-xl: 1.5rem;
        --spacing-xl: 3rem;
        --spacing-lg: 2rem;
    }

    /* Header Mobile Menu */
    .container_header .menu ul {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: rgba(17, 18, 26, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        justify-content: center;
        gap: var(--spacing-lg);
        padding: var(--spacing-2xl) var(--spacing-xl);
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
        z-index: 1001;
    }



    .container_header .menu ul li {
        width: 100%;
        text-align: center;
    }

    .container_header .menu ul li a {
        font-size: var(--font-size-lg);
        display: block;
        padding: var(--spacing-sm);
    }

    .responsive_menu {
        display: block !important;
        z-index: 1002;
    }

    .closeSVG {
        position: absolute;
        top: 25px;
        right: 25px;
        display: block !important;
        z-index: 1003;
        cursor: pointer;
        background: rgba(46, 253, 168, 0.1);
        border-radius: 50%;
        padding: 8px;
        width: 44px;
        height: 44px;
        border: 1px solid rgba(46, 253, 168, 0.2);
        transition: all 0.3s ease;
    }

    .closeSVG:hover {
        transform: rotate(90deg) scale(1.1);
        background: var(--accent-primary);
        box-shadow: 0 0 15px rgba(46, 253, 168, 0.4);
    }

    .closeSVG path {
        fill: var(--accent-primary);
        transition: fill 0.3s ease;
    }

    .closeSVG:hover path {
        fill: var(--bg-primary);
    }

    .theme-toggle {
        margin-left: 0;
        margin-top: var(--spacing-md);
    }

    /* Home Section Mobile */
    .home {
        padding: calc(80px + var(--spacing-sm)) var(--spacing-sm) var(--spacing-sm);
    }

    .container_home {
        gap: var(--spacing-md);
    }

    .main_text {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
    }

    .subtitle {
        font-size: clamp(1.125rem, 5vw, 1.5rem);
    }

    .stats-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .cta-buttons {
        flex-direction: column;
        width: 100%;
    }

    .cta-button.primary,
    .cta-button.secondary {
        width: 100%;
        justify-content: center;
    }

    /* About Section Mobile */
    .tab {
        flex-direction: column;
    }

    .tab button {
        width: 100%;
    }

    .container_left {
        gap: var(--spacing-md);
    }

    .container_left>span {
        width: 100%;
    }

    .container_left_left {
        width: 100%;
        padding: var(--spacing-md);
    }

    .container_left_left ul {
        grid-template-columns: 1fr;
    }

    /* Stats Section Mobile */
    .stats-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
        padding: var(--spacing-lg) 0 0;
    }

    .stat-item {
        padding: var(--spacing-lg);
    }

    .stat-number {
        font-size: clamp(2rem, 8vw, 2.5rem);
    }

    /* Work Section Mobile */
    .container_work_card {
        grid-template-columns: 1fr;
    }

    /* Contact Section Mobile */
    .Contact {
        padding: var(--spacing-xl) var(--spacing-md);
        min-height: auto;
    }

    .contact-subtitle {
        font-size: var(--font-size-md);
        margin-bottom: var(--spacing-lg);
    }

    .contact-cards-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .contact-card {
        flex-direction: row;
        text-align: left;
        align-items: center;
        padding: var(--spacing-md);
        gap: var(--spacing-md);
        justify-content: flex-start;
        height: auto;
    }

    .contact-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .contact-icon {
        width: 48px;
        height: 48px;
        min-width: 48px;
        /* Prevent shrinking */
        margin: 0;
    }

    .contact-icon svg {
        width: 24px;
        height: 24px;
    }

    .contact-card h3 {
        font-size: var(--font-size-md);
        margin: 0;
        margin-bottom: 2px;
    }

    .contact-card p {
        font-size: var(--font-size-sm);
        margin: 0;
        word-break: break-all;
        /* Ensure links break if needed */
    }

    .massage {
        width: 95%;
        padding: var(--spacing-md);
    }
}

/* ============================================
   SMALL MOBILE BREAKPOINT (< 480px)
   ============================================ */
@media only screen and (max-width: 480px) {
    :root {
        --font-size-3xl: 1.75rem;
        --font-size-2xl: 1.5rem;
        --font-size-xl: 1.25rem;
        --spacing-lg: 1.5rem;
        --spacing-md: 1rem;
    }

    .header {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .container_header .logo {
        font-size: var(--font-size-md);
    }

    .container_header .logo code {
        font-size: var(--font-size-md);
    }

    .home::before {
        width: 400px;
        height: 400px;
    }

    .container_img img {
        width: min(300px, 90%);
    }

    .container_icons_contact svg {
        width: 45px;
        height: 45px;
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media only screen and (max-height: 600px) and (orientation: landscape) {
    .home {
        min-height: auto;
        padding: calc(80px + var(--spacing-sm)) var(--spacing-md) var(--spacing-md);
    }

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

    .container_img img {
        width: min(250px, 100%);
    }
}

/* ============================================
   ENHANCED RESPONSIVE FIXES
   ============================================ */
@media only screen and (max-width: 768px) {

    /* Sound toggle button positioning */
    .sound-toggle {
        bottom: calc(var(--spacing-md) + 60px);
    }

    /* Custom cursor - hide on mobile */
    .custom-cursor,
    .cursor-follower {
        display: none !important;
    }

    /* Typing animation - adjust for mobile */
    .typing-text::after {
        right: -5px;
    }

    /* Reduce parallax effect on mobile */
    .home {
        transform: none !important;
    }

    .container_img img {
        transform: none !important;
    }

    /* Better touch targets */
    button,
    a,
    .theme-toggle,
    .sound-toggle {
        min-width: 44px;
        min-height: 44px;
    }

    /* Optimize animations for performance */
    /* Removed global animation-duration override to fix fast rotation issues */

    /* Reduce particle count handled by JS */
    #particles-canvas {
        opacity: 0.5;
    }
}

@media only screen and (max-width: 480px) {

    /* Further optimize for small screens */
    .sound-toggle {
        width: 45px;
        height: 45px;
        bottom: calc(var(--spacing-sm) + 60px);
        right: var(--spacing-sm);
    }

    .sound-toggle svg {
        width: 20px;
        height: 20px;
    }

    /* Make typing animation faster on small screens */
    .typing-text::after {
        animation-duration: 0.8s;
    }

    /* Optimize loader for mobile */
    .loader-spinner {
        width: 50px;
        height: 50px;
    }

    /* Adjust modal for small screens */
    .massage {
        width: 98%;
        padding: var(--spacing-sm);
    }

    .closeSVGMassage {
        width: 35px;
        height: 35px;
    }
}

/* ============================================
   HIGH DPI DISPLAYS (Retina)
   ============================================ */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-device-pixel-ratio: 2),
only screen and (min-resolution: 192dpi) {

    /* Sharper borders and shadows on retina displays */
    .card,
    .header,
    .theme-toggle,
    .sound-toggle {
        border-width: 0.5px;
    }
}

/* ============================================
   REDUCED MOTION (Accessibility)
   ============================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .custom-cursor,
    .cursor-follower {
        display: none !important;
    }

    #particles-canvas {
        display: none !important;
    }

    .typing-text::after {
        animation: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .header,
    .sound-toggle,
    .theme-toggle,
    .page-loader,
    #particles-canvas,
    .custom-cursor,
    .cursor-follower {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    .card,
    section {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    a[href]::after {
        content: " (" attr(href) ")";
    }
}