/* =============================================================
   EcoFert Agri Solutions — "Life on the Farm" Gallery Section
   gallery.css
   ============================================================= */

/* -------------------------------------------------------------
   1. FONTS
   ------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800&family=Open+Sans:wght@400;500;600&display=swap');

/* -------------------------------------------------------------
   2. COLOR VARIABLES (as specified in the brief)
   ------------------------------------------------------------- */
:root {
    --primary-green: #2E7D32;
    --dark-green:    #1B5E20;
    --light-green:   #F4FBF3;
    --accent-green:  #8BC34A;
    --text-color:    #333333;

    --radius: 20px;
    --shadow-soft: 0 12px 30px rgba(27, 94, 32, 0.10);
    --shadow-hover: 0 22px 45px rgba(27, 94, 32, 0.25);
}

/* -------------------------------------------------------------
   3. RESET (scoped lightly — safe to drop into an existing site)
   ------------------------------------------------------------- */
.farm-gallery, .farm-gallery * ,
.lightbox, .lightbox * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.farm-gallery img { max-width: 100%; display: block; }
.farm-gallery button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* -------------------------------------------------------------
   4. SECTION BACKGROUND — light agri theme + leaf watermark
   ------------------------------------------------------------- */
.farm-gallery {
    position: relative;
    background: var(--light-green);
    padding:50px 0;
    overflow: hidden;
    font-family: 'Open Sans', sans-serif;
    color: var(--text-color);
}

/* soft organic watermark pattern (pure CSS, no image needed) */
.farm-gallery::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(46, 125, 50, 0.06) 1.5px, transparent 1.5px);
    background-size: 26px 26px;
    pointer-events: none;
}

.gallery-container {
    position: relative;
    z-index: 2;
    width: 90%;
    max-width: 1280px;
    margin: 0 auto;
}

/* floating decorative leaves in the corners */
.floating-leaves { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.leaf {
    position: absolute;
    color: rgba(139, 195, 74, 0.35);
    animation: leaf-float 7s ease-in-out infinite;
}
.leaf-a { top: 6%;  left: 4%;  font-size: 46px; animation-delay: 0s; }
.leaf-b { top: 70%; left: 2%;  font-size: 30px; animation-delay: 1.5s; }
.leaf-c { top: 12%; right: 5%; font-size: 38px; animation-delay: .8s; }
.leaf-d { top: 78%; right: 6%; font-size: 26px; animation-delay: 2.2s; }

@keyframes leaf-float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-18px) rotate(12deg); }
}

/* -------------------------------------------------------------
   5. SECTION HEADER
   ------------------------------------------------------------- */
.gallery-header {
    text-align: center;
    max-width: 680px;
    margin: 0 auto 50px;
}

.gallery-subtitle {
    display: inline-block;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--primary-green);
    margin-bottom: 14px;
}

.gallery-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: clamp(30px, 4vw, 44px);
    color: var(--dark-green);
    margin-bottom: 18px;
}

.gallery-desc {
    font-size: 16px;
    line-height: 1.8;
    color: #555;
}

/* -------------------------------------------------------------
   6. STATS RIBBON
   ------------------------------------------------------------- */
.stats-ribbon {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    background: #fff;
    border-radius: 50px;
    padding: 20px 30px;
    box-shadow: var(--shadow-soft);
    max-width: 780px;
    margin: 0 auto 60px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 18px;
    position: relative;
}

.stat-item:not(:last-child)::after {
    content: "";
    position: absolute;
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 30px;
    background: #e2ede0;
}

.stat-item strong {
    font-family: 'Poppins', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-green);
}

.stat-item span {
    font-size: 12.5px;
    color: #777;
    margin-top: 4px;
    white-space: nowrap;
}

/* -------------------------------------------------------------
   7. MASONRY GALLERY GRID
   Uses CSS multi-column layout for a true Pinterest-style
   masonry effect — each card keeps its own aspect ratio so
   large / medium / small items line up naturally.
   ------------------------------------------------------------- */
.masonry-grid {
    column-count: 4;
    column-gap: 24px;
}

.gallery-item {
    position: relative;
    break-inside: avoid;
    margin-bottom: 24px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    background: #e9f3e6; /* skeleton base color while loading */

    /* scroll-reveal starting state (see gallery.js) */
    opacity: 0;
    transform: translateY(40px);
    transition: opacity .6s ease, transform .6s ease,
                box-shadow .45s ease;
}

.gallery-item.in-view {
    opacity: 1;
    transform: translateY(0);
}

.gallery-item:hover {
    box-shadow: var(--shadow-hover);
}

/* different aspect ratios create the masonry size variety */
.size-large  .gallery-img { aspect-ratio: 3 / 4; }
.size-medium .gallery-img { aspect-ratio: 1 / 1; }
.size-small  .gallery-img { aspect-ratio: 4 / 3; }

.gallery-img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity .5s ease, transform .5s ease;
}

.gallery-img.loaded {
    opacity: 1;
}

