/* ================================================================
   ByteSide.io — Mobile Shell Effects (Brand-Polish)
   --------------------------------------------------------------
   Etappe 4 voidcore.os mobile aesthetic: Mini-Boot-Animation,
   Hacker-HUD, Brand-Color-Glows, CRT-Wipe, Login-Prompt-Lockscreen,
   Tmux-Style-Dock-Labels.

   Lädt NACH mobile-shell.css. Alle Regeln scoped unter `.mobile-os`.
   Reduced-motion-Fallbacks Pflicht.
   ================================================================ */

/* ================================================================
   APP-ICON BRAND-GLOW (Idle pulse)
   ================================================================ */
body.mobile-os .mobile-home__icon-tile {
    /* Glow-Color via --app-glow-color (set on parent .mobile-home__icon
       data-color). Drop-shadow respects shape (vs box-shadow). */
    filter: drop-shadow(0 0 4px var(--app-glow-color));
    animation: mob-icon-pulse 3.2s ease-in-out infinite;
    /* Stagger pulses so all 12 don't sync (organic feel). Index via
       :nth-child for deterministic offset. */
}
body.mobile-os .mobile-home__icon:nth-child(2n)  .mobile-home__icon-tile { animation-delay: 0.4s; }
body.mobile-os .mobile-home__icon:nth-child(3n)  .mobile-home__icon-tile { animation-delay: 0.9s; }
body.mobile-os .mobile-home__icon:nth-child(4n)  .mobile-home__icon-tile { animation-delay: 1.4s; }
body.mobile-os .mobile-home__icon:nth-child(5n)  .mobile-home__icon-tile { animation-delay: 1.9s; }

@keyframes mob-icon-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 3px var(--app-glow-color));
    }
    50% {
        filter: drop-shadow(0 0 12px var(--app-glow-color));
    }
}

/* Pause icon-pulse animations when an app is active (home hidden anyway).
   Saves drop-shadow-filter rendering on 12 simultaneous animations. */
body.mobile-os.app-active .mobile-home__icon-tile {
    animation-play-state: paused;
}

body.mobile-os .mobile-home__icon:active .mobile-home__icon-tile {
    filter: drop-shadow(0 0 18px var(--app-glow-color));
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    body.mobile-os .mobile-home__icon-tile {
        animation: none;
        filter: drop-shadow(0 0 4px var(--app-glow-color));
    }
}

/* ================================================================
   CRT-WIPE Transition (replaces Slide-In on app-open)
   --------------------------------------------------------------
   Klassischer TV-On-Effekt: horizontal line expandiert, brightness
   ramped down. Slide bleibt als reduced-motion-Fallback.
   ================================================================ */
/* !important required: mobile-shell.css default `.window` state has
   `animation: none !important` (defensive against desktop opening-
   animation leak). Without override here, CRT-Wipe never runs. */
@media (prefers-reduced-motion: no-preference) {
    body.mobile-os .window.mobile-active {
        animation: mob-crt-wipe-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
    }
}

@keyframes mob-crt-wipe-in {
    0% {
        clip-path: inset(45% 0 45% 0);
        opacity: 0.4;
        filter: brightness(2.2) contrast(1.4) blur(1px);
        transform: scaleY(0.4);
    }
    35% {
        clip-path: inset(40% 0 40% 0);
        opacity: 1;
        filter: brightness(1.8) contrast(1.2) blur(0.5px);
        transform: scaleY(0.6);
    }
    65% {
        clip-path: inset(20% 0 20% 0);
        opacity: 1;
        filter: brightness(1.3) contrast(1.1);
        transform: scaleY(0.95);
    }
    100% {
        clip-path: inset(0 0 0 0);
        opacity: 1;
        filter: brightness(1) contrast(1);
        transform: scaleY(1);
    }
}

/* ================================================================
   MINI-BOOT-OVERLAY (terminal launch sequence per app)
   --------------------------------------------------------------
   first-launch-per-session pro App. Gates über mobile-shell-boot.js.
   Layered ÜBER active-window (z 200 vs 100), UNTER statusbar (1500).
   ================================================================ */
