/*
 * Electromagnetic Field Gallery 95
 * BEM naming convention throughout
 * Version: 1.0.0
 */

/* ============================================================
   CUSTOM PROPERTIES
   ============================================================ */

.emfg95-gallery {
    --emfg95-line-color:       #00d4ff;
    --emfg95-glow-core:        #ffffff;
    --emfg95-glow-outer:       #0055ff;
    --emfg95-spark-color:      #ffe566;
    --emfg95-bg:               #000814;
    --emfg95-transition:       400ms cubic-bezier(0.16, 1, 0.3, 1);
    --emfg95-dot-size:         10px;
    --emfg95-dot-gap:          8px;
    --emfg95-nav-height:       32px;
    --emfg95-caption-height:   40px;
    --emfg95-pole-size:        16px;
}

/* ============================================================
   GALLERY ROOT
   ============================================================ */

.emfg95-gallery {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.emfg95-gallery--empty {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(0, 212, 255, 0.25);
    border-radius: 4px;
    padding: 24px;
    color: rgba(0, 212, 255, 0.5);
    font-family: monospace;
    font-size: 14px;
}

/* ============================================================
   STAGE
   ============================================================ */

.emfg95-gallery__stage {
    position: relative;
    width: 100%;
    height: 500px;
    overflow: hidden;
    background-color: var(--emfg95-bg);
    cursor: crosshair;
}

.emfg95-gallery__stage--preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* ============================================================
   CANVAS LAYERS
   ============================================================ */

.emfg95-gallery__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.emfg95-gallery__canvas--overlay {
    pointer-events: none;
    z-index: 2;
}

/* ============================================================
   MAGNETIC POLES
   ============================================================ */

.emfg95-gallery__poles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

.emfg95-gallery__pole {
    position: absolute;
    width: var(--emfg95-pole-size);
    height: var(--emfg95-pole-size);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: transform 120ms ease;
    pointer-events: auto;
    cursor: grab;
}

.emfg95-gallery__pole:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.3);
}

.emfg95-gallery__pole--north {
    background: radial-gradient(circle, #ff4444 0%, #aa0000 100%);
    box-shadow:
        0 0 8px  4px rgba(255, 68, 68, 0.6),
        0 0 16px 8px rgba(255, 68, 68, 0.2);
}

.emfg95-gallery__pole--south {
    background: radial-gradient(circle, #4444ff 0%, #0000aa 100%);
    box-shadow:
        0 0 8px  4px rgba(68, 68, 255, 0.6),
        0 0 16px 8px rgba(68, 68, 255, 0.2);
}

.emfg95-gallery__pole--mouse {
    background: radial-gradient(circle, #00ffaa 0%, #006644 100%);
    box-shadow:
        0 0 8px  4px rgba(0, 255, 170, 0.6),
        0 0 16px 8px rgba(0, 255, 170, 0.2);
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
}

.emfg95-gallery__stage:hover .emfg95-gallery__pole--mouse {
    opacity: 1;
}

/* ============================================================
   CAPTION
   ============================================================ */

.emfg95-gallery__caption {
    min-height: var(--emfg95-caption-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--emfg95-line-color);
    text-shadow:
        0 0 8px  var(--emfg95-glow-core),
        0 0 16px var(--emfg95-line-color);
    transition: opacity var(--emfg95-transition);
}

.emfg95-gallery__caption--hidden {
    opacity: 0;
}

/* ============================================================
   NAVIGATION DOTS
   ============================================================ */

.emfg95-gallery__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--emfg95-dot-gap);
    height: var(--emfg95-nav-height);
}

.emfg95-gallery__nav-dot {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    padding: 0;
    width: var(--emfg95-dot-size);
    height: var(--emfg95-dot-size);
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.25);
    cursor: pointer;
    transition:
        background var(--emfg95-transition),
        transform  var(--emfg95-transition),
        box-shadow var(--emfg95-transition);
}

.emfg95-gallery__nav-dot:hover {
    background: rgba(0, 212, 255, 0.55);
    transform: scale(1.2);
}

.emfg95-gallery__nav-dot--active {
    background: var(--emfg95-line-color);
    box-shadow:
        0 0 6px  3px rgba(0, 212, 255, 0.5),
        0 0 12px 6px rgba(0, 212, 255, 0.15);
    transform: scale(1.1);
}

.emfg95-gallery__nav-dot:focus-visible {
    outline: 2px solid var(--emfg95-line-color);
    outline-offset: 3px;
}

/* ============================================================
   TOAST / BATTERY WARNING
   ============================================================ */

.emfg95-gallery__toast {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    z-index: 10;
    background: rgba(0, 8, 20, 0.9);
    border: 1px solid var(--emfg95-line-color);
    color: var(--emfg95-line-color);
    font-family: monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    padding: 8px 16px;
    border-radius: 2px;
    white-space: nowrap;
    box-shadow:
        0 0 12px rgba(0, 212, 255, 0.3),
        inset 0 0 8px rgba(0, 212, 255, 0.05);
    transition: opacity 300ms ease, transform 300ms ease;
}

.emfg95-gallery__toast--hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
    pointer-events: none;
}

