/* =========================================
   TWG: PREMIUM TESTIMONIAL CARD
========================================= */

.twg-testimonial-card {
    /* Define a local color palette */
    --twg-bg: #ffffff;
    --twg-text: #475569;
    --twg-heading: #0f172a;
    --twg-accent: #f59e0b; /* Warm amber/gold for links */
    --twg-border: #e2e8f0;
    
    position: relative;
    max-width: 650px;
    margin: 2.5rem auto;
    padding: 2.5rem;
    background-color: var(--twg-bg);
    border-radius: 16px;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.03);
    border: 1px solid var(--twg-border);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

/* Hover Lift Effect */
.twg-testimonial-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.12);
}

/* Faint Decorative Quote Mark in Background */
.twg-testimonial-card::before {
    content: "“";
    position: absolute;
    top: -20px;
    right: 20px;
    font-size: 180px;
    font-family: Georgia, serif;
    color: rgba(0,0,0,0.03);
    line-height: 1;
    z-index: 0;
    pointer-events: none;
}

/* Header (Avatar + Name) */
.twg-card-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* Avatar Styling */
.twg-avatar, .twg-avatar-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 2px solid #ffffff;
    flex-shrink: 0;
}

.twg-avatar-placeholder {
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.twg-avatar-placeholder svg { 
    width: 28px; 
    height: 28px; 
}

/* Metadata (Name & Links) */
.twg-meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.twg-name {
    margin: 0 0 4px 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--twg-heading);
    letter-spacing: -0.01em;
}

.twg-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.twg-links a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.twg-links a:hover {
    color: var(--twg-accent);
}

.twg-separator {
    color: #cbd5e1;
    font-size: 0.7rem;
}

/* Testimonial Text Body */
.twg-card-body {
    position: relative;
    z-index: 1;
    color: var(--twg-text);
}

.twg-card-body p {
    margin: 0 0 1.25rem 0;
    font-size: 1.1rem;
    line-height: 1.7;
    font-style: italic;
}

.twg-card-body p:last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .twg-testimonial-card {
        padding: 1.75rem;
        margin: 1.5rem 1rem;
        border-radius: 12px;
    }
    .twg-avatar, .twg-avatar-placeholder {
        width: 50px;
        height: 50px;
    }
    .twg-name { font-size: 1.1rem; }
    .twg-card-body p { font-size: 1.05rem; }
}

/* Strip theme backgrounds from inner text elements */
.twg-testimonial-card p,
.twg-testimonial-card h4,
.twg-testimonial-card div,
.twg-testimonial-card span {
    background-color: transparent !important;
}

.twg-testimonial-card { background-color: #ffffff !important; }
.twg-avatar-placeholder { background-color: #f1f5f9 !important; }

/* =========================================
   TWG: RESPONSIVE CAROUSEL REVAMP
========================================= */

.twg-carousel-wrapper {
    position: relative;
    width: 100%;
    max-width: 900px; /* Accommodates buttons and card */
    margin: 3rem auto;
    display: flex;
    flex-direction: column; 
    align-items: center;
}

.twg-carousel-viewport {
    overflow: hidden;
    width: 100%;
    padding: 20px 0; /* Leaves room for the drop shadow */
    transition: height 0.4s ease-out;
}

.twg-carousel-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
    will-change: transform;
    align-items: flex-start; /* Ensures short slides stay vertically centered */
}

/* The Slide is now a Flex container holding the buttons and card */
.twg-carousel-slide {
    flex: 0 0 100%;
    width: 100%;
    padding: 0 15px;
    box-sizing: border-box;
    display: flex;
    /* CHANGED: Align top */
    align-items: flex-start; 
    justify-content: center;
    gap: 20px; 
}

.twg-carousel-card, .twg-gallery-item {
    margin: 0 !important;
    width: 100%;
    max-width: 650px;
    height: fit-content !important; /* Allows short cards to stay short */
}

/* Navigation Buttons */
.twg-carousel-btn {
    position: static !important;
    transform: none !important;
    flex-shrink: 0;
    z-index: 10;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #475569 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    font-size: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1) !important;
    transition: all 0.2s ease !important;
    line-height: 0 !important;
    padding: 0 !important;
    align-self: center !important;
}

.twg-carousel-btn:hover {
    color: #f59e0b !important;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1) !important;
}

/* Pagination Dots */
.twg-carousel-pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.twg-pagination-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #cbd5e1;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.twg-pagination-dot:hover {
    background-color: #94a3b8;
}

.twg-pagination-dot.twg-active {
    background-color: #f59e0b;
    transform: scale(1.3);
}

@media (max-width: 768px) {
    .twg-carousel-slide { gap: 10px; padding: 0 10px; }
    .twg-carousel-btn { width: 36px !important; height: 36px !important; font-size: 24px !important; }
}

