/* ===================================
   CIDADÃO.AI - MOBILE OPTIMIZATIONS
   Mobile-first approach with best practices
   =================================== */

/* ===== MOBILE-FIRST BASE STYLES ===== */
/* Base styles for smallest devices (320px+) */

/* Optimize viewport and prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Improve tap targets for mobile */
button, a, .control-button, .btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Better touch feedback */
button:active, a:active, .btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Disable hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
    button:hover, a:hover, .btn:hover {
        transform: none !important;
        box-shadow: none !important;
    }
}

/* ===== MOBILE TYPOGRAPHY ===== */
@media (max-width: 768px) {
    /* Fluid typography with clamp() */
    .hero-title {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
        line-height: 1.2;
    }
    
    .hero-subtitle-large {
        font-size: clamp(1.1rem, 4vw, 1.4rem);
    }
    
    .hero-description {
        font-size: clamp(0.95rem, 3vw, 1.125rem);
    }
    
    .section-title {
        font-size: clamp(1.5rem, 6vw, 2rem);
    }
    
    p, .section-description {
        font-size: clamp(0.875rem, 2.5vw, 1rem);
    }
}

/* ===== MOBILE HEADER OPTIMIZATIONS ===== */
/* Header styles are handled by header-mobile-first.css */
@media (max-width: 768px) {
    /* Ensure navbar container is properly aligned */
    .navbar-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;
        width: 100%;
        max-width: 100%;
        padding: 0 1rem;
    }
}

/* ===== MOBILE HERO SECTION ===== */
@media (max-width: 768px) {
    .hero {
        padding: 1.5rem 1rem;
        min-height: auto;
    }
    
    .hero-container {
        padding: 0;
    }
    
    .hero-badge {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
        margin-bottom: 1rem;
    }
    
    .hero-buttons {
        width: 100%;
        gap: 0.75rem;
    }
    
    .btn {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* ===== MOBILE CONTENT SECTIONS ===== */
@media (max-width: 768px) {
    .section {
        padding: 2rem 0.75rem;
    }
    
    .section-container {
        padding: 0;
    }
    
    /* Single column layout for cards */
    .links-grid,
    .narrow-grid,
    #repositories .narrow-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
        max-width: 100%;
    }
    
    .link-card {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .link-icon {
        width: 40px;
        height: 40px;
    }
    
    .link-title {
        font-size: 1rem;
    }
    
    .link-description {
        font-size: 0.8rem;
        line-height: 1.3;
    }
}

/* ===== MOBILE CAROUSEL OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    .agents-carousel-section {
        padding: 2rem 0;
    }
    
    .carousel-context {
        padding: 0 1rem;
    }
    
    .agents-carousel-container {
        height: 80px;
        padding: 10px 0;
    }
    
    .agents-carousel-track {
        height: 60px;
        margin-top: 10px;
    }
    
    .carousel-agent {
        min-width: 50px;
        height: 50px;
    }
    
    .carousel-avatar {
        width: 50px;
        height: 50px;
    }
    
    /* Hardware-accelerated animation for mobile */
    @keyframes scroll-infinite {
        0% { transform: translate3d(0, 0, 0); }
        100% { transform: translate3d(calc(-15 * 50px), 0, 0); }
    }
    
    .carousel-floating-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
        margin-top: 1.5rem;
    }
}

/* ===== SLIDE DOWN ANIMATION ===== */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== MOBILE MODAL OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    
    .modal-content {
        margin: 0;
        border-radius: 0;
        max-width: 100%;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        padding: 1.5rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-header {
        position: sticky;
        top: -1.5rem;
        background: var(--bg-primary);
        padding: 1rem 0;
        margin-bottom: 1rem;
        z-index: 10;
    }
    
    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    /* Agent cards in modal */
    .agents-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .agent-card {
        height: auto !important;
        min-height: 300px;
        padding: 1.5rem;
    }
    
    .agent-avatar {
        width: 120px;
        height: 120px;
    }
}

/* ===== MOBILE PERFORMANCE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    /* Disable heavy animations on mobile */
    body::before,
    .hero::before {
        animation: none;
        display: none;
    }
    
    /* Simplify gradients for performance */
    body {
        background: var(--bg-primary);
    }
    
    .hero {
        background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    }
    
    /* Reduce shadow complexity */
    * {
        box-shadow: none !important;
    }
    
    .btn-primary,
    .carousel-floating-btn,
    .control-button.active {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
}

/* ===== MOBILE FOOTER OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    .footer {
        padding: 2rem 0 1.5rem;
        margin-top: 2rem;
    }
    
    .footer-container {
        padding: 0 1rem;
    }
    
    .footer-content {
        gap: 1.5rem;
    }
    
    .footer-section {
        padding: 0.5rem;
        text-align: center;
    }
    
    .footer-title {
        font-size: 1.25rem;
    }
    
    .footer-bottom {
        padding-top: 1rem;
        gap: 0.75rem;
    }
    
    .footer-badges {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ===== TOUCH-SPECIFIC OPTIMIZATIONS ===== */
@media (pointer: coarse) {
    /* Increase touch targets */
    .carousel-agent {
        min-width: 60px;
        padding: 5px;
    }
    
    /* Better scrolling */
    .modal-content,
    .agents-carousel-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Disable tooltip on touch devices */
    .global-tooltip,
    .carousel-tooltip {
        display: none !important;
    }
}

/* ===== LANDSCAPE MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 1rem;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .modal-content {
        height: 100vh;
        padding: 1rem;
    }
    
    .agents-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== ACCESSIBILITY FOR MOBILE ===== */
@media (max-width: 768px) {
    /* Ensure focus indicators are visible */
    *:focus {
        outline: 3px solid var(--text-accent);
        outline-offset: 2px;
    }
    
    /* Skip link more prominent on mobile */
    .skip-link:focus {
        top: 60px; /* Below fixed header */
        font-size: 1rem;
        padding: 1rem;
    }
}

/* ===== NETWORK-AWARE OPTIMIZATIONS ===== */
@media (prefers-reduced-data: reduce) {
    /* Disable non-essential images */
    .agent-avatar,
    .carousel-avatar {
        background: var(--bg-secondary);
    }
    
    /* Simplify animations */
    * {
        animation-duration: 0s !important;
        transition-duration: 0s !important;
    }
}

/* ===== PROGRESSIVE ENHANCEMENT ===== */
/* For browsers that support newer features */
@supports (padding: max(0px)) {
    /* Safe area insets for notched devices */
    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .modal-content {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
    
    .footer {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
}

/* ===== DARK MODE MOBILE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    [data-theme="dark"] .navbar {
        background-color: rgba(15, 23, 42, 0.98);
    }
    
    [data-theme="dark"] .modal-content {
        background: var(--bg-primary);
    }
    
    [data-theme="dark"] .modal-header {
        background: var(--bg-primary);
    }
}

/* ===== PRINT STYLES FOR MOBILE ===== */
@media print {
    .navbar,
    .carousel-floating-btn,
    .nav-controls,
    .agents-carousel-section {
        display: none !important;
    }
    
    body {
        padding-top: 0;
    }
    
    .section {
        page-break-inside: avoid;
    }
}