/* ============================================
   RESPONSIVE DESIGN - MOBILE FIX COMPLETE
   ============================================ */

/* ============================================
   BREAKPOINTS REFERENCE:
   - Mobile Small: 320px - 375px
   - Mobile Medium: 376px - 414px  
   - Mobile Large: 415px - 480px
   - Tablet Small: 481px - 768px
   - Tablet Large: 769px - 1024px
   - Desktop Small: 1025px - 1200px
   - Desktop Large: 1201px+
   ============================================ */

/* ============================================
   TABLET LARGE & DESKTOP SMALL (1024px)
   ============================================ */
@media (max-width: 1024px) {
    :root {
        --container-padding: 1.25rem;
    }

    /* Hero */
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2.5rem;
    }

    .hero-description {
        margin-left: auto;
        margin-right: auto;
    }

    .hero-buttons {
        justify-content: center;
    }

    .hero-socials {
        justify-content: center;
    }

    .hero-image {
        order: -1;
    }

    .code-window {
        max-width: 380px;
        transform: perspective(1000px) rotateY(-3deg) rotateX(3deg);
    }

    /* About */
    .about-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .about-image {
        position: relative;
        top: 0;
        max-width: 350px;
        margin: 0 auto;
    }

    /* Contact */
    .contact-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .contact-info {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .contact-item {
        flex: 1;
        min-width: 250px;
        max-width: 300px;
    }

    /* Gallery */
    .gallery-grid {
        gap: 1.5rem;
    }

    .gallery-item {
        min-width: 260px;
        max-width: 320px;
    }
}

/* ============================================
   TABLET SMALL (768px) - iPad Mini, etc
   ============================================ */
@media (max-width: 768px) {
    :root {
        --section-padding: 4rem 0;
        --container-padding: 1rem;
    }

    /* Typography */
    .hero-title {
        font-size: 2rem;
        min-height: auto;
    }

    .hero-greeting {
        font-size: 0.9rem;
        justify-content: center;
    }

    .section-title {
        font-size: 2rem;
    }

    .section-tag {
        font-size: 0.8rem;
    }

    /* ============================================
       NAVIGATION - FIXED MOBILE LAYOUT
       ============================================ */
    .navbar {
        padding: 0;
        min-height: 56px;
    }

    .nav-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 1rem;
        min-height: 56px;
        position: relative;
    }

    .nav-logo {
        font-size: 1rem;
        margin: 0;
        flex-shrink: 0;
    }

    .logo-text {
        font-size: 0.9rem;
    }

    .logo-bracket {
        font-size: 0.85rem;
    }

    /* Language switcher */
    .lang-switcher {
        position: static;
        transform: none;
        margin: 0;
        padding: 0.2rem;
        gap: 0.2rem;
    }

    .lang-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        min-height: 36px;
        min-width: 36px;
    }

    /* Toggle */
    .nav-toggle {
        display: flex;
        position: static;
        transform: none;
        margin: 0;
        padding: 0.4rem;
    }

    .hamburger {
        width: 22px;
    }

    .hamburger::before,
    .hamburger::after {
        width: 22px;
    }

    .hamburger::before {
        top: -6px;
    }

    .hamburger::after {
        top: 6px;
    }

    .nav-right {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    /* Menu mobile */
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        height: 100dvh;
        background: rgba(5, 7, 20, 0.98);
        flex-direction: column;
        padding: 4.5rem 1.5rem 2rem;
        transition: var(--transition-normal);
        border-left: 1px solid var(--cyber-border);
        box-shadow: var(--shadow-lg);
        backdrop-filter: blur(20px);
        overflow-y: auto;
        z-index: 1001;
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-link {
        font-size: 1rem;
        padding: 1rem 0;
        width: 100%;
        border-bottom: 1px solid var(--cyber-border);
    }

    .nav-link::after {
        display: none;
    }

    /* ============================================
       HERO SECTION - MOBILE FIX
       ============================================ */
    .hero {
        padding: 72px 0 3rem;
        min-height: auto;
    }

    .hero-content {
        gap: 2rem;
        padding: 1.5rem 1rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    /* Code window mobile fix */
    .code-window {
        max-width: 100%;
        width: 100%;
        transform: none;
        margin: 0;
    }

    .window-header {
        padding: 0.625rem 0.875rem;
    }

    .dot {
        width: 10px;
        height: 10px;
    }

    .window-title {
        font-size: 0.75rem;
    }

    .window-body {
        padding: 1rem;
        font-size: 0.8rem;
        line-height: 1.6;
    }

    .window-body pre {
        font-size: 0.75rem;
        white-space: pre-wrap;
        word-wrap: break-word;
    }

    .scroll-indicator {
        display: none;
    }

    /* Skills Mobile */
    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
        gap: 1rem;
    }

    .modern-card {
        padding: 1.25rem;
    }

    .skill-item i {
        font-size: 2rem;
    }

    /* Projects Mobile */
    .projects-grid {
        grid-template-columns: 1fr;
    }

    .project-card {
        max-width: 500px;
        margin: 0 auto;
    }

    /* Experience Mobile */
    .current-role {
        padding: 2rem;
    }

    .current-role h3 {
        font-size: 1.5rem;
    }

    /* Gallery Mobile */
    .gallery-grid {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }

    .gallery-item,
    .gallery-item.featured {
        width: 100%;
        max-width: 400px;
        min-width: auto;
    }

    .gallery-image {
        aspect-ratio: 4/5;
    }

    .gallery-overlay {
        opacity: 1;
        background: linear-gradient(
            to top,
            rgba(5, 7, 20, 0.9) 0%,
            rgba(5, 7, 20, 0.3) 60%,
            transparent 100%
        );
        padding: 1.5rem;
    }

    .gallery-caption {
        font-size: 1.25rem;
    }

    .gallery-meta span {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    /* Contact Mobile */
    .contact-info {
        flex-direction: column;
        align-items: center;
    }

    .contact-item {
        width: 100%;
        max-width: 100%;
    }

    .contact-form {
        padding: 1.5rem;
    }

    /* Footer Mobile */
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-socials {
        justify-content: center;
    }

    /* Back to Top Mobile */
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
    }
}

