/*
╔══════════════════════════════════════════════════════════╗
║                        NEURAL STYLE MEMORY BOOK                    ║
║                 Responsive Media Queries & Device Support          ║
╠══════════════════════════════════════════════════════════╣
║ File: css/queries.css                                              ║
║ Purpose: Mobile-first responsive design with modern device support ║
║ Version: 1.2.0                                                     ║
║ Author: Neural Style Memory Book Team                              ║
║ Created: 2024                                                      ║
║                                                                    ║
║ Features:                                                          ║
║ • Mobile-first responsive breakpoints (320px to 1920px+)           ║
║ • Foldable device support (Surface Duo, Galaxy Fold)               ║
║ • Container queries for component-level responsiveness             ║
║ • Touch device optimizations                                       ║
║ • High DPI display support                                         ║
║ • Accessibility media queries (reduced motion, high contrast)      ║
║ • Print styles for offline documentation                           ║
║ • Gaming display support (ultra-wide 32:9)                         ║
║ • Performance optimizations for lower-end devices                  ║
║                                                                    ║
║ Breakpoint Strategy:                                               ║
║ • 320px-479px: Mobile portrait (Galaxy Fold closed)                ║
║ • 480px-639px: Mobile landscape                                    ║
║ • 640px-767px: Tablet portrait                                     ║
║ • 768px-1023px: Tablet landscape                                   ║
║ • 1024px-1279px: Desktop                                           ║
║ • 1280px+: Large desktop                                           ║
║ • 1920px+: Ultra-wide displays                                     ║
║                                                                    ║
║ Special Devices:                                                   ║
║ • Surface Duo: Dual-screen layout support                          ║
║ • iPad Pro: Three-column layout                                    ║
║ • Gaming displays: Optimized ultra-wide layouts                    ║
║                                                                    ║
║ Dependencies: variables.css, styles.css                            ║
║ Browser Support: CSS Media Queries Level 4 with fallbacks          ║
╚══════════════════════════════════════════════════════════╝
*/

/* Neural Style Memory Book - Responsive Media Queries */
/* Mobile-first responsive design with support for foldables and modern devices */

/* === MOBILE PORTRAIT (320px - 480px) === */
/* Base styles are mobile-first, these are refinements */

@media (max-width: 479px) {
  :root {
    --space-fluid-sm: clamp(0.5rem, 3vw, 1rem);
    --space-fluid-md: clamp(1rem, 5vw, 2rem);
    --space-fluid-lg: clamp(1.5rem, 7vw, 3rem);
    --book-width: 95vw;
    --book-height: 50vh;
  }

  .header-content {
    padding: 0 var(--space-4);
    flex-direction: column;
    gap: var(--space-4);
  }

  .app-title {
    font-size: var(--font-size-lg);
  }

  .header-nav {
    justify-content: center;
    width: 100%;
  }

  .nav-btn {
    flex: 1;
    justify-content: center;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
  }

  .btn-icon {
    font-size: var(--font-size-base);
  }

  .upload-section {
    padding: var(--space-4);
  }

  .section-title {
    font-size: var(--font-size-xl);
  }

  .upload-zone {
    padding: var(--space-8);
  }

  .upload-icon {
    font-size: var(--font-size-3xl);
  }

  .upload-text {
    font-size: var(--font-size-base);
  }

  .upload-preview {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-3);
  }

  .style-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    transform: translateY(100%);
    width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }

  .style-panel.hidden {
    transform: translateY(100%);
  }

  .style-panel.open {
    transform: translateY(0);
  }

  .style-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .book-controls {
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-3);
  }

  .control-btn {
    width: 40px;
    height: 40px;
  }

  .settings-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    transform: translateY(100%);
    width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }

  .settings-panel.open {
    transform: translateY(0);
  }

  .modal-content {
    width: 95vw;
    max-height: 80vh;
  }

  .modal-header {
    padding: var(--space-4);
  }

  .modal-body {
    padding: var(--space-4);
  }
}

/* === MOBILE LANDSCAPE (481px - 640px) === */

