/* ==========================================================================
   SILICON OS 95 — os-windows.css
   Window chrome: Win95 title bar + glassmorphic body
   ========================================================================== */

/* ── Window Layer ─────────────────────────────────────────────────────── */
#os-window-layer {
    position: absolute; inset: 0;
    pointer-events: none; /* children restore their own */
    z-index: 100;
}

/* ── Base Window ──────────────────────────────────────────────────────── */
.os-window {
    position: absolute;
    min-width: 320px; min-height: 200px;
    display: flex; flex-direction: column;
    pointer-events: all;
    border-radius: 0;
    overflow: hidden;

    /* Glass body background (also applies to whole frame before titlebar) */
    background: var(--os-glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    /* Win95 outer bevel */
    border-top:   2px solid rgba(255,255,255,0.28);
    border-left:  2px solid rgba(255,255,255,0.28);
    border-right: 2px solid rgba(0,0,0,0.55);
    border-bottom:2px solid rgba(0,0,0,0.55);

    box-shadow:
        0 20px 60px rgba(0,0,0,0.75),
        0 0 0 1px rgba(255,255,255,0.04);

    transition: box-shadow 0.2s ease;
    will-change: transform;
}

/* Active (focused) window gets neon border glow */
.os-window.os-window--active {
    box-shadow:
        0 24px 80px rgba(0,0,0,0.85),
        0 0 0 1px rgba(0,188,212,0.25),
        0 0 30px rgba(0,188,212,0.08);
}
.os-window.os-window--active[data-color="purple"] {
    box-shadow: 0 24px 80px rgba(0,0,0,0.85), 0 0 0 1px rgba(157,0,255,0.3), 0 0 30px rgba(157,0,255,0.1);
}
.os-window.os-window--active[data-color="magenta"] {
    box-shadow: 0 24px 80px rgba(0,0,0,0.85), 0 0 0 1px rgba(255,0,127,0.3), 0 0 30px rgba(255,0,127,0.1);
}

/* ── Title Bar — Win95 bevel + neon gradient ─────────────────────────── */
.os-window__titlebar {
    display: flex; align-items: center; justify-content: space-between;
    height: 28px; padding: 0 4px 0 6px;
    flex-shrink: 0;
    cursor: move;
    /* Active gradient — purple-to-cyan like MFE brand */
    background: var(--os-titlebar-active);
    /* Win95 inner bevel on title bar bottom */
    border-bottom: 2px solid rgba(0,0,0,0.4);
    user-select: none;
}

/* Inactive windows get muted titlebar */
.os-window:not(.os-window--active) .os-window__titlebar {
    background: var(--os-titlebar-bg);
    opacity: 0.75;
}

/* Color-coded title bars */
.os-window[data-color="purple"] .os-window__titlebar {
    background: linear-gradient(90deg, #6b00cc 0%, #3d00b8 50%, #1a006b 100%);
}
.os-window[data-color="magenta"] .os-window__titlebar {
    background: linear-gradient(90deg, #cc0055 0%, #8b003a 50%, #5a001f 100%);
}
.os-window[data-color="cyan"] .os-window__titlebar {
    background: linear-gradient(90deg, #006b80 0%, #003d4d 50%, #001a24 100%);
}

.os-window__titlebar-left {
    display: flex; align-items: center; gap: 5px;
    overflow: hidden; flex: 1; min-width: 0;
}

.os-window__icon { font-size: 0.85rem; flex-shrink: 0; }

.os-window__title {
    font-family: var(--os-font-system);
    font-size: 0.65rem; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Win95 Window Control Buttons ─────────────────────────────────────── */
.os-window__controls {
    display: flex; gap: 2px; flex-shrink: 0;
}

.os-window__btn {
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: bold; line-height: 1;
    cursor: pointer;
    border-radius: 0;
    transition: none;
    color: #000;

    /* Win95 beveled button */
    background: #c0c0c0;
    border-top:   1.5px solid #ffffff;
    border-left:  1.5px solid #ffffff;
    border-right: 1.5px solid #404040;
    border-bottom:1.5px solid #404040;
}
.os-window__btn:hover {
    background: #d0d0d0;
}
.os-window__btn:active {
    border-top-color:    #404040;
    border-left-color:   #404040;
    border-right-color:  #ffffff;
    border-bottom-color: #ffffff;
}

.os-window__btn--close:hover { background: var(--os-magenta); color: #fff; }
.os-window__btn--max:hover   { background: var(--os-cyan); }
.os-window__btn--min:hover   { background: var(--os-purple); color: #fff; }

/* ── Window Body ──────────────────────────────────────────────────────── */
.os-window__body {
    flex: 1;
    position: relative;
    overflow: hidden;       /* clips loading overlay only — iframe scrolls internally */
    background: var(--os-glass-bg);
    color: var(--os-text-muted);
}

/* Loading state */
.os-window__loading {
    position: absolute; inset: 0; z-index: 10;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    background: var(--os-glass-bg);
    color: var(--os-text-muted);
    font-family: var(--os-font-body);
    font-size: 0.85rem;
    transition: opacity 0.3s ease;
}
.os-window__loading.os-loaded { opacity: 0; pointer-events: none; }

/* iframe fills the window body and handles its own scrolling */
.os-window__iframe {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    border: none;
    opacity: 0;
    transition: opacity 0.3s ease 0.1s;
    /* Allow the framed page to scroll vertically */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
}
.os-window__iframe.os-iframe-ready { opacity: 1; }

/* ── Resize Handle ────────────────────────────────────────────────────── */
.os-window__resize-handle {
    position: absolute;
    bottom: 0; right: 0;
    width: 16px; height: 16px;
    cursor: se-resize;
    z-index: 10;
    /* Win95-style resize grip dots */
    background-image:
        radial-gradient(circle, rgba(255,255,255,0.3) 1px, transparent 1px);
    background-size: 4px 4px;
    background-position: 0 0;
    opacity: 0.5;
}
.os-window:hover .os-window__resize-handle { opacity: 1; }

/* ── Window Animations ────────────────────────────────────────────────── */
@keyframes os-window-open {
    from { transform: scale(0.88) translateY(8px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes os-window-close {
    from { transform: scale(1); opacity: 1; }
    to   { transform: scale(0.88); opacity: 0; }
}
@keyframes os-window-minimise {
    from { transform: scale(1) translateY(0); opacity: 1; }
    to   { transform: scale(0.5) translateY(60vh); opacity: 0; }
}

.os-window--opening  { animation: os-window-open     0.22s cubic-bezier(0.165, 0.84, 0.44, 1) forwards; }
.os-window--closing  { animation: os-window-close     0.18s ease forwards; }
.os-window--minimise { animation: os-window-minimise  0.2s ease forwards; }

/* ── Maximised State ──────────────────────────────────────────────────── */
.os-window--maximised {
    top: 0 !important; left: 0 !important;
    width: 100vw !important; height: calc(100vh - var(--os-taskbar-h)) !important;
    border-radius: 0;
    border-left: none; border-right: none; border-top: none;
}
