/*
 * Gallery Modern Redesign Stylesheet
 * Sunflower English Centre
 */

/* Hero Simplification */
body.gallery-page .gallery-hero {
    display: block;
    padding: clamp(7.2rem, 9vw, 8.6rem) 0 clamp(0.8rem, 2vw, 1.2rem);
}

body.gallery-page .gallery-title {
    font-size: clamp(2.2rem, 5vw, 3.2rem);
    color: #181209;
    margin: 0.6rem 0 0.5rem;
    font-weight: 800;
}

/* True CSS Masonry Layout */
body.gallery-page .gallery-masonry {
    display: block;
    column-count: 4;
    column-gap: 1.2rem;
}

body.gallery-page .gallery-card {
    display: inline-block;
    width: 100%;
    margin-bottom: 1.2rem;
    break-inside: avoid;
}

body.gallery-page .gallery-card__media {
    position: relative;
    overflow: hidden;
    border-radius: 1.7rem;
    aspect-ratio: auto; /* Remove the 4/3 aspect ratio crop */
}

body.gallery-page .gallery-card__media img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body.gallery-page .gallery-card__link:hover .gallery-card__media img,
body.gallery-page .gallery-card__link:focus-visible .gallery-card__media img {
    transform: scale(1.06);
}

/* Light zoom button styling */
body.gallery-page .gallery-card__zoom {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #5f4300;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(27, 24, 14, 0.25);
    opacity: 0;
    pointer-events: none;
    z-index: 3;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

body.gallery-page .gallery-card__zoom svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.5;
}

body.gallery-page .gallery-card__link:hover .gallery-card__zoom,
body.gallery-page .gallery-card__link:focus-visible .gallery-card__zoom {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Overlay gradient & text */
body.gallery-page .gallery-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(24, 18, 9, 0) 30%, rgba(24, 18, 9, 0.85) 100%);
    display: flex;
    align-items: flex-end;
    padding: 1.4rem;
    opacity: 0;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.gallery-page .gallery-card__caption {
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    transform: translateY(12px);
    transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.gallery-page .gallery-card__link:hover .gallery-card__overlay,
body.gallery-page .gallery-card__link:focus-visible .gallery-card__overlay {
    opacity: 1;
}

body.gallery-page .gallery-card__link:hover .gallery-card__caption,
body.gallery-page .gallery-card__link:focus-visible .gallery-card__caption {
    transform: translateY(0);
}

/* Underlined Tabs Filter Redesign (Option 1) */
body.gallery-page .gallery-toolbar {
    border-bottom: 2px solid var(--ms-header-line, rgba(16, 129, 56, 0.13)) !important;
    padding-bottom: 0.2rem;
    margin-bottom: 1.8rem;
    align-items: center;
}

body.gallery-page .gallery-filters {
    gap: 1.8rem;
}

body.gallery-page .gallery-filter {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0.6rem 0.2rem !important;
    margin: 0 !important;
    position: relative;
    font-weight: 700 !important;
    color: var(--ms-header-muted, #71877c) !important;
    -webkit-text-fill-color: var(--ms-header-muted, #71877c) !important;
    box-shadow: none !important;
    transform: none !important;
    font-size: 1.05rem;
    transition: color 0.25s ease;
}

body.gallery-page .gallery-filter::after {
    content: '';
    position: absolute;
    bottom: -2px; /* Align exactly with the toolbar bottom border */
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--ms-header-green, #108138), var(--ms-header-yellow, #f6c928));
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

body.gallery-page .gallery-filter:hover {
    color: var(--ms-header-green, #108138) !important;
    -webkit-text-fill-color: var(--ms-header-green, #108138) !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
}

body.gallery-page .gallery-filter.is-active {
    color: var(--ms-header-green, #108138) !important;
    -webkit-text-fill-color: var(--ms-header-green, #108138) !important;
    font-weight: 800 !important;
    background: transparent !important;
    box-shadow: none !important;
}

body.gallery-page .gallery-filter.is-active::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* Count Badge styling */
body.gallery-page .gallery-filter span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: auto !important;
    height: auto !important;
    padding: 0.15rem 0.4rem !important;
    margin-left: 0.35rem;
    border-radius: 6px !important;
    background: var(--ms-header-soft, #f4fbf7) !important;
    color: var(--ms-header-muted, #71877c) !important;
    -webkit-text-fill-color: var(--ms-header-muted, #71877c) !important;
    font-size: 0.78rem !important;
    font-weight: 700;
    transition: background-color 0.25s ease, color 0.25s ease;
}

body.gallery-page .gallery-filter.is-active span {
    background: rgba(16, 129, 56, 0.12) !important;
    color: var(--ms-header-green, #108138) !important;
    -webkit-text-fill-color: var(--ms-header-green, #108138) !important;
}

/* Lightbox Enhancements */
body.gallery-page .gallery-lightbox {
    backdrop-filter: blur(14px);
    background: rgba(15, 12, 8, 0.82);
}

body.gallery-page .gallery-lightbox__dialog {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 254, 250, 0.98);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Lightbox SVGs & Navigation Control */
body.gallery-page .gallery-lightbox__close,
body.gallery-page .gallery-lightbox__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(188, 135, 0, 0.15);
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
}

body.gallery-page .gallery-lightbox__close svg,
body.gallery-page .gallery-lightbox__nav svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    transition: stroke 0.2s ease;
}

body.gallery-page .gallery-lightbox__close:hover,
body.gallery-page .gallery-lightbox__nav:not(:disabled):hover {
    background: #fff9e6;
    border-color: #ffd65a;
    transform: translateY(-50%) scale(1.06);
    box-shadow: 0 10px 20px rgba(188, 135, 0, 0.15);
}

body.gallery-page .gallery-lightbox__close:hover {
    transform: scale(1.06);
}

body.gallery-page .gallery-lightbox__close:active,
body.gallery-page .gallery-lightbox__nav:not(:disabled):active {
    transform: translateY(-50%) scale(0.96);
}

body.gallery-page .gallery-lightbox__close:active {
    transform: scale(0.96);
}

body.gallery-page .gallery-lightbox__status {
    background: rgba(188, 135, 0, 0.08);
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    width: fit-content;
    margin: 0 auto;
    font-size: 0.85rem;
    border: 1px solid rgba(188, 135, 0, 0.12);
}

body.gallery-page .gallery-lightbox__caption {
    font-size: 1.05rem;
    color: #1c1810;
    max-width: 90%;
    margin: 0 auto;
    line-height: 1.4;
}

/* Responsive Masonry Breakpoints */
@media (max-width: 1000px) {
    body.gallery-page .gallery-masonry {
        column-count: 3;
    }
}

@media (max-width: 700px) {
    body.gallery-page .gallery-masonry {
        column-count: 2;
    }
}

@media (max-width: 480px) {
    body.gallery-page .gallery-masonry {
        column-count: 1;
    }
}
