/* ==========================================================================
   GlitchReactor – Elementor Widget  |  assets/css/glitch-reactor.css
   ========================================================================== */

/* ---- Custom Properties ---- */
.gr-widget {
    --gr-accent:   #00ff9f;
    --gr-red:      #ff003c;
    --gr-blue:     #0090ff;
    --gr-bg:       #050a0e;
    --gr-caption-bg: rgba(5, 10, 14, 0.82);
    --gr-font:     'Courier New', 'Lucida Console', monospace;
    --gr-radius:   4px;
    --gr-transition: 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: var(--gr-bg);
    border-radius: var(--gr-radius);
    font-family: var(--gr-font);
    user-select: none;
}

/* ---- Slide ---- */
.gr-slide {
    position: relative;
    width: 100%;
    display: none;
}

.gr-slide--active {
    display: block;
}

/* ---- Ratio wrapper ---- */
.gr-ratio {
    position: relative;
    width: 100%;
}

/* ---- Canvas (rendered on top of <img>) ---- */
.gr-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    will-change: transform;
    image-rendering: pixelated;
    z-index: 2;
    pointer-events: none;
}

/* ---- Hidden source image (read by canvas) ---- */
.gr-source-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0; /* hidden; canvas draws on top */
    z-index: 1;
    border-radius: inherit;
}

/* ---- Green-tint overlay (cyberpunk atmosphere) ---- */
.gr-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    mix-blend-mode: screen;
    transition: opacity var(--gr-transition);
}

/* ---- Caption ---- */
.gr-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 4;
    padding: 18px 20px 16px;
    background: var(--gr-caption-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-top: 1px solid rgba(0, 255, 159, 0.18);
    transform: translateY(100%);
    transition: transform var(--gr-transition);
    pointer-events: none;
}

.gr-slide--active:hover .gr-caption,
.gr-slide--active:focus-within .gr-caption {
    transform: translateY(0);
}

.gr-caption__title {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--gr-accent);
    margin-bottom: 4px;
    text-shadow: 0 0 8px var(--gr-accent);
}

.gr-caption__text {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 0.05em;
    line-height: 1.5;
}

/* ---- Dots navigation ---- */
.gr-dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
}

.gr-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 159, 0.5);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: background var(--gr-transition), box-shadow var(--gr-transition);
}

.gr-dot--active,
.gr-dot:hover {
    background: var(--gr-accent);
    box-shadow: 0 0 6px var(--gr-accent);
}

/* ---- Cursor when hovering active scene ---- */
.gr-slide--active {
    cursor: crosshair;
}

/* ---- "Perfect" state (flash before explosion) ---- */
.gr-widget.gr--perfect .gr-canvas {
    opacity: 0;
}
.gr-widget.gr--perfect .gr-source-img {
    opacity: 1;
    transition: opacity 0.05s linear;
}

/* ---- Glitch explosion CSS ring (cosmetic) ---- */
.gr-widget.gr--explode::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 6;
    background: radial-gradient(circle at var(--gr-cx, 50%) var(--gr-cy, 50%),
                rgba(255, 0, 60, 0.35) 0%,
                rgba(0, 255, 159, 0.18) 40%,
                transparent 70%);
    animation: gr-explosion 0.45s ease-out forwards;
    pointer-events: none;
}

@keyframes gr-explosion {
    0%   { opacity: 1; transform: scale(0.6); }
    60%  { opacity: 0.7; transform: scale(1.08); }
    100% { opacity: 0; transform: scale(1.3); }
}

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

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

.gr-lightbox.gr-lb--open {
    pointer-events: all;
    opacity: 1;
}

/* Backdrop */
.gr-lb__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 14, 0.96);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Inner container */
.gr-lb__inner {
    position: relative;
    z-index: 1;
    max-width: min(90vw, 1200px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* Full-res image */
.gr-lb__img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    border: 1px solid rgba(0, 255, 159, 0.2);
    border-radius: var(--gr-radius);
    box-shadow: 0 0 60px rgba(0, 255, 159, 0.12), 0 0 120px rgba(255, 0, 60, 0.08);
}

/* Canvas overlay for lightbox glitch */
.gr-lb__canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    image-rendering: pixelated;
}

/* Close button */
.gr-lb__close {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 2;
    background: transparent;
    border: 1px solid rgba(0, 255, 159, 0.4);
    color: var(--gr-accent, #00ff9f);
    font-family: var(--gr-font, monospace);
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, box-shadow 0.2s;
}

.gr-lb__close:hover {
    background: rgba(0, 255, 159, 0.12);
    box-shadow: 0 0 10px rgba(0, 255, 159, 0.4);
}

/* Nav arrows */
.gr-lb__nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: transparent;
    border: 1px solid rgba(0, 255, 159, 0.3);
    color: rgba(255,255,255,0.8);
    font-size: 1.4rem;
    width: 44px;
    height: 60px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.gr-lb__nav:hover {
    background: rgba(0, 255, 159, 0.1);
    border-color: var(--gr-accent, #00ff9f);
}

.gr-lb__nav--prev { left: 16px; }
.gr-lb__nav--next { right: 16px; }

/* Caption */
.gr-lb__caption {
    text-align: center;
    font-family: var(--gr-font, monospace);
    color: rgba(255,255,255,0.75);
    max-width: 700px;
    padding: 0 20px;
}

.gr-lb__caption-title {
    display: block;
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gr-accent, #00ff9f);
    margin-bottom: 6px;
    text-shadow: 0 0 8px var(--gr-accent, #00ff9f);
}

.gr-lb__caption-text {
    display: block;
    font-size: 0.8rem;
    line-height: 1.6;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.6);
}

/* ---- Entry animation for lightbox ---- */
.gr-lb--anim-glitch-in .gr-lb__inner {
    animation: gr-lb-glitch-in 0.5s cubic-bezier(0.22,1,0.36,1) forwards;
}

@keyframes gr-lb-glitch-in {
    0%   { opacity: 0; transform: scale(0.92) skewX(-4deg); filter: brightness(3) saturate(0); }
    40%  { opacity: 1; transform: scale(1.02) skewX(1deg);  filter: brightness(1.4) saturate(1.5); }
    70%  { transform: scale(0.99) skewX(-0.5deg); }
    100% { opacity: 1; transform: scale(1) skewX(0);        filter: brightness(1)   saturate(1); }
}

.gr-lb--anim-fade .gr-lb__inner {
    animation: gr-lb-fade 0.35s ease forwards;
}

@keyframes gr-lb-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.gr-lb--anim-zoom .gr-lb__inner {
    animation: gr-lb-zoom 0.35s cubic-bezier(0.22,1,0.36,1) forwards;
}

@keyframes gr-lb-zoom {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

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

@media (max-width: 768px) {
    .gr-lb__nav { display: none; } /* swipe on mobile */

    .gr-caption {
        transform: translateY(0); /* always visible on mobile */
        padding: 12px 14px 10px;
    }

    .gr-caption__title { font-size: 0.62rem; }
    .gr-caption__text  { font-size: 0.7rem; }
}

/* ========================================================================
   EDITOR PLACEHOLDER (Elementor backend)
   ======================================================================== */

.elementor-editor-active .gr-source-img {
    opacity: 1 !important;
}

.elementor-editor-active .gr-canvas {
    opacity: 0.5;
}
