/* Universal Mobile Responsive Styles for All Projects */

/* Responsive breakpoints */
:root {
    --mobile-small: 320px;
    --mobile: 480px;
    --tablet: 768px;
    --desktop: 1024px;
    --desktop-large: 1440px;
}

/* Base responsive adjustments */
@media (max-width: 768px) {
    /* Touch-friendly button sizes */
    button, .btn, .control-btn, .nav-btn, .tool-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Stack controls vertically on mobile */
    .controls, .control-group, .data-controls {
        flex-direction: column;
        width: 100%;
    }
    
    /* Full-width inputs on mobile */
    input[type="text"],
    input[type="number"],
    input[type="range"],
    select,
    textarea {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Responsive canvas sizing */
    canvas {
        max-width: 100%;
        height: auto;
        touch-action: none; /* Better touch handling */
    }
    
    /* Hide secondary elements on mobile */
    .desktop-only {
        display: none;
    }
    
    /* Responsive grid layouts */
    .grid, .projects-grid, .theory-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Responsive navigation */
    .nav, .navigation, .module-navigation {
        flex-direction: column;
        width: 100%;
    }
    
    .nav-item, .nav-btn {
        width: 100%;
        text-align: center;
    }
    
    /* Responsive text sizing */
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    p, body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    /* Panel adjustments */
    .panel, .info-panel, .control-panel, .tools-panel {
        position: relative;
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
    }
    
    /* Modal/overlay adjustments */
    .modal, .overlay, .info-overlay {
        padding: 1rem;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        overflow-y: auto;
    }
    
    /* Slider adjustments for touch */
    input[type="range"] {
        -webkit-appearance: none;
        height: 40px;
        background: transparent;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        cursor: pointer;
    }
    
    input[type="range"]::-moz-range-thumb {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        cursor: pointer;
    }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
    /* Further reduce text sizes */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    /* Compact spacing */
    .container {
        padding: 0.5rem;
    }
    
    /* Single column layouts */
    .main-content {
        grid-template-columns: 1fr;
    }
    
    /* Compact buttons */
    .btn-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
}

/* Tablet adjustments */
@media (min-width: 481px) and (max-width: 768px) {
    /* Two-column grids on tablets */
    .grid, .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Side-by-side controls where appropriate */
    .control-row {
        display: flex;
        gap: 1rem;
    }
    
    .control-row > * {
        flex: 1;
    }
}

/* Touch device enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects on touch devices */
    *:hover {
        transform: none !important;
    }
    
    /* Larger touch targets */
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover-only UI elements */
    .hover-only {
        display: none;
    }
    
    /* Add visual feedback for touch */
    button:active, .btn:active {
        opacity: 0.8;
        transform: scale(0.95);
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 600px) {
    /* Reduce vertical spacing in landscape */
    header {
        padding: 0.5rem;
    }
    
    .hero, .header {
        min-height: auto;
        padding: 1rem;
    }
    
    /* Hide less important elements */
    .subtitle, .description {
        display: none;
    }
    
    /* Compact controls */
    .controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.9);
        padding: 0.5rem;
        z-index: 100;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Thinner borders for retina displays */
    * {
        border-width: 0.5px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, but ensure readability */
    body {
        background: #1a1a1a;
        color: #e0e0e0;
    }
}

/* Print styles */
@media print {
    /* Hide interactive elements */
    button, .controls, nav, .navigation {
        display: none !important;
    }
    
    /* Ensure canvas prints properly */
    canvas {
        max-width: 100%;
        page-break-inside: avoid;
    }
}

/* Utility classes for responsive design */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

.tablet-up {
    display: none;
}

@media (min-width: 769px) {
    .tablet-up {
        display: block;
    }
}

/* Responsive containers */
.responsive-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (max-width: 768px) {
    .responsive-container {
        padding: 0 0.5rem;
    }
}

/* Responsive flex utilities */
.flex-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

@media (max-width: 768px) {
    .flex-responsive {
        flex-direction: column;
    }
}

/* Canvas container responsive sizing */
.canvas-responsive {
    position: relative;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
}

@media (max-width: 768px) {
    .canvas-responsive {
        aspect-ratio: 4 / 3;
    }
}

@media (max-width: 480px) {
    .canvas-responsive {
        aspect-ratio: 1 / 1;
    }
}

/* Responsive typography scale */
.text-responsive {
    font-size: clamp(14px, 2.5vw, 18px);
    line-height: 1.6;
}

.heading-responsive {
    font-size: clamp(1.5rem, 5vw, 3rem);
}

/* Responsive spacing */
.spacing-responsive {
    padding: clamp(1rem, 3vw, 2rem);
    margin: clamp(0.5rem, 2vw, 1.5rem);
}