/* Dark mode (js/theme.js sets <html data-theme="dark">).
   The same sunset, grid and bust, turned right down (the WebGL colours are in js/wallpaper.js),
   with pairs of eyes that open in the dark now and then and fade away again (js/eyes.js).
   The Win95 chrome is redone in charcoal: same bevels, darker greys, light text.
   Loaded after the other stylesheets so it wins on equal specificity. */

/* ------------------------------------------------------------ the eyes */
.eyes { display: none; }
html.js .eyes { display: block; position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
html.js .eyes[hidden] { display: none; }
.eyes-pair {
    position: absolute;
    left: calc(var(--x) * 1%); top: calc(var(--y) * 1%);
    width: min(calc(var(--w) * 1%), calc(var(--w) * 1.7vh / var(--ui-scale, 1)));
    height: auto; aspect-ratio: 220 / 130;
    transform: translate(-50%, -50%);
    overflow: visible;
    opacity: 0;
    transition: opacity 0.9s ease;
}
.eyes-pair.is-shown { opacity: 1; }
.eye-white { fill: #f2f1ea; }
.eye-pupil { fill: #050505; transition: transform 0.25s ease-out; }
.eye-line { fill: none; stroke: #f2f1ea; stroke-width: 4; stroke-linecap: round; }
.eye-lid { transform-box: fill-box; transform-origin: 50% 50%; transition: transform 0.08s ease-in; }
.eyes-pair.is-shut .eye-lid { transform: scaleY(0.04); }

@media (max-width: 640px), (max-height: 480px) {
    .eyes-pair { width: min(calc(var(--w) * 1%), calc(var(--w) * 0.9vh / var(--ui-scale, 1))); }
}

/* ------------------------------------------------------------ wallpaper, after dark */
html.js[data-theme="dark"] body { background: radial-gradient(ellipse at 50% 40%, #120a1c 0%, #07050c 55%, #030305 100%) fixed; }
html[data-theme="dark"] .wallpaper-sun {
    background: linear-gradient(180deg, #5c4a22 0%, #5a2c22 26%, #4a1838 56%, #2a0c46 100%);
    opacity: 0.7;
}
html[data-theme="dark"] .wallpaper-sun::after { background: radial-gradient(closest-side, rgba(120, 30, 90, 0.3), rgba(120, 30, 90, 0) 70%); }

/* ------------------------------------------------------------ desktop */
html[data-theme="dark"] {
    --desktop: #07050c;
    --silver: #34343c;
    --grey: #5c5c68;
    --face: #34343c;
    --light: #6e6e7c;
    --shadow: #1c1c22;
    --field: #141418;
    --text: #e4e4ea;
    --muted: #a8a8b4;
    --bevel-out: inset -1px -1px #000, inset 1px 1px var(--light), inset -2px -2px var(--shadow), inset 2px 2px #4a4a55;
    --bevel-in: inset -1px -1px var(--light), inset 1px 1px #000, inset -2px -2px #4a4a55, inset 2px 2px var(--shadow);
    color-scheme: dark;
}
:where(html[data-theme="dark"]) body { color: var(--text); }
:where(html[data-theme="dark"]) :focus-visible { outline-color: var(--text); }

/* ------------------------------------------------------------ 98.css surfaces */
:where(html[data-theme="dark"]) .window {
    background: var(--face); color: var(--text);
    box-shadow: inset -1px -1px #000, inset 1px 1px #4a4a55, inset -2px -2px var(--shadow), inset 2px 2px var(--light);
}
:where(html[data-theme="dark"]) .title-bar { background: #1d1d6b; }
:where(html[data-theme="dark"]) .title-bar.inactive { background: #2a2a30; }
:where(html[data-theme="dark"]) .title-bar.inactive .title-bar-text { color: #8a8a96; }
:where(html[data-theme="dark"]) legend { background: var(--face); color: var(--text); }
:where(html[data-theme="dark"]) .status-bar-field { box-shadow: inset -1px -1px var(--light), inset 1px 1px var(--shadow); }

/* Buttons: 98.css draws their label as a text-shadow on transparent text. */
:where(html[data-theme="dark"]) button,
:where(html[data-theme="dark"]) input[type="submit"],
:where(html[data-theme="dark"]) input[type="reset"] {
    background: var(--face);
    box-shadow: var(--bevel-out);
    text-shadow: 0 0 var(--text);
}
:where(html[data-theme="dark"]) button.default { box-shadow: inset -2px -2px #000, inset 1px 1px #000, inset 2px 2px var(--light), inset -3px -3px var(--shadow), inset 3px 3px #4a4a55; }
:where(html[data-theme="dark"]) button:not(:disabled):active { box-shadow: var(--bevel-in); text-shadow: 1px 1px var(--text); }
:where(html[data-theme="dark"]) button:disabled { text-shadow: 1px 1px 0 #000; color: var(--grey); }
:where(html[data-theme="dark"]) button:focus { outline-color: var(--text); }
/* The title-bar buttons keep their light faces: their glyphs are black images. */
:where(html[data-theme="dark"]) .title-bar-controls button {
    background-color: #c0c0c0;
    box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px grey, inset 2px 2px #dfdfdf;
}
:where(html[data-theme="dark"]) .title-bar-controls button:not(:disabled):active {
    box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px grey;
}

/* Fields */
:where(html[data-theme="dark"]) input[type="text"],
:where(html[data-theme="dark"]) input[type="email"],
:where(html[data-theme="dark"]) input[type="search"],
:where(html[data-theme="dark"]) input[type="url"],
:where(html[data-theme="dark"]) input[type="tel"],
:where(html[data-theme="dark"]) input[type="number"],
:where(html[data-theme="dark"]) input[type="password"],
:where(html[data-theme="dark"]) select,
:where(html[data-theme="dark"]) textarea {
    background-color: var(--field); color: var(--text); box-shadow: var(--bevel-in);
}
:where(html[data-theme="dark"]) input[type]:read-only,
:where(html[data-theme="dark"]) textarea:disabled,
:where(html[data-theme="dark"]) .mail-fields input[readonly] { background-color: var(--face); }
:where(html[data-theme="dark"]) select:focus { background-color: #1d1d6b; }
:where(html[data-theme="dark"]) select option { background: var(--field); color: var(--text); }
:where(html[data-theme="dark"]) input[type="checkbox"] + label::before { background-color: #e8e8ee; }
:where(html[data-theme="dark"]) input[type="checkbox"]:focus + label,
:where(html[data-theme="dark"]) input[type="radio"]:focus + label { outline-color: var(--text); }
:where(html[data-theme="dark"]) :disabled + label { color: var(--grey); text-shadow: 1px 1px 0 #000; }

:where(html[data-theme="dark"]) a { color: #8fb4ff; }
:where(html[data-theme="dark"]) .sunken-panel,
:where(html[data-theme="dark"]) table,
:where(html[data-theme="dark"]) pre,
:where(html[data-theme="dark"]) .field-border { background-color: var(--field); color: var(--text); }
:where(html[data-theme="dark"]) table > thead > tr > * { background: var(--face); box-shadow: var(--bevel-out); }
:where(html[data-theme="dark"]) table > tbody > tr.highlighted { background-color: #2b2b8f; }
:where(html[data-theme="dark"]) table.interactive tbody tr:focus { outline-color: var(--text); }
:where(html[data-theme="dark"]) fieldset { border-color: var(--grey); }

/* ------------------------------------------------------------ desktop.css surfaces */
:where(html[data-theme="dark"]) .toolbar,
:where(html[data-theme="dark"]) .player-controls { box-shadow: 0 1px var(--light); }
:where(html[data-theme="dark"]) .toolbar-note,
:where(html[data-theme="dark"]) .display-current,
:where(html[data-theme="dark"]) .wallpaper-credit,
:where(html[data-theme="dark"]) .review-detail .meta { color: var(--muted); }
:where(html[data-theme="dark"]) .wallpaper-credit a { color: #8fb4ff; }
:where(html[data-theme="dark"]) .file-grid,
:where(html[data-theme="dark"]) .notepad-page,
:where(html[data-theme="dark"]) .review-detail { background: var(--field); color: var(--text); }
:where(html[data-theme="dark"]) .file-icon { color: var(--text); }
:where(html[data-theme="dark"]) .file-icon:focus-visible span { outline-color: var(--text); }
:where(html[data-theme="dark"]) .welcome-tip { background: #26261a; }
:where(html[data-theme="dark"]) .welcome-95 { -webkit-text-stroke-color: #1d1d6b; }
:where(html[data-theme="dark"]) .welcome-actions hr,
:where(html[data-theme="dark"]) .start-sep { border-top-color: #000; border-bottom-color: var(--light); }
:where(html[data-theme="dark"]) .review-detail .stars { color: var(--accent); }
:where(html[data-theme="dark"]) .mail .mail-fields label,
:where(html[data-theme="dark"]) .mail .mail-fields input[readonly] { color: var(--text); }
:where(html[data-theme="dark"]) .status-bar-field.is-error { color: #ff8080; }
:where(html[data-theme="dark"]) .status-bar-field.is-success { color: #7ddc7d; }
:where(html[data-theme="dark"]) .glyph { color: var(--text); }
:where(html[data-theme="dark"]) .mp-button:disabled .glyph { color: var(--grey); filter: drop-shadow(1px 1px 0 #000); }
:where(html[data-theme="dark"]) .mp-divider { border-left-color: #000; border-right-color: var(--light); }

/* Taskbar and Start menu */
:where(html[data-theme="dark"]) .taskbar { box-shadow: inset 0 1px #4a4a55, inset 0 2px var(--light); }
:where(html[data-theme="dark"]) .task[aria-pressed="true"] { background: repeating-conic-gradient(#46464f 0 25%, var(--face) 0 50%) 0 0 / 2px 2px; }
:where(html[data-theme="dark"]) .tray { box-shadow: inset -1px -1px var(--light), inset 1px 1px #000; }
:where(html[data-theme="dark"]) .tray .tray-button:focus-visible { outline-color: var(--text); }
:where(html[data-theme="dark"]) .start-banner { background: #18181d; }
:where(html[data-theme="dark"]) .start-banner span { color: #6e6e7c; }
:where(html[data-theme="dark"]) .start-menu a,
:where(html[data-theme="dark"]) .start-menu ul button { color: var(--text); text-shadow: none; }
:where(html[data-theme="dark"]) .start-menu a:hover,
:where(html[data-theme="dark"]) .start-menu a:focus,
:where(html[data-theme="dark"]) .start-menu ul button:hover,
:where(html[data-theme="dark"]) .start-menu ul button:focus { background: #1d1d6b; }

/* Guestbook */
:where(html[data-theme="dark"]) .gb-entries { background: var(--field); }
:where(html[data-theme="dark"]) .gb-who,
:where(html[data-theme="dark"]) .gb-empty,
:where(html[data-theme="dark"]) .gb-note,
:where(html[data-theme="dark"]) .gb-left { color: var(--muted); }
:where(html[data-theme="dark"]) .gb-who b { color: #a9b8ff; }
:where(html[data-theme="dark"]) .gb-entries:focus-visible { outline-color: var(--text); }

@media (prefers-reduced-motion: reduce) {
    .eyes-pair.is-shut .eye-lid { transform: none; }
}
