/* ===================================================================== */
/* ===== MODE SYSTEM:  Desktop  /  CLI  /  GUI ======================== */
/* ===================================================================== */

/* --- top-right rail: a fixed vertical stack of controls --- */
#rail {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}
.glass-btn {
    position: relative;               /* flex item + anchor for the icon SVGs */
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}
.glass-btn:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14); }
.glass-btn:active { transform: translateY(0) scale(0.95); }
[data-theme="dark"] .glass-btn { border-color: rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.04); }
#rail .glass-btn { position: relative; top: auto; right: auto; left: auto; z-index: auto; margin: 0; }

#toGuide svg { width: 22px; height: 22px; }

/* the swap button shows the icon of the app you'll go TO (like the old version) */
#modeSwap .ms-icon {
    position: absolute;
    width: 21px;
    height: 21px;
    transition: opacity 0.2s ease, transform 0.3s ease;
}
#modeSwap .ms-to-gui { opacity: 0; transform: scale(0.6) rotate(-25deg); }
body.mode-cli #modeSwap .ms-to-cli { opacity: 0; transform: scale(0.6) rotate(25deg); }
body.mode-cli #modeSwap .ms-to-gui { opacity: 1; transform: scale(1) rotate(0); }

/* the tooltip names the app you'll switch TO */
#modeSwap .rail-tip--to-gui { display: none; }
body.mode-cli #modeSwap .rail-tip--to-cli { display: none; }
body.mode-cli #modeSwap .rail-tip--to-gui { display: block; }

/* on the plain desktop the whole rail hides (the dock has everything) */
body.mode-home #toDesktop,
body.mode-home #modeSwap,
body.mode-home #toGuide { display: none; }

/* --- hover label that pops out to the left of any rail item --- */
.rail-tip {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    padding: 0.24rem 0.6rem;
    border-radius: 7px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    font-family: 'Fira Code', monospace;
    font-size: 0.72rem;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
}
.glass-btn:hover .rail-tip,
.min-chip:hover .rail-tip { opacity: 1; transform: translateY(-50%) translateX(0); }

/* --- separator + minimized-window chips (below the buttons) --- */
.rail-sep {
    display: none;
    width: 22px;
    height: 1px;
    background: var(--text-secondary);
    opacity: 0.4;
    margin: 0.15rem 0;
}
#rail.has-min .rail-sep { display: block; }

#minDock { display: flex; flex-direction: column; align-items: center; gap: 0.65rem; }
.min-chip {
    position: relative;
    flex-shrink: 0;
    width: 52px;                     /* same as the glass buttons */
    height: 52px;
    border-radius: 50%;
    border: 1px solid rgba(39, 201, 63, 0.55);
    background: rgba(39, 201, 63, 0.14);
    color: #27c93f;
    display: grid;
    place-items: center;
    cursor: pointer;
    animation: bubbleIn 0.2s cubic-bezier(0.34, 1.2, 0.5, 1);
    transition: transform 0.15s ease, background 0.15s ease;
}
.min-chip:hover { transform: scale(1.06); background: rgba(39, 201, 63, 0.24); }
.min-chip svg { width: 21px; height: 21px; }

/* a restore chip only appears on the page its window belongs to
   (and never on the plain desktop) */
.min-chip { display: none; }
body.mode-cli .min-chip[data-mode="cli"],
body.mode-gui .min-chip[data-mode="gui"] { display: grid; }

/* --- which screen is showing --- */
body.mode-home #cli, body.mode-home #guiDesktop { display: none !important; }
body.mode-cli  #home, body.mode-cli #guiDesktop { display: none !important; }
body.mode-gui  #home, body.mode-gui #cli { display: none !important; }

body.mode-home, body.mode-cli, body.mode-gui {
    overflow: hidden;
    height: 100vh;
}

/* the "opening an app" flourish */
body.mode-home #home,
body.mode-cli #cli,
body.mode-gui #guiDesktop { animation: appIn 0.3s cubic-bezier(0.2, 0.7, 0.3, 1); }
@keyframes appIn {
    from { opacity: 0; transform: scale(0.986); }
    to   { opacity: 1; transform: scale(1); }
}
