/* Projects content inside the shared .main-frame from base.css.
   Fixed two-pane layout, mobile dropdown, and enlarged preview dialog. */
.projects-page {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: clamp(420px, 60vh, 560px);
    min-height: 0;
}

.projects-page > hr {
    width: 100%;
    margin: 0;
}

/* Keep the page heading accessible without duplicating the selected title. */
.projects-page > h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.projects-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 18px;
}

/* --- Sidebar --- */
.projects-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-right: 10px;
    border-right: 1px solid var(--retro-border-light);
    overflow-y: auto;
}

.project-item {
    display: block;
    padding: 5px 8px;
    border: 1px dotted transparent;
    color: #000;
    font-size: inherit;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    user-select: none;
}

.project-item:hover {
    border-color: #000;
}

.project-item.active {
    background-color: var(--retro-selection);
    /* classic 1999 selected navy blue */
    color: #FFF;
    border-color: #FFF;
}

/* --- Detail pane --- */
.project-details {
    min-width: 0;
    min-height: 0;
    padding: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* Only the content pane scrolls; changing projects cannot resize the frame. */
.project-detail {
    display: none;
    overflow-wrap: anywhere;
}

.project-detail.active {
    display: block;
}

.project-header {
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--retro-border-light);
}

.project-header h3 {
    margin: 0;
    font-size: 1.17em;
    line-height: 1.3;
}

/* Classic raised image button, pressed inward on click. */
.project-thumb-btn {
    float: right;
    display: block;
    width: 180px;
    max-width: 100%;
    margin: 0 0 8px 14px;
    padding: 2px;
    background-color: var(--retro-surface);
    border: 2px outset var(--retro-border-light);
    cursor: pointer;
    color: #000;
    text-decoration: none;
}

.project-thumb-btn:active {
    border-style: inset;
    padding: 3px 1px 1px 3px;
}

.project-thumb-btn:focus-visible {
    outline: 1px dotted #000;
    outline-offset: 2px;
}

.project-thumb-img {
    width: 100%;
    height: auto;
    aspect-ratio: 18 / 11;
    object-fit: contain;
    border: 1px solid #000;
    display: block;
    background: #000;
}

.project-thumb-pair {
    display: grid;
    gap: 2px;
}

.project-thumb-trio {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
}

.project-thumb-trio .project-thumb-img {
    aspect-ratio: 2 / 1;
}

.project-thumb-trio .project-thumb-img:first-child {
    grid-column: 1 / -1;
}

.thumb-code {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 18 / 11;
    background: #000;
    color: var(--neon-green);
    font-family: monospace;
    font-weight: bold;
    font-size: 1.6rem;
    border: 1px solid #000;
}

/* Match the shared body typography used on Experience. */
.project-desc {
    display: flow-root;
    font-size: inherit;
    line-height: inherit;
    margin: 0;
}

.project-desc p {
    margin: 0 0 0.6em;
}

.project-desc p:last-child {
    margin-bottom: 0;
}

/* Tech stack tags */
.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.main-frame .project-tags li {
    margin: 0;
    padding: 1px 6px;
    background-color: var(--retro-hover);
    border: 2px outset var(--retro-border-light);
    font-family: inherit;
    font-size: inherit;
}

/* --- Retro Win95 Modal Dialog for enlarged preview --- */
.retro-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.retro-modal.active {
    display: flex;
}

.retro-modal-window {
    background-color: var(--retro-surface);
    border: 2px outset var(--retro-border-light);
    outline: 1px solid #000;
    width: 660px;
    max-width: 92vw;
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    padding: 3px;
}

.retro-modal-titlebar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 4px 3px 8px;
    background: var(--retro-selection);
    color: #FFF;
    font-family: monospace;
    font-weight: bold;
    font-size: 0.9rem;
    user-select: none;
    gap: 8px;
}

.retro-modal-titlebar span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.modal-close-btn {
    width: 18px;
    height: 16px;
    background-color: var(--retro-surface);
    border: 2px outset var(--retro-border-light);
    color: #000;
    font-family: monospace;
    font-size: 11px;
    font-weight: bold;
    line-height: 11px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

.modal-close-btn:active {
    border-style: inset;
}

.retro-modal-body {
    min-height: 0;
    padding: 8px;
    background-color: #FFF;
    border: 2px inset var(--retro-border-light);
    margin-top: 3px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-image {
    max-width: 100%;
    max-height: min(420px, calc(100dvh - 140px));
    height: auto;
    display: block;
    border: 1px solid #000;
}

.preview-pair .retro-modal-window {
    width: 980px;
}

.preview-pair .retro-modal-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 8px;
    max-height: min(72dvh, calc(100dvh - 120px));
}

.preview-pair .modal-image {
    width: 100%;
    max-height: none;
}

.preview-trio .modal-image:last-of-type {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .preview-pair .retro-modal-body {
        grid-template-columns: minmax(0, 1fr);
    }
}

.modal-terminal {
    background-color: #000;
    color: var(--neon-green);
    font-family: monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    padding: 16px 18px;
    width: 100%;
    border: 1px solid #000;
}

.modal-terminal p {
    margin: 0 0 4px;
}

.retro-modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    padding: 6px 2px 2px;
}

.modal-ok-btn {
    padding: 3px 18px;
    background-color: var(--retro-surface);
    border: 2px outset var(--retro-border-light);
    font-family: monospace;
    font-size: 0.85rem;
    cursor: pointer;
}

.modal-ok-btn:active {
    border-style: inset;
}

/* --- Custom Win95 Mobile Dropdown --- */
.custom-win95-dropdown {
    display: none;
    position: relative;
    width: 100%;
    margin-bottom: 0;
    user-select: none;
}

.dropdown-trigger {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 36px;
    padding: 0;
    background-color: #FFF;
    border: 2px inset var(--retro-border-light);
    cursor: pointer;
    font: inherit;
    color: #000;
}

.dropdown-selected-text {
    flex: 1;
    display: block;
    padding: 7px 10px;
    font-size: inherit;
    font-weight: bold;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: left;
}

.dropdown-arrow-btn {
    width: 28px;
    background-color: var(--retro-surface);
    border-left: 2px outset var(--retro-border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #000;
}

.dropdown-trigger:active .dropdown-arrow-btn {
    border-left-style: inset;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    background-color: #FFF;
    border: 2px solid #000;
    box-shadow: 2px 2px 0 #000;
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
    padding: 2px 0;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 8px 12px;
    font-size: inherit;
    color: #000;
    cursor: pointer;
    line-height: 1.25;
}

.dropdown-item:hover,
.dropdown-item:active {
    background-color: var(--retro-selection);
    color: #FFF;
}

.dropdown-item.active {
    background-color: var(--retro-selection);
    color: #FFF;
    font-weight: bold;
}

/* Responsive Projects Layout */
@media (max-width: 768px) {
    .projects-page {
        height: clamp(420px, calc(100dvh - 20px), 640px);
        gap: 12px;
    }

    .projects-page > .lang-switcher {
        margin-bottom: 0;
    }

    .projects-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        gap: 12px;
    }

    .projects-list {
        padding: 0;
        border: none;
        background: none;
        overflow: visible;
    }

    .project-item {
        display: none;
    }

    .custom-win95-dropdown {
        display: block;
    }

    .project-thumb-btn {
        float: none;
        width: 100%;
        max-width: 360px;
        margin: 0 auto 12px;
    }

    .project-thumb-pair {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}
