/*
 * Responsive Styles for Fadi MRIRI's Portfolio
 * Author: Fadi MRIRI
 * Version: 1.0
 */

/* ===== Media Queries ===== */

/* Base responsive styles for all screen sizes */
html {
    font-size: 16px;
}

body {
    overflow-x: hidden;
}

img, video {
    max-width: 100%;
    height: auto;
}

/* Large Desktops (1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }

    .timeline {
        max-width: 1200px;
    }
}

/* Desktops (992px to 1199px) */
@media (max-width: 1199px) {
    .container {
        max-width: 960px;
    }

    h1 {
        font-size: 3rem;
    }

    h2 {
        font-size: 2.2rem;
    }

    .hero-content {
        padding: 0 var(--spacing-lg);
    }
}

/* Tablets (768px to 991px) */
@media (max-width: 991px) {
    .container {
        max-width: 720px;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    .hero-content {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-lg);
    }

    .hero-text {
        order: 2;
    }

    .hero-3d {
        order: 1;
    }

    .cta-buttons {
        justify-content: center;
    }

    .about-card {
        max-width: 700px;
    }

    .about-text {
        max-height: 180px;
    }

    .timeline::before {
        left: 30px;
        transform: none;
    }

    .timeline-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .timeline-dot {
        left: 30px;
        transform: none;
    }

    .timeline-date {
        left: 80px;
        transform: none;
        top: 30px;
    }

    .timeline-company {
        width: calc(100% - 60px);
        margin-left: 60px;
        margin-right: 0;
        text-align: left;
        margin-bottom: var(--spacing-md);
        order: 1;
    }

    .timeline-content {
        width: calc(100% - 60px);
        margin-left: 60px;
        margin-right: 0;
        order: 2;
    }
}

/* Mobile Landscape (576px to 767px) */
@media (max-width: 767px) {
    .container {
        max-width: 540px;
    }

    h1 {
        font-size: 2.2rem;
    }

    h2 {
        font-size: 1.8rem;
    }

    section {
        padding: var(--spacing-lg) var(--spacing-sm);
    }

    .navbar {
        padding: 1rem;
    }

    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        flex-direction: column;
        background-color: rgba(10, 10, 10, 0.95);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
        padding: 2rem 0;
        backdrop-filter: blur(10px);
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        margin: 1.5rem 0;
    }

    .menu-toggle {
        display: flex;
    }

    .menu-toggle.active .bar:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }

    .menu-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.active .bar:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }

    /* Position language switcher and theme toggle for mobile */
    .language-switcher {
        top: 20px;
        right: 20px;
        padding: 4px 8px;
        z-index: 1001;
    }

    .toggle-track {
        width: 36px;
        height: 18px;
    }

    .toggle-thumb {
        width: 14px;
        height: 14px;
    }

    .cube-container {
        width: 150px;
        height: 150px;
    }

    .face {
        width: 150px;
        height: 150px;
        font-size: 3rem;
    }

    .front {
        transform: translateZ(75px);
    }

    .back {
        transform: rotateY(180deg) translateZ(75px);
    }

    .right {
        transform: rotateY(90deg) translateZ(75px);
    }

    .left {
        transform: rotateY(-90deg) translateZ(75px);
    }

    .top {
        transform: rotateX(90deg) translateZ(75px);
    }

    .bottom {
        transform: rotateX(-90deg) translateZ(75px);
    }

    .skills-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .skill-item {
        width: 100px;
        height: 100px;
    }

    .footer-content {
        flex-direction: column;
        gap: var(--spacing-md);
    }
}

