/* ==============================
   MOBILE STYLES
   Applies to screens under 768px
   ============================== */

@media (max-width: 768px) {

  /* === HEADER === */
  .site-header { padding: 0; }
  .header-inner {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .main-nav { display: none; }
  .search-box { 
    min-width: 0; 
    flex: 1;
    margin-left: 0;
  }

  /* === BOTTOM NAV === */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 0.5px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 0.6rem 0 0.75rem;
    z-index: 150;
  }
  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-family: 'Source Serif 4', serif;
    transition: color 0.1s;
  }
  .mobile-nav a.active { color: var(--green); }
  .mobile-nav svg { display: block; }

  /* Push page content above fixed nav */
  body { padding-bottom: 60px; }

  /* === HOMEPAGE === */
  .home-page { padding: 1rem; }
  .about-card {
    grid-template-columns: 56px 1fr;
    gap: 0.75rem;
    padding: 1rem;
  }
  .about-avatar { width: 56px; height: 56px; }
  .about-name { font-size: 18px; }
  .about-bio { font-size: 13px; }
  .cat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }

  /* === BROWSE PAGE === */
  .page-layout {
    grid-template-columns: 1fr !important;
    padding: 0.75rem;
    gap: 0.75rem;
  }
  .sidebar {
    position: static !important;
    display: none !important;
  }
  .mobile-filter-bar {
    display: flex !important;
    overflow-x: auto;
    gap: 6px;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
  }
  .mobile-filter-bar::-webkit-scrollbar { display: none; }
  .mobile-filter-bar .ftag {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 11px;
  }
  .main-content { padding: 0.75rem; }
  .main-topbar { flex-wrap: wrap; gap: 0.5rem; }
  .species-grid { grid-template-columns: 1fr 1fr; gap: 8px; }

  /* === ALL SIGHTINGS === */
  .sightings-page { padding: 0.75rem; }
  .sightings-header { flex-wrap: wrap; gap: 0.5rem; }
  .filter-bar {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }
  .filter-bar-divider { display: none; }
  .filter-bar-group { min-width: 0; }

  /* === FIELD NOTES === */
  .notes-page { padding: 0.75rem; }
  .notes-layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .notes-sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .notes-main { padding: 1rem; }

  /* === SPECIES DETAIL PANEL === */
  .detail-overlay { padding: 0; align-items: flex-end; }
  .detail-panel {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.25rem 1rem;
  }
  .detail-hero {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .detail-img-wrap {
    aspect-ratio: 16/9;
    width: 100%;
  }

  /* === FIELD NOTES ARTICLE === */
  .art-hero {
    grid-template-columns: 1fr;
  }
  .art-title { font-size: 20px; }

  /* === CARDS === */
  .card-name { font-size: 12px; }
  .card-latin { font-size: 10px; }
}

/* Tablet — just adjust columns */
@media (max-width: 768px) {

  /* === HEADER === */
  .site-header { padding: 0; }
  .header-inner {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .main-nav { display: none !important; }
  .search-box {
    min-width: 0;
    flex: 1;
    margin-left: 0;
  }

  /* === BOTTOM NAV === */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 0.5px solid var(--border);
    display: flex !important;
    justify-content: space-around;
    padding: 0.6rem 0 0.75rem;
    z-index: 150;
  }
  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-family: 'Source Serif 4', serif;
    transition: color 0.1s;
  }
  .mobile-nav a.active { color: var(--green); }
  .mobile-nav svg { display: block; }

  body { padding-bottom: 60px; }

  /* === HOMEPAGE === */
  .home-page { padding: 1rem !important; }
  .about-card {
    grid-template-columns: 56px 1fr !important;
    gap: 0.75rem !important;
    padding: 1rem !important;
  }
  .about-avatar { width: 56px !important; height: 56px !important; }
  .about-name { font-size: 18px !important; }
  .about-bio { font-size: 13px !important; }
  .cat-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }

  /* === BROWSE PAGE === */
  .page-layout {
    grid-template-columns: 1fr !important;
    padding: 0.75rem !important;
    gap: 0.75rem !important;
  }
  .sidebar { display: none !important; }
  .main-content { padding: 0.75rem !important; }
  .main-topbar { flex-wrap: wrap; gap: 0.5rem; }
  .species-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* === ALL SIGHTINGS === */
  .sightings-page { padding: 0.75rem !important; }
  .sightings-header { flex-wrap: wrap; gap: 0.5rem; }
  .filter-bar {
    flex-direction: column !important;
    gap: 0.75rem !important;
    padding: 0.75rem !important;
  }
  .filter-bar-divider { display: none !important; }

  /* === FIELD NOTES === */
  .notes-page { padding: 0.75rem !important; }
  .notes-layout {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  .notes-sidebar {
    position: static !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .notes-main { padding: 1rem !important; }

  /* === SPECIES DETAIL PANEL === */
  .detail-overlay { padding: 0 !important; align-items: flex-end !important; }
  .detail-panel {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    padding: 1.25rem 1rem !important;
  }
  .detail-hero {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  .detail-img-wrap {
    aspect-ratio: 16/9 !important;
    width: 100% !important;
  }

  /* === CARDS === */
  .card-name { font-size: 12px !important; }
  .card-latin { font-size: 10px !important; }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .page-layout { grid-template-columns: 180px 1fr; }
  .species-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .notes-layout { grid-template-columns: 1fr 180px; }
}

@media (max-width: 768px) {

  /* === ADMIN PAGES === */
  .admin-layout {
    grid-template-columns: 1fr !important;
  }

  .admin-sidebar {
    position: static !important;
    display: block !important;
    max-height: 200px;
    overflow-y: auto;
  }

  .admin-editor {
    min-height: auto !important;
  }

  .editor-form {
    padding: 1rem !important;
  }

  .editor-topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .editor-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .sa-stats-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .form-row {
    flex-direction: column !important;
  }

  .form-group {
    width: 100% !important;
  }

  .photo-preview {
    aspect-ratio: 16/9 !important;
  }

  .photo-browser-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
    max-height: 240px !important;
  }

  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }

  .dashboard-card {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  .editor-toolbar {
    flex-wrap: wrap;
  }

  .sa-section-label {
    margin-top: 1rem !important;
  }

}