/* =========================================================
   SHAAGIRD PHOTO ARCHIVE — GLIMPSES OF IMPACT
   Branded with Shaagird Teal (#299D8E) & Design System
========================================================= */

.m2s-gallery,
.m2s-image-modal {
    --accent: #299D8E;
    --accent-dark: #217F74;
    --text: #173B38;
    --muted: #5F716E;
    --line: #DCE9E6;
    --bg: #E7F5F2;
    --soft: #E7F5F2;
    --panel: #ffffff;
    --ink: #173B38;
    --shadow: 0 18px 50px rgba(23, 59, 56, 0.08);
}

.m2s-gallery,
.m2s-gallery *,
.m2s-image-modal,
.m2s-image-modal * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.m2s-gallery {
    width: 100%; max-width: 100%; margin-left: 0; margin-right: 0; overflow-x: hidden;
    padding: 36px 0 70px;
    font-family: "Inter", Arial, sans-serif;
    background:
        linear-gradient(90deg, rgba(41, 157, 142, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(41, 157, 142, 0.03) 1px, transparent 1px),
        linear-gradient(180deg, #FFFFFF 0%, var(--bg) 42%, #ffffff 100%);
    background-size: 44px 44px, 44px 44px, 100% 100%;
    color: var(--text);
}

body.m2s-modal-open {
    overflow: hidden;
}

.m2s-gallery button,
.m2s-gallery input,
.m2s-image-modal button {
    font: inherit;
}

.m2s-gallery {
    isolation: isolate;
}

.m2s-gallery .gallery-header,
.m2s-gallery .gallery-nav,
.m2s-gallery .gallery-content {
    width: min(1400px, calc(100% - 24px));
    margin-left: auto !important;
    margin-right: auto !important;
}

.m2s-gallery .gallery-header {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    padding: clamp(24px, 4vw, 42px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.96) 0%, rgba(231, 245, 242, 0.96) 62%, rgba(0, 0, 0, 0.08) 100%);
    box-shadow: var(--shadow);
}

.m2s-gallery .gallery-header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
}

.m2s-gallery .gallery-header::after {
    content: "";
    position: absolute;
    right: clamp(18px, 4vw, 50px);
    bottom: -36px;
    width: 180px;
    height: 180px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    pointer-events: none;
}

.m2s-gallery .gallery-header > * {
    position: relative;
    z-index: 1;
}

.m2s-gallery .eyebrow,
.m2s-gallery .category-heading p {
    margin-bottom: 8px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.m2s-gallery .gallery-header h1 {
    max-width: 720px;
    color: var(--ink);
    font-size: clamp(36px, 6vw, 68px);
    line-height: 1;
    letter-spacing: 0;
}

.m2s-gallery .header-copy {
    max-width: 620px;
    margin-top: 14px;
    color: #333333;
    font-size: 15px;
    line-height: 1.7;
}

.m2s-gallery .gallery-header-logo {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(41, 157, 142, 0.22);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(41, 157, 142, 0.08);
    backdrop-filter: blur(8px);
}

.m2s-gallery .gallery-header-logo img {
    height: 48px;
    width: auto;
    max-width: 135px;
    object-fit: contain;
    display: block;
}

.m2s-gallery .category-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.m2s-gallery .channel-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    padding: 6px 14px;
    background: var(--accent);
    color: #FFFFFF !important;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none !important;
    transition: background 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(41, 157, 142, 0.25);
}

.m2s-gallery .channel-link:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.m2s-gallery .channel-link svg {
    flex-shrink: 0;
}

.m2s-gallery .gallery-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    padding: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.74);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.07);
}

.m2s-gallery .gallery-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px 8px 10px;
    background: transparent;
    color: #222222;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.m2s-gallery .gallery-btn:hover, .m2s-gallery .gallery-btn.active {
    color: #FFFFFF !important;
    border-color: var(--accent-dark);
    background: var(--accent);
    color: #FFFFFF;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.m2s-gallery .btn-index {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: var(--ink);
    font-size: 11px;
    font-weight: 800;
}

