/* ═══════════════════════════════════════════════
   WINDOWS — glassmorphism, drag, controls
   ═══════════════════════════════════════════════ */
.window {
    position: absolute;
    display: none;
    /* hidden until opened */
    flex-direction: column;
    min-width: min(340px, 100vw - 20px);
    min-height: 220px;
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    overflow: hidden;
    transition: box-shadow 0.25s;
    transform: translateZ(0);
    /* Hardware acceleration */
    will-change: transform, opacity;
}

.window.open {
    display: flex;
    animation: windowOpen 0.35s var(--ease-spring) both;
}

.window.focused {
    border-color: var(--glass-border-strong);
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset,
        0 0 60px -10px var(--accent-glow);
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100vh - var(--taskbar-h)) !important;
    border-radius: 0;
}

/* Applied temporarily during maximize / restore toggle for smooth animation */
.window.animating {
    transition: top 0.35s var(--ease-out),
        left 0.35s var(--ease-out),
        width 0.35s var(--ease-out),
        height 0.35s var(--ease-out),
        border-radius 0.35s var(--ease-out);
}

/* Applied during drag for GPU-accelerated performance */
.window.dragging {
    will-change: left, top;
    transition: none !important;
}

.window.minimizing {
    animation: windowMinimize 0.3s var(--ease-out) forwards;
}

@keyframes windowOpen {
    from {
        opacity: 0;
        transform: scale(0.88) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes windowMinimize {
    to {
        opacity: 0;
        transform: scale(0.7) translateY(40px);
    }
}

@keyframes windowClose {
    to {
        opacity: 0;
        transform: scale(0.85);
    }
}

/* ─── Title Bar ─── */
.window-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 42px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: grab;
    flex-shrink: 0;
}

.window-titlebar:active {
    cursor: grabbing;
}

.window-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    pointer-events: none;
    /* so drag works even clicking on text */
}

.window-title-icon {
    font-size: 1rem;
}

/* ─── Window Control Buttons ─── */
.window-controls {
    display: flex;
    gap: 8px;
}

.win-btn {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: none;
    font-size: 0;
    /* hide text visually */
    cursor: pointer;
    transition: transform 0.15s, filter 0.15s;
    position: relative;
    /* Expand clickable area without changing visual size */
    padding: 0;
    margin: 0;
}

/* Invisible expanded hitbox */
.win-btn::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
}

.win-btn:hover {
    transform: scale(1.25);
}

.win-btn:active {
    transform: scale(0.9);
}

/* Show the symbol on hover */
.win-btn:hover::after {
    font-size: 9px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.win-btn.close {
    background: #ff5f57;
}

.win-btn.minimize {
    background: #ffbd2e;
}

.win-btn.maximize {
    background: #28c840;
}

.win-btn.close:hover::after {
    content: '×';
}

.win-btn.minimize:hover::after {
    content: '−';
}

.win-btn.maximize:hover::after {
    content: '+';
}

/* ─── Window Body ─── */
.window-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.window-body::-webkit-scrollbar {
    width: 6px;
}

.window-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}