/* ============================================
   SHARED CSS COMPONENTS
   Components used across multiple pages
   ============================================ */

/* NOTE: variables.css is loaded via <link> in HTML for better performance */

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Page wrapper for main content (used on map pages) */
.page-wrapper {
  pointer-events: none;
}

/* ============================================
   VIEW TRANSITIONS - STABLE NAVIGATION
   Navigation persists smoothly between pages
   ============================================ */

@view-transition {
  navigation: auto;
}

/* Navigation stays stable during page transitions */
.nav {
  view-transition-name: nav;
}

/* Prevent nav from animating */
::view-transition-old(nav),
::view-transition-new(nav) {
  animation: none;
  mix-blend-mode: normal;
}


/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--stone-800);
  color: var(--stone-100);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-tooltip);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.3s ease, 
              visibility 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.toast--visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.toast__icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast__icon::after {
  content: '';
  width: 6px;
  height: 10px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

/* Toast mobile styles */
@media only screen and (max-width: 767px) {
  .toast {
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
    left: 16px;
    right: 16px;
    transform: translateX(0) translateY(100px);
    text-align: center;
    justify-content: center;
  }
  
  .toast--visible {
    transform: translateX(0) translateY(0);
  }
}

/* ============================================
   LIGHTBOX (Image Viewer)
   ============================================ */

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  cursor: zoom-out;
}

.lightbox--open {
  opacity: 1;
  visibility: visible;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.lightbox--open .lightbox__img {
  transform: scale(1);
}

.lightbox__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.lightbox__close::before,
.lightbox__close::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 2px;
  background: white;
  border-radius: 1px;
}

.lightbox__close::before {
  transform: rotate(45deg);
}

.lightbox__close::after {
  transform: rotate(-45deg);
}

/* Lightbox mobile styles */
@media (max-width: 768px) {
  .lightbox {
    padding: 20px;
  }
  
  .lightbox__close {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
  }
}

/* ============================================
   MODAL BASE STYLES
   ============================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top, 20px)) 
           max(20px, env(safe-area-inset-right, 20px)) 
           max(20px, env(safe-area-inset-bottom, 20px)) 
           max(20px, env(safe-area-inset-left, 20px));
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal--open {
  opacity: 1;
  visibility: visible;
}

.modal__content {
  background: white;
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}

.modal--open .modal__content {
  transform: scale(1) translateY(0);
}

.modal__header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 0px;
  margin-bottom: 16px;
  background: linear-gradient(to bottom, 
    rgba(255, 255, 255, 1) 0%, 
    rgba(255, 255, 255, 0.7) 50%, 
    rgba(255, 255, 255, 0) 100%
  );
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}

.modal__title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 500;
  color: var(--stone-800);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--stone-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.modal__close:hover {
  background: var(--stone-200);
}

.modal__close ion-icon {
  font-size: 18px;
  color: var(--stone-600);
}

.modal__body {
  padding: 20px;
}

/* Modal mobile styles */
@media (max-width: 640px) {
  .modal__content {
    max-height: 90vh;
  }

  .modal__body {
    padding: 16px;
  }

  .modal__header {
    padding: 14px 16px 20px;
    margin-bottom: -12px;
  }

  .modal__title {
    font-size: 17px;
  }
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading {
  text-align: center;
  padding: 60px 0;
}

.loading__spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--stone-200);
  border-top-color: var(--stone-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.loading__text {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--stone-400);
}

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

/* ============================================
   EMPTY STATE
   ============================================ */

.empty {
  text-align: center;
  padding: 60px 20px;
  font-family: var(--font-body);
  font-size: 16px;
  font-style: italic;
  color: var(--stone-400);
}

/* ============================================
   ERROR STATE
   ============================================ */

.error-state {
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.error-state__icon {
  font-size: 48px;
  color: var(--stone-300);
}

.error-state__icon ion-icon {
  display: block;
}

.error-state__message {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--stone-500);
  margin: 0;
}

.error-state__retry {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--stone-700);
  background: var(--stone-100);
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.error-state__retry:hover {
  background: var(--stone-200);
  border-color: var(--stone-300);
}

.error-state__retry:active {
  transform: scale(0.98);
}

.error-state__retry ion-icon {
  font-size: 18px;
}

/* ============================================
   COMMON ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes heartPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================
   THEME TOGGLE
   Elegant sun/moon toggle switch
   ============================================ */

.theme-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--stone-200);
  border: 1px solid var(--stone-300);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--theme-transition);
  display: flex;
  align-items: center;
  padding: 2px;
}

.theme-toggle:hover {
  border-color: var(--stone-400);
}

.theme-toggle:focus-visible {
  box-shadow: var(--focus-ring);
}

.theme-toggle__track {
  position: absolute;
  inset: 2px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--stone-100) 0%, var(--stone-200) 100%);
  transition: background 0.3s ease;
}

[data-theme="dark"] .theme-toggle__track {
  background: linear-gradient(135deg, var(--stone-200) 0%, var(--stone-300) 100%);
}

.theme-toggle__thumb {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

[data-theme="dark"] .theme-toggle__thumb {
  transform: translateX(20px);
  background: var(--stone-700);
}

.theme-toggle__icon {
  font-size: 12px;
  color: var(--accent-clay);
  transition: opacity 0.2s ease, transform 0.3s ease;
}

.theme-toggle__icon--sun {
  position: absolute;
}

.theme-toggle__icon--moon {
  position: absolute;
  opacity: 0;
  transform: rotate(-45deg);
}

[data-theme="dark"] .theme-toggle__icon--sun {
  opacity: 0;
  transform: rotate(45deg);
}

[data-theme="dark"] .theme-toggle__icon--moon {
  opacity: 1;
  transform: rotate(0deg);
  color: var(--accent-rating);
}

/* Theme toggle wrapper for positioning */
.theme-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle-label {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--stone-500);
  letter-spacing: 0.02em;
  user-select: none;
}

/* ============================================
   DARK MODE COMPONENT OVERRIDES
   ============================================ */

/* Modal content for dark mode */
[data-theme="dark"] .modal__content {
  background: var(--stone-100);
}

[data-theme="dark"] .modal__header {
  background: linear-gradient(to bottom, 
    var(--stone-100) 0%, 
    rgba(17, 33, 45, 0.7) 50%, 
    rgba(17, 33, 45, 0) 100%
  );
}

/* Toast for dark mode */
[data-theme="dark"] .toast {
  background: var(--stone-900);
  color: var(--stone-50);
}

/* Body transition for theme change */
body {
  transition: var(--theme-transition);
}

/* Smooth transitions for common elements */
.sidebar,
.content-wrapper,
.content-container,
.nav,
.modal__content,
.toast,
.tag,
.book-card,
.drink-card,
.vinyl-card {
  transition: var(--theme-transition);
}
