/* "Press Start 2P" by CodeMan38, licensed under the SIL Open Font License 1.1.
   License text published alongside the font at /fonts/PressStart2P-OFL.txt,
   https://www.maksyche.com/fonts/PressStart2P-OFL.txt
   (see also https://openfontlicense.org). */
@font-face {
    font-family: 'Press Start 2P';
    src: url('/fonts/PressStart2P.ttf') format('truetype');
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Press Start 2P', monospace;
    background: #0d0f0b;
    min-height: 100vh;
    overflow: hidden;
    margin: 0;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#xp-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    background: linear-gradient(to bottom, #4a4e38 0%, #252820 100%);
    overflow: hidden;
}

#desktop {
    width: 100%;
    height: calc(100% - 64px);
    position: relative;
    padding: 10px;
}

#desktop-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
}

.desktop-icon {
    width: 140px;
    text-align: center;
    position: absolute;
    cursor: pointer;
    user-select: none;
    padding: 10px;
    overflow: visible;
    display: block;
    text-decoration: none;
    color: inherit;
}

/* Static positions (no inline styles, so they apply without JS too). JS dragging overrides via the CSSOM. */
.desktop-icon[data-icon="youtube"]   { left: 40px; top: 40px; }
.desktop-icon[data-icon="github"]    { left: 40px; top: 180px; }
.desktop-icon[data-icon="hackerone"] { left: 40px; top: 320px; }
.desktop-icon[data-icon="bugcrowd"]  { left: 40px; top: 460px; }
.desktop-icon[data-icon="trash"]     { right: 40px; bottom: 40px; }

.desktop-icon:hover {
    background: rgba(138, 144, 117, 0.3);
    border: 2px dotted #b8bfa0;
    padding: 8px;
}

.desktop-icon.selected {
    background: rgba(138, 144, 117, 0.5);
    border: 2px dotted #b8bfa0;
    padding: 8px;
}

.icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 8px auto;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.icon-label {
    color: #b8bfa0;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 2px 2px 4px #0d0f0b;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-extlink {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-left: 6px;
    filter: drop-shadow(2px 2px 4px #0d0f0b);
}

#taskbar {
    width: 100%;
    height: 64px;
    background: #181a14;
    position: absolute;
    bottom: 0;
    border-top: 4px solid #0d0f0b;
    box-shadow: 0 -4px 0 #252820;
    display: flex;
    align-items: center;
    padding: 0 8px;
}

#start-button {
    height: 56px;
    padding: 0 16px;
    background: #4a4e38;
    border: none;
    color: #b8bfa0;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: inset -4px -4px 0 #252820, inset 4px 4px 0 #626650;
}

#start-button:hover {
    background: #626650;
}

#start-button:active {
    box-shadow: inset 4px 4px 0 #252820, inset -4px -4px 0 #626650;
}


#legalbs-link {
    margin-left: auto;
    color: #b8bfa0;
    font-size: 14px;
    font-weight: bold;
    text-decoration: underline;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-right: 8px;
}

#legalbs-link:hover {
    color: #d0d8b8;
}

#clock {
    color: #b8bfa0;
    font-size: 16px;
    padding: 0 16px;
    background: #0d0f0b;
    height: 56px;
    display: flex;
    align-items: center;
    font-weight: bold;
    box-shadow: inset 4px 4px 0 #000000, inset -4px -4px 0 #252820;
}

/* Hidden control for the CSS-only start-menu toggle */
#start-toggle {
    display: none;
}

#start-menu {
    display: none;
    position: absolute;
    bottom: 64px;
    left: 0;
    width: 300px;
    background: #363829;
    box-shadow: inset -4px -4px 0 #252820, inset 4px 4px 0 #4a4e38, 4px 0 0 #0d0f0b;
}

#start-toggle:checked ~ #start-menu {
    display: block;
}

.menu-header {
    background: #252820;
    color: #b8bfa0;
    padding: 30px 16px;
    font-weight: bold;
    font-size: 16px;
    border-bottom: 2px solid #b8bfa0;
    user-select: none;
}

.menu-items {
    padding: 4px 0;
}

.menu-item {
    padding: 12px 32px;
    font-size: 12px;
    cursor: pointer;
    color: #d0d8b8;
    text-decoration: none;
    display: block;
    font-weight: bold;
    user-select: none;
}

.menu-item:hover {
    background: #4a4e38;
    color: #d0d8b8;
}

.menu-separator {
    height: 2px;
    background: #252820;
    margin: 4px 8px;
}

