/* ============================================
   DICELEXIA — Gallery Page Styles
   ============================================ */

/* --- Locked State --- */
.gallery-locked {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.gallery-lock-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 15px rgba(200, 168, 78, 0.3));
}

.gallery-locked h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.gallery-locked p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2rem;
    max-width: 400px;
}

/* --- Page Layout --- */
.gallery-page {
    min-height: 100vh;
    padding: 100px 0 60px;
    position: relative;
    z-index: 1;
}

/* --- Page Header --- */
.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.gallery-header-text h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: 2px;
    text-transform: uppercase;
    line-height: 1.1;
}

.gallery-header-text p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 0.4rem;
}

.gallery-upload-btn {
    min-height: 44px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Carousel --- */
.gallery-carousel {
    position: relative;
    width: 100%;
    height: 420px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.carousel-track {
    position: relative;
    width: 100%;
    height: 100%;
}

.carousel-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.carousel-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.carousel-slide-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1.5rem 1.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    overflow: hidden;
    max-height: 80%;
}

.carousel-slide-caption p {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.carousel-slide-caption span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.carousel-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 1rem;
    flex-direction: column;
    gap: 0.75rem;
}

.carousel-empty-icon {
    font-size: 3rem;
    opacity: 0.4;
}

/* Carousel dots */
.carousel-dots {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    z-index: 2;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background var(--transition), transform var(--transition);
    min-height: unset;
}

.carousel-dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

/* Carousel arrows */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(200, 168, 78, 0.3);
    color: var(--text-primary);
    font-size: 2rem;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), border-color var(--transition);
}

.carousel-arrow:hover {
    background: rgba(200, 168, 78, 0.2);
    border-color: var(--accent);
}

.carousel-prev { left: 0.75rem; }
.carousel-next { right: 0.75rem; }

/* --- Grid Section --- */
.gallery-grid-section {
    margin-top: 1rem;
}

.gallery-section-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* --- Photo Grid --- */
.gallery-grid {
    columns: 3;
    column-gap: 1rem;
}

.gallery-grid-item {
    break-inside: avoid;
    margin-bottom: 1rem;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.gallery-grid-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), var(--shadow-accent);
    border-color: var(--accent);
}

.gallery-grid-item img {
    width: 100%;
    display: block;
    transition: transform var(--transition);
}

.gallery-grid-item:hover img {
    transform: scale(1.04);
}

.gallery-grid-item-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 0.75rem 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    opacity: 0;
    transition: opacity var(--transition);
}

.gallery-grid-item:hover .gallery-grid-item-caption {
    opacity: 1;
}

.gallery-grid-item-caption p {
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.15rem;
}

.gallery-grid-item-caption span {
    color: var(--text-secondary);
    font-size: 0.72rem;
}

/* --- Skeleton Loading --- */
.gallery-skeleton {
    columns: 3;
    column-gap: 1rem;
}

.skeleton-card {
    break-inside: avoid;
    margin-bottom: 1rem;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-card:nth-child(1) { height: 220px; }
.skeleton-card:nth-child(2) { height: 160px; }
.skeleton-card:nth-child(3) { height: 280px; }
.skeleton-card:nth-child(4) { height: 180px; }
.skeleton-card:nth-child(5) { height: 240px; }
.skeleton-card:nth-child(6) { height: 200px; }

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* --- Empty State --- */
.gallery-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.gallery-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.gallery-empty p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

/* --- Upload Modal --- */
.gallery-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.gallery-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.gallery-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 1101;
    background: #16162a;
    border: 1px solid var(--border-accent);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
    box-shadow: var(--shadow);
}

.gallery-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.gallery-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.gallery-modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.gallery-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color var(--transition), background var(--transition);
}

.gallery-modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

/* Drop zone */
.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    margin-bottom: 1.25rem;
    overflow: hidden;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--accent);
    background: rgba(200, 168, 78, 0.05);
}

.upload-file-hidden {
    display: none;
}

.upload-dropzone-inner {
    text-align: center;
    padding: 2rem 1.5rem;
    pointer-events: none;
}

.upload-dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.6;
}

