/* ==========================================================================
   Wim OS — retro base
   Design tokens, resets, and the reusable bevel primitives that every other
   stylesheet builds on (.retro-panel, .retro-button, .retro-input, ...).
   ========================================================================== */

:root {
    /* Chrome */
    --win-face: #c0c0c0;
    --win-light: #ffffff;
    --win-highlight: #dfdfdf;
    --win-shadow: #808080;
    --win-dark-shadow: #000000;

    /* Title bars */
    --title-active-start: #000080;
    --title-active-end: #1084d0;
    --title-inactive-start: #808080;
    --title-inactive-end: #b5b5b5;
    --title-text: #ffffff;
    --title-text-inactive: #dfdfdf;

    /* Text */
    --text: #000000;
    --text-disabled: #808080;
    --text-disabled-light: #ffffff;

    /* Selection */
    --selection: #000080;
    --selection-text: #ffffff;

    /* Fields */
    --field-bg: #ffffff;
    --field-text: #000000;

    /* Desktop */
    --desktop-bg: #3a6ea5;
    --desktop-icon-label: #ffffff;

    /* Metrics */
    --taskbar-height: 34px;
    --titlebar-height: 22px;
    --window-border: 2px;
    --desktop-icon-width: 76px;

    /* Fonts */
    --font-ui: "MS Sans Serif", "Pixelated MS Sans Serif", Tahoma, "Segoe UI", Arial, sans-serif;
    --font-mono: "Courier New", Courier, monospace;

    --speed: 80ms;
}

/* Night theme — same chrome geometry, dimmed palette. */
[data-theme="night"] {
    --win-face: #6e6e6e;
    --win-light: #a4a4a4;
    --win-highlight: #888888;
    --win-shadow: #3a3a3a;
    --win-dark-shadow: #000000;

    --title-active-start: #10103a;
    --title-active-end: #2a4a76;
    --title-inactive-start: #4a4a4a;
    --title-inactive-end: #6a6a6a;
    --title-text-inactive: #b8b8b8;

    --text: #f2f2f2;
    --text-disabled: #3a3a3a;
    --text-disabled-light: #9a9a9a;

    --field-bg: #1c1c24;
    --field-text: #e6e6e6;

    --selection: #2a4a76;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text);
    background: #000;
    overflow: hidden;
    overflow: clip;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
    color: var(--text);
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: bold;
}

p {
    margin: 0 0 10px;
    line-height: 1.45;
}

ul {
    margin: 0 0 10px;
    padding-left: 18px;
}

a {
    color: var(--title-active-start);
}

[data-theme="night"] a {
    color: #9fc8ff;
}

/* Visible keyboard focus everywhere — retro dotted marching-ants outline. */
:focus-visible {
    outline: 1px dotted var(--text);
    outline-offset: 1px;
}

/* --------------------------------------------------------------------------
   Bevel primitives
   -------------------------------------------------------------------------- */

/* Raised surface: light top/left, dark bottom/right. */
.retro-panel {
    background: var(--win-face);
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-shadow);
    border-bottom: 2px solid var(--win-shadow);
}

/* Sunken surface: the inverse — used for fields, list views, status wells. */
.retro-inset {
    background: var(--field-bg);
    border-top: 2px solid var(--win-shadow);
    border-left: 2px solid var(--win-shadow);
    border-right: 2px solid var(--win-light);
    border-bottom: 2px solid var(--win-light);
}

/* Thin engraved separator used inside group boxes and dialogs. */
.retro-divider {
    height: 2px;
    margin: 8px 0;
    border-top: 1px solid var(--win-shadow);
    border-bottom: 1px solid var(--win-light);
}

.retro-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 72px;
    min-height: 23px;
    padding: 3px 12px;
    background: var(--win-face);
    color: var(--text);
    font-size: 12px;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-shadow);
    border-bottom: 2px solid var(--win-shadow);
    box-shadow: 1px 1px 0 0 var(--win-dark-shadow);
    transition: none;
}

.retro-button:active:not(:disabled),
.retro-button[aria-pressed="true"],
.retro-button.is-pressed {
    border-top-color: var(--win-shadow);
    border-left-color: var(--win-shadow);
    border-right-color: var(--win-light);
    border-bottom-color: var(--win-light);
    box-shadow: none;
    padding: 4px 11px 2px 13px;
}

.retro-button:disabled {
    color: var(--text-disabled);
    text-shadow: 1px 1px 0 var(--text-disabled-light);
    cursor: default;
}

.retro-button:focus-visible {
    outline: 1px dotted var(--text);
    outline-offset: -4px;
}

.retro-input,
.retro-textarea,
.retro-select {
    width: 100%;
    padding: 3px 4px;
    background: var(--field-bg);
    color: var(--field-text);
    border-top: 2px solid var(--win-shadow);
    border-left: 2px solid var(--win-shadow);
    border-right: 2px solid var(--win-light);
    border-bottom: 2px solid var(--win-light);
    border-radius: 0;
    outline-offset: -3px;
    transition: none;
}

.retro-textarea {
    resize: vertical;
    min-height: 72px;
    line-height: 1.4;
}

.retro-input::placeholder,
.retro-textarea::placeholder {
    color: var(--text-disabled);
}

/* Group box — the classic labelled frame from Control Panel property sheets. */
.retro-group {
    position: relative;
    margin: 14px 0 12px;
    padding: 12px 10px 10px;
    border-top: 1px solid var(--win-shadow);
    border-left: 1px solid var(--win-shadow);
    border-right: 1px solid var(--win-light);
    border-bottom: 1px solid var(--win-light);
}

.retro-group > legend,
.retro-group > .retro-group__title {
    padding: 0 4px;
    margin-left: 4px;
    font-weight: bold;
}

/* Radio / checkbox rows keep native controls (accessible) with retro spacing. */
.retro-choice {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 3px 0;
    cursor: pointer;
}

.retro-choice input {
    margin: 1px 0 0;
    accent-color: var(--title-active-start);
    flex: none;
}

/* Retro scrollbars where the engine supports them. */
.retro-scroll {
    scrollbar-color: var(--win-face) var(--win-highlight);
}

.retro-scroll::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

.retro-scroll::-webkit-scrollbar-track {
    background: repeating-conic-gradient(var(--win-light) 0 25%, var(--win-highlight) 0 50%) 0 0 / 2px 2px;
}

.retro-scroll::-webkit-scrollbar-thumb {
    background: var(--win-face);
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-shadow);
    border-bottom: 2px solid var(--win-shadow);
}

.retro-scroll::-webkit-scrollbar-corner {
    background: var(--win-face);
}

/* Screen-reader-only helper. */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

[hidden] {
    display: none !important;
}

/* Very subtle CRT texture. Never enough to soften text. */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.6) 0,
        rgba(0, 0, 0, 0.6) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0.02;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
