/*
 * ORBITRON OS — shared responsive layer
 * Kept separate so every static module receives the same mobile behavior.
 *
 * ARCHITECTURE NOTE (important for future edits):
 *   Each HTML shell already contains a correct @media (max-width: 768px) block
 *   that handles the structural mobile layout:
 *     - .desktop-shell  → position: fixed; inset: 0
 *     - .desktop-canvas → position: absolute; inset: 0 0 taskbarHeight 0; overflow-y: auto
 *     - .statusbar      → position: fixed; bottom: 0; left: 0; right: 0
 *
 *   DO NOT override those structural rules from here — doing so breaks the layout.
 *   The structural rules below intentionally mirror the known-good OG shell.
 */

/* ─── Neural boot sequence ───────────────────────────────────────────────── */
.neural-splash {
    isolation: isolate;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 46%, rgba(8, 145, 178, 0.2), transparent 25%),
        radial-gradient(circle at 50% 50%, #06152d 0%, #020617 48%, #01030b 100%);
}

.neural-splash::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.42;
    background-image:
        linear-gradient(rgba(34, 211, 238, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(34, 211, 238, 0.08) 1px, transparent 1px);
    background-size: 42px 42px;
    -webkit-mask-image: radial-gradient(circle at center, black, transparent 72%);
    mask-image: radial-gradient(circle at center, black, transparent 72%);
    animation: neuralGrid 2.05s ease-out both;
}

.neural-splash::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(transparent 0%, rgba(103, 232, 249, 0.16) 48%, transparent 52%);
    transform: translateY(-100%);
    animation: neuralScan 1.7s 0.08s ease-out both;
}

.neural-splash-core {
    position: relative;
    width: 112px;
    height: 112px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(103, 232, 249, 0.85);
    border-radius: 999px;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.32), rgba(2, 6, 23, 0.8) 60%);
    box-shadow:
        0 0 18px rgba(34, 211, 238, 0.85),
        0 0 65px rgba(6, 182, 212, 0.5),
        inset 0 0 28px rgba(34, 211, 238, 0.38);
    animation: neuralCore 2.05s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.neural-splash-core::before,
.neural-splash-core::after {
    content: '';
    position: absolute;
    inset: -16px;
    border: 1px solid rgba(34, 211, 238, 0.42);
    border-radius: inherit;
    animation: neuralRing 2.05s ease-out both;
}

.neural-splash-core::after {
    inset: -31px;
    border-color: rgba(59, 130, 246, 0.28);
    animation-delay: 0.1s;
}