/* ============================================================
   FALLBACK (no-JS / reduced motion)
   ============================================================ */

.emfg95-gallery__fallback {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.emfg95-gallery__fallback-item {
    position: relative;
}

.emfg95-gallery__fallback-item img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 2px;
}

.emfg95-gallery__fallback-item figcaption {
    padding: 8px 0;
    font-size: 13px;
    color: #aaa;
}

/* Reduced motion: hide canvas, show fallback grid */
@media (prefers-reduced-motion: reduce) {
    .emfg95-gallery[data-respect-motion="true"] .emfg95-gallery__stage,
    .emfg95-gallery[data-respect-motion="true"] .emfg95-gallery__caption,
    .emfg95-gallery[data-respect-motion="true"] .emfg95-gallery__nav {
        display: none;
    }

    .emfg95-gallery[data-respect-motion="true"] .emfg95-gallery__fallback {
        display: grid;
    }
}

/* When JS is present and reduced motion is not, hide fallback inside noscript (already hidden)
   but also ensure noscript content never shows with JS */
.emfg95-gallery__fallback {
    display: none;
}

/* ============================================================
   PREVIEW LABEL (Elementor editor only)
   ============================================================ */

.emfg95-gallery__preview-label {
    font-family: monospace;
    font-size: 15px;
    color: rgba(0, 212, 255, 0.6);
    letter-spacing: 0.06em;
    text-align: center;
    padding: 24px;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */

.emfg95-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
}

.emfg95-lightbox[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
}

.emfg95-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 4, 12, 0.92);
    backdrop-filter: blur(4px);
}

.emfg95-lightbox__inner {
    position: relative;
    z-index: 1;
    width: min(90vw, 1200px);
    height: min(85vh, 800px);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.emfg95-lightbox__canvas {
    flex: 1;
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 2px;
    box-shadow:
        0 0 40px rgba(0, 212, 255, 0.15),
        0 0 80px rgba(0, 212, 255, 0.05);
}

.emfg95-lightbox__poles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.emfg95-lightbox__controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 5;
}

.emfg95-lightbox__btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(0, 212, 255, 0.35);
    background: rgba(0, 8, 20, 0.8);
    color: var(--emfg95-line-color, #00d4ff);
    font-family: monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 6px 14px;
    border-radius: 2px;
    cursor: pointer;
    transition:
        border-color var(--emfg95-transition),
        background   var(--emfg95-transition),
        box-shadow   var(--emfg95-transition);
}

.emfg95-lightbox__btn:hover {
    border-color: var(--emfg95-line-color, #00d4ff);
    background: rgba(0, 212, 255, 0.1);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

.emfg95-lightbox__btn:focus-visible {
    outline: 2px solid var(--emfg95-line-color, #00d4ff);
    outline-offset: 2px;
}

.emfg95-lightbox__btn--close {
    font-size: 20px;
    line-height: 1;
    padding: 4px 10px;
}

.emfg95-lightbox__caption {
    font-family: monospace;
    font-size: 13px;
    color: var(--emfg95-line-color, #00d4ff);
    text-align: center;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow:
        0 0 8px  #fff,
        0 0 16px var(--emfg95-line-color, #00d4ff);
    min-height: 20px;
}

/* ============================================================
   DISCHARGE / PULSE ANIMATION (CSS only flash)
   ============================================================ */

@keyframes emfg95-discharge-flash {
    0%   { opacity: 0; }
    10%  { opacity: 0.9; }
    30%  { opacity: 0.4; }
    50%  { opacity: 0.8; }
    70%  { opacity: 0.2; }
    100% { opacity: 0; }
}

.emfg95-gallery__discharge-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    background: radial-gradient(ellipse at center,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(0, 200, 255, 0.4)   30%,
        rgba(0, 0, 80, 0)        70%
    );
    opacity: 0;
    animation: emfg95-discharge-flash 400ms ease-out forwards;
}

/* ============================================================
   SPARK PARTICLES (canvas-drawn, but CSS hint class)
   ============================================================ */

.emfg95-gallery--sparking .emfg95-gallery__canvas--overlay {
    mix-blend-mode: screen;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
    .emfg95-gallery__stage {
        height: 380px;
    }
}

@media (max-width: 767px) {
    .emfg95-gallery__stage {
        height: 260px;
        cursor: default;    /* Use touch instead */
    }

    .emfg95-lightbox__inner {
        width: 96vw;
        height: 88vh;
    }

    .emfg95-lightbox__controls {
        top: 6px;
        right: 6px;
    }

    .emfg95-lightbox__btn {
        font-size: 10px;
        padding: 5px 10px;
    }
}

/* ============================================================
   HIGH-CONTRAST / FORCED-COLOURS ACCESSIBILITY
   ============================================================ */

@media (forced-colors: active) {
    .emfg95-gallery__nav-dot {
        forced-color-adjust: none;
        border: 2px solid ButtonText;
    }

    .emfg95-gallery__nav-dot--active {
        background-color: Highlight;
        border-color: Highlight;
    }

    .emfg95-lightbox__btn {
        forced-color-adjust: none;
        border: 2px solid ButtonText;
        color: ButtonText;
        background: ButtonFace;
    }
}
