/**
 * Responsive CSS for WWWUI Grid Slider
 * Mobile-first approach with progressive enhancement
 */

/* ========== Mobile First Base Styles ========== */
/* Default styles for mobile devices (320px - 767px) */

:root {
  /* Mobile-optimized sizing */
  --mobile-logo-width: 80px; /* Doubled from 40px */
  /* Typography sizes moved to typography.css for consistency */
  --mobile-button-size: 40px;
  --mobile-minimap-size: 80px;
  --mobile-minimap-dot-size: 16px;
  --mobile-edge-offset: 15px;
  --mobile-arrow-size: 35px;
  
  /* Touch-friendly spacing */
  --mobile-touch-target: 44px; /* Minimum touch target size */
  --mobile-spacing: 15px;
}

/* Mobile base adjustments */
@media (max-width: 767px) {
  /* Scrollbars are hidden globally in style.css */
  
  /* Ensure body and html don't show scrollbars and prevent bounce */
  html, body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Hide navigation arrows on mobile */
  .arrow-btn {
    display: none !important;
  }
  
  /* Force proper grid sizing on mobile */
  #grid-wrapper {
    /* Ensure transform-origin is correct */
    transform-origin: 0 0;
  }
  
  /* Grid items layout (typography handled in typography.css) */
  .grid-item {
    /* Remove padding to prevent offset */
    padding: 0;
    /* Use percentage to fill grid cell */
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    /* Prevent any transform issues */
    position: relative;
    top: 0;
    left: 0;
  }
  
  .grid-item h2 {
    max-width: 80%;
    text-align: center;
  }
  
  /* Ensure grid containers have no offset */
  #grid-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  

  
  /* More info button */
  .more-info-btn {
    width: var(--mobile-button-size);
    height: var(--mobile-button-size);
  }
  
  /* Logo adjustments */
  #logo-button {
    top: var(--mobile-edge-offset);
    left: var(--mobile-edge-offset);
  }
  
  .logo-wrapper {
    width: var(--mobile-logo-width);
    height: var(--mobile-logo-width);
  }
  
  #top-left-logo {
    width: var(--mobile-logo-width);
  }
  
  /* Minimap for mobile */
  #minimap {
    top: 50%;
    right: var(--mobile-edge-offset);
    transform: translateY(-50%);
    width: fit-content;
    height: fit-content;
    padding: 8px;
    gap: 4px;
  }
  
  .minimap-dot {
    width: var(--mobile-minimap-dot-size);
    height: var(--mobile-minimap-dot-size);
  }
  
  /* Navigation arrows - adjust hover zones for mobile */
  #arrow-up, #arrow-down {
    width: 150px;
    height: 60px;
  }
  
  #arrow-left, #arrow-right {
    width: 60px;
    height: 150px;
  }
  
  /* Arrow button icon mobile styles moved to icons.css */
  
  /* HUD adjustments */
  #coords-hud {
    padding: 6px 10px;
    bottom: var(--mobile-edge-offset);
    left: var(--mobile-edge-offset);
  }
  
  /* Menu toggle */
  #menu-toggle {
    top: var(--mobile-edge-offset);
    right: var(--mobile-edge-offset); /* Keep closer on mobile */
    width: var(--mobile-touch-target);
    height: var(--mobile-touch-target);
  }
  
  
  /* Touch-friendly popover positioning */
  #minimap-popover,
  #arrow-popover {
    padding: 6px 10px;
  }
  
  /* Horizontal Nav HUD inherits minimap styles on mobile */
  
  /* Off-canvas header */
  #off-canvas-header {
    /* Remove padding from container to fix visibility issue */
    padding: 0;
  }
  
  .header-content {
    padding: var(--mobile-edge-offset);
    /* Center nav when title is hidden */
    justify-content: center;
    align-items: center;
    height: var(--mobile-logo-width); /* Match logo height */
    padding-left: calc(var(--mobile-logo-width) + var(--mobile-edge-offset) + 15px); /* Account for larger logo */
  }
  
  .header-content nav {
    width: 100%;
    display: flex;
    justify-content: center;
  }
  
  #off-canvas-header h1 {
    /* Hide DANGER title on mobile */
    display: none;
  }
  
  #off-canvas-header nav ul {
    /* Display navigation items in a row */
    flex-direction: row;
    gap: 20px;
  }
  
  #off-canvas-header nav a {
    padding: 12px;
  }
}

/* ========== Small Tablets (768px - 991px) ========== */
@media (min-width: 768px) and (max-width: 991px) {
  :root {
    --grid-item-font-size: 2.5rem;
    --logo-width: 45px;
    --page-edge-offset: 20px;
    --minimap-dot-size: 10px;
  }
  
  /* Hide navigation arrows on tablets */
  .arrow-btn {
    display: none !important;
  }
  
  .more-info-btn {
    width: 45px;
    height: 45px;
  }
  
  #minimap {
    width: fit-content;
    height: fit-content;
    padding: 10px;
    gap: 4px;
  }
  
  .arrow-btn {
    width: 40px;
    height: 40px;
  }
  
  /* Keep arrow buttons square for consistent chevron appearance */
  
  /* Ensure header nav stays horizontal on tablets */
  #off-canvas-header nav ul {
    flex-direction: row !important;
    gap: 30px;
  }
  
  .header-content {
    flex-direction: row;
    justify-content: space-between;
    padding-left: 90px; /* Add space for logo */
  }
  
  #off-canvas-header h1 {
    display: block; /* Show title on tablets */
  }
}

