/* ============================================================
   Helix — Gallery Styles (Modern Graphics Edition)
   Glass morphism cards, ambient glow, non-intrusive delete.
   ============================================================ */

/* --- Gallery Header --- */
.gallery-header {
    position: relative;
    padding: 80px 0 50px;
    text-align: center;
}

.gallery-header::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 200px;
    background: radial-gradient(ellipse, rgba(124, 106, 239, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.gallery-header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -1.5px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #7c6aef 0%, #a78bfa 40%, #818cf8 70%, #c084fc 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 8s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(124, 106, 239, 0.2));
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.gallery-header p {
    color: var(--color-text-muted);
    font-size: 1.05rem;
    max-width: 420px;
    margin: 0 auto;
    line-height: 1.6;
}

.gallery-count {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-text-dim);
    margin-top: 14px;
    letter-spacing: 0.5px;
}

/* --- Gallery Grid Container --- */
.gallery-grid {
    padding-bottom: 80px;
}

/* --- Gallery Sections --- */
.gallery-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: rgba(18, 18, 26, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 4px;
    width: fit-content;
}

.gallery-tab {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-dim);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms ease;
    letter-spacing: -0.3px;
}

.gallery-tab span {
    font-weight: 400;
    color: var(--color-text-dim);
    font-size: 0.8rem;
    margin-left: 4px;
}

.gallery-tab:hover {
    color: var(--color-text-muted);
    background: rgba(255, 255, 255, 0.04);
}

.gallery-tab.active {
    background: rgba(124, 106, 239, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(124, 106, 239, 0.2);
}

.gallery-tab.active span {
    color: rgba(196, 181, 253, 0.7);
}

.gallery-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* --- Glass Morphism Gallery Item --- */
.gallery-item {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 4 / 3;
    background: rgba(18, 18, 26, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1);
}

.gallery-item::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(135deg, transparent 20%, rgba(124, 106, 239, 0.2) 45%, rgba(167, 139, 250, 0.15) 65%, transparent 80%);
    background-size: 300% 300%;
    z-index: 3;
    opacity: 0;
    transition: opacity 450ms ease;
    animation: borderShimmer 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes borderShimmer {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.gallery-item:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 40px rgba(124, 106, 239, 0.06);
    transform: translateY(-5px) scale(1.01);
}

.gallery-item:hover::before { opacity: 1; }

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 500ms cubic-bezier(0.23, 1, 0.32, 1);
}

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

/* --- Video Thumbnail (grid) --- */
.video-thumb {
    position: relative;
    width: 100%;
    height: 100%;
    background: #0f0f1a;
}

.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 500ms cubic-bezier(0.23, 1, 0.32, 1);
}

.gallery-item:hover .video-thumb img {
    transform: scale(1.05);
}

.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    fill: rgba(255, 255, 255, 0.85);
    filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.6));
    transition: transform 300ms ease, fill 200ms ease;
    z-index: 1;
}

.gallery-item:hover .play-icon {
    fill: rgba(255, 255, 255, 0.95);
    transform: translate(-50%, -50%) scale(1.15);
}

/* --- Overlay --- */
.gallery-item .overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, transparent 55%);
    opacity: 0;
    transition: opacity 350ms ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
    z-index: 2;
}

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

.overlay .image-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.overlay .image-meta {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

/* --- Non-intrusive Delete Button --- */
.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 250ms cubic-bezier(0.23, 1, 0.32, 1);
    padding: 0;
}

.delete-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.gallery-item:hover .delete-btn {
    opacity: 1;
    transform: scale(1);
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.7);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fff;
    transform: scale(1.1) !important;
}

.delete-btn:active { transform: scale(0.95) !important; }

/* --- Delete confirmation toast --- */
.delete-confirm {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(18, 18, 26, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 14px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 300ms cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 20px rgba(239, 68, 68, 0.08);
}

.delete-confirm.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.delete-confirm p { font-size: 0.9rem; color: #e4e4ef; white-space: nowrap; }
.delete-confirm-actions { display: flex; gap: 8px; }

.delete-confirm .btn-confirm-delete {
    padding: 7px 16px;
    background: rgba(239, 68, 68, 0.8);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 8px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms ease;
}

.delete-confirm .btn-confirm-delete:hover { background: #ef4444; }

.delete-confirm .btn-cancel-delete {
    padding: 7px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #9ca3af;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 200ms ease;
}

.delete-confirm .btn-cancel-delete:hover { background: rgba(255, 255, 255, 0.1); color: #e4e4ef; }

.gallery-item.removing {
    opacity: 0;
    transform: scale(0.85) translateY(10px);
    transition: all 400ms cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: none;
}

/* --- Lightbox --- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

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

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.lightbox-content img,
.lightbox-content video {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-content video {
    outline: none;
    background: #000;
}

.lightbox-info { text-align: center; }
.lightbox-info h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.lightbox-info p { font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 16px; }

.btn-download {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(18, 18, 26, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 1001;
}
.btn-download:hover {
  background: rgba(124, 106, 239, 0.5);
  border-color: rgba(124, 106, 239, 0.4);
  color: #fff;
  transform: translateY(-1px);
}
.btn-download svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(18, 18, 26, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: #e4e4ef;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.lightbox-close svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(18, 18, 26, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: #e4e4ef;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.lightbox-prev { left: -60px; }
.lightbox-next { right: -60px; }

/* --- Empty State --- */
.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 100px 20px;
    color: var(--color-text-dim);
}

.gallery-empty svg {
    width: 64px;
    height: 64px;
    stroke: var(--color-accent);
    fill: none;
    stroke-width: 1.2;
    margin-bottom: 20px;
    opacity: 0.4;
    filter: drop-shadow(0 0 20px rgba(124, 106, 239, 0.2));
}

.gallery-empty h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--color-text-muted); }
.gallery-empty p { font-size: 0.9rem; }

/* --- Noise overlay --- */
.noise-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.018;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .gallery-header { padding: 60px 0 30px; }
    .gallery-section-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
    .lightbox-close { top: 10px; right: 10px; position: fixed; }
    .delete-btn { opacity: 1; transform: scale(1); }
}

@media (max-width: 480px) {
    .gallery-section-grid { grid-template-columns: 1fr; }
}

/* --- iOS / Mobile --- */
@supports (padding: env(safe-area-inset-top)) {
    .lightbox-close { top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); }
    .lightbox-prev { left: calc(10px + env(safe-area-inset-left)); }
    .lightbox-next { right: calc(10px + env(safe-area-inset-right)); }
    .lightbox-info { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
    .btn-download { bottom: calc(24px + env(safe-area-inset-bottom)); right: calc(24px + env(safe-area-inset-right)); }
    .delete-confirm { bottom: calc(30px + env(safe-area-inset-bottom)); }
}

@media (pointer: coarse) {
    .lightbox-close { min-width: 44px; min-height: 44px; }
    .lightbox-prev, .lightbox-next { min-width: 48px; min-height: 48px; }
    .delete-btn { width: 36px; height: 36px; }
    .gallery-item:hover { transform: none; }
    .gallery-item:active { transform: scale(0.98); transition-duration: 50ms; }
}

.gallery-item, .delete-btn, .lightbox-close, .lightbox-prev, .lightbox-next { -webkit-user-select: none; user-select: none; }
.lightbox-image { touch-action: pinch-zoom; }
.lightbox-overlay { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* --- Loading Skeleton --- */
.gallery-skeleton {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.skel-item {
    aspect-ratio: 1;
    border-radius: 12px;
    background: linear-gradient(110deg, #1a1a26 30%, #222234 50%, #1a1a26 70%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