/* =========================================
   TWG: GALLERY CAROUSEL STYLES
========================================= */

.twg-gallery-item {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: zoom-in;
    background: #111;
    box-shadow: 0 10px 30px -5px rgba(0,0,0,0.15);
    height: 500px;
}

.twg-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.twg-gallery-item:hover img {
    transform: scale(1.05);
    opacity: 0.8;
}

/* Gallery Hover Overlay */
.twg-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
    color: #fff;
    padding: 30px 20px 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.twg-gallery-item:hover .twg-overlay { opacity: 1; }

.twg-species-title { margin: 0; font-size: 1.2rem; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.twg-scientific-name { margin: 2px 0 8px 0; font-size: 0.8rem; font-style: italic; color: #ccc; }
.twg-caption-preview { font-size: 0.85rem; color: #ddd; margin: 0 0 10px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.twg-credit, .twg-credit-link { font-size: 0.8rem; color: #f59e0b; text-decoration: none; }
.twg-credit-link:hover { text-decoration: underline; }

/* =========================================
   TWG: LIGHTBOX MODAL
========================================= */
.twg-lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.twg-lightbox.twg-active { opacity: 1; visibility: visible; }

.twg-lightbox-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.95);
}

.twg-lightbox-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.twg-lightbox-image-container {
    max-height: 75vh;
    display: flex;
    justify-content: center;
}

.twg-lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

.twg-lightbox-caption-area {
    margin-top: 20px;
    color: #fff;
    text-align: center;
    max-width: 800px;
}

.twg-lightbox-caption-area .twg-species-title { font-size: 1.5rem; margin-bottom: 5px; }
.twg-lightbox-full-caption { font-size: 1rem; color: #eee; margin-bottom: 10px; line-height: 1.6; }
.twg-lightbox-full-caption a { color: #f59e0b; }
.twg-lightbox-credit { margin-top: 10px; font-weight: bold; }

.twg-lightbox-close, .twg-lightbox-prev, .twg-lightbox-next {
    position: absolute;
    background: transparent !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    transition: color 0.2s ease !important;
    box-shadow: none !important;
}
.twg-lightbox-close:hover, .twg-lightbox-prev:hover, .twg-lightbox-next:hover { color: #f59e0b !important; }

.twg-lightbox-close { top: 20px; right: 20px; font-size: 40px; line-height: 1; }
.twg-lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); font-size: 60px; }
.twg-lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); font-size: 60px; }

@media (max-width: 768px) {
    .twg-lightbox-content { padding: 20px; }
    .twg-lightbox-prev, .twg-lightbox-next { display: none; }
}

/* =========================================
   TWG: DENSE AUTO-FLOW GRID (TESTIMONIALS)
========================================= */

.twg-testimonial-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 150px; /* The baseline block height */
    gap: 20px;
    grid-auto-flow: dense; /* The magic packer that fills empty spaces */
    max-width: 1200px;
    margin: 3rem auto;
    padding: 0 15px;
}

/* Base override for grid cards */
.twg-testimonial-grid .twg-grid-card {
    margin: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
    
    /* Pre-Animation State */
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Post-Animation State */
.twg-testimonial-grid .twg-grid-card.twg-in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Dynamic Span Classes */
.twg-testimonial-grid .twg-short { grid-row: span 2; }
.twg-testimonial-grid .twg-medium { grid-row: span 3; }
.twg-testimonial-grid .twg-tall { grid-row: span 4; }

/* Handle internal card overflow if text is slightly larger than the spanned block */
.twg-testimonial-grid .twg-card-header { flex-shrink: 0; }
.twg-testimonial-grid .twg-card-body { 
    flex-grow: 1; 
    overflow-y: auto; 
    padding-right: 5px;
}
.twg-testimonial-grid .twg-card-body::-webkit-scrollbar { width: 4px; }
.twg-testimonial-grid .twg-card-body::-webkit-scrollbar-track { background: transparent; }
.twg-testimonial-grid .twg-card-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .twg-testimonial-grid .twg-grid-card {
        transition: opacity 0.6s ease;
        transform: none;
    }
}

/* Responsive Breakpoints */
@media (max-width: 991px) {
    .twg-testimonial-grid { 
        grid-template-columns: repeat(2, 1fr); 
    }
}

@media (max-width: 767px) {
    .twg-testimonial-grid { 
        grid-template-columns: 1fr; 
        grid-auto-rows: auto; /* Allow natural heights */
    }
    .twg-testimonial-grid .twg-grid-card { 
        grid-row: auto !important; /* Cancel the span 2/3 forcing */
    }
    .twg-testimonial-grid .twg-card-body {
        overflow-y: visible; /* Disable scrollbars on mobile */
    }
}