/* ==========================================================================
   macOS Window Frame, Titlebar, Window Controls & Sidebar
   ========================================================================== */

.window {
    position: absolute;
    width: 650px;
    height: 400px;
    background: var(--window-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--window-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
    overflow: hidden;
    resize: both;
    min-width: 400px;
    min-height: 250px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.hidden {
    display: none !important;
}

.window.hidden {
    display: none !important;
}

/* Maximised state lives in a class so JS never has to sniff inline styles. */
.window.is-maximized {
    /* Windows normally live inside .desktop, which starts below the menu
       bar. A maximised window must instead use the viewport as its frame. */
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    resize: none !important;
    box-shadow: none !important;
    z-index: 1100 !important;
}

/* A maximised app takes over the portfolio without a desktop inset. */
body.has-fullscreen-app .desktop,
body:has(.window.is-maximized:not(.hidden):not(.minimized)) .desktop {
    top: 0;
    padding: 0;
    z-index: 100;
}

.fullscreen-reveal-zone {
    display: none;
}

.window.is-maximized > .window-content {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
}

.window.minimized {
    transform: scale(0.05) translateY(60vh);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.42s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.32s ease-in;
}

/* ── Focus state ──────────────────────────────────────────────────────────
   macOS dims everything except the frontmost window: title text greys out,
   the traffic lights lose their colour, and the shadow flattens. */
.window:not(.is-active) {
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

.window:not(.is-active) .window-title {
    color: rgba(255, 255, 255, 0.35);
}

.window:not(.is-active) .control {
    background-color: rgba(255, 255, 255, 0.22) !important;
}

.window.is-active {
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.title-bar {
    height: 38px;
    background: var(--titlebar-bg);
    display: flex;
    align-items: center;
    padding: 0 15px;
    border-bottom: 1px solid var(--window-border);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.window-controls {
    display: flex;
    gap: 8px;
    position: absolute;
    z-index: 10;
}

.control {
    width: 12px;
    height: 12px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: default;
    position: relative;
    transition: filter 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* macOS reveals the glyphs only while the pointer is over the window. */
.control::before {
    content: '';
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    color: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.12s ease;
}

.title-bar:hover .control::before,
.window-controls:hover .control::before {
    opacity: 1;
}

.window:not(.is-active) .control::before { opacity: 0 !important; }

.control.close::before    { content: '\00d7'; font-size: 11px; }
.control.minimize::before { content: '\2212'; }
.control.maximize::before { content: '\002b'; }

.control:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.close { background-color: var(--traffic-close); }
.minimize { background-color: var(--traffic-minimize); }
.maximize { background-color: var(--traffic-maximize); }

.window-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
}

.window-content {
    display: flex;
    flex: 1;
    height: calc(100% - 38px);
}

/* Base Sidebar */
.sidebar {
    width: 160px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--window-border);
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
}

.sidebar-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 5px;
    padding-left: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-item {
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ddd;
    transition: background 0.1s ease, color 0.1s ease;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-item.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 500;
}