.m2s-gallery .gallery-btn.active .btn-index {
    background: #FFFFFF;
    color: var(--accent);
}

.m2s-gallery .gallery-content {
    display: grid;
    gap: 14px;
    padding: clamp(18px, 3vw, 28px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow);
}

.m2s-gallery .category-block {
    display: block;
}

.m2s-gallery .category-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.m2s-gallery .category-heading:not(:first-child) {
    margin-top: 22px;
}

.m2s-gallery .category-heading h2 {
    color: var(--ink);
    font-size: clamp(24px, 4vw, 36px);
    line-height: 1.05;
}

.m2s-gallery .category-heading span {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 9px 12px;
    background: #f3f5f0;
    color: #222222;
    font-size: 13px;
    font-weight: 700;
}

.m2s-gallery .category-panel {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 0;
    overflow: hidden;
    will-change: height;
    transition: border-color 0.32s ease, box-shadow 0.32s ease, background 0.32s ease;
}

.m2s-gallery .category-panel[open] {
    border-bottom: 3px solid var(--accent);
    padding-bottom: 18px;
}

.m2s-gallery .category-panel.is-animating,
.m2s-gallery .category-panel[open] {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0));
}

.m2s-gallery .category-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 62px;
    padding: 0 2px;
    cursor: pointer;
    list-style: none;
    font-size: 17px;
    font-weight: 700;
    transition: color 0.24s ease, background 0.28s ease, padding 0.28s ease, transform 0.28s ease;
}

.m2s-gallery .category-panel summary:hover {
    background: rgba(253, 197, 19, 0.08);
    transform: translateX(2px);
}

.m2s-gallery .category-panel.is-animating summary {
    background: rgba(253, 197, 19, 0.12);
}

.m2s-gallery .category-panel + .category-panel {
    margin-top: 4px;
}

.m2s-gallery .category-panel summary::-webkit-details-marker {
    display: none;
}

.m2s-gallery .category-panel summary::before {
    content: "";
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background:
        linear-gradient(var(--ink), var(--ink)) center / 11px 2px no-repeat,
        linear-gradient(var(--ink), var(--ink)) center / 2px 11px no-repeat,
        var(--soft);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
    transition: transform 0.28s ease, background 0.28s ease;
}

.m2s-gallery .category-panel[open] summary::before {
    background:
        linear-gradient(#ffffff, #ffffff) center / 11px 2px no-repeat,
        #000000;
    transform: rotate(180deg);
}

.m2s-gallery .category-panel summary span {
    flex: 1;
}

.m2s-gallery .category-panel summary strong {
    border-radius: 999px;
    padding: 6px 9px;
    background: #f6f7f4;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.m2s-gallery .accordion-body {
    display: grid;
    gap: 22px;
    padding: 4px 0 28px 42px;
    transform-origin: top;
    backface-visibility: hidden;
}

.m2s-gallery .category-panel[open] .accordion-body {
    animation: m2sAccordionOpen 0.58s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.m2s-gallery .category-panel[open] .place-block,
.m2s-gallery .category-panel[open] .photo-card {
    animation: m2sFadeRise 0.58s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.m2s-gallery .category-panel[open] .place-block:nth-child(2),
.m2s-gallery .category-panel[open] .photo-card:nth-child(2) {
    animation-delay: 0.035s;
}

.m2s-gallery .category-panel[open] .place-block:nth-child(3),
.m2s-gallery .category-panel[open] .photo-card:nth-child(3) {
    animation-delay: 0.07s;
}

.m2s-gallery .category-panel[open] .place-block:nth-child(4),
.m2s-gallery .category-panel[open] .photo-card:nth-child(4) {
    animation-delay: 0.105s;
}

.m2s-gallery .place-block {
    position: relative;
    display: grid;
    gap: 12px;
    padding: 2px 0 26px;
}

.m2s-gallery .place-block::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 999px;
    background: var(--accent);
}

.m2s-gallery .place-block:last-child {
    padding-bottom: 4px;
}

.m2s-gallery .place-block:last-child::after {
    display: none;
}

.m2s-gallery .place-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.m2s-gallery .place-title span {
    width: 26px;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), #000000);
}

.m2s-gallery .place-title h2 {
    color: #111111;
    font-size: 16px;
    line-height: 1.2;
}

.m2s-gallery .place-title small {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.m2s-gallery .empty-place {
    border: 1px dashed rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    padding: 14px 16px;
    background: #fbfbf8;
    color: var(--muted);
    font-size: 13px;
}

.m2s-gallery .item-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.m2s-gallery .photo-card {
    position: relative;
    overflow: hidden;
    min-height: 242px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.m2s-gallery .photo-card:hover,
.m2s-gallery .photo-card:focus-visible {
    border-color: rgba(253, 197, 19, 0.7);
    outline: none;
    transform: translateY(-8px);
    box-shadow: 0 22px 46px rgba(0, 0, 0, 0.17);
}

.m2s-gallery .photo-thumb {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(253, 197, 19, 0.9), rgba(0, 0, 0, 0.72)),
        var(--accent);
}

.m2s-gallery .photo-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(17, 17, 17, 0.02), rgba(17, 17, 17, 0.4));
    opacity: 0.58;
    transition: opacity 0.25s ease;
}

