/*
 * mobile.css -- Mobile-specific styles for Pivot Explorer
 * 
 * This file is loaded ONLY on viewports <= 768px via:
 *   <link rel="stylesheet" href="mobile.css" media="(max-width: 768px)">
 * 
 * The browser ignores this file entirely on desktop viewports.
 * src/styles.css is NEVER modified -- all mobile overrides live here.
 * 
 * Added in v1.5.0 (Feb 2026)
 */

/* ── Prevent browser default gestures (pull-to-refresh, pinch-zoom page) ── */
html, body {
  overscroll-behavior: none;
}

.viewer, .viewer canvas {
  touch-action: none;
}

/* Allow native touch on sidebar so selects/inputs/sliders work */
.sidebar, .sidebar * {
  touch-action: auto;
}

/* ── Sidebar: hidden by default, slides in as overlay when toggled ── */
.sidebar {
  transform: translateX(-100%);
  width: 280px;
  z-index: 200;
  transition: transform 0.3s ease;
}

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

.sidebar.collapsed {
  width: 0;
  transform: translateX(-100%);
}

/* Hamburger button: fixed to top-left, always visible */
.sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 201;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  width: 44px;
  height: 44px;
}

/* Sidebar content: ensure scrollable on small screens */
.sidebar-content {
  padding: 16px 14px 20px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Viewer: full-width (canvas fills entire screen) ── */
.viewer {
  left: 0 !important;
}

/* ── Semi-transparent backdrop behind sidebar overlay ── */
.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  display: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-backdrop.visible {
  display: block;
}

/* ── Zoom indicator: smaller and tighter to corner ── */
.zoom-indicator {
  bottom: 10px;
  right: 10px;
  font-size: 10px;
  padding: 5px 10px;
}

/* ── Info panel: compact bottom-right on phones, full-width on tablets ── */
.image-info-panel {
  width: calc(100vw - 24px) !important;
  min-width: unset !important;
  right: 12px !important;
  left: 12px !important;
  padding: 16px 18px 20px !important;
  font-size: 12px !important;
}

body.phone .image-info-panel {
  width: auto !important;
  min-width: unset !important;
  max-width: 55vw !important;
  max-height: 28vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  left: auto !important;
  right: 6px !important;
  padding: 10px 12px 12px !important;
  font-size: 10px !important;
  line-height: 1.3 !important;
  border-radius: 5px !important;
  transition: opacity 0.3s ease !important;
}

/* ── Fullscreen overlay: tap-friendly close target ── */
.fullscreen-overlay img {
  max-width: 98vw;
  max-height: 98vh;
}

/* ── Total count display: reposition to avoid overlap ── */
#total-count {
  bottom: 8px;
  left: 8px;
  font-size: 10px;
}

body.phone .total-count {
  left: auto !important;
  right: 8px !important;
  top: auto !important;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4px) !important;
  font-size: 9px !important;
  padding: 4px 8px !important;
  background: rgba(0, 0, 0, 0.6) !important;
  border: none !important;
  z-index: 201 !important;
}

body.phone .total-count .total-count-date {
  display: none !important;
}

/* ── Prevent overlay elements from triggering browser gestures ── */
.total-count, .zoom-indicator, .admin-btn, .admin-save-btn,
.heart-btn, .image-info-panel, .sidebar-toggle {
  touch-action: none;
}

/* ═══════════════════════════════════════════════════════════════
   iPhone portrait: compact always-visible bottom toolbar.
   Activated by body.phone class (set by inline <script> in HTML).
   iPad / desktop styles are NOT affected.
   ═══════════════════════════════════════════════════════════════ */

/* ── Sidebar → fixed bottom panel, always visible ── */
body.phone .sidebar {
  transform: none !important;
  top: auto !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: auto !important;
  max-height: 35vh;
  flex-direction: column;
  border-right: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.5);
  background: rgba(10, 10, 10, 0.96) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
}

body.phone .sidebar.collapsed,
body.phone .sidebar.mobile-open {
  transform: none !important;
  width: 100% !important;
}

body.phone .sidebar-toggle {
  display: none !important;
}

body.phone .sidebar-header,
body.phone .filters-header {
  display: none !important;
}

body.phone .mobile-header {
  display: block !important;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 150;
  font-family: 'Chakra Petch', -apple-system, sans-serif;
  text-align: left;
  pointer-events: none;
}

body.phone .mobile-header-title {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.7);
}

body.phone .mobile-header-version {
  display: block;
  font-size: 8px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.4);
}

body.phone .sidebar-content {
  display: flex !important;
  flex-wrap: wrap;
  gap: 3px 5px;
  padding: 6px 6px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  max-height: none !important;
  overflow-y: visible !important;
  align-items: center;
}

body.phone .filter-section {
  margin-bottom: 0 !important;
  flex-shrink: 0;
}

body.phone #color-filter-section {
  display: none !important;
}

body.phone .filter-title {
  display: none !important;
}

/* Hide slideshow on phone — not useful in touch context */
body.phone .filter-section:has(.slideshow-btn) {
  display: none !important;
}

body.phone .year-filter-select {
  width: auto !important;
  min-width: 0;
  padding: 5px 7px !important;
  font-size: 10px !important;
  height: 28px;
}

body.phone .filter-input {
  width: 100% !important;
  padding: 5px 7px !important;
  font-size: 10px !important;
  height: 28px;
}

body.phone .filter-section:has(.filter-input) {
  flex: 1;
  min-width: 80px;
}

body.phone .clear-all-btn,
body.phone .cache-test-btn,
body.phone .favorites-sidebar-btn {
  width: auto !important;
  padding: 5px 8px !important;
  font-size: 9px !important;
  white-space: nowrap;
  height: 28px;
  line-height: 1;
}

/* ── Special filter toggles: compact inline row ── */
body.phone #special-filters-section {
  display: flex !important;
  flex-direction: row;
  gap: 3px;
  width: auto;
}

body.phone .special-filter-container {
  margin-bottom: 0 !important;
}

body.phone .special-filter-container .color-toggle-label {
  padding: 4px 6px !important;
  gap: 3px;
  border-radius: 4px;
}

body.phone .special-filter-container .color-toggle-text {
  font-size: 7px !important;
  letter-spacing: 0.5px !important;
}

body.phone .special-filter-container .toggle-switch {
  width: 28px !important;
  height: 14px !important;
  min-width: 28px;
  border-radius: 7px;
}

body.phone .special-filter-container .toggle-switch::after {
  width: 10px !important;
  height: 10px !important;
  top: 2px !important;
  left: 2px !important;
}

body.phone .special-filter-container .color-toggle-checkbox:checked + .color-toggle-text + .toggle-switch::after {
  left: 14px !important;
}

body.phone .cache-progress {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin: 0 0 4px 0;
  height: 14px;
}

body.phone #total-count {
  bottom: 100px !important;
}

body.phone .zoom-indicator {
  bottom: 100px !important;
}

body.phone .mobile-backdrop {
  display: none !important;
}

/* ── Note modal: compact for phones ── */
body.phone .note-modal {
  width: 96vw !important;
  max-height: 85vh !important;
}

body.phone .note-modal-preview,
body.phone .note-modal-playback,
body.phone .note-modal-viewer-video {
  max-height: 234px !important;
}

body.phone .note-modal-text {
  font-size: 12px !important;
  min-height: 60px !important;
}

body.phone .note-popup {
  left: 6px !important;
  right: 6px !important;
  width: auto !important;
  max-height: 45vh !important;
}

body.phone .note-popup-body .note-modal-viewer-video {
  max-height: 150px !important;
}
