/* Responsive Design and Mobile Optimizations */

/* Mobile-specific improvements */
@media (max-width: 768px) {
    /* Prevent horizontal overflow */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Improve touch targets */
    .nav-link,
    .btn,
    .filter-btn,
    .project-link,
    .social-links a,
    .theme-toggle,
    .hamburger {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }

    /* Better spacing for mobile */
    section {
        padding: 3rem 0;
        overflow-x: hidden;
    }

    .hero {
        padding-top: 70px;
        min-height: calc(100vh - 20px);
        overflow-x: hidden;
    }

    /* Improve scroll behavior */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* Better text rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }

    /* Improve animations performance */
    .animate-on-scroll,
    .project-card,
    .skill-category,
    .tech-logo,
    .contact-item {
        will-change: transform;
        transform: translateZ(0);
    }

    /* Better focus management */
    .btn:focus,
    .filter-btn:focus,
    .nav-link:focus,
    input:focus,
    textarea:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
        box-shadow: 0 0 0 3px rgba(138, 47, 237, 0.2);
    }

    /* Improve loading states */
    .btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none !important;
    }

    /* Better section spacing */
    .section-title {
        font-size: 2rem;
        margin-bottom: 2rem;
        padding: 0 10px;
    }

    /* Prevent any element from causing horizontal scroll */
    .container,
    .nav-container,
    .hero-container,
    .about-content,
    .contact-content,
    .projects-grid,
    .skills-grid {
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Ensure all text wraps properly */
    .hero-description,
    .about-description,
    .project-description,
    .timeline-content p {
        word-wrap: break-word;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Better spacing for mobile */
    .terminal-window,
    .code-editor,
    .code-block {
        margin: 0 10px 1.5rem 10px;
        max-width: calc(100% - 20px);
    }
    
    .terminal-body,
    .editor-content,
    .code-content {
        padding: 16px;
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    .about-description {
        font-size: 0.95rem;
        line-height: 1.5;
        padding: 0 5px;
        margin-bottom: 1.5rem;
    }
    
    .timeline-item {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    .tech-stack {
        gap: 0.75rem;
        margin-top: 1rem;
    }
    
    .tech-stack .tech-tag {
        font-size: 0.8rem;
        padding: 0.3rem 0.8rem;
    }
    
    /* Prevent text breaking issues */
    .code-content .code-line {
        word-break: keep-all;
        overflow-wrap: break-word;
        hyphens: none;
        white-space: normal;
        display: block;
    }
    
    .code-content .code-line .code {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
    }
    
    .code-content .code-line .string {
        white-space: normal;
        word-break: break-word;
    }
    
    /* Better spacing between sections */
    section {
        padding: 3.5rem 0;
    }
    
    .container {
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    /* Extra small screen optimizations */
    .hero {
        padding-top: 70px;
        overflow-x: hidden;
    }

    .hero-container {
        padding: 0 10px;
        overflow-x: hidden;
    }

    .terminal-window,
    .code-editor,
    .code-block {
        border-radius: 8px;
        margin: 0 5px;
        max-width: calc(100% - 10px);
    }

    .terminal-header,
    .editor-header,
    .code-header {
        padding: 10px 12px;
        overflow-x: hidden;
    }

    /* Improve button spacing */
    .hero-buttons {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        padding: 0 10px;
    }

    /* Better project filter layout */
    .projects-filter {
        padding: 0 10px;
        overflow-x: hidden;
    }

    .filter-btn {
        flex: 1;
        min-width: 0;
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
        max-width: calc(100% - 1rem);
        white-space: normal;
        line-height: 1.2;
        text-align: center;
        min-height: 44px;
    }

    /* Improve contact form */
    .contact-form {
        padding: 1rem;
        overflow-x: hidden;
    }

    /* Better stats layout */
    .about-stats {
        padding: 0 10px;
        overflow-x: hidden;
    }

    .stat-item {
        padding: 1rem;
        overflow-x: hidden;
    }

    /* Prevent any element from causing horizontal scroll */
    .container,
    .nav-container,
    .hero-container,
    .about-content,
    .contact-content,
    .projects-grid,
    .skills-grid {
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Ensure all text wraps properly */
    .hero-description,
    .about-description,
    .project-description,
    .timeline-content p {
        word-wrap: break-word;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Extra small screen button fixes */
    .btn {
        padding: 10px 16px;
        font-size: 0.8rem;
        min-width: 120px;
    }

    .filter-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        white-space: normal;
        line-height: 1.2;
        text-align: center;
        min-height: 44px;
    }

    /* Better text sizing for very small screens */
    .about-description {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .timeline-content h4 {
        font-size: 1rem;
    }

    .timeline-content p {
        font-size: 0.9rem;
    }

    .code-content {
        font-size: 0.8rem;
        line-height: 1.4;
        padding: 12px;
    }
    
    .code-content .code-line {
        margin-bottom: 3px;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .code-content .code-line .code {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .code-content .code-line .string {
        white-space: normal;
        word-break: break-word;
    }
    
    /* Fix WordPress icon on very small screens */
    .tech-tag i.fab.fa-wordpress {
        font-size: 0.8em;
    }
    
    /* Better spacing for tech tags */
    .tech-stack .tech-tag {
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
    }

    /* Extra small screen optimizations */
    .hero {
        padding-top: 70px;
        overflow-x: hidden;
    }

    .hero-container {
        padding: 0 10px;
        overflow-x: hidden;
    }

    .terminal-window,
    .code-editor,
    .code-block {
        border-radius: 8px;
        margin: 0 5px;
        max-width: calc(100% - 10px);
    }

    .terminal-header,
    .editor-header,
    .code-header {
        padding: 10px 12px;
        overflow-x: hidden;
    }

    /* Improve button spacing */
    .hero-buttons {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        padding: 0 10px;
    }

    /* Better project filter layout */
    .projects-filter {
        padding: 0 10px;
        overflow-x: hidden;
    }

    .filter-btn {
        flex: 1;
        min-width: 0;
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
        max-width: calc(100% - 1rem);
        white-space: normal;
        line-height: 1.2;
        text-align: center;
        min-height: 44px;
    }

    /* Improve contact form */
    .contact-form {
        padding: 1rem;
        overflow-x: hidden;
    }

    /* Better stats layout */
    .about-stats {
        padding: 0 10px;
        overflow-x: hidden;
    }

    .stat-item {
        padding: 1rem;
        overflow-x: hidden;
    }

    /* Prevent any element from causing horizontal scroll */
    .container,
    .nav-container,
    .hero-container,
    .about-content,
    .contact-content,
    .projects-grid,
    .skills-grid {
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Ensure all text wraps properly */
    .hero-description,
    .about-description,
    .project-description,
    .timeline-content p {
        word-wrap: break-word;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Extra small screen button fixes */
    .btn {
        padding: 10px 16px;
        font-size: 0.8rem;
        min-width: 120px;
    }

    .filter-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        white-space: normal;
        line-height: 1.2;
        text-align: center;
        min-height: 44px;
    }

    /* Better text sizing for very small screens */
    .about-description {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .timeline-content h4 {
        font-size: 1rem;
    }

    .timeline-content p {
        font-size: 0.9rem;
    }

    .code-content {
        font-size: 0.8rem;
        line-height: 1.4;
        padding: 12px;
    }
    
    .code-content .code-line {
        margin-bottom: 3px;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .code-content .code-line .code {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .code-content .code-line .string {
        white-space: normal;
        word-break: break-word;
    }
    
    /* Fix WordPress icon on very small screens */
    .tech-tag i.fab.fa-wordpress {
        font-size: 0.8em;
    }
    
    /* Better spacing for tech tags */
    .tech-stack .tech-tag {
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
    }
}
