/* ==========================================================================
   CodeNest - Responsive Stylesheet (Mobile-First + Fluid Adjustments)
   ========================================================================== */

/* Tablet & Smaller Screens (< 1024px) */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }

  .chat-container {
    height: calc(100vh - var(--header-height) - 3.5rem);
  }

  .chat-members-sidebar {
    display: none;
  }
}

/* Mobile & Small Tablets (< 768px) */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
    --header-height: 58px;
  }

  /* Off-canvas mobile sidebar */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  /* Backdrop for mobile drawer */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
  }

  .sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
  }

  .mobile-menu-btn {
    display: flex;
  }

  #top-bar {
    padding: 0 1rem;
  }

  .search-trigger-btn {
    padding: 0.4rem 0.6rem;
  }

  .kbd-shortcut {
    display: none;
  }

  .deadline-radar-chip span.deadline-title {
    display: none;
  }

  #view-container {
    padding: 1rem 0.85rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.15rem;
  }

  .page-title-group h1 {
    font-size: 1.35rem;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .metric-card {
    padding: 0.85rem;
    gap: 0.65rem;
  }

  .metric-icon-wrap {
    width: 38px;
    height: 38px;
    font-size: 1.15rem;
  }

  .metric-value {
    font-size: 1.15rem;
  }

  /* Chat mobile layout */
  .chat-container {
    height: calc(100vh - var(--header-height) - 2rem);
    flex-direction: column;
  }

  .chat-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .channel-list {
    flex-direction: row;
    overflow-x: auto;
    padding: 0.4rem;
  }

  .channel-btn {
    white-space: nowrap;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
  }

  /* Code snippet card */
  .code-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .code-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Pomodoro */
  .timer-display {
    font-size: 3.25rem;
  }

  .pomodoro-box {
    padding: 1.5rem 1rem;
  }
}

/* Very Small Mobile Phones (< 480px) */
@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .top-bar-right .streak-pill,
  .top-bar-right .xp-pill {
    display: none;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }
}

/* Reduced Motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