/* ============================================
   MOBILE LARGE (480px) - Large phones
   ============================================ */
@media (max-width: 480px) {
    :root {
        --container-padding: 0.875rem;
    }

    /* Navigation - More compact */
    .navbar {
        min-height: 52px;
    }

    .nav-container {
        padding: 0.4rem 0.75rem;
        min-height: 52px;
    }

    .nav-logo {
        font-size: 0.9rem;
    }

    .logo-text {
        font-size: 0.8rem;
    }

    .logo-bracket {
        font-size: 0.75rem;
    }

    .lang-switcher {
        padding: 0.15rem;
        gap: 0.15rem;
    }

    .lang-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        min-height: 32px;
        min-width: 32px;
    }

    .nav-toggle {
        padding: 0.35rem;
    }

    .hamburger {
        width: 20px;
    }

    .hamburger::before,
    .hamburger::after {
        width: 20px;
    }

    .hamburger::before {
        top: -6px;
    }

    .hamburger::after {
        top: 6px;
    }

    /* Hero */
    .hero {
        padding: 68px 0 2.5rem;
    }

    .hero-content {
        padding: 1.25rem 0.875rem;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-greeting {
        font-size: 0.8rem;
        letter-spacing: 0.5px;
    }

    .hero-description {
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.7rem 1rem;
        font-size: 0.75rem;
    }

    .hero-buttons {
        flex-direction: column;
        width: 100%;
        max-width: 260px;
        margin-left: auto;
        margin-right: auto;
    }

    .hero-buttons .btn {
        width: 100%;
    }

    .social-link {
        width: 40px;
        height: 40px;
        font-size: 0.95rem;
    }

    /* Code Window */
    .code-window {
        font-size: 0.7rem;
        border-radius: 8px;
    }

    .window-header {
        padding: 0.5rem 0.75rem;
    }

    .dot {
        width: 8px;
        height: 8px;
    }

    .window-title {
        font-size: 0.7rem;
    }

    .window-body {
        padding: 0.875rem;
        font-size: 0.7rem;
        line-height: 1.55;
    }

    .window-body pre {
        font-size: 0.7rem;
        line-height: 1.55;
    }

    /* Section Headers */
    .section-title {
        font-size: 1.625rem;
    }

    .section-tag {
        font-size: 0.75rem;
        padding: 0.35rem 0.75rem;
    }

    /* About */
    .about-text h3 {
        font-size: 1.15rem;
    }

    .about-text p {
        font-size: 0.9rem;
    }

    .timeline-year {
        font-size: 0.7rem;
    }

    .timeline-content h4 {
        font-size: 0.95rem;
    }

    .timeline-content p {
        font-size: 0.8rem;
    }

    /* Skills */
    .category-title {
        font-size: 1rem;
    }

    .skills-grid {
        gap: 0.75rem;
    }

    .modern-card {
        padding: 1rem;
    }

    .skill-item i {
        font-size: 1.75rem;
    }

    .skill-item span {
        font-size: 0.75rem;
    }

    /* Experience */
    .current-role {
        padding: 1.5rem;
    }

    .role-badge {
        font-size: 0.65rem;
    }

    .current-role h3 {
        font-size: 1.25rem;
    }

    .company {
        font-size: 0.95rem;
    }

    .period {
        font-size: 0.8rem;
    }

    .role-description p,
    .role-description li {
        font-size: 0.85rem;
    }

    /* Projects */
    .projects-intro {
        font-size: 0.95rem;
    }

    .project-info {
        padding: 1.25rem;
    }

    .project-info h3 {
        font-size: 1.15rem;
    }

    .project-info > p {
        font-size: 0.85rem;
    }

    .project-tech span {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    /* Gallery */
    .gallery-intro {
        font-size: 0.95rem;
    }

    .gallery-item,
    .gallery-item.featured {
        max-width: 100%;
    }

    .gallery-image {
        aspect-ratio: 1/1;
    }

    .gallery-overlay {
        padding: 1.25rem;
    }

    .gallery-caption {
        font-size: 1.05rem;
    }

    .gallery-meta {
        gap: 0.5rem;
    }

    .gallery-meta span {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    /* Contact */
    .contact-icon {
        width: 42px;
        height: 42px;
        font-size: 1.05rem;
    }

    .contact-detail h4 {
        font-size: 0.8rem;
    }

    .contact-detail p,
    .contact-detail a {
        font-size: 0.85rem;
    }

    .contact-form {
        padding: 1.25rem;
    }

    .form-group input,
    .form-group textarea {
        padding: 0.875rem;
        font-size: 16px;
    }

    .form-group label {
        font-size: 0.8rem;
    }

    /* Footer */
    .footer {
        padding: 1.75rem 0 1rem;
    }

    .footer-brand .nav-logo {
        font-size: 1rem;
    }

    .footer-brand p {
        font-size: 0.8rem;
    }

    .footer-bottom {
        font-size: 0.75rem;
    }
}

/* ============================================
   MOBILE MEDIUM (414px) - iPhone Plus/Max
   ============================================ */
@media (max-width: 414px) {
    .hero-title {
        font-size: 1.75rem;
    }

    .section-title {
        font-size: 1.625rem;
    }

    .code-window {
        font-size: 0.7rem;
    }

    .window-body pre {
        font-size: 0.7rem;
        line-height: 1.6;
    }
}

/* ============================================
   MOBILE SMALL (375px) - iPhone SE/Mini
   ============================================ */
@media (max-width: 375px) {
    :root {
        --container-padding: 0.75rem;
    }

    .navbar {
        min-height: 48px;
    }

    .nav-container {
        padding: 0.35rem 0.5rem;
        min-height: 48px;
    }

    .nav-logo {
        font-size: 0.8rem;
    }

    .logo-text {
        font-size: 0.7rem;
    }

    .logo-bracket {
        font-size: 0.65rem;
    }

    .lang-switcher {
        transform: scale(0.9);
    }

    .lang-btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.65rem;
        min-width: 28px;
        min-height: 28px;
    }

    .hero {
        padding: 64px 0 2rem;
    }

    .hero-content {
        padding: 1rem 0.75rem;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-greeting {
        font-size: 0.75rem;
    }

    .btn {
        padding: 0.65rem 0.875rem;
        font-size: 0.7rem;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .skills-grid {
        gap: 0.75rem;
    }

    .modern-card {
        padding: 0.875rem;
    }

    .current-role {
        padding: 1.25rem;
    }

    .current-role h3 {
        font-size: 1.25rem;
    }

    /* Code Window */
    .window-title {
        font-size: 0.65rem;
        max-width: 80px;
    }

    .window-body {
        padding: 0.75rem;
        font-size: 0.65rem;
    }

    .window-body pre {
        font-size: 0.65rem;
        line-height: 1.5;
    }
}

/* ============================================
   MOBILE EXTRA SMALL (320px) - Smallest phones
   ============================================ */
@media (max-width: 320px) {
    .navbar {
        min-height: 44px;
    }

    .nav-container {
        padding: 0.3rem 0.5rem;
        min-height: 44px;
    }

    .nav-logo {
        font-size: 0.75rem;
    }

    .logo-text {
        font-size: 0.65rem;
    }

    .lang-switcher {
        transform: scale(0.85);
    }

    .lang-btn {
        padding: 0.15rem 0.35rem;
        font-size: 0.6rem;
        min-width: 26px;
        min-height: 26px;
    }

    .hero-title {
        font-size: 1.35rem;
    }

    .hero-greeting {
        font-size: 0.7rem;
        letter-spacing: 0.5px;
    }

    .section-title {
        font-size: 1.35rem;
    }

    .btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.65rem;
    }

    .code-window {
        font-size: 0.65rem;
        border-radius: 6px;
    }

    .window-header {
        padding: 0.4rem 0.5rem;
    }

    .window-title {
        font-size: 0.6rem;
        max-width: 70px;
    }

    .window-body {
        padding: 0.625rem;
        font-size: 0.6rem;
        line-height: 1.45;
    }

    .window-body pre {
        font-size: 0.6rem;
        line-height: 1.45;
    }

    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.625rem;
    }

    .skill-item i {
        font-size: 1.5rem;
    }

    .skill-item span {
        font-size: 0.75rem;
    }

    .gallery-caption {
        font-size: 1rem;
    }

    .gallery-meta span {
        font-size: 0.65rem;
    }
}

/* ============================================
   TABLET SPECIFIC OPTIMIZATIONS
   ============================================ */

/* iPad Pro 12.9" & similar large tablets */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: portrait) {
    .hero-content {
        gap: 3rem;
    }

    .code-window {
        max-width: 400px;
    }
}

