/**
 * @filename      assets/css/theme.css
 * @author        Plantnimals Team
 * @created       2025-10-18
 * @modified      10/12/2025
 * @description   Custom styles supplementing Tailwind for the Plantnimals theme
 *                (prose, maps, gallery, and lightbox polish).
 */

/* ==========================================================================
   PROSE TYPOGRAPHY (Article Content)
   ========================================================================== */

.prose {
    color: #334155;
    line-height: 1.75;
}

.prose h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #065f46;
    padding-bottom: 0.5rem;
    display: inline-block;
}

.prose h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e293b;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.prose h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.prose p {
    margin-bottom: 1.5rem;
}

.prose a {
    color: #065f46;
    text-decoration: underline;
    font-weight: 500;
}

.prose a:hover {
    color: #064e3b;
}

.prose strong {
    font-weight: 600;
    color: #0f172a;
}

.prose em {
    font-style: italic;
}

/* Lists */
.prose ul,
.prose ol {
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
    padding-left: 1.625rem;
}

.prose ul {
    list-style-type: disc;
}

.prose ol {
    list-style-type: decimal;
}

.prose li {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.prose li>p {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
}

/* Nested lists */
.prose ul ul,
.prose ul ol,
.prose ol ul,
.prose ol ol {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
}

/* Callout Boxes / Blockquotes */
.prose blockquote {
    font-style: italic;
    border-left: 4px solid #065f46;
    padding-left: 1.5rem;
    margin: 2rem 0;
    color: #64748b;
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 0.5rem;
}

.prose blockquote p {
    margin: 0;
}

/* Code blocks */
.prose code {
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    font-family: 'Courier New', monospace;
    color: #065f46;
}

.prose pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.prose pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

/* Tables */
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
}

.prose th {
    background: #f1f5f9;
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.prose td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

/* Images */
.prose img {
    border-radius: 0.5rem;
    margin: 2rem 0;
}

.prose figure {
    margin: 2rem 0;
}

.prose figcaption {
    text-align: center;
    font-size: 0.875rem;
    color: #64748b;
    margin-top: 0.75rem;
}

/* Horizontal Rule */
.prose hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 3rem 0;
}

/* ==========================================================================
   MAP MODAL STYLES
   ========================================================================== */

#map-modal {
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#map-modal button:hover {
    background: #f1f5f9;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 768px) {
    .prose h2 {
        font-size: 1.5rem;
    }

    .prose h3 {
        font-size: 1.25rem;
    }

    #map-modal {
        padding: 1rem;
    }
}

/* ==========================================================================
   GLIGHTBOX POLISH (NAV + CAPTION)
   ========================================================================== */

.glightbox-clean .gprev,
.glightbox-clean .gnext {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.glightbox-clean .gprev:hover,
.glightbox-clean .gnext:hover {
    background: rgba(0, 0, 0, 0.75);
}

.glightbox-clean .gprev svg,
.glightbox-clean .gnext svg {
    display: none;
}

.glightbox-clean .gprev::after,
.glightbox-clean .gnext::after {
    content: '';
    width: 14px;
    height: 14px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.glightbox-clean .gprev::after {
    background-image: url('../images/icons/arrow-left.svg');
}

.glightbox-clean .gnext::after {
    background-image: url('../images/icons/arrow-right.svg');
}

.glightbox-clean .gslide-description {
    background: rgba(0, 0, 0, 0.65);
    color: #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
}

.glightbox-clean .gslide-description .gslide-title {
    color: #fff;
    font-weight: 700;
    margin-bottom: 6px;
}

.glightbox-clean .gslide-description p {
    color: #e2e8f0;
    margin: 0;
}

/* ==========================================================================
   CONSERVATION BADGES
   ========================================================================== */

.pn-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #e2e8f0;
    color: #0f172a;
}

.pn-badge::before {
    content: '';
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 9999px;
    background: currentColor;
    opacity: 0.9;
}

.pn-badge--least-concern {
    background: #ecfdf3;
    color: #166534;
    border-color: #bbf7d0;
}

.pn-badge--near-threatened {
    background: #fefce8;
    color: #854d0e;
    border-color: #fde68a;
}

.pn-badge--vulnerable {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fed7aa;
}

.pn-badge--endangered {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecdd3;
}

.pn-badge--critically-endangered {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.pn-badge--extinct-in-the-wild,
.pn-badge--extinct {
    background: #0f172a;
    color: #f8fafc;
    border-color: #1f2937;
}

.pn-badge--data-deficient {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

.pn-badge--not-evaluated {
    background: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}

/* ==========================================================================
   MOBILE NAV
   ========================================================================== */
#primary-navigation.mobile-nav {
    display: none;
}

#primary-navigation.mobile-nav.is-open {
    display: block;
}

body.nav-open {
    overflow: hidden;
}

/* ==========================================================================
   ENHANCED GALLERY STYLES
   ========================================================================== */

/* Gallery Item Hover Effects */
.pn-gallery-item {
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
}

.pn-gallery-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(6, 95, 70, 0.1) 0%, rgba(6, 95, 70, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
    border-radius: inherit;
}

.pn-gallery-item:hover::before {
    opacity: 1;
}

/* Smooth Image Loading */
.pn-gallery-item img {
    transition: opacity 0.5s ease-in-out, transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Loading Animation */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.pn-gallery-item .animate-pulse {
    animation: shimmer 2s infinite linear;
    background: linear-gradient(90deg, #e5e7eb 0%, #f3f4f6 50%, #e5e7eb 100%);
    background-size: 1000px 100%;
}

/* Lightbox Enhancements */
[x-cloak] {
    display: none !important;
}

/* Smooth Backdrop Blur */
.backdrop-blur-md {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.backdrop-blur-sm {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Image Quality Enhancement */
img[style*="image-rendering"] {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Navigation Button Pulse Effect */
@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* Touch Feedback for Mobile */
@media (hover: none) and (pointer: coarse) {
    .pn-gallery-item:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    .pn-gallery-item img {
        transform: none !important;
    }
}

/* Responsive Gallery Adjustments */
@media (max-width: 768px) {
    .pn-gallery-item {
        border-radius: 0.75rem;
    }
    
    /* Optimize for mobile performance */
    .pn-gallery-item img {
        will-change: auto;
    }
}

/* High Resolution Display Optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .pn-gallery-item img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Gallery Info Bar Animation */
.pn-gallery-item + * {
    animation: slideUp 0.5s ease-out;
}

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

/* Lightbox Image Container */
.lightbox-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

/* Prevent Image Dragging in Lightbox */
[x-show="isOpen"] img {
    user-select: none;
    -webkit-user-drag: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

/* Loading Spinner Enhancement */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Smooth Transitions for Alpine.js */
[x-transition] {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Gallery Section Background */
.bg-gradient-to-b {
    background-image: linear-gradient(to bottom, var(--tw-gradient-stops));
}

/* Focus Visible Styles for Accessibility */
.pn-gallery-item:focus-visible {
    outline: 4px solid rgba(6, 95, 70, 0.5);
    outline-offset: 2px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .pn-gallery-item,
    .pn-gallery-item img,
    [x-transition],
    .animate-pulse,
    .animate-spin {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}