.gallery-item:hover .gallery-img.loaded {
    transform: scale(1.08); /* smooth zoom on hover */
}

/* shimmer skeleton shown until the lazy image finishes loading */
.img-skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, #e9f3e6 30%, #f4fbf3 50%, #e9f3e6 70%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

.gallery-img.loaded + .img-skeleton {
    display: none;
}

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

/* -------------------------------------------------------------
   8. HOVER OVERLAY
   ------------------------------------------------------------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 26px;
    background: linear-gradient(to top,
        rgba(15, 40, 18, 0.88) 0%,
        rgba(15, 40, 18, 0.35) 55%,
        rgba(15, 40, 18, 0) 100%);
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .45s ease, transform .45s ease;
}

.gallery-item:hover .overlay {
    opacity: 1;
    transform: translateY(0);
}

.overlay-leaf {
    color: var(--accent-green);
    font-size: 20px;
    margin-bottom: 10px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .5s ease .1s, transform .5s ease .1s;
}

.gallery-item:hover .overlay-leaf {
    opacity: 1;
    transform: translateY(0);
}

.overlay h3 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    margin-bottom: 6px;
}

.overlay p {
    font-size: 13.5px;
    color: rgba(255,255,255,.85);
    line-height: 1.5;
    opacity: 0;
    transition: opacity .5s ease .15s;
}

.gallery-item:hover .overlay p {
    opacity: 1;
}

/* -------------------------------------------------------------
   9. BOTTOM CTA
   ------------------------------------------------------------- */
.gallery-cta {
    text-align: center;
    max-width: 640px;
    margin: 40px auto 0;
}

.gallery-cta h3 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: clamp(22px, 3vw, 30px);
    color: var(--dark-green);
    margin-bottom: 14px;
}

.gallery-cta p {
    font-size: 15.5px;
    color: #555;
    line-height: 1.8;
    margin-bottom: 30px;
}

.btn-view-gallery {
    display: inline-block;
    padding: 16px 40px;
    background: var(--primary-green);
    color: #5cd60a;
    font-weight: 600;
    font-size: 15px;
    border-radius: 50px;
    transition: transform .35s ease, box-shadow .35s ease, background .35s ease;
    box-shadow: 0 12px 24px rgba(46, 125, 50, 0.25);
}

.btn-view-gallery:hover {
    background: linear-gradient(120deg, var(--primary-green), var(--accent-green));
    transform: translateY(-4px) scale(1.04);
    box-shadow: 0 18px 34px rgba(46, 125, 50, 0.35);
}

/* -------------------------------------------------------------
   10. LIGHTBOX
   ------------------------------------------------------------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity .35s ease, visibility .35s ease;
}

.lightbox.active {
    visibility: visible;
    opacity: 1;
}

.lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 20, 12, 0.85);
    backdrop-filter: blur(8px);
}

.lightbox-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 20px;
    width: 90%;
    max-width: 900px;
}

.lightbox-media {
    position: relative;
    flex: 1;
    background: #0f1f10;
    border-radius: var(--radius);
    overflow: hidden;
    transform: scale(.92);
    transition: transform .4s ease;
}

.lightbox.active .lightbox-media {
    transform: scale(1);
}

.lightbox-media img {
    width: 100%;
    max-height: 72vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    background: #0f1f10;
}

.lightbox-caption {
    padding: 20px 26px 26px;
    text-align: center;
    color: #fff;
}

.lightbox-caption h3 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 19px;
    margin-bottom: 6px;
}

.lightbox-caption p {
    font-size: 13.5px;
    color: rgba(255,255,255,.75);
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .3s ease, transform .3s ease;
}

.lightbox-close:hover {
    background: var(--primary-green);
    transform: rotate(90deg);
}

.lightbox-nav {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .3s ease, transform .3s ease;
}

.lightbox-nav:hover {
    background: var(--primary-green);
    transform: scale(1.1);
}

/* -------------------------------------------------------------
   11. RESPONSIVE
   ------------------------------------------------------------- */
@media (max-width: 1024px) {
    .masonry-grid { column-count: 3; }
}

@media (max-width: 768px) {
    .farm-gallery { padding: 70px 0; }
    .masonry-grid { column-count: 2; column-gap: 16px; }
    .gallery-item { margin-bottom: 16px; }
    .stats-ribbon { border-radius: 24px; padding: 20px; gap: 10px 0; }
    .stat-item { padding: 8px 14px; flex: 1 1 45%; }
    .stat-item:nth-child(odd)::after { display: none; }
    .lightbox-content { flex-direction: column; }
    .lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); }
    .lightbox-prev { left: -6px; }
    .lightbox-next { right: -6px; }
    .lightbox-close { top: -46px; }
}

@media (max-width: 520px) {
    .masonry-grid { column-count: 1; }
    .gallery-title { font-size: 28px; }
    .leaf-a, .leaf-c { font-size: 30px; }
    .leaf-b, .leaf-d { display: none; }
}