.m2s-gallery .photo-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease, filter 0.35s ease;
}

.m2s-gallery .photo-thumb span {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border: 1px solid rgba(17, 17, 17, 0.16);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.76);
    color: var(--text);
    font-size: 17px;
    font-weight: 800;
}

.m2s-gallery .photo-thumb b {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: grid;
    place-items: center;
    z-index: 2;
    min-width: 54px;
    min-height: 32px;
    border-radius: 999px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    opacity: 0;
    transform: translateY(8px);
    transition: background 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
}

.m2s-gallery .photo-card:hover .photo-thumb img {
    transform: scale(1.06);
    filter: saturate(1.05) brightness(0.86);
}

.m2s-gallery .photo-card:hover .photo-thumb::after {
    opacity: 0.82;
}

.m2s-gallery .photo-card:hover .photo-thumb b {
    opacity: 1;
    transform: translateY(0);
}

.m2s-gallery .photo-info {
    min-height: 82px;
    padding: 15px 14px 18px;
}

.m2s-gallery .photo-card h3 {
    color: var(--ink);
    font-size: 15px;
    line-height: 1.35;
    font-weight: 700;
}

.m2s-gallery .empty-state {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 28px;
    background: #fbfbf8;
    color: var(--muted);
    text-align: center;
    font-weight: 600;
}

.m2s-image-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: none;
}

.m2s-image-modal.active {
    display: flex;
    pointer-events: auto;
}

.m2s-image-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(12, 16, 14, 0.78);
    backdrop-filter: blur(10px);
}

.m2s-image-modal .modal-slider {
    position: relative;
    z-index: 2;
    width: min(920px, 100%);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.m2s-image-modal .modal-close,
.m2s-image-modal .slider-btn {
    border: 0;
    cursor: pointer;
    background: #ffffff;
    color: var(--text);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

.m2s-image-modal .modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 700;
    pointer-events: auto;
}

.m2s-image-modal .slider-frame {
    overflow: hidden;
    border-radius: 10px;
}

.m2s-image-modal .slider-frame img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--soft);
}

.m2s-image-modal .slider-frame figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px 18px;
    border-top: 5px solid var(--accent);
}

.m2s-image-modal .slider-frame strong {
    font-size: 18px;
    line-height: 1.3;
}

.m2s-image-modal .slider-frame span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.m2s-image-modal .slider-btn {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    font-size: 34px;
    line-height: 1;
    transform: translateY(-50%);
    transition: background 0.2s ease, transform 0.2s ease;
}

.m2s-image-modal .slider-btn:hover,
.m2s-image-modal .modal-close:hover {
    background: var(--accent);
}

.m2s-image-modal .slider-prev {
    left: -23px;
}

