/* ══════════════════════════════════════════════════════════════════════════════
   UX ENHANCEMENTS - 10/10 Mobile Experience
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── SKELETON LOADING STATES ── */
.skeleton {
  background: linear-gradient(90deg, 
    var(--bo-rule) 25%, 
    rgba(181, 97, 10, 0.1) 50%, 
    var(--bo-rule) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 100%;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.title { height: 20px; width: 70%; }

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-card {
  padding: 20px;
  background: white;
  border: 1px solid var(--bo-rule);
  border-radius: 6px;
}

.skeleton-button {
  height: 36px;
  width: 120px;
  border-radius: 4px;
}

/* ── PAGE TRANSITIONS ── */
.page-transition {
  animation: pageEnter 0.4s ease-out;
}

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

.page-exit {
  animation: pageExit 0.3s ease-in forwards;
}

@keyframes pageExit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Staggered card animations */
.stagger-enter > * {
  opacity: 0;
  transform: translateY(20px);
  animation: staggerIn 0.4s ease-out forwards;
}

.stagger-enter > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-enter > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-enter > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-enter > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-enter > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-enter > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-enter > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-enter > *:nth-child(8) { animation-delay: 0.4s; }

@keyframes staggerIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── PULL TO REFRESH ── */
.pull-to-refresh {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  z-index: 999;
}

.pull-to-refresh.pulling {
  transform: translateY(0);
}

.pull-to-refresh.refreshing .ptr-spinner {
  animation: spin 1s linear infinite;
}

.ptr-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(181, 97, 10, 0.2);
  border-top-color: var(--bo-accent);
  border-radius: 50%;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ptr-text {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--paper);
  margin-left: 12px;
}

/* ── SWIPE NAVIGATION INDICATOR ── */
.swipe-indicator {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 19, 15, 0.8);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 998;
  pointer-events: none;
}

.swipe-indicator.left { left: 8px; }
.swipe-indicator.right { right: 8px; }

.swipe-indicator.visible {
  opacity: 1;
}

.swipe-indicator svg {
  color: var(--paper);
  width: 24px;
  height: 24px;
}

/* ── HAPTIC FEEDBACK VISUAL ── */
.haptic-tap {
  position: relative;
}

.haptic-tap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(181, 97, 10, 0.15);
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
}

.haptic-tap:active::after {
  animation: hapticPulse 0.3s ease-out;
}

@keyframes hapticPulse {
  0% { opacity: 1; transform: scale(0.95); }
  100% { opacity: 0; transform: scale(1); }
}

/* ── SMOOTH SCROLL BEHAVIOR ── */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  .skeleton {
    animation: none;
  }
  
  .page-transition,
  .stagger-enter > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ── OFFLINE INDICATOR ── */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #e74c3c;
  color: white;
  text-align: center;
  padding: 8px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  z-index: 10000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-banner.visible {
  transform: translateY(0);
}

/* ── TOAST NOTIFICATIONS ── */
.toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
}

.toast.success {
  border-left: 3px solid var(--gd-accent);
}

.toast.error {
  border-left: 3px solid #e74c3c;
}

.toast.info {
  border-left: 3px solid var(--fr-accent);
}

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

.toast.toast-out {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* ── LOADING OVERLAY ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 19, 15, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.loading-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(181, 97, 10, 0.2);
  border-top-color: var(--bo-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ── BOTTOM SHEET (for filters, etc.) ── */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 1001;
}

.bottom-sheet-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 1002;
  max-height: 80vh;
  overflow-y: auto;
}

.bottom-sheet.visible {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--bo-rule);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.bottom-sheet-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--bo-ink);
  margin-bottom: 16px;
}

/* ── FLOATING ACTION BUTTON ── */
.fab {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--bo-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 16px rgba(181, 97, 10, 0.4);
  z-index: 999;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  border: none;
}

.fab:active {
  transform: scale(0.95);
}

.fab:hover {
  box-shadow: 0 6px 20px rgba(181, 97, 10, 0.5);
}

.fab svg {
  width: 24px;
  height: 24px;
}

@media (min-width: 769px) {
  .fab {
    display: none;
  }
}

/* ── IMAGE LAZY LOADING ── */
.lazy-image {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lazy-image.loaded {
  opacity: 1;
}

/* ── SCROLL PROGRESS INDICATOR ── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--bo-accent);
  z-index: 10000;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.1s linear;
}
