/* ═════════════════════════════════════════════════════════
   News Gallery – Frontend Styles
   Mobile-first, responsive, professional news design
═════════════════════════════════════════════════════════ */

:root {
    /* Color palette - news-neutral */
    --ng-text:              #1a1a1a;
    --ng-text-light:        #666;
    --ng-border:            #ddd;
    --ng-overlay-bg:        rgba(0,0,0,0.75);
    --ng-overlay-text:      #fff;
    --ng-hover-overlay:     rgba(0,0,0,0.85);
    --ng-button-bg:         rgba(0,0,0,0.6);
    --ng-button-bg-hover:   rgba(0,0,0,0.8);
    --ng-transition:        0.3s ease;
    --ng-border-radius:     4px;
}

/* ─────────────────────────────────────────────────────
   Container
───────────────────────────────────────────────────────── */
.wp-block-news-gallery {
    width: 100%;
}

.ng-gallery {
    margin: 1.5em 0;
    --ng-cols-mobile: 1;
    --ng-cols-tablet: 2;
    --ng-cols-desktop: 3;
    --ng-spacing: 16px;
    --ng-fit: cover;
}

.ng-empty {
    padding: 2em;
    text-align: center;
    background: #f5f5f5;
    border-radius: var(--ng-border-radius);
    color: var(--ng-text-light);
    font-size: 14px;
}

/* ─────────────────────────────────────────────────────
   Layout: GRID (mobile-first default)
───────────────────────────────────────────────────────── */
.ng-layout--grid {
    display: grid;
    grid-template-columns: repeat( var(--ng-cols-mobile), 1fr );
    gap: var(--ng-spacing);
    width: 100%;
}

/* Tablet breakpoint */
@media (min-width: 600px) {
    .ng-layout--grid {
        grid-template-columns: repeat( var(--ng-cols-tablet), 1fr );
    }
}

/* Desktop breakpoint */
@media (min-width: 1024px) {
    .ng-layout--grid {
        grid-template-columns: repeat( var(--ng-cols-desktop), 1fr );
    }
}

/* ─────────────────────────────────────────────────────
   Layout: LIST (full width, stacked)
───────────────────────────────────────────────────────── */
.ng-layout--list {
    display: flex;
    flex-direction: column;
    gap: var(--ng-spacing);
}

.ng-layout--list .ng-figure {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 600px) {
    .ng-layout--list .ng-figure {
        grid-template-columns: 300px 1fr;
        align-items: start;
        gap: 20px;
    }

    .ng-layout--list .ng-image-wrapper {
        max-height: 220px;
    }

    .ng-layout--list .ng-caption {
        grid-column: 2;
    }
}

/* ─────────────────────────────────────────────────────
   Layout: SLIDER (carousel - horizontal scroll)
───────────────────────────────────────────────────────── */
.ng-layout--slider {
    display: flex;
    gap: var(--ng-spacing);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
    /* Hide scrollbar but keep scrollability */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.ng-layout--slider::-webkit-scrollbar {
    display: none;
}

.ng-layout--slider .ng-figure {
    flex: 0 0 min(100%, 400px);
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

@media (min-width: 600px) {
    .ng-layout--slider .ng-figure {
        flex: 0 0 min(calc(50% - var(--ng-spacing) / 2), 500px);
    }
}

@media (min-width: 1024px) {
    .ng-layout--slider .ng-figure {
        flex: 0 0 min(calc(33.333% - var(--ng-spacing) / 3), 550px);
    }
}

/* ─────────────────────────────────────────────────────
   Figure & Image Wrapper
───────────────────────────────────────────────────────── */
.ng-figure {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ng-image-wrapper {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    aspect-ratio: 4 / 3;
    border-radius: var(--ng-border-radius);
    line-height: 0; /* Remove baseline spacing */
}

.ng-image {
    width: 100%;
    height: 100%;
    object-fit: var(--ng-fit);
    object-position: center;
    display: block;
}

/* ─────────────────────────────────────────────────────
   Caption (always visible)
───────────────────────────────────────────────────────── */
.ng-caption {
    margin: 0;
    padding: 0 4px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ng-text);
    font-weight: 500;
}

@media (max-width: 599px) {
    .ng-caption {
        font-size: 13px;
    }
}

/* ─────────────────────────────────────────────────────
   Credits Toggle Button
───────────────────────────────────────────────────────── */
.ng-creds-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ng-button-bg);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ng-transition);
    padding: 0;
    font-size: 0;
    -webkit-tap-highlight-color: transparent;
}

.ng-creds-toggle:hover,
.ng-creds-toggle:focus {
    background: var(--ng-button-bg-hover);
    border-color: rgba(255,255,255,0.6);
    outline: none;
}

.ng-creds-toggle:active {
    transform: scale(0.95);
}

.ng-creds-toggle[aria-pressed="true"] {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.8);
}

.ng-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────
   Credits Block (overlay or below)
───────────────────────────────────────────────────────── */
.ng-credits {
    display: none;
    opacity: 0;
    transition: opacity var(--ng-transition);
    pointer-events: none;
}

/* State: visible */
.ng-image-wrapper.ng-credits-visible .ng-credits {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

/* Position: Overlay */
.ng-creds-pos--overlay .ng-credits {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--ng-overlay-bg);
    backdrop-filter: blur(4px);
    padding: 12px;
    flex-direction: column;
    gap: 6px;
    border-radius: 0 0 var(--ng-border-radius) var(--ng-border-radius);
}

.ng-creds-pos--overlay .ng-image-wrapper:hover .ng-credits {
    display: flex;
    opacity: 1;
}

/* Position: Below */
.ng-creds-pos--below .ng-credits {
    display: flex;
    margin-top: 6px;
    flex-direction: column;
    gap: 6px;
    padding: 0;
    background: transparent;
}

.ng-creds-pos--below .ng-image-wrapper {
    position: static;
}

.ng-creds-pos--below .ng-creds-toggle {
    position: absolute;
    bottom: -45px;
    right: 0;
}

/* ─────────────────────────────────────────────────────
   Credit Items
───────────────────────────────────────────────────────── */
.ng-credit-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--ng-overlay-text);
}

.ng-creds-pos--below .ng-credit-item {
    color: var(--ng-text-light);
    font-size: 13px;
}

.ng-credit-label {
    font-weight: 700;
    opacity: 0.8;
    min-width: 50px;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.ng-credit-value {
    opacity: 0.95;
    flex: 1;
}

.ng-creds-pos--below .ng-credit-value {
    opacity: 1;
}

/* ─────────────────────────────────────────────────────
   Source Link
───────────────────────────────────────────────────────── */
.ng-source-link {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: opacity var(--ng-transition);
}

.ng-source-link:hover {
    opacity: 0.8;
}

.ng-source-text {
    text-decoration: underline;
    opacity: 0.95;
}

/* ─────────────────────────────────────────────────────
   Accessibility & States
───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ng-creds-toggle,
    .ng-credits,
    .ng-image {
        transition: none;
    }
}

/* Focus visible for keyboard navigation */
.ng-creds-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ─────────────────────────────────────────────────────
   Editor-specific
───────────────────────────────────────────────────────── */
.block-editor-block-settings-menu__popover .components-popover__content {
    max-width: 100%;
}

/* Make sure gallery displays well in editor */
.wp-block-news-gallery.wp-block-news-gallery {
    padding: 0;
}
