/*
 * Modern Faceted Search - Responsive Styles
 * Mobile-first responsive design with breakpoints
 * Mobile (375px+) → Tablet (768px+) → Desktop (1024px+) → Large (1280px+)
 */

/* ---------- Mobile Base (375px+) ---------- */
/* Base styles in modern-base.css are mobile-first */

/* Mobile-specific adjustments */
@media (max-width: 767px) {
  .container {
    padding: 0 1rem;
  }

  /* Header */
  .header {
    padding: 0.5rem 0;
  }

  .logo img {
    height: 32px;
  }

  .header-actions a {
    font-size: 0;
    padding: 0.5rem;
  }

  .header-actions i {
    font-size: 1.2rem;
  }

  /* Navigation */
  .nav-content {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .nav-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-actions {
    justify-content: center;
    margin-left: 0;
  }

  .nav-action span {
    display: none;
  }

  /* Search Card */
  .search-card {
    padding: 1rem;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-mode,
  .search-input,
  .search-submit {
    width: 100%;
  }

  /* Query Info */
  .query-title-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .query-actions {
    order: 2;
  }

  .query-info h3 {
    font-size: 1rem;
  }

  /* Results Table - Card Layout on Mobile */
  .results-table {
    border-radius: var(--radius-md);
  }

  .results-table table,
  .results-table thead,
  .results-table tbody,
  .results-table tr,
  .results-table td {
    display: block;
  }

  .results-table thead {
    display: none;
  }

  .results-table tr {
    margin-bottom: 1rem;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: 0.75rem;
  }

  .results-table td {
    border-bottom: none;
    padding: 0.5rem 0;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.5rem;
  }

  .results-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--slate-600);
    font-size: 0.875rem;
  }

  /* Pagination */
  .pagination-nav {
    flex-direction: column;
    gap: 1rem;
  }

  .pagination-left,
  .pagination-right {
    width: 100%;
    justify-content: space-between;
  }

  .page-info {
    width: 100%;
    justify-content: center;
  }

  .pagination-goto {
    width: 100%;
    justify-content: center;
  }

  .page-button {
    flex: 1;
    justify-content: center;
  }

  /* Responsive inline pagination for description pages */
  #nav {
    margin-left: 0;
  }

  .inline-pagination {
    flex-direction: column;
    gap: 1rem;
  }

  .pagination-controls {
    flex-direction: column;
    gap: 1rem;
  }

  .pagination-group {
    justify-content: center;
    width: 100%;
  }

  .pagination-nav {
    flex: none;
    width: 100%;
    justify-content: center;
  }

  .pagination-info {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0;
  }

  .pagination-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  .pagination-input {
    width: 4rem;
  }

  /* Floating Panel - Full Screen on Mobile */
  .floating-panel {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    max-width: 100%;
    min-width: 100%;
    border-radius: 0;
  }

  .panel-header {
    cursor: default;
  }

  .drag-handle {
    display: none;
  }

  /* Modal */
  .modal-overlay {
    padding: 1rem;
  }

  .modal {
    max-width: 100%;
  }

  .result-card .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- Tablet (768px+) ---------- */
@media (min-width: 768px) {
  .container {
    max-width: 720px;
    padding: 0 1.5rem;
  }

  /* Show table layout on tablet+ */
  .results-table table {
    display: table;
  }

  .results-table thead {
    display: table-header-group;
  }

  .results-table tbody {
    display: table-row-group;
  }

  .results-table tr {
    display: table-row;
  }

  .results-table td {
    display: table-cell;
  }

  .results-table td::before {
    display: none;
  }

  /* Pagination - horizontal layout */
  .pagination-nav {
    flex-direction: row;
    justify-content: space-between;
  }

  .pagination-left,
  .pagination-right {
    width: auto;
  }

  /* Floating panel - draggable on tablet+ */
  .floating-panel {
    position: fixed;
    top: 120px;
    right: 1.5rem;
    left: auto;
    bottom: auto;
    width: 300px;
    height: 450px;
    max-height: 80vh;
    border-radius: 1rem;
  }

  .panel-header {
    cursor: move;
  }

  .drag-handle {
    display: block;
  }

  /* Modal grid layout */
  .modal-body .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Desktop (1024px+) ---------- */
@media (min-width: 1024px) {
  .container {
    max-width: 960px;
  }

  /* Show floating panel by default */
  .floating-panel {
    display: flex;
  }

  /* 3-column grid for cards */
  .modal-body .results-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Search card wider */
  .search-card {
    max-width: 900px;
  }
}

/* ---------- Large Desktop (1280px+) ---------- */
@media (min-width: 1280px) {
  .container {
    max-width: 1200px;
  }
}

/* ---------- Extra Large (1536px+) ---------- */
@media (min-width: 1536px) {
  .container {
    max-width: 1400px;
  }
}

/* ---------- Touch Device Optimizations ---------- */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets on touch devices */
  .nav-action,
  .sidebar-link,
  .page-button {
    min-height: 44px;
    min-width: 44px;
  }

  /* No hover effects on touch devices */
  .result-card:hover,
  .page-button:hover,
  .sidebar-link:hover {
    transform: none;
  }
}

/* ---------- Print Styles ---------- */
@media print {
  .header,
  .main-nav,
  .floating-panel,
  .pagination-nav,
  .footer {
    display: none;
  }

  .results-table {
    box-shadow: none;
    border: 1px solid #000;
  }

  .results-table th,
  .results-table td {
    border: 1px solid #000;
  }

  body {
    background: white;
  }
}

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

/* ---------- Dark Mode (Optional) ---------- */
@media (prefers-color-scheme: dark) {
  /* Add dark mode styles here if needed in the future */
  /* Currently defaults to light mode only */
}

/* ---------- High Contrast Mode ---------- */
@media (prefers-contrast: high) {
  .results-table,
  .search-card,
  .query-info-lozenge {
    border: 2px solid currentColor;
  }

  .button-primary,
  .search-submit {
    border: 2px solid var(--white-color);
  }
}