.mob-boot-overlay {
    position: fixed;
    top: var(--mob-statusbar-h, 32px);
    left: 0;
    right: 0;
    bottom: var(--mob-dock-h, 60px);
    z-index: 200;
    background: var(--mob-bg, #06171E);
    color: var(--mob-text, #d8e3ec);
    font-family: var(--mob-mono, 'JetBrains Mono', monospace);
    font-size: 13px;
    line-height: 1.65;
    padding: 28px 22px;
    opacity: 0;
    transition: opacity 140ms ease;
    pointer-events: none;
    overflow: hidden;
}
.mob-boot-overlay.is-visible { opacity: 1; }
.mob-boot-overlay.is-fading { opacity: 0; transition: opacity 220ms ease; }

.mob-boot-overlay__line {
    margin: 0 0 4px;
    color: var(--mob-text-dim, #7a8b96);
    white-space: pre-wrap;
}
.mob-boot-overlay__line.is-done {
    color: var(--mob-text, #d8e3ec);
}
.mob-boot-overlay__cursor {
    display: inline-block;
    width: 7px;
    height: 13px;
    background: #ff9c4f;
    vertical-align: text-bottom;
    margin-left: 1px;
    animation: mob-cursor-blink 1s steps(2) infinite;
}
.mob-boot-overlay__line .ok { color: #95c96b; }
.mob-boot-overlay__line .arrow { color: #ff9c4f; }

@media (prefers-reduced-motion: reduce) {
    .mob-boot-overlay { transition: opacity 80ms linear; }
    .mob-boot-overlay__cursor { animation: none; opacity: 1; }
}

/* ================================================================
   HACKER-HUD STATUSBAR LAYOUT
   --------------------------------------------------------------
   Right side stretches with multiple HUD-segments. Mono Sep `│` zw
   Segmenten. Auto-skip auf < 380px viewport.
   ================================================================ */
.mobile-statusbar__right {
    gap: 6px;
    font-size: 11px;
}
.mobile-statusbar__hud-pid,
.mobile-statusbar__hud-mem,
.mobile-statusbar__hud-net,
.mobile-statusbar__hud-wifi {
    color: var(--mob-text-dim, #7a8b96);
    font-variant-numeric: tabular-nums;
}
.mobile-statusbar__hud-wifi { font-size: 13px; line-height: 1; }
.mobile-statusbar__hud-wifi.is-offline { opacity: 0.35; }
.mobile-statusbar__sep {
    color: var(--mob-border, rgba(255,255,255,0.18));
    font-weight: 300;
}

/* On narrower viewports, drop pid+mem to keep clock + app-name visible. */
@media (max-width: 379px) {
    .mobile-statusbar__hud-pid,
    .mobile-statusbar__hud-mem,
    .mobile-statusbar__sep {
        display: none;
    }
    .mobile-statusbar__hud-net { font-size: 10px; }
}
@media (max-width: 339px) {
    .mobile-statusbar__hud-net { display: none; }
    .mobile-statusbar__app-name { display: none; }
}

/* ================================================================
   TMUX-STYLE DOCK (Icon + Mono-Label)
   ================================================================ */
body.mobile-os .mobile-dock {
    border-radius: 0;
    border-top: 1px solid var(--mob-border, rgba(255,255,255,0.08));
    background: var(--mob-bg, #06171E);
    padding: 4px 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
body.mobile-os .mobile-dock__btn {
    flex-direction: column;
    gap: 2px;
    height: auto;
    padding: 6px 4px 4px;
    font-family: var(--mob-mono, 'JetBrains Mono', monospace);
}
body.mobile-os .mobile-dock__btn i {
    font-size: 18px;
    line-height: 1;
}
.mobile-dock__label {
    font-size: 10px;
    letter-spacing: 0.04em;
    line-height: 1;
}
@media (max-width: 339px) {
    .mobile-dock__label { display: none; }
    body.mobile-os .mobile-dock__btn i { font-size: 22px; }
}

/* ================================================================
   LOGIN-PROMPT LOCKSCREEN (Mobile-OS scope only)
   --------------------------------------------------------------
   Replaces standard "click anywhere to wake" with a TTY-style login
   prompt. Existing date+time bleibt, aber kompakter + monospace.
   Subtle CRT-scanlines.
   ================================================================ */
body.mobile-os .lock-screen {
    background:
        repeating-linear-gradient(
            180deg,
            transparent 0,
            transparent 2px,
            rgba(255,255,255,0.015) 2px,
            rgba(255,255,255,0.015) 3px
        ),
        radial-gradient(ellipse 60% 50% at 50% 35%, rgba(253, 125, 0, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse at center, var(--byte-ink-900, #06171E) 0%, var(--byte-ink-950, #04101a) 70%);
}
body.mobile-os .lock-screen__inner {
    font-family: var(--mob-mono, 'JetBrains Mono', monospace);
}
body.mobile-os .lock-screen__login {
    margin-bottom: 20px;
    font-size: 16px;
    color: var(--mob-text, #d8e3ec);
    letter-spacing: 0.02em;
}
body.mobile-os .lock-screen__login-arrow { color: #ff9c4f; }
body.mobile-os .lock-screen__login-cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    background: #ff9c4f;
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: mob-cursor-blink 1s steps(2) infinite;
}
@media (prefers-reduced-motion: reduce) {
    body.mobile-os .lock-screen__login-cursor { animation: none; opacity: 1; }
}

/* ================================================================
   NOTIFICATION-CENTER (Pull-Down Terminal-Log Tray)
   --------------------------------------------------------------
   Slides down from top via translateY. Layers between Statusbar
   (1500) and Power-Overlay (9500). Dark backdrop bei is-open.
   ================================================================ */
.mobile-notif-tray {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1700;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px) saturate(110%);
    -webkit-backdrop-filter: blur(6px) saturate(110%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms ease, visibility 0s linear 220ms;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}
.mobile-notif-tray.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 220ms ease, visibility 0s linear 0s;
}
.mobile-notif-tray__inner {
    background: var(--mob-bg, #06171E);
    border-bottom: 1px solid var(--mob-border, rgba(255,255,255,0.08));
    padding: calc(12px + env(safe-area-inset-top, 0)) 16px 14px;
    transform: translateY(-100%);
    transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    font-family: var(--mob-mono, monospace);
}
.mobile-notif-tray.is-open .mobile-notif-tray__inner {
    transform: translateY(0);
}
.mobile-notif-tray__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mob-border);
}
.mobile-notif-tray__title {
    color: var(--mob-text);
    font-size: 12px;
    letter-spacing: 0.04em;
}
.mobile-notif-tray__close {
    background: none;
    border: none;
    color: var(--mob-text-dim);
    font-family: inherit;
    font-size: 11px;
    padding: 4px 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.mobile-notif-tray__close:active { color: var(--mob-text); }
.mobile-notif-tray__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mobile-notif-tray__entry {
    font-size: 12px;
    line-height: 1.5;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.mobile-notif-tray__ts { color: #ff9c4f; }
.mobile-notif-tray__source { color: #95c96b; font-weight: 500; }
.mobile-notif-tray__text { color: var(--mob-text); }
.mobile-notif-tray__empty {
    padding: 24px 0;
    color: var(--mob-text-dim);
    font-size: 12px;
    text-align: center;
}
.mobile-notif-tray__hint {
    margin-top: 14px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.04);
    font-size: 10px;
    color: var(--mob-text-dim);
    text-align: center;
    letter-spacing: 0.04em;
}

@media (prefers-reduced-motion: reduce) {
    .mobile-notif-tray,
    .mobile-notif-tray__inner {
        transition: opacity 100ms linear, visibility 0s linear 0s;
    }
    .mobile-notif-tray__inner { transform: none; }
}

/* ================================================================
   APP-SWITCHER (ps aux Style Process-List)
   --------------------------------------------------------------
   Fullscreen overlay opened via [apps]-Button im Dock. Tap row
   to switch, swipe-up to kill. Process-list-style mit mono font.
   ================================================================ */
.mobile-switcher {
    position: fixed;
    inset: 0;
    z-index: 1800;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms ease, visibility 0s linear 220ms;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    padding-top: calc(24px + env(safe-area-inset-top, 0));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}
.mobile-switcher.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 220ms ease, visibility 0s linear 0s;
}
.mobile-switcher__inner {
    background: var(--mob-bg, #06171E);
    border: 1px solid var(--mob-border, rgba(255,255,255,0.12));
    border-radius: 8px;
    width: 100%;
    max-width: 480px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    font-family: var(--mob-mono, monospace);
    transform: scale(0.96) translateY(8px);
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.mobile-switcher.is-visible .mobile-switcher__inner {
    transform: scale(1) translateY(0);
}
.mobile-switcher__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--mob-border);
}
.mobile-switcher__title {
    color: var(--mob-text);
    font-size: 12px;
    letter-spacing: 0.04em;
}
.mobile-switcher__close {
    background: none;
    border: none;
    color: var(--mob-text-dim);
    font-family: inherit;
    font-size: 11px;
    padding: 4px 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.mobile-switcher__close:active { color: var(--mob-text); }
.mobile-switcher__table-head,
.mobile-switcher__row {
    display: grid;
    grid-template-columns: 56px 1fr 56px 60px;
    gap: 8px;
    padding: 8px 14px;
    align-items: center;
    font-size: 11px;
}
.mobile-switcher__table-head {
    color: var(--mob-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--mob-border);
    background: rgba(255,255,255,0.02);
}
.mobile-switcher__list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.mobile-switcher__row {
    color: var(--mob-text);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 120ms ease;
}
.mobile-switcher__row:active {
    background: rgba(255, 156, 79, 0.08);
}
.mobile-switcher__row .col-pid { color: #ff9c4f; font-variant-numeric: tabular-nums; }
.mobile-switcher__row .col-app { color: var(--mob-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-switcher__row .col-mem { color: var(--mob-text-dim); font-variant-numeric: tabular-nums; text-align: right; }
.mobile-switcher__row .col-state { color: var(--mob-text-dim); font-size: 10px; }
.mobile-switcher__row.is-active .col-state { color: #95c96b; }
.mobile-switcher__row.is-active { background: rgba(149, 201, 107, 0.06); }
.mobile-switcher__empty {
    padding: 32px 14px;
    color: var(--mob-text-dim);
    font-size: 12px;
    text-align: center;
}
.mobile-switcher__hint {
    padding: 10px 14px;
    border-top: 1px solid var(--mob-border);
    font-size: 10px;
    color: var(--mob-text-dim);
    text-align: center;
    letter-spacing: 0.04em;
}

@media (prefers-reduced-motion: reduce) {
    .mobile-switcher,
    .mobile-switcher__inner {
        transition: opacity 100ms linear, visibility 0s linear 0s;
    }
    .mobile-switcher__inner { transform: none; }
}