/* ========== Large Tablets / Small Desktops (992px - 1199px) ========== */
@media (min-width: 992px) and (max-width: 1199px) {
  :root {
    --grid-item-font-size: 2.75rem;
    --logo-width: 48px;
    --minimap-dot-size: 9px;
  }
  

  
  #minimap {
    width: fit-content;
    height: fit-content;
    padding: 10px;
    gap: 4px;
  }
  
  /* Ensure header nav stays horizontal */
  #off-canvas-header nav ul {
    flex-direction: row !important;
    gap: 35px;
  }
  
  .header-content {
    flex-direction: row;
    justify-content: space-between;
    padding-left: 95px; /* Add space for logo */
  }
}

/* ========== Desktop (1200px - 1599px) ========== */
@media (min-width: 1200px) {
  /* Most styles are already optimized for this range in style.css */
  /* Only minor adjustments needed */
  
  .grid-item h2 {
    max-width: 600px;
  }
}

/* ========== Large Desktop (1600px+) ========== */
@media (min-width: 1600px) {
  :root {
    --grid-item-font-size: 3.5rem;
    --logo-width: 60px;
    --page-edge-offset: 30px;
    --minimap-dot-size: 14px;
  }
  
  .grid-item h2 {
    max-width: 800px;
  }
  
  .more-info-btn {
    width: 60px;
    height: 60px;
  }
  
  #minimap {
    /* Keep fit-content for vertical layout */
    width: fit-content;
    height: fit-content;
    padding: 12px;
    gap: 4px;
  }
  
  .arrow-btn {
    width: 50px;
    height: 50px;
  }
  
  /* Keep arrow buttons square for consistent chevron appearance */
  
  #coords-hud {
    padding: 10px 16px;
  }
}

/* ========== Orientation-specific styles ========== */
/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  .grid-item h1 {
    margin-bottom: 0.25rem;
  }
  
  .more-info-btn {
    width: 35px;
    height: 35px;
  }
  
  #minimap {
    width: fit-content;
    height: fit-content;
  }
  
  #coords-hud {
    padding: 4px 8px;
  }
}

/* ========== High-DPI / Retina displays ========== */
@media (min-resolution: 192dpi) {
  /* Ensure crisp borders and text */
  .grid-item,
  .bsp-node {
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* Sharper shadows for high-DPI */
  #minimap {
    /* box-shadow: 0 3px 15px rgba(0, 0, 0, 0.4); */
  }
  
  .more-info-btn {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* ========== Touch device optimizations ========== */
@media (hover: none) and (pointer: coarse) {
  /* Hide navigation arrows on all touch devices */
  .arrow-btn {
    display: none !important;
  }
  
  /* Remove hover effects on touch devices */
  .more-info-btn:hover {
    transform: translate(-50%, -50%);
    opacity: 0.8;
  }
  
  .minimap-dot:hover {
    transform: none;
    opacity: 0.8;
  }
  
  /* Fix logo hover persistence on touch devices */
  #logo-button:hover #top-left-logo {
    opacity: 0.5; /* Keep default opacity on touch */
  }
  
  
  /* Larger touch targets */
  .more-info-btn {
    min-width: var(--mobile-touch-target);
    min-height: var(--mobile-touch-target);
  }
  
  .minimap-dot {
    min-width: 12px;
    min-height: 12px;
  }
  
  /* Disable cursor changes on touch */
  #grid-container {
    cursor: default !important;
  }
}

/* ========== Reduced motion preferences ========== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  #grid-wrapper {
    transition: none !important;
  }
  
  #top-left-logo {
    transition: none !important;
  }
}

/* ========== Print styles ========== */
@media print {
  /* Hide interactive elements */
  #minimap,
  .arrow-btn,
  .more-info-btn,
  #menu-toggle,
  #coords-hud,
  #off-canvas-header {
    display: none !important;
  }
  
  /* Optimize for print */
  .grid-item {
    page-break-inside: avoid;
    border: 1px solid #ccc;
  }
  
  /* Show all grid items */
  #grid-wrapper {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
  }
  
  .grid-item {
    width: 33.333% !important;
    height: 33.333vh !important;
  }
}

/* ========== Accessibility improvements ========== */
@media (prefers-contrast: high) {
  /* High contrast mode adjustments */
  .grid-item {
    border: 2px solid currentColor;
  }
  
  .more-info-btn,
  .arrow-btn {
    border: 2px solid currentColor;
    font-weight: bold;
  }
  
  #minimap {
    border: 2px solid currentColor;
  }
  
  .minimap-dot {
    border: 1px solid currentColor;
  }
}

/* ========== Dark mode support ========== */
@media (prefers-color-scheme: dark) {
  /* Dark mode is already the default, but we can enhance it */
  :root {
    --popover-bg: rgba(0, 0, 0, 0.95);
    --minimap-bg: rgba(0, 0, 0, 0.5);
  }
}

