/* North American Apothecary - Custom Styles */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #10b981;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #059669;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid #10b981;
    outline-offset: 2px;
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #10b981;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

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

/* Text selection */
::selection {
    background: #10b981;
    color: white;
}

/* Responsive text sizing - Optimized for 35-60 demographic */
body {
    font-size: 18px; /* Base 18px for better readability (was 16px default) */
    line-height: 1.75; /* Relaxed leading for comfortable reading */
}

@media (max-width: 640px) {
    body {
        font-size: 16px; /* Slightly smaller on mobile but still readable */
    }
}

/* Offline indicator */
body.offline::before {
    content: 'Offline Mode - Changes saved locally';
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #f59e0b;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Utility classes */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

.text-balance {
    text-wrap: balance;
}

/* Herb card hover effect */
.herb-card {
    transition: all 0.3s ease;
}

.herb-card:hover {
    transform: translateY(-4px);
}

/* Modal backdrop blur */
.modal-backdrop {
    backdrop-filter: blur(4px);
}

/* ========================================
   MOBILE RESPONSIVENESS ENHANCEMENTS
   Added: 2025-12-30
   ======================================== */

/* Ensure minimum touch targets on all interactive elements */
@media (max-width: 640px) {
    button, a.button, .touch-target {
        min-height: 44px;
        min-width: 44px;
    }

    /* Reduce modal padding on mobile for more content space */
    .modal-content-padding {
        padding: 1rem; /* 16px instead of 32px */
    }

    /* Improve modal max-height on mobile */
    .modal-container-mobile {
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    /* Better scrollbar visibility on mobile */
    .scroll-container {
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure text doesn't get too small */
    .text-xs {
        font-size: 0.875rem; /* 14px instead of 12px */
    }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Ensure adequate spacing for touch on tablets */
    button, a.button {
        min-height: 44px;
    }
}

/* Horizontal scroll indicator for tabs */
.scroll-tabs-container {
    position: relative;
}

.scroll-tabs-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to left, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.scroll-tabs-container.has-scroll::after {
    opacity: 1;
}

/* Improve tap target visibility */
@media (hover: none) and (pointer: coarse) {
    /* Mobile/touch devices */
    button:active, a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Prevent horizontal scroll on body */
body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Better modal scroll behavior */
.modal-scroll-content {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Responsive text containers - prevent overly long lines */
.text-container {
    max-width: 65ch; /* ~65 characters for optimal readability */
}

@media (max-width: 640px) {
    .text-container {
        max-width: 100%; /* Full width on mobile */
    }
}

/* Fix for iOS Safari bottom bar */
@supports (-webkit-touch-callout: none) {
    .modal-container-mobile {
        max-height: calc(100vh - 2rem - env(safe-area-inset-bottom));
    }
}

/* Improve scrollbar for desktop */
@media (min-width: 1024px) {
    .scroll-container::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }

    .scroll-container::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 6px;
    }

    .scroll-container::-webkit-scrollbar-thumb {
        background: #10b981;
        border-radius: 6px;
        border: 2px solid #f1f5f9;
    }

    .scroll-container::-webkit-scrollbar-thumb:hover {
        background: #059669;
    }
}

/* Responsive spacing utilities */
@media (max-width: 640px) {
    .mobile-compact-spacing {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .mobile-reduce-gap > * + * {
        margin-top: 0.75rem;
    }
}

/* Ensure modals don't exceed safe viewport */
.modal-safe-area {
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

/* Focus states for accessibility - enhanced for mobile */
@media (max-width: 640px) {
    *:focus-visible {
        outline: 3px solid #10b981;
        outline-offset: 2px;
    }
}

/* Prevent text selection on interactive elements (better UX on mobile) */
button, .no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* Improve image loading on mobile */
@media (max-width: 640px) {
    img {
        image-rendering: auto;
        image-rendering: -webkit-optimize-contrast;
    }
}

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

/* ========================================
   PHOTOSWIPE GALLERY CUSTOM STYLES
   HerbChecker Green Theme Integration
   Added: 2025-12-31
   ======================================== */

/* PhotoSwipe button colors - HerbChecker green theme */
.pswp__button {
    background-color: rgba(16, 185, 129, 0.7) !important;
    color: white !important;
}

.pswp__button:hover {
    background-color: rgba(16, 185, 129, 0.9) !important;
}

.pswp__button--close {
    background-color: rgba(239, 68, 68, 0.7) !important;
}

.pswp__button--close:hover {
    background-color: rgba(239, 68, 68, 0.9) !important;
}

/* PhotoSwipe counter styling */
.pswp__counter {
    color: white !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    font-size: 14px !important;
    background: rgba(16, 185, 129, 0.7) !important;
    padding: 4px 12px !important;
    border-radius: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    top: 12px !important;
}

/* Filmstrip scrollbar styling */
.pswp__filmstrip::-webkit-scrollbar {
    height: 6px;
}

.pswp__filmstrip::-webkit-scrollbar-track {
    background: rgba(31, 41, 55, 0.5);
}

.pswp__filmstrip::-webkit-scrollbar-thumb {
    background: rgba(16, 185, 129, 0.8);
    border-radius: 3px;
}

.pswp__filmstrip::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 185, 129, 1);
}

/* Filmstrip thumbnail hover effects */
.pswp__filmstrip-thumb:hover {
    opacity: 0.9 !important;
    transform: scale(1.05);
}

/* Loading spinner with HerbChecker green */
.pswp__preloader__icn {
    fill: #10b981 !important;
}

/* Mobile optimizations for gallery */
@media (max-width: 640px) {
    /* Make buttons larger for easier tapping */
    .pswp__button {
        width: 48px !important;
        height: 48px !important;
    }

    /* Adjust filmstrip for mobile */
    .pswp__filmstrip {
        padding: 6px 8px !important;
        height: 64px !important;
    }

    .pswp__filmstrip-thumb {
        width: 48px !important;
        height: 48px !important;
    }

    /* Custom caption adjustments */
    .pswp__custom-caption {
        bottom: 70px !important;
        font-size: 14px !important;
    }

    .pswp__custom-caption > div:first-child {
        font-size: 14px !important;
    }

    .pswp__custom-caption > div:last-child {
        font-size: 12px !important;
    }
}

/* Tablet optimizations */
@media (min-width: 641px) and (max-width: 1023px) {
    .pswp__button {
        width: 44px !important;
        height: 44px !important;
    }
}

/* Desktop enhancements */
@media (min-width: 1024px) {
    .pswp__filmstrip-thumb:hover {
        border-color: #10b981 !important;
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    }
}

/* Zoom animation */
.pswp__img {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Better backdrop */
.pswp__bg {
    background: rgba(0, 0, 0, 0.95) !important;
}

/* PhotoSwipe z-index fix to ensure it appears above modals */
.pswp {
    z-index: 9999 !important;
}

/* Gallery grid hover effects in modal */
#herb-gallery a:focus-visible {
    outline: 3px solid #10b981;
    outline-offset: 2px;
    border-radius: 8px;
}

/* Image loading state */
#herb-gallery img {
    transition: opacity 0.3s ease-in-out;
}

#herb-gallery img[loading="lazy"] {
    background: linear-gradient(90deg, #e5e7eb 0%, #f3f4f6 50%, #e5e7eb 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* Touch feedback for gallery thumbnails */
@media (hover: none) and (pointer: coarse) {
    #herb-gallery a:active {
        transform: scale(0.95);
    }
}

/* Smooth scroll for filmstrip */
.pswp__filmstrip {
    scroll-behavior: smooth;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pswp__button {
        background-color: rgba(16, 185, 129, 1) !important;
        border: 2px solid white;
    }

    .pswp__filmstrip-thumb[style*="border: 2px solid #10b981"] {
        border-width: 3px !important;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    .pswp__bg {
        background: rgba(0, 0, 0, 0.98) !important;
    }
}

/* Accessibility: Focus trap indication */
.pswp:focus-within .pswp__button:focus-visible {
    outline: 3px solid white;
    outline-offset: 2px;
}

/* Performance: GPU acceleration for smoother animations */
.pswp__filmstrip-thumb,
#herb-gallery img {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Offline support indicator for gallery */
.pswp.offline::after {
    content: 'Viewing cached images';
    position: absolute;
    top: 60px;
    right: 20px;
    background: rgba(245, 158, 11, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
}
