/*
  Things For Download: a late-90s desktop.
  Bevels follow the classic two-pixel recipe (light top-left, dark bottom-right).
  Font: "W95 Sans" from the Windows 95 UI Kit (MIT, fonts/LICENSE-windows-95-ui-kit.txt).
*/
@font-face {
  font-family: "W95 Sans";
  src: url("fonts/w-95-sans-serif.woff2") format("woff2"), url("fonts/w-95-sans-serif.woff") format("woff");
  font-display: swap;
}

:root {
  --desk: #008080;
  --face: #c0c0c0;
  --light: #dfdfdf;
  --white: #fff;
  --shadow: #808080;
  --dark: #0a0a0a;
  --title: #000080;
  --select: #000080;
  --taskbar-h: 40px;
  --raised: inset -1px -1px var(--dark), inset 1px 1px var(--white), inset -2px -2px var(--shadow), inset 2px 2px var(--light);
  --pressed: inset -1px -1px var(--white), inset 1px 1px var(--dark), inset -2px -2px var(--light), inset 2px 2px var(--shadow);
  --sunken: inset -1px -1px var(--white), inset 1px 1px var(--shadow), inset -2px -2px var(--light), inset 2px 2px var(--dark);
  --status: inset -1px -1px var(--white), inset 1px 1px var(--shadow);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--desk) var(--wallpaper, none) center / cover no-repeat;
  color: #000;
  font: 16px/1.25 "W95 Sans", "MS Sans Serif", Tahoma, Geneva, sans-serif;
  -webkit-font-smoothing: none;
  overflow: hidden;
}
img { image-rendering: pixelated; }
a { color: #0000ee; }
:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

/* ---------- Bevel pieces ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 84px; min-height: 30px; padding: 4px 12px;
  background: var(--face); color: #000; text-decoration: none;
  border: 0; box-shadow: var(--raised); font: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active, .btn.is-active { box-shadow: var(--pressed); }
.btn:active > *, .btn.is-active > * { transform: translate(1px, 1px); }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.btn-default { box-shadow: inset 0 0 0 1px var(--dark), var(--raised); }
.btn-default:active { box-shadow: inset 0 0 0 1px var(--dark), var(--pressed); }
.field { background: var(--white); box-shadow: var(--sunken); padding: 4px 6px; }

/* ---------- Desktop ---------- */
.desktop { position: fixed; inset: 0 0 var(--taskbar-h) 0; }
.icons { list-style: none; margin: 0; padding: 0; }
.desk-icons {
  height: 100%; padding: 8px 4px;
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 112px); grid-auto-columns: 128px;
  align-content: start; justify-content: start; overflow: auto;
}
.icon {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 124px; padding: 4px 2px; text-decoration: none; color: #000; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.icon img { flex: none; }
.icon-label {
  max-width: 100%; padding: 1px 3px; overflow-wrap: break-word; line-height: 1.15;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.icon:focus .icon-label { -webkit-line-clamp: unset; line-clamp: none; }
.desk-icons .icon-label { color: var(--white); }
.icon:focus { outline: none; }
.icon:focus img, .icon:active img { filter: brightness(.55) sepia(1) hue-rotate(190deg) saturate(6); }
.icon:focus .icon-label, .icon:active .icon-label { background: var(--select); color: var(--white); outline: 1px dotted #ff0; }
@media (hover: hover) {
  .icon:hover .icon-label { text-decoration: underline; }
}

/* ---------- Window ---------- */
.win-slot:empty { display: none; }
.win {
  position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%);
  width: min(680px, calc(100% - 140px)); max-height: calc(100% - 32px);
  display: flex; flex-direction: column;
  background: var(--face); box-shadow: var(--raised); padding: 4px;
}
.win:focus { outline: none; }
.win-item { width: min(560px, calc(100% - 140px)); }
.win-alert { width: min(440px, calc(100% - 32px)); }
.win-folder { height: min(460px, calc(100% - 32px)); }

.win-titlebar {
  display: flex; align-items: center; gap: 6px; flex: none;
  height: 28px; padding: 0 3px 0 6px; background: var(--title); color: var(--white);
}
.win-titlebar h1 { flex: 1; margin: 0; font: inherit; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-close {
  position: relative; flex: none; width: 24px; height: 21px; background: var(--face); box-shadow: var(--raised);
  -webkit-tap-highlight-color: transparent;
}
.win-close:active { box-shadow: var(--pressed); }
.win-close span::before, .win-close span::after {
  content: ""; position: absolute; left: 6px; top: 9px; width: 11px; height: 2px; background: #000;
  transform: rotate(45deg);
}
.win-close span::after { transform: rotate(-45deg); }
.win-close:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

.win-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 2px; flex: none; }
.btn-tool { min-width: 0; padding: 3px 10px; }
.win-address { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.win-address .field { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.win-status { flex: none; padding-top: 4px; }
.win-status .field { display: block; background: none; box-shadow: var(--status); padding: 2px 6px; }

/* Folder window: white icon pane */
.pane { flex: 1; min-height: 0; overflow: auto; background: var(--white); box-shadow: var(--sunken); padding: 10px 6px; }
.pane .icons { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px 4px; }
.empty { margin: 8px; color: var(--shadow); }

/* Item window */
.win-item .win-body { padding: 4px 2px 2px; }
.item { flex: 1; overflow: auto; background: var(--white); box-shadow: var(--sunken); padding: 14px 16px; }
.item-photo { margin: 0 0 12px; text-align: center; }
.item-photo img {
  display: inline-block; max-width: 100%; height: auto; max-height: min(320px, 42vh); object-fit: contain;
  image-rendering: auto; border: 1px solid var(--shadow); background: var(--face);
}
.item-title { margin: 0 0 8px; font-size: 1.25em; }
.item-desc { overflow-wrap: break-word; }
.item-desc > :first-child { margin-top: 0; }
.item-desc > :last-child { margin-bottom: 0; }
.item-desc img { max-width: 100%; height: auto; image-rendering: auto; }
.win-buttons { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin: 10px 2px 2px; flex: none; }
.muted { color: var(--shadow); }

/* Alert window */
.alert { display: flex; gap: 14px; align-items: flex-start; padding: 14px 10px 4px; }
.alert p { margin: 4px 0 0; }
.alert-mark {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: #ff0; color: #000; font-weight: bold; font-size: 22px; box-shadow: inset -2px -2px 0 rgba(0,0,0,.25), 0 0 0 1px #000;
}
.alert-info { background: var(--white); color: var(--title); font-family: Georgia, serif; font-style: italic; }
.win-alert .win-buttons { justify-content: center; }

/* ---------- Taskbar ---------- */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--taskbar-h); z-index: 10;
  display: flex; align-items: center; gap: 4px; padding: 4px;
  background: var(--face); box-shadow: inset 0 1px var(--light), inset 0 2px var(--white);
}
.taskbar .btn { min-height: 0; height: 100%; }
.tb-home { flex: none; min-width: 0; padding: 0 10px; font-weight: bold; }
.tb-home img { image-rendering: auto; }
.tb-tasks { flex: 1; min-width: 0; height: 100%; display: flex; padding-left: 4px; border-left: 1px solid var(--shadow); box-shadow: inset 1px 0 var(--white); }
.tb-task { justify-content: flex-start; width: min(220px, 100%); min-width: 0; cursor: default;
  background-image: repeating-conic-gradient(var(--white) 0 25%, var(--face) 0 50%); background-size: 2px 2px; }
.tb-task span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
.tb-task img { flex: none; }
.tb-tray { flex: none; height: 100%; display: flex; align-items: center; gap: 6px; padding: 0 10px; background: none; box-shadow: var(--status); }
.tb-tray time:empty { display: none; }

/* ---------- Phones: windows fill the screen ---------- */
@media (max-width: 640px) {
  .desk-icons { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(auto-fill, 120px); grid-auto-rows: max-content; justify-content: space-evenly; padding: 8px 0; }
  .icon { width: 120px; }
  .win, .win-item, .win-folder {
    left: 0; top: 0; transform: none; width: 100%; height: 100%; max-height: none;
  }
  .win-alert { left: 50%; top: 45%; transform: translate(-50%, -50%); height: auto; }
  .win-address-label { display: none; }
  .tb-home span { display: none; }
  .tb-tray img { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .win.is-opening { animation: win-open .12s steps(3) both; }
  @keyframes win-open { from { opacity: 0; clip-path: inset(0 100% 100% 0); } to { opacity: 1; clip-path: inset(0); } }
}