.m2s-image-modal .slider-next {
    right: -23px;
}

@media (max-width: 900px) {
    .m2s-gallery .gallery-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 18px;
    }

    .m2s-gallery .gallery-header-logo {
        align-self: flex-start;
    }

    .m2s-gallery .item-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .m2s-gallery {
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding: 28px 0 46px;
    }

    .m2s-gallery .gallery-nav {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 10px !important;
        overflow: visible;
        margin-bottom: 18px;
        padding: 10px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.07);
    }

    .m2s-gallery .gallery-header h1 {
        max-width: 100%;
        white-space: nowrap;
        font-size: clamp(24px, 7vw, 36px);
        line-height: 1;
    }

    .m2s-gallery .gallery-header-logo {
        display: none;
    }

    .m2s-gallery .gallery-btn {
        display: inline-flex !important;
        align-items: flex-start !important;
        gap: 9px;
        justify-content: flex-start;
        flex: 0 0 auto !important;
        min-width: 0;
        min-height: auto;
        width: fit-content !important;
        max-width: calc(100% - 6px) !important;
        border-color: transparent;
        padding: 9px 10px;
        background: transparent;
        box-shadow: none;
        color: #000000;
        font-size: 12px !important;
        font-weight: 800;
        line-height: 1.25;
        transform: none;
        white-space: normal;
        word-break: normal;
    }

    .m2s-gallery .gallery-btn:hover {
        border-color: transparent;
        background: transparent;
        box-shadow: none;
        color: #000000;
        transform: none;
    }

    .m2s-gallery .gallery-btn.active,
    .m2s-gallery .gallery-btn.active:hover {
        border-color: transparent;
        background: var(--accent);
        box-shadow: none;
        color: #000000;
        transform: none;
    }

    .m2s-gallery .gallery-btn .btn-index {
        flex: 0 0 24px;
        width: 24px;
        height: 24px;
        background: #f0f0f0;
        color: #000000;
        font-size: 11px;
    }

    .m2s-gallery .gallery-btn.active .btn-index {
    background: #FFFFFF;
    color: var(--accent);
}

    .m2s-gallery .gallery-btn > span:last-child {
        min-width: 0;
        max-width: 92px;
        font-size: 12px !important;
        line-height: 1.25 !important;
        overflow-wrap: normal;
        word-break: normal;
    }

    .m2s-gallery .category-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .m2s-gallery .accordion-body {
        padding-left: 0;
    }

    .m2s-gallery .item-grid {
        grid-template-columns: 1fr !important;
        gap: 18px;
    }

    .m2s-gallery .photo-card {
        min-height: auto;
    }

    .m2s-image-modal {
        padding: 14px;
    }

    .m2s-image-modal .modal-close {
        top: 8px;
        right: 8px;
    }

    .m2s-image-modal .slider-btn {
        top: auto;
        bottom: 70px;
        width: 40px;
        height: 40px;
        font-size: 30px;
        transform: none;
    }

    .m2s-image-modal .slider-prev {
        left: 14px;
    }

    .m2s-image-modal .slider-next {
        right: 14px;
    }

    .m2s-image-modal .slider-frame figcaption {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }
}

@media (max-width: 768px) {
    .m2s-gallery .item-grid {
        grid-template-columns: 1fr !important;
        gap: 18px;
    }

    .m2s-gallery .photo-card {
        min-height: auto;
    }
}

@keyframes m2sAccordionOpen {
    from {
        opacity: 0;
        clip-path: inset(0 0 100% 0);
        transform: translateY(-14px) scaleY(0.965);
        filter: blur(3px);
    }

    to {
        opacity: 1;
        clip-path: inset(0 0 0 0);
        transform: translateY(0) scaleY(1);
        filter: blur(0);
    }
}

@keyframes m2sFadeRise {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.982);
        filter: blur(2px);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .m2s-gallery .category-panel[open] .accordion-body,
    .m2s-gallery .category-panel[open] .place-block,
    .m2s-gallery .category-panel[open] .photo-card {
        animation: none;
    }
}