/**
 * Gramps Gallery Viewer - LightGallery-style design
 * Full-screen image viewer with Swiper
 */

/* ========================================
   OVERLAY / BACKDROP
   ======================================== */
.gramps-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 99999;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gramps-viewer.active {
    display: flex;
    opacity: 1;
}

.gramps-viewer.opening {
    display: flex;
}

/* ========================================
   TOOLBAR (TOP BAR)
   ======================================== */
.gramps-viewer__toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.gramps-viewer__counter {
    color: #999;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.gramps-viewer__counter-current {
    color: #fff;
}

.gramps-viewer__actions {
    display: flex;
    gap: 5px;
}

.gramps-viewer__btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 16px;
}

.gramps-viewer__btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.gramps-viewer__btn--close {
    font-size: 20px;
}

.gramps-viewer__btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gramps-viewer__btn--autoplay.active i {
    color: #4fc3f7;
}

/* ========================================
   MAIN SWIPER (CENTER)
   ======================================== */
.gramps-viewer__main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 60px 16px 60px;
    min-height: 0;
}

.gramps-viewer__main-swiper {
    width: 100%;
    height: 100%;
}

.gramps-viewer__main-swiper .swiper-slide {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gramps-viewer__image-wrapper {
    max-width: 100%;
    max-height: calc(100% - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gramps-viewer__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 5px 40px rgba(0,0,0,0.5);
    border-radius: 2px;
    transition: transform 0.15s ease-out;
}

.gramps-viewer__meta {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 28px;
    padding: 4px 72px 10px 72px;
    min-height: 74px;
}

.gramps-viewer__meta-center {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.gramps-viewer__meta-title {
    color: rgba(255,255,255,0.94);
    font-size: 17px;
    line-height: 1.2;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.gramps-viewer__meta-description {
    margin: 6px auto 0;
    max-width: 720px;
    color: rgba(224, 217, 206, 0.86);
    font-size: 13px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: default;
}

.gramps-viewer__meta-description.is-empty {
    color: rgba(176, 168, 157, 0.72);
    font-style: italic;
}

.gramps-viewer__meta-actions {
    position: absolute;
    right: 72px;
    top: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gramps-viewer__meta-btn {
    appearance: none;
    border: 1px solid rgba(186, 168, 140, 0.48);
    background: rgba(66, 52, 40, 0.22);
    color: rgba(238, 231, 221, 0.92);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.gramps-viewer__meta-btn:hover,
.gramps-viewer__meta-btn.is-active {
    background: rgba(129, 104, 72, 0.34);
    border-color: rgba(206, 186, 156, 0.72);
    color: #fff;
}

.gramps-viewer__meta-btn.is-disabled,
.gramps-viewer__meta-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.gramps-viewer__family-panel {
    position: absolute;
    top: 50px;
    right: 0;
    bottom: 95px;
    width: min(420px, 92vw);
    padding: 16px 18px 18px 0;
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
    opacity: 0;
    transform: translateX(32px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 20;
}

.gramps-viewer__family-panel.is-open {
    pointer-events: auto;
    opacity: 1;
    transform: translateX(0);
}

.gramps-viewer__family-panel-inner {
    width: 100%;
    background: rgba(29, 24, 19, 0.76);
    border: 1px solid rgba(194, 176, 149, 0.22);
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
    backdrop-filter: blur(12px);
    border-radius: 18px 0 0 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gramps-viewer__family-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(194, 176, 149, 0.16);
}

.gramps-viewer__family-panel-header h3 {
    margin: 0;
    color: rgba(243, 236, 226, 0.95);
    font-size: 16px;
    font-weight: 500;
}

.gramps-viewer__family-panel-close {
    appearance: none;
    border: none;
    background: transparent;
    color: rgba(225, 217, 204, 0.72);
    cursor: pointer;
    font-size: 18px;
}

.gramps-viewer__family-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px 20px;
}

.gramps-viewer__family-panel-caption {
    color: rgba(214, 201, 184, 0.76);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 14px;
}

.gramps-viewer__family-loading,
.gramps-viewer__family-empty {
    color: rgba(234, 227, 217, 0.82);
    font-size: 13px;
    line-height: 1.55;
}

.gramps-viewer__family-empty.is-error {
    color: rgba(255, 194, 194, 0.9);
}

.gramps-viewer__family-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.gramps-viewer__family-entry {
    padding: 14px 14px 12px;
    border-radius: 14px;
    background: rgba(255, 248, 239, 0.05);
    border: 1px solid rgba(194, 176, 149, 0.12);
}

.gramps-viewer__family-entry.is-pending {
    border-color: rgba(214, 178, 112, 0.35);
}

.gramps-viewer__family-entry-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: rgba(232, 224, 212, 0.78);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gramps-viewer__family-entry-status {
    margin-bottom: 8px;
    color: rgba(232, 196, 132, 0.95);
    font-size: 11px;
    letter-spacing: 0.04em;
}

.gramps-viewer__family-entry-text {
    color: rgba(248, 244, 238, 0.92);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.gramps-viewer__family-form-wrap {
    margin-top: 16px;
}

.gramps-viewer__family-inline-add {
    appearance: none;
    border: 1px solid rgba(186, 168, 140, 0.38);
    background: rgba(84, 67, 52, 0.22);
    color: rgba(240, 232, 223, 0.9);
    padding: 9px 14px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}

.gramps-viewer__family-form {
    display: none;
    margin-top: 14px;
}

.gramps-viewer__family-form-wrap.is-open .gramps-viewer__family-form {
    display: block;
}

.gramps-viewer__family-form-label {
    display: block;
    margin-bottom: 8px;
    color: rgba(232, 224, 212, 0.82);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.gramps-viewer__family-form-textarea {
    width: 100%;
    min-height: 120px;
    border-radius: 14px;
    border: 1px solid rgba(186, 168, 140, 0.22);
    background: rgba(255,255,255,0.08);
    color: #f4efe7;
    padding: 14px 16px;
    resize: vertical;
}

.gramps-viewer__family-form-textarea:focus {
    outline: none;
    border-color: rgba(222, 201, 168, 0.62);
    box-shadow: 0 0 0 3px rgba(168, 130, 82, 0.18);
}

.gramps-viewer__family-form-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.gramps-viewer__family-submit {
    appearance: none;
    border: 1px solid rgba(190, 160, 119, 0.5);
    background: rgba(124, 92, 54, 0.34);
    color: #fff;
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
}

.gramps-viewer__family-form-message {
    margin-top: 10px;
    min-height: 18px;
    color: rgba(228, 221, 210, 0.8);
    font-size: 12px;
}

.gramps-viewer__family-form-message.is-success {
    color: rgba(176, 227, 174, 0.94);
}

.gramps-viewer__family-form-message.is-error {
    color: rgba(255, 194, 194, 0.94);
}

/* ========================================
   NAVIGATION ARROWS
   ======================================== */
.gramps-viewer__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    font-size: 24px;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.gramps-viewer__nav:hover {
    opacity: 1;
}

.gramps-viewer__nav--prev {
    left: 10px;
}

.gramps-viewer__nav--next {
    right: 10px;
}

.gramps-viewer__nav.swiper-button-disabled {
    opacity: 0.2;
    cursor: default;
}

/* ========================================
   THUMBNAILS (BOTTOM)
   ======================================== */
.gramps-viewer__thumbs-wrapper {
    padding: 10px 60px 15px 60px;
    background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.gramps-viewer__thumbs-swiper {
    width: 100%;
    height: 70px;
}

.gramps-viewer__thumbs-swiper .swiper-slide {
    width: 100px;
    height: 70px;
    opacity: 0.4;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    border-radius: 3px;
    border: 2px solid transparent;
}

.gramps-viewer__thumbs-swiper .swiper-slide:hover {
    opacity: 0.7;
}

.gramps-viewer__thumbs-swiper .swiper-slide-thumb-active {
    opacity: 1;
    border-color: #fff;
}

.gramps-viewer__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   LOADING SPINNER
   ======================================== */
.gramps-viewer__loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: gramps-spin 0.8s linear infinite;
}

@keyframes gramps-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ========================================
   ZOOM FUNCTIONALITY
   ======================================== */
.gramps-viewer__image.zoomed {
    cursor: grab;
    /* Keep size constraints - zoom only via transform scale */
}

/* Disable transition during panning for immediate response */
.gramps-viewer__image.zoomed:active {
    cursor: grabbing;
    transition: none;
}

/* Allow zoomed image to overflow container */
.gramps-viewer__main-swiper .swiper-slide:has(.gramps-viewer__image.zoomed) {
    overflow: visible;
}

.gramps-viewer__main-swiper .swiper-slide:has(.gramps-viewer__image.zoomed) .gramps-viewer__image-wrapper {
    overflow: visible;
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */
@media (max-width: 991px) {
    .gramps-viewer__main {
        padding: 55px 45px 15px 45px;
    }

    .gramps-viewer__meta {
        padding: 0 26px 10px;
    }

    .gramps-viewer__meta-actions {
        position: static;
        flex-shrink: 0;
    }

    .gramps-viewer__thumbs-wrapper {
        padding: 10px 20px 10px 20px;
    }

    .gramps-viewer__thumbs-swiper {
        height: 60px;
    }

    .gramps-viewer__thumbs-swiper .swiper-slide {
        width: 80px;
        height: 60px;
    }

    .gramps-viewer__nav {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */
@media (max-width: 576px) {
    .gramps-viewer__toolbar {
        height: 45px;
        padding: 0 10px;
    }

    .gramps-viewer__counter {
        font-size: 12px;
    }

    .gramps-viewer__btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .gramps-viewer__main {
        padding: 50px 10px 10px 10px;
    }

    .gramps-viewer__meta {
        flex-direction: column;
        gap: 12px;
        padding: 0 12px 10px;
        min-height: 0;
    }

    .gramps-viewer__meta-center {
        order: 1;
    }

    .gramps-viewer__meta-title {
        font-size: 15px;
    }

    .gramps-viewer__meta-description {
        font-size: 12px;
    }

    .gramps-viewer__meta-actions {
        position: static;
        order: 2;
        justify-content: center;
        flex-wrap: wrap;
    }

    .gramps-viewer__meta-btn {
        padding: 8px 12px;
        font-size: 11px;
    }

    .gramps-viewer__nav {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    .gramps-viewer__nav--prev {
        left: 5px;
    }

    .gramps-viewer__nav--next {
        right: 5px;
    }

    .gramps-viewer__thumbs-wrapper {
        padding: 8px 10px;
    }

    .gramps-viewer__thumbs-swiper {
        height: 50px;
    }

    .gramps-viewer__thumbs-swiper .swiper-slide {
        width: 65px;
        height: 50px;
    }

    .gramps-viewer__family-panel {
        top: 45px;
        bottom: 78px;
        width: 100%;
        padding: 10px 0 0;
    }

    .gramps-viewer__family-panel-inner {
        border-radius: 16px 16px 0 0;
    }
}

/* ========================================
   FULLSCREEN MODE
   ======================================== */
.gramps-viewer.fullscreen {
    background: #000;
}

/* ========================================
   BODY LOCK (prevent scroll when viewer open)
   ======================================== */
body.gramps-viewer-open {
    overflow: hidden;
}

/* ========================================
   KEYBOARD FOCUS STATES
   ======================================== */
.gramps-viewer__btn:focus,
.gramps-viewer__nav:focus {
    outline: 2px solid rgba(255,255,255,0.5);
    outline-offset: 2px;
}

/* ========================================
   ANIMATIONS
   ======================================== */
.gramps-viewer__image {
    animation: gramps-fadeIn 0.3s ease;
}

@keyframes gramps-fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ========================================
   ZOOM FROM THUMBNAIL ANIMATION
   ======================================== */
.gramps-viewer__zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 100000;
    transition: background 0.4s ease;
}

.gramps-viewer__zoom-overlay.active {
    background: rgba(0, 0, 0, 1);
}

.gramps-viewer__zoom-image {
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

/* Disable all animations when using zoom transition */
.gramps-viewer.no-anim {
    transition: none;
    opacity: 1;
}

.gramps-viewer.no-anim .gramps-viewer__image {
    animation: none;
}