.neural-lightning {
    position: absolute;
    z-index: 2;
    width: 3px;
    height: 148px;
    opacity: 0;
    filter: drop-shadow(0 0 5px #67e8f9) drop-shadow(0 0 14px #06b6d4);
    background: linear-gradient(180deg, transparent, #e0f2fe 18%, #22d3ee 50%, #3b82f6 82%, transparent);
    clip-path: polygon(45% 0, 72% 0, 57% 38%, 100% 38%, 28% 100%, 43% 55%, 0 55%);
    transform-origin: center;
}

.neural-lightning.left {
    left: calc(50% - 82px);
    top: calc(50% - 77px);
    transform: rotate(-37deg);
    animation: lightningStrike 1.35s 0.12s ease-out both;
}

.neural-lightning.right {
    right: calc(50% - 82px);
    top: calc(50% - 77px);
    transform: rotate(37deg) scaleX(-1);
    animation: lightningStrikeRight 1.35s 0.3s ease-out both;
}

.neural-splash-shockwave {
    position: absolute;
    z-index: 1;
    width: 210px;
    height: 210px;
    border: 2px solid rgba(103, 232, 249, 0.8);
    border-radius: 999px;
    opacity: 0;
    animation: neuralShockwave 1.55s 0.38s ease-out both;
}

.neural-splash-sparks {
    position: absolute;
    z-index: 2;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: #a5f3fc;
    box-shadow:
        68px -54px 0 #22d3ee,
        -70px -42px 0 #60a5fa,
        86px 22px 0 #67e8f9,
        -82px 32px 0 #38bdf8,
        28px 82px 0 #3b82f6,
        -34px 78px 0 #22d3ee;
    animation: neuralSparks 1.55s 0.2s ease-out both;
}

.neural-splash-title {
    text-shadow: 0 0 12px rgba(34, 211, 238, 0.55), 0 0 34px rgba(37, 99, 235, 0.45);
    animation: neuralTitle 1s 0.18s ease-out both;
}

@keyframes neuralGrid {
    from { opacity: 0; transform: scale(1.08); }
    to   { opacity: 0.42; transform: scale(1); }
}
@keyframes neuralScan {
    from { transform: translateY(-100%); }
    to   { transform: translateY(200%); }
}
@keyframes neuralCore {
    0%   { opacity: 0; transform: scale(0.55); }
    60%  { opacity: 1; transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes neuralRing {
    0%   { opacity: 0; transform: scale(0.6); }
    50%  { opacity: 0.8; }
    100% { opacity: 0.42; transform: scale(1); }
}
@keyframes lightningStrike {
    0%   { opacity: 0; transform: rotate(-37deg) scaleY(0); }
    20%  { opacity: 1; }
    80%  { opacity: 0.8; transform: rotate(-37deg) scaleY(1); }
    100% { opacity: 0; }
}
@keyframes lightningStrikeRight {
    0%   { opacity: 0; transform: rotate(37deg) scaleX(-1) scaleY(0); }
    20%  { opacity: 1; }
    80%  { opacity: 0.8; transform: rotate(37deg) scaleX(-1) scaleY(1); }
    100% { opacity: 0; }
}
@keyframes neuralShockwave {
    0%   { opacity: 0.9; transform: scale(0.2); }
    100% { opacity: 0; transform: scale(2.2); }
}
@keyframes neuralSparks {
    0%   { opacity: 0; transform: scale(0); }
    30%  { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.6); }
}
@keyframes neuralTitle {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.neural-splash-status {
    animation: neuralTitle 0.8s 0.55s ease-out both;
}

/* ─── Install banner ─────────────────────────────────────────────────────── */
.install-prompt-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px 14px;
    background: rgba(4, 16, 36, 0.98);
    border-top: 1px solid rgba(103, 232, 249, 0.28);
    backdrop-filter: blur(20px);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
.install-prompt-banner.visible { transform: translateY(0); }
.install-prompt-text { flex: 1; font-size: 13px; color: #e0f2fe; line-height: 1.4; }
.install-prompt-btn { padding: 8px 16px; border-radius: 8px; border: 1px solid rgba(103, 232, 249, 0.5); background: rgba(6, 182, 212, 0.2); color: #67e8f9; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.install-prompt-dismiss { width: 28px; height: 28px; display: grid; place-items: center; border: none; background: transparent; color: rgba(103, 232, 249, 0.5); font-size: 16px; cursor: pointer; }

/* ─── Vektor-style side drawer ───────────────────────────────────────────── */
.mobile-shortcuts-drawer {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100dvh;
    z-index: 800;
    display: flex;
    flex-direction: column;
    background: rgba(4, 14, 30, 0.97);
    border-right: 1px solid rgba(103, 232, 249, 0.18);
    backdrop-filter: blur(20px);
    transition: left 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 16px 0 24px;
}
.mobile-shortcuts-drawer.open { left: 0; }

a, button { -webkit-tap-highlight-color: transparent; }

/* ─── Small-screen neural splash tweaks ─────────────────────────────────── */
@media (max-width: 480px) {
    .neural-splash-core { width: 96px; height: 96px; margin-bottom: 32px; }
    .neural-lightning { height: 130px; }
    .neural-lightning.left { left: calc(50% - 74px); }
    .neural-lightning.right { right: calc(50% - 74px); }
    .neural-splash-shockwave { width: 188px; height: 188px; }
    .neural-splash-title { font-size: clamp(1.45rem, 8vw, 1.875rem); white-space: nowrap; }
    .neural-splash-status { font-size: 8px; letter-spacing: 0.2em; }
}

@media (max-width: 380px) {
    .neural-splash-core { width: 84px; height: 84px; margin-bottom: 28px; }
    .neural-lightning { height: 110px; }
    .neural-lightning.left { left: calc(50% - 68px); }
    .neural-lightning.right { right: calc(50% - 68px); }
    .neural-splash-shockwave { width: 174px; height: 174px; }
}

/* ─── Reduced-motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Image explorer ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .image-explorer-layout { grid-template-columns: 1fr !important; }
    .image-explorer-sidebar {
        display: flex !important;
        gap: 5px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 8px !important;
        border-right: 0 !important;
        border-bottom: 1px solid var(--desktop-border) !important;
    }
    .image-explorer-sidebar h2 { display: none !important; }
    .image-category-button {
        width: auto !important;
        min-width: max-content !important;
        min-height: 36px !important;
        margin: 0 !important;
        padding: 7px 9px !important;
    }
    .image-explorer-toolbar { padding: 9px !important; }
    .image-search-box { width: 100% !important; }
    .image-explorer-search { width: 100% !important; }
    .image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        padding: 9px !important;
    }
}

@media (max-width: 380px) {
    html body .desktop-shortcuts {
        grid-template-columns: repeat(3, minmax(64px, 1fr)) !important;
    }
    .explorer-grid { grid-template-columns: 1fr !important; }
}