/* iPad Mini & similar small tablets */
@media (min-width: 768px) and (max-width: 834px) and (orientation: portrait) {
    .hero-title {
        font-size: 3rem;
    }

    .about-content {
        grid-template-columns: 1fr 1.5fr;
        gap: 2rem;
    }

    .about-image {
        position: relative;
        top: 0;
    }

    .skills-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .gallery-grid {
        flex-wrap: wrap;
        justify-content: center;
    }

    .gallery-item {
        flex: 0 0 calc(50% - 1rem);
        max-width: 300px;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION SPECIFIC
   ============================================ */

/* Mobile Landscape */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 60px 0 3rem;
    }

    .hero-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        align-items: start;
    }

    .hero-image {
        order: 0;
    }

    .code-window {
        max-width: 280px;
    }

    .scroll-indicator {
        display: none;
    }

    .nav-menu {
        padding-top: 4rem;
    }

    .nav-link {
        padding: 0.75rem 0;
    }
}

/* Tablet Landscape */
@media (min-width: 1024px) and (max-height: 800px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 6rem 0 4rem;
    }

    .code-window {
        max-width: 380px;
    }
}

/* ============================================
   HIGH DPI / RETINA DISPLAYS
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .cyber-grid {
        background-size: 25px 25px;
    }
}

/* ============================================
   HOVER CAPABILITY DETECTION
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects on touch devices */
    .modern-card:hover,
    .project-card:hover,
    .gallery-card:hover,
    .social-link:hover,
    .btn:hover {
        transform: none;
    }

    /* Show gallery overlay by default on mobile */
    .gallery-overlay {
        opacity: 1;
        background: linear-gradient(
            to top,
            rgba(5, 7, 20, 0.9) 0%,
            rgba(5, 7, 20, 0.4) 50%,
            transparent 100%
        );
    }

    /* Make tap targets larger */
    .nav-link,
    .btn,
    .lang-btn,
    .social-link {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .navbar,
    .scroll-indicator,
    .back-to-top,
    .hero-socials,
    .hero-buttons,
    .contact-form,
    .footer-socials {
        display: none !important;
    }

    .hero {
        min-height: auto;
        padding: 2rem 0;
    }

    .section {
        padding: 2rem 0;
        page-break-inside: avoid;
    }

    body {
        background: white;
        color: black;
    }

    .code-window {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}

/* ============================================
   SAFE AREA INSETS (Notch devices)
   ============================================ */
@supports (padding: max(0px)) {
    .navbar {
        padding-left: max(var(--container-padding), env(safe-area-inset-left));
        padding-right: max(var(--container-padding), env(safe-area-inset-right));
    }

    .back-to-top {
        bottom: max(2rem, env(safe-area-inset-bottom));
        right: max(2rem, env(safe-area-inset-right));
    }

    @media (max-width: 768px) {
        .back-to-top {
            bottom: max(1rem, env(safe-area-inset-bottom));
            right: max(1rem, env(safe-area-inset-right));
        }
    }
}
