/* ====== RESET ====== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #050505;
    --surface: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.1);
    --text: #e8e8e8;
    --text-dim: rgba(255, 255, 255, 0.35);
    --accent: #c8ff00;
    --accent-dim: rgba(200, 255, 0, 0.12);
    --accent-glow: rgba(200, 255, 0, 0.25);
    --panel-w: 240px;
    --ui-font: 'Space Mono', monospace;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    font-family: var(--ui-font);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    touch-action: none;
}

/* Noise overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    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)' opacity='0.035'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: overlay;
}

input[type=range] {
    width: 100%;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    background: transparent;
}

select {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 4px 6px;
    font-family: var(--ui-font);
    font-size: 12px;
    letter-spacing: 0.05em;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.3s;
}

select:focus {
    border-color: var(--accent);
}

/* ====== STAGE — FULL VIEWPORT ====== */
#stage {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    overflow: hidden;
    z-index: 0;
}

#content-wrapper {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

#layer-top,
#layer-bottom {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    pointer-events: none;
}

#layer-top {
    z-index: 30;
    mix-blend-mode: normal;
    opacity: 1;
    image-rendering: pixelated;
}

#layer-bottom {
    z-index: 10;
}

.gif-fragment {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    -webkit-mask-size: cover;
    mask-size: cover;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

/* ====== LOGO OVERLAY ====== */
#logo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    padding: 0 5%;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    opacity: 0;
    animation: logoReveal 2s 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#logo-overlay img {
    width: 100%;
    max-width: 600px;
    height: auto;
    filter: brightness(0);
    object-fit: contain;
}

@keyframes logoReveal {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ====== BOTTOM BAR ====== */
#bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(12px, 2vw, 24px);
    height: clamp(48px, 7vh, 64px);
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.7) 30%, rgba(0, 0, 0, 0.92) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Left: status */
#bottom-bar .bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

#status-text {
    font-size: clamp(8px, 1.1vw, 11px);
    color: var(--text-dim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: clamp(100px, 20vw, 250px);
}

.live-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.3;
        transform: scale(0.8);
    }
}

/* Center: keyword input + shuffle */
.search-container {
    display: flex;
    align-items: center;
    pointer-events: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    transition: border-color 0.3s;
    padding: 0;
}

.search-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-dim);
}

#keyword-input {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    color: #ffffff;
    border: none;
    box-sizing: border-box;
    height: auto !important;
    padding: 12px 14px 10px 14px !important;
    width: clamp(220px, 40vw, 300px);
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    line-height: 1 !important;
    vertical-align: middle;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
    outline: none;
    border-radius: 0;
}

#keyword-input::placeholder {
    color: #ffffff;
    opacity: 1;
}

#shuffle-btn {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    background: transparent;
    color: var(--accent);
    border: none;
    border-left: 1px solid var(--border);
    padding: 12px 14px 10px 14px;
    height: auto;
    font-family: var(--ui-font);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#shuffle-btn:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

#shuffle-btn:active {
    transform: scale(0.92);
}

/* Right: instagram link */
#bottom-bar .bar-right {
    display: flex;
    align-items: center;
}


.socials {
    display: flex;
    gap: clamp(8px, 1vw, 12px);
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-dim);
    padding: 6px;
    border-radius: 4px;
    transition: all 0.3s;
}

.social-link:hover {
    color: var(--text);
}

.social-link svg {
    width: clamp(16px, 1.8vw, 20px);
    height: clamp(16px, 1.8vw, 20px);
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.3s;
}

.social-link:hover svg {
    stroke: var(--accent);
}

/* ====== HAMBURGER BUTTON ====== */
#hamburger-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 300;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    transition: all 0.3s;
}

#hamburger-btn:hover {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.7);
}

#hamburger-btn span {
    display: block;
    width: 14px;
    height: 1.5px;
    background: var(--text-dim);
    border-radius: 1px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

#hamburger-btn:hover span {
    background: var(--accent);
}

/* Hamburger → X morph */
#hamburger-btn.active span:nth-child(1) {
    transform: translateY(5.5px) rotate(45deg);
}

#hamburger-btn.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

#hamburger-btn.active span:nth-child(3) {
    transform: translateY(-5.5px) rotate(-45deg);
}

/* ====== PANEL OVERLAY ====== */
#panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

#panel-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ====== CONTROL PANEL (slide from right) ====== */
#control-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(var(--panel-w), 85vw);
    height: 100%;
    background: #080808;
    border-left: 1px solid var(--border);
    z-index: 280;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 55px 10px 40px;
    overflow-y: auto;
    overflow-x: hidden;
}

#control-panel.active {
    transform: translateX(0);
}

/* Scrollbar */
#control-panel::-webkit-scrollbar {
    width: 3px;
}

#control-panel::-webkit-scrollbar-track {
    background: transparent;
}

#control-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.panel-title {
    font-size: clamp(9px, 1.1vw, 11px);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.panel-section {
    margin-bottom: 8px;
}

.section-header {
    font-size: clamp(8px, 1vw, 10px);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.panel-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

.panel-label span {
    color: var(--accent);
    font-weight: 700;
}

.layer-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-dim);
    padding: 4px 0;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.layer-toggle:hover {
    color: var(--text);
}

.layer-toggle input {
    margin-right: 12px;
    transform: scale(1.1);
    accent-color: var(--accent);
}

#reprocess-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    font-family: var(--ui-font);
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 4px;
    margin-top: 8px;
    transition: all 0.3s;
}

#reprocess-btn:hover {
    background: var(--accent);
    color: var(--bg);
}

/* Separator line in panel */
.panel-divider {
    width: 100%;
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}


/* ====== MOBILE ====== */
@media (max-width: 600px) {

    #layer-top,
    #layer-bottom,
    .gif-fragment {
        background-size: auto 100%;
        -webkit-mask-size: auto 100%;
        mask-size: auto 100%;
    }

    #bottom-bar {
        flex-wrap: wrap;
        height: auto;
        padding: 8px clamp(8px, 2vw, 16px);
        gap: 6px;
    }

    #bottom-bar .bar-left {
        order: 3;
        width: 100%;
        justify-content: center;
    }



    #bottom-bar .bar-right {
        order: 2;
    }

    #keyword-input {
        width: 100%;
        flex: 1;
    }

    #status-text {
        max-width: none;
        text-align: center;
    }


}

/* ====== TRANSITION FADE FOR VISUAL ====== */
#content-wrapper.generating {
    animation: genPulse 1.5s ease-in-out infinite;
}

@keyframes genPulse {

    0%,
    100% {
        box-shadow: 0 0 120px rgba(0, 0, 0, 0.9);
    }

    50% {
        box-shadow: 0 0 120px rgba(0, 0, 0, 0.9), 0 0 60px var(--accent-dim);
    }
}

.menu-link {
    display: block;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 12px;
    letter-spacing: 0.1em;
    transition: color 0.3s;
}

.menu-link:hover {
    color: var(--accent);
}

.tools-section {
    background: var(--accent);
    padding: 8px;
    border-radius: 6px;
    margin-top: 10px;
}

.menu-link-tools {
    display: block;
    color: #222;
    text-decoration: none;
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 6px;
    letter-spacing: 0.1em;
    transition: all 0.3s;
    padding: 4px;
    border-radius: 4px;
}

.menu-link-tools:hover {
    color: var(--text);
    background: #333;
}