/**
 * codemastertool.com - Comprehensive Responsive Design System
 * Mobile-First Approach with Desktop Enhancements
 * Breakpoints: 480px, 768px, 992px, 1200px, 1400px
 */

/* =================================
   BASE RESPONSIVE VARIABLES
   ================================= */
:root {
    /* Responsive Spacing */
    --mobile-padding: 1rem;
    --tablet-padding: 1.5rem;
    --desktop-padding: 2rem;
    --wide-padding: 3rem;
    
    /* Responsive Font Sizes */
    --mobile-base-font: 0.9rem;
    --tablet-base-font: 1rem;
    --desktop-base-font: 1.1rem;
    
    /* Touch Target Sizes */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;
    
    /* Responsive Grid Gaps */
    --mobile-gap: 1rem;
    --tablet-gap: 1.5rem;
    --desktop-gap: 2rem;
}

/* =================================
   MOBILE FIRST BASE STYLES
   ================================= */

/* Base mobile styles (320px+) */
html {
    font-size: var(--mobile-base-font);
    scroll-behavior: smooth;
}

body {
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container responsive behavior */
.container,
.main-container,
.editor-container {
    width: 100%;
    max-width: 100%;
    padding: 0 var(--mobile-padding);
}

/* =================================
   SMALL MOBILE (480px and below)
   ================================= */
@media (max-width: 480px) {
    :root {
        --space-xs: 0.25rem;
        --space-sm: 0.5rem;
        --space-md: 0.75rem;
        --space-lg: 1rem;
        --space-xl: 1.25rem;
    }
    
    /* Ultra-compact spacing for small screens */
    .professional-nav {
        height: 56px;
        padding: 0;
    }
    
    .main-content-wrapper {
        margin-top: 56px;
    }
    
    /* Stack everything vertically on small screens */
    .hero-section,
    .tools-row,
    .features-grid {
        display: flex;
        flex-direction: column;
        gap: var(--mobile-gap);
    }
    
    /* Touch-friendly buttons */
    .editor-btn,
    .cta-button,
    .action-btn,
    .mobile-menu-btn {
        min-height: var(--touch-target-min);
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .mobile-menu-btn {
        width: 36px;
        height: 36px;
        padding: 0;
    }
    
    /* Compact text sizes */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    
    /* Mobile editor adjustments */
    .editor-container {
        padding: 0.5rem;
        gap: 0.75rem;
        height: auto;
        min-height: calc(100vh - 80px);
    }
    
    .code-editor-container {
        min-height: 250px;
    }
    
    .line-numbers {
        min-width: 40px;
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }
    
    .code-editor-container textarea {
        font-size: 0.8rem;
        line-height: 1.4;
        padding: 0.5rem;
    }
}

/* =================================
   LARGE MOBILE / SMALL TABLET (481px - 768px)
   ================================= */
@media (min-width: 481px) and (max-width: 768px) {
    html {
        font-size: 1rem;
    }
    
    .container,
    .main-container,
    .editor-container {
        padding: 0 var(--tablet-padding);
    }
    
    .professional-nav {
        height: 60px;
    }
    
    .main-content-wrapper {
        margin-top: 60px;
    }
    
    /* Improved spacing for larger mobiles */
    .hero-section {
        padding: 3rem 1rem;
        gap: 2rem;
    }
    
    .tools-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .editor-container {
        padding: 1rem;
        gap: 1rem;
    }
    
    .code-editor-container {
        min-height: 300px;
    }
    
    .line-numbers {
        min-width: 50px;
        font-size: 0.85rem;
    }
    
    .code-editor-container textarea {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
}

/* =================================
   TABLET (769px - 992px)
   ================================= */
@media (min-width: 769px) and (max-width: 992px) {
    html {
        font-size: var(--tablet-base-font);
    }
    
    .container,
    .main-container {
        max-width: 750px;
        margin: 0 auto;
        padding: 0 var(--tablet-padding);
    }
    
    /* Two-column layouts for tablets */
    .tools-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--tablet-gap);
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--tablet-gap);
    }
    
    .hero-section {
        grid-template-columns: 1fr 1fr;
        gap: 3rem;
        align-items: center;
    }
    
    /* Desktop-like navigation */
    .nav-menu {
        display: flex;
        gap: var(--space-md);
    }
    
    .mobile-menu-btn {
        display: none;
    }
    
    /* Editor improvements */
    .editor-container {
        padding: 1.5rem;
        gap: 1.5rem;
        max-width: 1000px;
        margin: 0 auto;
    }
    
    .section-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .editor-controls {
        flex-direction: row;
        gap: 1rem;
    }
}

/* =================================
   SMALL DESKTOP (993px - 1200px)
   ================================= */
