/* Mobile Responsive -- Hyprland Rice */

/* ── Mobile App Styling ─────────────────────────── */
@media (max-width: 768px) {
  /* Safe area insets for notched devices */
  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  /* App-like scrolling */
  #desktop {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Prevent pull-to-refresh on desktop */
  #desktop {
    overscroll-behavior-y: none;
  }

  /* Rounded corners for app-like feel */
  .plasma-window {
    border-radius: 16px !important;
  }

  /* Status bar theming with accent indicator */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background: var(--bg-primary);
    border-bottom: 2px solid var(--accent);
    z-index: 9998;
  }

  .desktop-icon:active .icon-img img {
    filter: drop-shadow(0 0 6px var(--accent-glow));
  }
}

/* ── Tablet ─────────────────────────────────────── */
@media (max-width: 768px) {
  #desktop-icons {
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    height: auto;
    overflow-y: auto;
  }
  .desktop-icon { width: calc(25% - 10px); min-width: 60px; }
  .desktop-icon .icon-img { width: 52px; height: 52px; font-size: 24px; }
  .desktop-icon .icon-img img { max-width: 52px; max-height: 52px; }
}

/* ── Phone ──────────────────────────────────────── */
@media (max-width: 480px) {
  /* Computer wallpaper: keep centered on mobile */
  #desktop-video[src*="wp-pixel-computer"] {
    object-position: center center !important;
  }

  /* Beach wallpaper: shift right to center person on mobile */
  #desktop-video[src*="wp-pixel-beach"] {
    object-position: 70% center !important;
  }

  /* Arcade wallpaper: keep centered */
  #desktop-video[src*="wp-pixel-arcade"] {
    object-position: center center !important;
  }

  /* Icons: 3 columns with accent border when selected */
  .desktop-icon { width: calc(33.33% - 10px); }
  .desktop-icon .icon-img { width: 48px; height: 48px; font-size: 22px; }
  .desktop-icon .icon-img img { max-width: 48px; max-height: 48px; }
  .desktop-icon.selected .icon-img img {
    filter: drop-shadow(0 0 8px var(--accent-glow));
  }

  /* Windows: forced fullscreen below waybar */
  .plasma-window {
    position: fixed !important;
    top: calc(var(--bar-height) + 8px) !important;
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - var(--bar-height) - 8px) !important;
    border-radius: 0 !important;
    max-height: calc(100vh - var(--bar-height) - 8px) !important;
  }

  /* Window body must scroll within fullscreen */
  .plasma-window .window-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide resize grips on touch */
  .plasma-resize-handle { display: none; }

  /* Hide animated border on mobile for perf */
  .plasma-window::before { display: none !important; }

  /* Show workspace dots on phone - make them compact */
  #waybar-workspaces {
    display: flex;
    gap: 4px;
  }
  .ws-dot {
    width: 16px;
    height: 16px;
    font-size: 8px;
  }

  /* Compact module pills */
  .module-pill { height: 24px; padding: 0 6px; font-size: 11px; }
  .bar-sep { height: 14px; }

  /* Waybar tabs: horizontal scroll, compact */
  #waybar-windows {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #waybar-windows::-webkit-scrollbar { display: none; }
  .taskbar-tab {
    max-width: 90px;
    font-size: 10px;
    padding: 2px 6px;
    height: 22px;
  }

  /* Waybar: edge-to-edge on phone */
  #waybar {
    margin: 0;
    border-radius: 0;
  }

  /* Desktop & window container: adjust for no waybar margin */
  #desktop { top: var(--bar-height); }
  #windows-container { top: var(--bar-height); }
  .plasma-window {
    top: var(--bar-height) !important;
    height: calc(100vh - var(--bar-height)) !important;
    max-height: calc(100vh - var(--bar-height)) !important;
  }

  /* Rofi: full width on mobile */
  #rofi-panel {
    width: 95%;
    max-width: none;
    border-radius: 12px;
  }
  #rofi-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  /* Rofi search: prevent iOS zoom */
  #rofi-search input { font-size: 16px; }

  /* Hide AI assistant on mobile */
  #clippy { display: none !important; }

  /* Kernel panic: smaller text */
  #bsod {
    font-size: 12px;
    padding: 20px;
  }

  /* Larger touch targets for menus */
  .ctx-item { padding: 10px 24px; }
}

/* ── Very Small Phones ──────────────────────────── */
@media (max-width: 360px) {
  .desktop-icon { width: calc(33.33% - 8px); }
  .desktop-icon .icon-img {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }
  .desktop-icon .icon-img img { max-width: 42px; max-height: 42px; }
  .desktop-icon .icon-label { font-size: 10px; }
}

/* ── Touch Devices ──────────────────────────────── */
@media (hover: none) {
  /* Window controls need bigger hit area */
  .plasma-window .title-bar-controls button {
    min-width: 28px;
    min-height: 28px;
  }

  /* Drop hover effects that don't translate to touch */
  .desktop-icon:hover { outline: none; }
}

/* ── Color Picker Mobile Overlay ──────────────────── */
#color-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.color-picker-modal {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-window);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-window);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.color-picker-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  text-align: center;
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.color-swatch {
  height: 56px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}

.color-swatch::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(0,0,0,0.1));
  pointer-events: none;
}

.color-swatch span {
  font-size: 13px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 1;
}

.color-swatch:active {
  transform: scale(0.95);
  border-color: white;
}

.color-picker-cancel {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.color-picker-cancel:active {
  background: rgba(255, 255, 255, 0.1);
}