.upload-dropzone-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.upload-dropzone-subtext {
    color: var(--accent);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.upload-dropzone-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Preview */
.upload-preview {
    position: relative;
    width: 100%;
}

.upload-preview img {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    display: block;
    background: rgba(0, 0, 0, 0.3);
}

.upload-preview-clear {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.upload-preview-clear:hover {
    background: rgba(200, 168, 78, 0.3);
}

/* Caption field */
.upload-caption-group {
    margin-bottom: 1rem;
}

.upload-caption-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.upload-caption-optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.upload-caption-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color var(--transition);
    min-height: 44px;
}

.upload-caption-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.char-count {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Progress bar */
.upload-progress-wrap {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.2s ease;
}

/* Upload feedback */
.upload-feedback {
    font-size: 0.875rem;
    min-height: 1.2rem;
    margin-bottom: 0.5rem;
}

.upload-feedback.success { color: #4caf50; }
.upload-feedback.error   { color: var(--red-bright); }

/* Modal action buttons */
.gallery-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(200, 168, 78, 0.05);
}

/* --- Lightbox --- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: background var(--transition), border-color var(--transition);
}

.lightbox-close:hover {
    background: rgba(200, 168, 78, 0.2);
    border-color: var(--accent);
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(200, 168, 78, 0.3);
    color: var(--text-primary);
    font-size: 2.5rem;
    line-height: 1;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: background var(--transition), border-color var(--transition);
}

.lightbox-arrow:hover {
    background: rgba(200, 168, 78, 0.2);
    border-color: var(--accent);
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: calc(100vw - 8rem);
    max-height: 90vh;
}

.lightbox-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 6px;
    display: block;
}

.lightbox-info {
    width: 100%;
    max-width: 700px;
    padding: 1rem 0.5rem 0;
    text-align: center;
}

.lightbox-caption {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    min-height: 1.4rem;
}

.lightbox-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.lightbox-uploader,
.lightbox-date {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.lightbox-uploader::before {
    content: '👤 ';
}

.lightbox-date::before {
    content: '📅 ';
}

.lightbox-delete {
    margin-top: 0.75rem;
    background: none;
    border: 1px solid var(--red-bright);
    color: var(--red-bright);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    min-height: 36px;
    transition: background var(--transition), color var(--transition);
}

.lightbox-delete:hover {
    background: var(--red-bright);
    color: #fff;
}

/* --- Carousel Comments --- */
.carousel-comments {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.carousel-comment {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.carousel-comment-meta {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
}

.carousel-comment-text {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.carousel-more-comments {
    font-size: 0.72rem;
    color: var(--accent);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    margin-top: 0.15rem;
    text-decoration: none;
}

.carousel-more-comments:hover {
    text-decoration: underline;
}

/* --- Lightbox Comments --- */
.lightbox-comments {
    width: 100%;
    max-width: 700px;
    max-height: 260px;
    overflow-y: auto;
    margin-top: 1rem;
    padding: 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.lightbox-comments::-webkit-scrollbar {
    width: 4px;
}

.lightbox-comments::-webkit-scrollbar-track {
    background: transparent;
}

.lightbox-comments::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.lightbox-comment {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    border-left: 2px solid rgba(200, 168, 78, 0.25);
}

.lightbox-comment-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.lightbox-comment-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.45;
    word-break: break-word;
}

.lightbox-no-comments {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.75rem 0;
}

.lightbox-comment-form {
    width: 100%;
    max-width: 700px;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
    padding: 0 0.5rem;
}

.lightbox-comment-input {
    flex: 1;
    padding: 0.6rem 0.9rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.88rem;
    min-height: 44px;
    transition: border-color var(--transition);
}

.lightbox-comment-input:focus {
    outline: none;
    border-color: var(--accent);
}

.lightbox-comment-input::placeholder {
    color: var(--text-muted);
}

.lightbox-comment-submit {
    background: rgba(200, 168, 78, 0.15);
    color: var(--accent);
    border: 1px solid rgba(200, 168, 78, 0.4);
    border-radius: 6px;
    padding: 0 1.1rem;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    min-height: 44px;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition);
}

.lightbox-comment-submit:hover {
    background: rgba(200, 168, 78, 0.28);
    border-color: var(--accent);
}

.lightbox-comment-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* --- Tablet (≤ 992px) --- */
@media (max-width: 992px) {
    .gallery-carousel {
        height: 320px;
    }

    .gallery-grid,
    .gallery-skeleton {
        columns: 2;
    }
}

/* --- Mobile (≤ 768px) --- */
@media (max-width: 768px) {
    .gallery-page {
        padding-top: 80px;
    }

    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .gallery-header-text h1 {
        font-size: 1.7rem;
    }

    .gallery-upload-btn {
        width: 100%;
        justify-content: center;
    }

    .gallery-carousel {
        height: 240px;
        border-radius: 8px;
        margin-bottom: 2rem;
    }

    .carousel-slide-caption p {
        font-size: 0.9rem;
    }

    .gallery-grid,
    .gallery-skeleton {
        columns: 2;
        column-gap: 0.75rem;
    }

    .gallery-grid-item-caption {
        opacity: 1;
    }

    /* Upload modal becomes bottom-sheet on mobile */
    .gallery-modal {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translateY(100%);
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 1.5rem 1rem;
        max-height: 92vh;
    }

    .gallery-modal.active {
        transform: translateY(0);
    }

    /* Lightbox arrows on mobile */
    .lightbox-prev { left: 0.25rem; }
    .lightbox-next { right: 0.25rem; }

    .lightbox-arrow {
        width: 44px;
        height: 44px;
        font-size: 2rem;
    }

    .lightbox-content {
        max-width: calc(100vw - 5rem);
    }

    .lightbox-img {
        max-height: 60vh;
    }

    .gallery-modal-actions {
        flex-direction: column-reverse;
    }

    .gallery-modal-actions .btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .lightbox-comments {
        max-height: 180px;
        padding: 0 0.25rem;
    }

    .lightbox-comment-form {
        padding: 0 0.25rem;
        flex-wrap: wrap;
    }

    .lightbox-comment-input {
        width: 100%;
        flex: none;
    }

    .lightbox-comment-submit {
        width: 100%;
    }
}

/* --- Small mobile (≤ 480px) --- */
@media (max-width: 480px) {
    .gallery-carousel {
        height: 200px;
    }

    .gallery-grid,
    .gallery-skeleton {
        columns: 1;
    }

    .gallery-header-text h1 {
        font-size: 1.4rem;
    }

    .lightbox-content {
        max-width: 100vw;
        padding: 0 0.5rem;
    }
}