/* Mobile Portrait (up to 575px) */
@media (max-width: 575px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    .hero-section {
        height: auto;
        min-height: 100vh;
        padding-top: 100px;
        padding-bottom: 50px;
    }

    .hero-content {
        flex-direction: column;
        gap: var(--spacing-lg);
    }

    .hero-text {
        text-align: center;
        max-width: 100%;
    }

    .name-underline {
        margin: 10px auto 0;
    }

    .tech-sphere {
        width: 200px;
        height: 200px;
        margin-top: 20px;
    }

    .orbit {
        width: 200px;
        height: 200px;
    }

    .orbit-icon {
        transform-origin: 100px 100px;
    }

    .orbit-icon:nth-child(1) { transform: rotate(calc(60deg * var(--i))) translateX(100px) rotate(calc(-60deg * var(--i))); }
    .orbit-icon:nth-child(2) { transform: rotate(calc(60deg * var(--i))) translateX(100px) rotate(calc(-60deg * var(--i))); }
    .orbit-icon:nth-child(3) { transform: rotate(calc(60deg * var(--i))) translateX(100px) rotate(calc(-60deg * var(--i))); }
    .orbit-icon:nth-child(4) { transform: rotate(calc(60deg * var(--i))) translateX(100px) rotate(calc(-60deg * var(--i))); }
    .orbit-icon:nth-child(5) { transform: rotate(calc(60deg * var(--i))) translateX(100px) rotate(calc(-60deg * var(--i))); }
    .orbit-icon:nth-child(6) { transform: rotate(calc(60deg * var(--i))) translateX(100px) rotate(calc(-60deg * var(--i))); }

    /* Hide scroll indicator on mobile */
    .scroll-indicator {
        display: none;
    }

    /* Adjust theme toggle and language switcher for smaller screens */
    .language-switcher {
        position: fixed;
        top: 60px;
        right: 15px;
        padding: 3px 6px;
        z-index: 1001;
    }

    .toggle-track {
        width: 32px;
        height: 16px;
        margin: 0 5px;
    }

    .toggle-thumb {
        width: 12px;
        height: 12px;
        top: 1px;
    }

    .lang-btn {
        font-size: 0.8rem;
        padding: 3px 5px;
    }

    .cta-buttons {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .btn {
        width: 100%;
    }

    .about-card {
        height: auto;
        min-height: 500px;
        max-width: 100%;
    }

    .about-text {
        max-height: 250px;
        font-size: 0.95rem;
    }

    .card-back {
        padding: var(--spacing-md);
    }

    /* Fix location display on mobile */
    .info-item {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        font-size: 0.9rem;
        flex-wrap: wrap;
    }

    .info-item i {
        margin-right: 10px;
        width: 20px;
        text-align: center;
    }

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

    .projects-content {
        grid-template-columns: 1fr;
    }

    /* Enhanced flip card responsive handling */
    .project-card {
        height: auto;
        min-height: 300px;
    }

    .project-card-inner {
        /* Ensure smooth transition on mobile */
        transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }

    .project-card-front,
    .project-card-back {
        padding: var(--spacing-sm);
        font-size: 0.9rem;
    }

    .timeline-company,
    .timeline-content {
        width: calc(100% - 60px);
        margin-left: 60px;
        padding: var(--spacing-sm);
    }

    .timeline-date {
        font-size: 0.8rem;
        left: 60px;
    }

    .education-content, .contact-content {
        flex-direction: column;
    }

    .contact-form {
        padding: var(--spacing-md);
    }

    /* Improve scrolling on mobile */
    .card-back {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Very Small Devices (up to 375px) */
@media (max-width: 375px) {
    h1 {
        font-size: 1.8rem;
    }

    /* Further adjust theme toggle and language switcher for very small screens */
    .language-switcher {
        top: 80px;
        right: 10px;
        padding: 2px 5px;
    }

    .toggle-track {
        width: 28px;
        height: 14px;
        margin: 0 4px;
    }

    .toggle-thumb {
        width: 10px;
        height: 10px;
        top: 1px;
    }

    .lang-btn {
        font-size: 0.7rem;
        padding: 2px 4px;
    }

    .cube-container {
        width: 120px;
        height: 120px;
    }

    .face {
        width: 120px;
        height: 120px;
        font-size: 2.5rem;
    }

    .front {
        transform: translateZ(60px);
    }

    .back {
        transform: rotateY(180deg) translateZ(60px);
    }

    .right {
        transform: rotateY(90deg) translateZ(60px);
    }

    .left {
        transform: rotateY(-90deg) translateZ(60px);
    }

    .top {
        transform: rotateX(90deg) translateZ(60px);
    }

    .bottom {
        transform: rotateX(-90deg) translateZ(60px);
    }

    .skill-item {
        width: 90px;
        height: 90px;
    }

    .skill-item i {
        font-size: 2rem;
    }

    .skill-item span {
        font-size: 0.8rem;
    }

    .about-text {
        font-size: 0.9rem;
    }

    .card-back {
        padding: var(--spacing-sm);
    }

    .info-item {
        font-size: 0.9rem;
    }

    .timeline-company,
    .timeline-content {
        width: calc(100% - 40px);
        margin-left: 40px;
        padding: var(--spacing-xs);
    }

    .timeline-date {
        left: 40px;
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    .timeline::before {
        left: 20px;
    }

    .timeline-dot {
        left: 20px;
        width: 15px;
        height: 15px;
    }

    .project-details {
        padding: var(--spacing-xs);
    }

    .tech-stack-small .tech-tag {
        font-size: 0.6rem;
        padding: 2px 6px;
    }

    /* Fix navbar on very small screens */
    .navbar {
        padding: 0.8rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    .menu-toggle .bar {
        width: 22px;
        height: 2px;
    }
}
