/* Macintosh System 6 / Windows 3.1 Retro Window Styles */

.retro-window {
    position: fixed; /* Fixed positioning relative to viewport */
    background-color: var(--page-bg);
    transition: background-color var(--transition-theme);
    /* Pseudo-3D Bevels - "Outset" style */
    border: 2px solid;
    border-top-color: rgba(255, 255, 255, 0.5);     /* Light source top-left */
    border-left-color: rgba(255, 255, 255, 0.5);
    border-right-color: #222222;   /* Shadow bottom-right */
    border-bottom-color: #222222;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.2); /* Drop shadow for the window itself */

    width: 90%;
    max-width: 1200px;
    /* Height = viewport - nav height - bottom margin */
    height: calc(100vh - var(--nav-height, 80px) - 40px);
    min-height: 0; /* Override inherited min-height: 100% from main > section */

    /* Initial Centering */
    top: var(--nav-height, 80px);
    left: 50%;
    transform: translateX(-50%);

    display: block; /* Use block layout with absolute children */
    z-index: 200; /* Above nav (100) so windows can overlap nav when dragged */

    /* Reset section styles */
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Maximized State */
.retro-window.maximized {
    top: var(--nav-height) !important; /* Align below nav */
    left: 0 !important;
    transform: none !important;
    width: 100% !important;
    max-width: none !important;
    height: calc(100vh - var(--nav-height)) !important;
    box-shadow: none;
    border: none;
    border-top: 2px solid #fff;
}

/* Remove hover effects from original sections if they interfere */
.retro-window:hover {
    border-left-color: rgba(255, 255, 255, 0.5) !important; /* Keep bevel color */
    transform: translateX(-50%); /* Keep centered by default */
}

.retro-window.maximized:hover {
    transform: none !important;
}

.retro-window-header {
    height: 36px; /* Explicit height */
    background-color: var(--black);
    color: #fff;
    padding: 0 8px;
    display: flex;
    justify-content: space-between; /* Title left/center, buttons right */
    align-items: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
    cursor: grab;
    user-select: none;
    border: 1px solid #222222;
    border-bottom: 2px solid #222222;
    margin: 2px;
    box-sizing: border-box;
}

.retro-window-header:active {
    cursor: grabbing;
}

.win-title {
    flex-grow: 1;
    text-align: center;
    padding-left: 50px; 
    pointer-events: none;
    line-height: 36px;
}

.win-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    height: 100%;
}

.win-btn {
    width: 20px;
    height: 20px;
    border: 1px solid #000;
    background: #fff;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0 #000;
    transition: transform 0.1s, box-shadow 0.1s;
}

.win-btn:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

.win-btn:hover {
    background-color: #eee;
}

/* Maximize Icon (Square) */
.win-max::before {
    content: "";
    display: block;
    width: 10px;
    height: 10px;
    border: 2px solid #000;
    border-top-width: 4px;
}

/* Close Icon (X) */
.win-close::before {
    content: "\00D7";
    font-size: 22px;
    font-weight: bold;
    line-height: 18px;
    color: #000;
}


.retro-window-content {
    position: absolute;
    top: 40px; /* header height (36) + margins (2+2) approx */
    bottom: 4px; /* Scrollbar extends to here */
    left: 4px;
    right: 4px;
    
    padding: 20px;
    overflow-y: scroll; /* Always show scrollbar */
    font-family: var(--font-body);
    background-color: var(--page-bg);
    transition: background-color var(--transition-theme);
    border: 1px solid #222222;
    
    /* Fix for text extending beyond box */
    word-wrap: break-word;
    overflow-x: hidden;
    
    /* Scrollbar Styling */
    scrollbar-width: auto;
    scrollbar-color: #000 var(--yellow);
    
    font-size: 14px;
}

/* Scrollbar Corner - should be covered by resize handle, but useful for blending */
.retro-window-content::-webkit-scrollbar-corner {
    background-color: transparent; /* Or match window background */
}

.retro-window-content p,
.retro-window-content li,
.retro-window-content h3,
.retro-window-content h4 {
    font-size: 14px !important;
    line-height: 1.5 !important;
}

/* Overrides for inner containers */
.retro-window .questions-card-container,
.retro-window .blog-card-container,
.retro-window .projects-card-container {
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    max-width: 100% !important;
    height: auto !important; /* Ensure content height is auto */
}

/* Retro Mac Scrollbar CSS */
.retro-window-content::-webkit-scrollbar {
  width: 16px; 
  background: #ffffff;
  border-left: 1px solid #222222;
}

/* Track */
.retro-window-content::-webkit-scrollbar-track {
  background: #ffffff;
  background-image: 
    linear-gradient(45deg, #000000 25%, transparent 25%, transparent 75%, #000000 75%), 
    linear-gradient(45deg, #000000 25%, transparent 25%, transparent 75%, #000000 75%);
  background-size: 2px 2px;
  background-position: 0 0, 1px 1px;
  opacity: 1;
}

/* Thumb */
.retro-window-content::-webkit-scrollbar-thumb {
  background-color: #ffffff;
  border: 1px solid #222222;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.5), inset -1px -1px 0 #222222;
  min-height: 16px;
}

/* Buttons */
.retro-window-content::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* Resize Handle - Bottom Right Corner */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    z-index: 10;
    /* Invisible but still interactive */
    background: transparent;
}

/* Optional: subtle visual indicator (diagonal lines like classic Windows) */
.resize-handle::before {
    content: "";
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 10px;
    height: 10px;
    background:
        linear-gradient(135deg, transparent 30%, #888 30%, #888 40%, transparent 40%),
        linear-gradient(135deg, transparent 50%, #888 50%, #888 60%, transparent 60%),
        linear-gradient(135deg, transparent 70%, #888 70%, #888 80%, transparent 80%);
    opacity: 0.6;
    pointer-events: none;
}

/* Hide resize handle when maximized */
.retro-window.maximized .resize-handle {
    display: none;
}

/* Mobile: Auto-maximize windows and simplify chrome */
@media (max-width: 768px) {
    .retro-window {
        /* Force maximized appearance on mobile */
        top: var(--nav-height) !important;
        left: 0 !important;
        transform: none !important;
        width: 100% !important;
        max-width: none !important;
        height: calc(100vh - var(--nav-height)) !important;
        box-shadow: none;
        border: none;
        border-top: 2px solid #fff;
    }

    /* Hide window control buttons on mobile (keep just title and close) */
    .retro-window .win-max {
        display: none;
    }

    /* Hide resize handle on mobile */
    .retro-window .resize-handle {
        display: none;
    }

    /* Disable grab cursor on mobile since dragging is disabled */
    .retro-window-header {
        cursor: default;
    }

    .retro-window-header:active {
        cursor: default;
    }
}

/* Way of Code (VIM Editor) Window - Special Styling */
.wayofcode-content {
    padding: 0 !important;
    overflow: hidden !important;  /* Editor handles its own scrolling */
}

#wayofcode-editor {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}