@media (min-width: 993px) and (max-width: 1200px) {
    html {
        font-size: var(--desktop-base-font);
    }
    
    .container,
    .main-container {
        max-width: 970px;
        margin: 0 auto;
        padding: 0 var(--desktop-padding);
    }
    
    .editor-container {
        max-width: 1100px;
        margin: 0 auto;
        padding: var(--desktop-padding);
        gap: var(--desktop-gap);
    }
    
    /* Full desktop navigation */
    .nav-menu {
        display: flex;
        gap: var(--space-lg);
    }
    
    .mobile-menu-btn {
        display: none !important;
    }
    
    /* Mega menus and dropdowns work */
    .mega-menu,
    .dropdown-menu {
        display: block;
    }
    
    /* Three-column layouts */
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--desktop-gap);
    }
    
    /* Side-by-side editors and output */
    .editor-layout-horizontal {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--desktop-gap);
    }
    
    .code-editor-container {
        min-height: 400px;
    }
}

/* =================================
   LARGE DESKTOP (1201px - 1400px)
   ================================= */
@media (min-width: 1201px) and (max-width: 1400px) {
    .container,
    .main-container {
        max-width: 1170px;
        margin: 0 auto;
    }
    
    .editor-container {
        max-width: 1300px;
        margin: 0 auto;
        padding: var(--desktop-padding);
    }
    
    /* Desktop navigation only */
    .mobile-menu-btn {
        display: none !important;
    }
    
    /* More breathing room */
    .hero-section {
        padding: 6rem 2rem;
        gap: 4rem;
    }
    
    .tools-section,
    .features-section {
        padding: 6rem 2rem;
    }
    
    /* Optimal editor size */
    .code-editor-container {
        min-height: 450px;
    }
    
    .output-container,
    .preview-container {
        min-height: 350px;
    }
}

/* =================================
   EXTRA LARGE DESKTOP (1401px+)
   ================================= */
@media (min-width: 1401px) {
    .container,
    .main-container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .editor-container {
        max-width: 1400px;
        margin: 0 auto;
        padding: var(--wide-padding);
    }
    
    /* Desktop navigation only */
    .mobile-menu-btn {
        display: none !important;
    }
    
    /* Maximum comfort spacing */
    .hero-section {
        padding: 8rem 3rem;
        gap: 6rem;
    }
    
    /* Larger editor for better coding experience */
    .code-editor-container {
        min-height: 500px;
    }
    
    .line-numbers {
        min-width: 60px;
        font-size: 1rem;
    }
    
    .code-editor-container textarea {
        font-size: 1rem;
        line-height: 1.5;
    }
}

/* =================================
   HIGH DPI / RETINA DISPLAYS
   ================================= */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Sharper borders */
    .editor-section,
    .output-section,
    .tool-card {
        border-width: 0.5px;
    }
}

/* =================================
   PRINT STYLES
   ================================= */
@media print {
    .professional-header,
    .mobile-menu,
    .mobile-menu-overlay,
    .action-bar,
    .cta-section {
        display: none !important;
    }
    
    .main-content-wrapper {
        margin-top: 0 !important;
    }
    
    .editor-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .code-editor-container {
        border: 1px solid #ccc;
        background: white !important;
    }
    
    .code-editor-container textarea {
        color: black !important;
        background: white !important;
    }
}

/* =================================
   REDUCED MOTION PREFERENCES
   ================================= */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* =================================
   DARK MODE PREFERENCES
   ================================= */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #1a1a1a;
        --text-color: #000000;
        --border-color: #333333;
    }
}

/* =================================
   TOUCH DEVICE OPTIMIZATIONS
   ================================= */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .nav-link,
    .editor-btn,
    .action-btn,
    .tool-card,
    .mobile-item {
        min-height: var(--touch-target-comfortable);
        touch-action: manipulation;
    }
    
    /* Remove hover effects that don't work on touch */
    .tool-card:hover,
    .feature-card:hover,
    .nav-link:hover {
        transform: none;
    }
    
    /* Add active states for touch feedback */
    .tool-card:active,
    .feature-card:active,
    .editor-btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Improve scrolling */
    .mobile-menu,
    .editor-container,
    .output-container {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* =================================
   LANDSCAPE ORIENTATION (MOBILE)
   ================================= */
@media (max-width: 768px) and (orientation: landscape) {
    .professional-nav {
        height: 48px;
    }
    
    .main-content-wrapper {
        margin-top: 48px;
    }
    
    .editor-container {
        height: calc(100vh - 60px);
    }
    
    .hero-section {
        padding: 2rem 1rem;
        min-height: auto;
    }
    
    .hero-stats {
        flex-direction: row;
        justify-content: center;
        gap: 1rem;
    }
}

/* =================================
   LOADING AND PERFORMANCE
   ================================= */

/* Optimize animations for better performance */
.tool-card,
.feature-card,
.nav-link {
    will-change: transform;
}

/* Smooth scrolling behavior */
html {
    scroll-behavior: smooth;
}

/* Prevent horizontal scroll on mobile */
body {
    overflow-x: hidden;
}

/* =================================
   ACCESSIBILITY IMPROVEMENTS
   ================================= */

/* Focus states for keyboard navigation */
.nav-link:focus,
.editor-btn:focus,
.tool-card:focus,
.mobile-item:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Skip links for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 9999;
}

.skip-link:focus {
    top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tool-card,
    .feature-card,
    .editor-section {
        border: 2px solid currentColor;
    }
}