.window {
    position: absolute;
    background: #363829;
    box-shadow: inset -4px -4px 0 #252820, inset 4px 4px 0 #4a4e38, 4px 4px 0 #0d0f0b;
    display: none;
    flex-direction: column;
    /* Default: 50% x 75% of the desktop, centered in the middle of the screen.
       Works without JS; JS dragging/resizing overrides these via the CSSOM. */
    width: 50%;
    height: 75%;
    min-width: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.window.visible {
    display: flex;
}

.window-title-bar {
    background: #252820;
    color: #b8bfa0;
    padding: 8px 12px;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.window-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.window-close {
    width: 32px;
    height: 32px;
    background: #363829;
    border: none;
    color: #d0d8b8;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: inset -3px -3px 0 #252820, inset 3px 3px 0 #4a4e38;
}

.window-close:hover {
    background: #626650;
}

.window-close:active {
    box-shadow: inset 3px 3px 0 #252820, inset -3px -3px 0 #4a4e38;
}

.window-content {
    padding: 24px;
    background: #8a9075;
    box-shadow: inset 4px 4px 0 #626650, inset -4px -4px 0 #b8bfa0;
    margin: 4px;
    font-size: 12px;
    color: #0d0f0b;
    overflow: auto;
    flex: 1;
}

.window-content a {
    color: #181a14;
    text-decoration: underline;
    font-weight: bold;
}

.window-content a:hover {
    color: #000000;
}

.window-content.terminal {
    background: #0d0f0b;
    color: #b8bfa0;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    padding: 16px;
    border: 2px inset #252820;
    user-select: text;
    /* The framed box does NOT scroll; the inner .terminal-scroll does. That keeps the padding a
       constant margin between the text and the frame the whole time you scroll (padding on a
       scroll container only shows at the very top/bottom of the range). */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.terminal-scroll {
    flex: 1;
    min-height: 0;   /* allow the flex child to shrink and scroll instead of growing the window */
    overflow: auto;
}

.window-content.terminal a {
    color: #8a9075;
    font-weight: bold;
}

.window-content.terminal a:hover {
    color: #d0d8b8;
}

.term-prompt {
    color: #626650;
    font-weight: bold;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Block cursor: toggle the inverse highlight (not opacity) so the character under it stays visible */
@keyframes blink {
    0%, 100% { background: #b8bfa0; color: #0d0f0b; }
    50%      { background: transparent; color: #b8bfa0; }
}

.terminal-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

.terminal-input {
    position: absolute;
    background: transparent;
    border: none;
    outline: none;
    color: transparent;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    caret-color: transparent;
    width: 100%;
    user-select: none;
}

.terminal-input-mirror {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    color: #b8bfa0;
    white-space: pre;
    pointer-events: none;
}

.terminal-cursor {
    background: #b8bfa0;
    color: #0d0f0b;
    animation: blink 1s step-end infinite;
}

.term-error, .term-log {
    color: #cc4444;
}

.term-command {
    color: #b8bfa0;
}

/* Headings inside terminal output (e.g. the legal note). Inherit the monospace terminal font. */
.window-content.terminal h2,
.window-content.terminal h3 {
    color: #d0d8b8;
    font-weight: bold;
    line-height: 1.3;
    margin: 0;   /* spacing before a heading comes from an explicit <br>, not margins */
}
.window-content.terminal h2 {
    font-size: 18px;
    padding-bottom: 4px;
    border-bottom: 1px solid #4a4e38;
}
.window-content.terminal h3 {
    font-size: 15px;
}

.dragging {
    cursor: grabbing !important;
}

.window-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 0%, transparent 40%, #252820 40%, #252820 60%, transparent 60%);
}

.selection-box {
    position: absolute;
    border: 2px dotted #b8bfa0;
    background: rgba(138, 144, 117, 0.2);
    pointer-events: none;
    display: none;
    z-index: 50;
}

.selection-box.active {
    display: block;
}

/* ===== Folders (incl. Trash) ===== */
.folder-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
}

/* Inside a folder, icons flow in a grid instead of being absolutely positioned */
.folder-items .desktop-icon {
    position: static;
}

/* Folder icon highlight while a dragged icon hovers over it */
.desktop-icon.drop-target {
    background: rgba(138, 144, 117, 0.5);
    border: 2px dotted #b8bfa0;
    padding: 8px;
}

/* ===== Mobile (phones) =====
   Touch can't drag/resize windows, so make them near-full-screen, and shrink the taskbar and
   desktop icons so everything fits a narrow viewport. JS reads the icon positions from these rules
   at load, so the layout applies on phones without any script changes. */
@media (max-width: 640px) {
    .window {
        width: 94%;
        height: 84%;
        min-width: 0;
    }

    #start-button { font-size: 11px; padding: 0 8px; gap: 5px; }
    #start-button svg { width: 20px; height: 20px; }
    #legalbs-link { font-size: 9px; padding: 0 6px; margin-right: 4px; }
    #clock { font-size: 11px; padding: 0 8px; }
    #start-menu { width: 84vw; }

    .desktop-icon { width: 88px; padding: 6px; }
    .icon { width: 44px; height: 44px; margin-bottom: 6px; }
    .icon-label { font-size: 10px; }
    .desktop-icon[data-icon="youtube"]   { left: 12px; top: 12px; }
    .desktop-icon[data-icon="github"]    { left: 12px; top: 108px; }
    .desktop-icon[data-icon="hackerone"] { left: 12px; top: 204px; }
    .desktop-icon[data-icon="bugcrowd"]  { left: 12px; top: 300px; }
    .desktop-icon[data-icon="trash"]     { right: 12px; bottom: 12px; }

    .window-content.terminal { font-size: 14px; }
    .window-content.terminal h2 { font-size: 16px; }
    .window-content.terminal h3 { font-size: 14px; }
}
