/* =============================================
   ProWatchly - Reusable Gallery Component
   Use Case pages: Education, Healthcare, Retail, etc.
   ============================================= */

/* Optional: use page theme vars if defined, else defaults */
.usecase-gallery {
    --gallery-bg: var(--bg-dark, #0a0e1a);
    --gallery-card-bg: var(--bg-section, #0d1220);
    --gallery-card-border: var(--border-color, #1e293b);
    --gallery-accent: var(--accent-blue, #0ea5e9);
    --gallery-accent-glow: rgba(14, 165, 233, 0.35);
    --gallery-text: var(--text-primary, #f8fafc);
    --gallery-text-muted: var(--text-muted, #64748b);
    --gallery-radius: 16px;
    --gallery-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    --gallery-shadow-hover: 0 20px 48px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--gallery-card-border);
}

/* Light theme for index / main landing */
.usecase-gallery--light {
    --gallery-bg: #f0f9f6;
    --gallery-card-bg: #ffffff;
    --gallery-card-border: #e2e8f0;
    --gallery-accent: #1a936f;
    --gallery-accent-glow: rgba(26, 147, 111, 0.25);
    --gallery-text: #0f172a;
    --gallery-text-muted: #64748b;
    --gallery-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --gallery-shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px var(--gallery-card-border);
}

.usecase-gallery--light .usecase-gallery__card-media {
    background: #f1f5f9;
}

/* =============================================
   Gallery: Large auto-play video hero (second section)
   ============================================= */
.gallery-video-hero {
    margin-top: 4.5rem;
    margin-bottom: 4.5rem;
    width: 100%;
}

.gallery-video-hero__wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.gallery-video-hero__title {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    font-weight: 700;
    color: var(--gallery-text, #f8fafc);
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.gallery-video-hero__desc {
    font-size: 1.05rem;
    color: var(--gallery-text-muted, #64748b);
    margin: 0 0 1.5rem;
    max-width: 560px;
    line-height: 1.5;
}

.gallery-video-hero__player {
    position: relative;
    width: 100%;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);
    background: #0a0e1a;
}

.gallery-video-hero__video {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    min-height: min(56vw, 70vh);
}

.gallery-video-hero__caption {
    font-size: 0.875rem;
    color: var(--gallery-text-muted, #64748b);
    margin: 1rem 0 0;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .gallery-video-hero {
        margin-top: 3.5rem;
        margin-bottom: 3.5rem;
    }
    .gallery-video-hero__video {
        min-height: min(56vw, 50vh);
    }
}

.usecase-gallery {
    padding: 5rem 2rem 6rem;
    background: var(--gallery-bg);
    position: relative;
}

.usecase-gallery::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(14, 165, 233, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.usecase-gallery__inner {
    max-width: 1520px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.usecase-gallery__header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.usecase-gallery__title {
    font-size: clamp(1.9rem, 4.5vw, 2.75rem);
    font-weight: 700;
    color: var(--gallery-text);
    margin: 0 0 0.75rem;
    letter-spacing: -0.02em;
}

.usecase-gallery__subtitle {
    font-size: 1.1rem;
    color: var(--gallery-text-muted);
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.55;
}

/* Gallery subsection: contained panel for clear grouping */
.usecase-gallery__subsection {
    margin-top: 3.5rem;
    padding: 2.25rem 2rem 2.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--gallery-card-border);
    border-radius: 20px;
}

.usecase-gallery__subsection:first-of-type {
    margin-top: 0;
}

.usecase-gallery--light .usecase-gallery__subsection {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--gallery-card-border);
}

.usecase-gallery__subsection-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gallery-card-border);
}

.usecase-gallery__subsection-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gallery-text);
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.usecase-gallery__subsection-title::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 1.5rem;
    border-radius: 2px;
    background: var(--gallery-accent);
    flex-shrink: 0;
}

.usecase-gallery__subsection-desc {
    font-size: 1rem;
    color: var(--gallery-text-muted);
    margin: 0;
    line-height: 1.6;
    max-width: 720px;
}

/* Card category label — pill style */
.usecase-gallery__card-label {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gallery-accent);
    background: rgba(14, 165, 233, 0.12);
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    margin-bottom: 0.65rem;
    width: fit-content;
}

.usecase-gallery--light .usecase-gallery__card-label {
    background: rgba(26, 147, 111, 0.12);
}

/* Featured grid: single wide card */
.usecase-gallery__grid--featured {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 0;
}

/* Grid: 3 columns desktop for balanced rows, 2 tablet, 1 mobile */
.usecase-gallery__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
    align-items: stretch;
}

.usecase-gallery__grid--three {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1024px) {
    .usecase-gallery__grid,
    .usecase-gallery__grid--three {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (max-width: 560px) {
    .usecase-gallery__grid,
    .usecase-gallery__grid--three {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    .usecase-gallery__subsection {
        padding: 1.5rem 1.25rem 2rem;
    }
    .usecase-gallery__subsection-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1.25rem;
    }
}

/* Card — consistent structure, equal-height content */
.usecase-gallery__card {
    background: var(--gallery-card-bg);
    border: 1px solid var(--gallery-card-border);
    border-radius: var(--gallery-radius);
    overflow: hidden;
    box-shadow: var(--gallery-shadow);
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.35s ease, border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: relative;
}

.usecase-gallery__card:hover {
    transform: translateY(-8px);
    box-shadow: var(--gallery-shadow-hover), 0 0 40px var(--gallery-accent-glow);
    border-color: var(--gallery-accent);
}

.usecase-gallery__card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.08) 100%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.usecase-gallery__card:hover::after {
    opacity: 1;
}

.usecase-gallery__card:active {
    transform: translateY(-4px);
    transition-duration: 0.15s;
}

.usecase-gallery__card:focus-visible {
    outline: 2px solid var(--gallery-accent);
    outline-offset: 3px;
}

/* Wide featured card (e.g. ProWatchly for Campus video) */
.usecase-gallery__card--wide .usecase-gallery__card-media {
    aspect-ratio: 16 / 9;
    min-height: 320px;
}

.usecase-gallery__card--wide .usecase-gallery__card-body {
    padding: 1.5rem 1.75rem 1.75rem;
}

.usecase-gallery__card--wide .usecase-gallery__card-title {
    font-size: 1.25rem;
}

.usecase-gallery__card--wide .usecase-gallery__card-desc {
    font-size: 1rem;
}

/* Media block — fixed aspect for consistent card heights */
.usecase-gallery__card-media {
    position: relative;
    aspect-ratio: 4 / 3;
    min-height: 200px;
    background: #0f172a;
    overflow: hidden;
    flex-shrink: 0;
}

.usecase-gallery__card-media--icon {
    display: grid;
    place-items: center;
    background: radial-gradient(ellipse 80% 80% at 30% 20%, rgba(14, 165, 233, 0.22), transparent 55%),
                linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

.usecase-gallery--light .usecase-gallery__card-media--icon {
    background: radial-gradient(ellipse 80% 80% at 30% 20%, rgba(26, 147, 111, 0.18), transparent 55%),
                linear-gradient(135deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.01));
}

.usecase-gallery__card-media--icon svg {
    width: 64px;
    height: 64px;
    color: var(--gallery-accent);
    opacity: 0.95;
}

.usecase-gallery__card--static {
    cursor: default;
}

.usecase-gallery__card--static:hover {
    transform: none;
    box-shadow: var(--gallery-shadow);
    border-color: var(--gallery-card-border);
}

.usecase-gallery__card--static:hover::after {
    opacity: 0;
}

.usecase-gallery__card--static .usecase-gallery__card-cta {
    display: none;
}

.usecase-gallery__card-media img,
.usecase-gallery__card-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.usecase-gallery__card:hover .usecase-gallery__card-media img,
.usecase-gallery__card:hover .usecase-gallery__card-media video {
    transform: scale(1.04);
}

/* Lazy loading placeholder */
.usecase-gallery__card-media img[data-src],
.usecase-gallery__card-media video[data-src] {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.usecase-gallery__card-media img.loaded,
.usecase-gallery__card-media video.loaded {
    opacity: 1;
}

/* Video play overlay */
.usecase-gallery__card-media.is-video::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.usecase-gallery__card:hover .usecase-gallery__card-media.is-video::after {
    opacity: 1;
}

.usecase-gallery__card-play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--gallery-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 28px rgba(14, 165, 233, 0.5);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
    pointer-events: none;
}

.usecase-gallery__card--wide .usecase-gallery__card-play {
    width: 80px;
    height: 80px;
}

.usecase-gallery__card-play svg {
    width: 26px;
    height: 26px;
    margin-left: 5px;
}

.usecase-gallery__card--wide .usecase-gallery__card-play svg {
    width: 32px;
    height: 32px;
    margin-left: 6px;
}

.usecase-gallery__card:hover .usecase-gallery__card-play {
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 14px 36px rgba(14, 165, 233, 0.6);
}

/* Card content — equal height, clear hierarchy */
.usecase-gallery__card-body {
    padding: 1.4rem 1.4rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.usecase-gallery__card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gallery-text);
    margin: 0 0 0.5rem;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.usecase-gallery__card-desc {
    font-size: 0.9rem;
    color: var(--gallery-text-muted);
    line-height: 1.55;
    margin: 0 0 1rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.usecase-gallery__card-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.925rem;
    font-weight: 600;
    color: var(--gallery-accent);
    margin-top: auto;
    transition: gap 0.25s ease, color 0.2s ease;
}

.usecase-gallery__card:hover .usecase-gallery__card-cta {
    gap: 0.65rem;
}

.usecase-gallery__card:focus-visible .usecase-gallery__card-cta {
    color: var(--gallery-accent);
}

.usecase-gallery__card-cta svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Lightbox / Modal */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gallery-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.gallery-lightbox__content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.gallery-lightbox.is-open .gallery-lightbox__content {
    transform: scale(1);
}

.gallery-lightbox__content img,
.gallery-lightbox__content video {
    width: 100%;
    height: auto;
    max-height: 85vh;
    object-fit: contain;
    display: block;
    background: #0a0e1a;
}

.gallery-lightbox__close {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    color: #1a1d24;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.gallery-lightbox__close:hover {
    background: #fff;
    color: #1a1d24;
    transform: scale(1.05);
}

.gallery-lightbox__close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.gallery-lightbox__close svg {
    width: 24px;
    height: 24px;
}

/* Video in lightbox: show controls */
.gallery-lightbox__content video {
    max-height: 85vh;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .usecase-gallery__card,
    .usecase-gallery__card--wide,
    .usecase-gallery__card-media img,
    .usecase-gallery__card-media video,
    .usecase-gallery__card-play,
    .gallery-lightbox,
    .gallery-lightbox__content {
        transition: none;
    }
    .usecase-gallery__card:hover,
    .usecase-gallery__card:active {
        transform: none;
    }
}