@media (min-width: 480px) and (max-width: 639px) {
  :root {
    --book-width: min(85vw, 600px);
    --book-height: min(55vh, 400px);
  }

  .header-content {
    padding: 0 var(--space-5);
  }

  .upload-preview {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .style-panel {
    width: 240px;
    left: var(--space-4);
  }

  .settings-panel {
    width: 280px;
    right: var(--space-4);
  }
}

/* === TABLET PORTRAIT (640px - 768px) === */

@media (min-width: 640px) and (max-width: 767px) {
  :root {
    --book-width: min(80vw, 700px);
    --book-height: min(60vh, 500px);
  }

  .upload-preview {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .style-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .book-controls {
    flex-direction: row;
  }
}

/* === TABLET LANDSCAPE (768px - 1024px) === */

@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --book-width: min(75vw, 750px);
    --book-height: min(65vh, 550px);
  }

  .header-content {
    padding: 0 var(--space-6);
  }

  .upload-preview {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .style-panel {
    width: 260px;
  }

  .settings-panel {
    width: 300px;
  }
}

/* === DESKTOP (1024px - 1280px) === */

@media (min-width: 1024px) and (max-width: 1279px) {
  :root {
    --book-width: min(70vw, 800px);
    --book-height: min(70vh, 600px);
  }

  .upload-preview {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

/* === LARGE DESKTOP (1280px+) === */

@media (min-width: 1280px) {
  :root {
    --book-width: min(65vw, 900px);
    --book-height: min(75vh, 700px);
  }

  .header-content {
    padding: 0 var(--space-8);
  }

  .upload-preview {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }

  .style-panel {
    width: 300px;
  }

  .settings-panel {
    width: 340px;
  }
}

/* === ULTRA-WIDE DISPLAYS (1920px+) === */

@media (min-width: 1920px) {
  :root {
    --book-width: min(60vw, 1000px);
    --book-height: min(80vh, 800px);
  }

  .upload-preview {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

/* === FOLDABLE DEVICES === */

/* Surface Duo (Portrait) */
@media (min-width: 540px) and (max-width: 720px) and (min-height: 720px) {
  .app {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
  }

  .app-header {
    grid-column: 1 / -1;
  }

  .upload-section {
    grid-column: 1;
    padding: var(--space-4);
  }

  .book-container {
    grid-column: 2;
    padding: var(--space-4);
  }

  .style-panel {
    position: relative;
    width: 100%;
    max-height: none;
    transform: none;
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
  }

  .settings-panel {
    position: relative;
    width: 100%;
    max-height: none;
    transform: none;
    border-radius: var(--radius-lg);
  }
}

/* Surface Duo (Landscape) */
@media (min-width: 720px) and (max-width: 1080px) and (max-height: 540px) {
  .book-container {
    min-height: calc(100vh - 150px);
  }

  :root {
    --book-width: min(45vw, 500px);
    --book-height: min(80vh, 400px);
  }
}

/* Galaxy Fold (Folded) */
@media (min-width: 280px) and (max-width: 320px) {
  :root {
    --font-size-xs: 0.7rem;
    --font-size-sm: 0.8rem;
    --font-size-base: 0.9rem;
    --space-4: 0.75rem;
    --space-6: 1rem;
    --book-width: 95vw;
    --book-height: 40vh;
  }

  .header-content {
    padding: 0 var(--space-2);
  }

  .app-title {
    font-size: var(--font-size-base);
  }

  .nav-btn {
    padding: var(--space-1) var(--space-2);
  }

  .style-panel,
  .settings-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 50vh;
    transform: translateY(100%);
  }
}

/* === ORIENTATION CHANGES === */

@media (orientation: landscape) and (max-height: 600px) {
  .loading-screen {
    padding: var(--space-4);
  }

  .loading-container {
    max-width: 300px;
    padding: var(--space-4);
  }

  .neural-loader {
    width: 80px;
    height: 80px;
    margin-bottom: var(--space-4);
  }

  .book-container {
    min-height: calc(100vh - 120px);
    padding: var(--space-4);
  }

  .style-panel {
    max-height: 70vh;
  }

  .settings-panel {
    max-height: 70vh;
  }
}

/* === HIGH DPI DISPLAYS === */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .style-preview {
    background-size: 100% 100%;
  }

  .upload-icon {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* === TOUCH DEVICES === */

@media (hover: none) and (pointer: coarse) {
  .nav-btn,
  .control-btn,
  .style-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .hotspot {
    width: 32px;
    height: 32px;
    --hotspot-size: 32px;
  }

  .range-input::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  .range-input::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }

  .modal-close {
    width: 40px;
    height: 40px;
  }

  .upload-zone {
    min-height: 120px;
  }
}

/* === HOVER CAPABLE DEVICES === */

@media (hover: hover) and (pointer: fine) {
  .upload-zone:hover {
    border-color: var(--color-neural-secondary);
    box-shadow: var(--shadow-glow-sm);
  }

  .three-canvas:hover {
    box-shadow: var(--shadow-glow-md);
  }
}

/* === CONTAINER QUERIES === */

/* For panels that use container queries */
@container (max-width: 300px) {
  .style-grid {
    grid-template-columns: 1fr;
  }

  .style-btn {
    flex-direction: row;
    padding: var(--space-2);
  }

  .style-preview {
    width: 40px;
    height: 40px;
  }
}

@container (min-width: 400px) {
  .style-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* === VIEWPORT HEIGHT ADJUSTMENTS === */

@media (max-height: 600px) {
  .book-container {
    min-height: calc(100vh - 100px);
  }

  :root {
    --book-height: min(50vh, 300px);
  }

  .upload-section {
    padding: var(--space-4);
  }

  .section-title {
    margin-bottom: var(--space-4);
  }
}

@media (min-height: 900px) {
  .book-container {
    min-height: calc(100vh - 250px);
  }

  :root {
    --book-height: min(70vh, 650px);
  }
}

/* === PRINT STYLES === */

@media print {
  .app-header,
  .style-panel,
  .settings-panel,
  .book-controls,
  .performance-monitor,
  .loading-screen,
  .processing-overlay {
    display: none !important;
  }

  .book-container {
    min-height: auto;
    page-break-inside: avoid;
  }

  .three-canvas {
    border: 2px solid #000;
    background: #fff;
  }

  .upload-section {
    page-break-after: always;
  }

  .modal-content {
    box-shadow: none;
    border: 2px solid #000;
  }
}

/* === REDUCED DATA MODE === */

@media (prefers-reduced-data: reduce) {
  .neural-loader,
  .processing-spinner {
    animation: none;
  }

  .gradient-neural-primary,
  .gradient-neural-secondary,
  .gradient-neural-accent {
    background: var(--color-neural-primary);
  }

  .glass-effect {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--color-surface-secondary);
  }
}

/* === DARK MODE REFINEMENTS === */

@media (prefers-color-scheme: dark) {
  .upload-zone {
    border-color: var(--color-border-secondary);
  }

  .style-preview.original {
    background: linear-gradient(45deg, #2a2a2a, #1a1a1a);
  }
}

/* === SPECIFIC DEVICE ADAPTATIONS === */

/* iPhone 12/13/14 Mini */
@media only screen 
  and (device-width: 375px) 
  and (device-height: 812px) 
  and (-webkit-device-pixel-ratio: 3) {
  
  .app-header {
    padding-top: env(safe-area-inset-top, var(--space-4));
  }

  .book-container {
    padding-bottom: env(safe-area-inset-bottom, var(--space-4));
  }
}

/* iPhone 12/13/14 Pro Max */
@media only screen 
  and (device-width: 428px) 
  and (device-height: 926px) 
  and (-webkit-device-pixel-ratio: 3) {
  
  :root {
    --book-width: min(90vw, 380px);
    --book-height: min(60vh, 500px);
  }
}

/* iPad Pro 12.9" */
@media only screen 
  and (device-width: 1024px) 
  and (device-height: 1366px) 
  and (-webkit-device-pixel-ratio: 2) {
  
  .app {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    grid-template-rows: auto 1fr;
  }

  .app-header {
    grid-column: 1 / -1;
  }

  .style-panel {
    position: relative;
    transform: none;
    grid-column: 1;
    width: auto;
    max-height: none;
    height: fit-content;
    margin: var(--space-6);
  }

  .book-container {
    grid-column: 2;
  }

  .settings-panel {
    position: relative;
    transform: none;
    grid-column: 3;
    width: auto;
    max-height: none;
    height: fit-content;
    margin: var(--space-6);
  }

  .upload-section {
    grid-column: 1 / -1;
    order: 2;
  }
}

/* === GAMING DISPLAYS (32:9) === */

@media (min-aspect-ratio: 3/1) {
  .app {
    display: grid;
    grid-template-columns: 350px 1fr 350px;
    grid-template-rows: auto 1fr;
  }

  .app-header {
    grid-column: 1 / -1;
  }

  .style-panel {
    position: relative;
    transform: none;
    grid-column: 1;
    width: auto;
    height: fit-content;
    margin: var(--space-6);
  }

  .book-container {
    grid-column: 2;
  }

  .settings-panel {
    position: relative;
    transform: none;
    grid-column: 3;
    width: auto;
    height: fit-content;
    margin: var(--space-6);
  }

  :root {
    --book-width: min(50vw, 800px);
    --book-height: min(80vh, 700px);
  }
}

/* === ACCESSIBILITY ENHANCEMENTS === */

@media (prefers-contrast: high) {
  .style-btn {
    border-width: 3px;
  }

  .control-btn {
    border-width: 2px;
  }

  .hotspot {
    border-width: 3px;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .glass-effect {
    background: var(--color-surface-secondary);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .modal-backdrop {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* === FUTURE-PROOFING === */

/* Support for new CSS features */
@supports (container-type: inline-size) {
  .style-panel,
  .settings-panel {
    container-type: inline-size;
  }
}

@supports (scroll-timeline: auto) {
  .book-container {
    scroll-timeline: --book-scroll auto;
  }
}

@supports (color-mix(in srgb, red, blue)) {
  .nav-btn:hover {
    background: color-mix(in srgb, var(--color-neural-primary) 10%, transparent);
  }
}

/* === PERFORMANCE OPTIMIZATIONS === */

@media (max-width: 768px) {
  .neural-loader {
    will-change: transform;
  }

  .three-canvas {
    will-change: transform;
  }

  .processing-spinner {
    will-change: transform;
  }
}

/* Reduce animations on lower-end devices */
@media (max-width: 480px) and (max-height: 800px) {
  .node {
    animation-duration: 4s;
  }

  .gradientShift {
    animation-duration: 8s;
  }

  .hotspotPulse {
    animation-duration: 4s;
  }
}
