/* ============================================================
   ONRYO OS 95  -  core UI kit
   Windows 95 chrome: windows, buttons, fields, menus, taskbar.
   ============================================================ */

@font-face {
  font-family: "W95FA";
  src: url("W95FA.otf") format("opentype");
  font-display: swap;
}

:root {
  --face:        #c0c0c0;
  --face-light:  #dfdfdf;
  --white:       #ffffff;
  --shadow:      #808080;
  --dark:        #000000;
  --title-a1:    #000080;
  --title-a2:    #1084d0;
  --title-i1:    #808080;
  --title-i2:    #b5b5b5;
  --title-text:  #ffffff;
  --desk:        #008080;
  --sel:         #000080;
  --sel-text:    #ffffff;
  --font: "W95FA", "MS Sans Serif", Tahoma, Geneva, Verdana, sans-serif;
  --taskbar-h: 30px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 12px;
  -webkit-font-smoothing: none;
  background: var(--desk);
}

body.no-select, .no-select { user-select: none; -webkit-user-select: none; }

img { image-rendering: pixelated; }

/* ---------- bevels ---------- */
.raised {
  border: 1px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: inset 1px 1px 0 var(--white), inset -1px -1px 0 var(--shadow);
  background: var(--face);
}
.sunken {
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark), inset -1px -1px 0 var(--face-light);
  background: var(--white);
}

/* ---------- desktop ---------- */
#desktop {
  position: absolute;
  inset: 0 0 var(--taskbar-h) 0;
  background-color: var(--desk);
  background-repeat: no-repeat;
  background-position: center;
  overflow: hidden;
}
#desktop.wall-tile    { background-repeat: repeat; background-size: auto; }
#desktop.wall-center  { background-repeat: no-repeat; background-size: auto; }
#desktop.wall-stretch { background-repeat: no-repeat; background-size: 100% 100%; }

/* ---------- desktop icons ---------- */
.dicon {
  position: absolute;
  width: 78px;
  padding: 4px 2px 6px;
  text-align: center;
  cursor: default;
  z-index: 1;
}
.dicon .ico { width: 32px; height: 32px; display: block; margin: 0 auto 3px; pointer-events: none; }
.dicon .lbl {
  color: #fff;
  font-size: 11px;
  line-height: 1.2;
  text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000;
  padding: 1px 2px;
  display: inline-block;
  word-break: break-word;
}
/* A photograph behind white labels needs more than a 1px outline.
   Shell.applyTheme puts `has-wall` on the body whenever a wallpaper
   image is set, so unlocked picture wallpapers stay usable. */
body.has-wall .dicon .lbl {
  text-shadow:
    1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000,
    0 0 4px rgba(0, 0, 0, .9), 0 0 9px rgba(0, 0, 0, .75);
}
.dicon.sel .lbl { background: var(--sel); text-shadow: none; outline: 1px dotted #fff; }
.dicon.sel .ico { opacity: .75; }
.dicon.drop-target .lbl { background: #b00000; }

/* ---------- windows ---------- */
.win {
  position: absolute;
  min-width: 160px;
  min-height: 80px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: inset 1px 1px 0 var(--white), inset -1px -1px 0 var(--shadow);
  padding: 2px;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.win.minimized { display: none; }

.titlebar {
  height: 20px;
  flex: 0 0 20px;
  background: linear-gradient(90deg, var(--title-a1), var(--title-a2));
  color: var(--title-text);
  display: flex;
  align-items: center;
  padding: 0 2px 0 3px;
  cursor: default;
  user-select: none;
}
.win.inactive .titlebar { background: linear-gradient(90deg, var(--title-i1), var(--title-i2)); }
.titlebar .t-ico { width: 16px; height: 16px; margin-right: 4px; flex: 0 0 16px; }
.titlebar .t-txt {
  flex: 1 1 auto;
  font-weight: bold;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.titlebar .t-btns { display: flex; gap: 2px; flex: 0 0 auto; }

.tbtn {
  width: 16px; height: 14px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  box-shadow: inset 1px 1px 0 var(--face-light), inset -1px -1px 0 var(--shadow);
  display: flex; align-items: center; justify-content: center;
  padding: 0; cursor: default; color: #000;
  font-family: var(--font);
}
.tbtn:active { border-color: var(--dark) var(--white) var(--white) var(--dark); box-shadow: inset 1px 1px 0 var(--shadow); }
.tbtn svg { display: block; }
.tbtn.close { margin-left: 2px; }

/* menu bar */
.menubar {
  flex: 0 0 auto;
  display: flex;
  padding: 1px 0 2px;
  font-size: 12px;
}
.menubar .mi { padding: 1px 6px; cursor: default; position: relative; }
.menubar .mi:hover, .menubar .mi.open { background: var(--sel); color: #fff; }

/* window body */
.win-body {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.win-body.pad { padding: 8px; }

/* statusbar */
.statusbar {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  padding: 2px 0 0;
  font-size: 11px;
}
.statusbar > span {
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  padding: 1px 4px;
  overflow: hidden;
  white-space: nowrap;
}
.statusbar > span.grow { flex: 1 1 auto; }

/* resize handles */
.resizer { position: absolute; z-index: 5; }
.rz-n  { top: -2px; left: 6px; right: 6px; height: 5px; cursor: ns-resize; }
.rz-s  { bottom: -2px; left: 6px; right: 6px; height: 5px; cursor: ns-resize; }
.rz-w  { left: -2px; top: 6px; bottom: 6px; width: 5px; cursor: ew-resize; }
.rz-e  { right: -2px; top: 6px; bottom: 6px; width: 5px; cursor: ew-resize; }
.rz-nw { left: -2px; top: -2px; width: 8px; height: 8px; cursor: nwse-resize; }
.rz-ne { right: -2px; top: -2px; width: 8px; height: 8px; cursor: nesw-resize; }
.rz-sw { left: -2px; bottom: -2px; width: 8px; height: 8px; cursor: nesw-resize; }
.rz-se { right: -2px; bottom: -2px; width: 8px; height: 8px; cursor: nwse-resize; }
.win.maximized .resizer { display: none; }
.win.noresize .resizer { display: none; }

#dragghost {
  position: absolute;
  border: 3px dotted #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

/* ---------- controls ---------- */
button.w95, .w95btn {
  font-family: var(--font);
  font-size: 12px;
  min-width: 70px;
  padding: 3px 10px 4px;
  background: var(--face);
  color: #000;
  border: 1px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: inset 1px 1px 0 var(--white), inset -1px -1px 0 var(--shadow);
  cursor: default;
}
button.w95:active, .w95btn:active, button.w95.pressed {
  border-color: var(--dark) var(--white) var(--white) var(--dark);
  box-shadow: inset 1px 1px 0 var(--shadow);
  padding: 4px 9px 3px 11px;
}
button.w95:focus { outline: 1px dotted #000; outline-offset: -4px; }
button.w95:disabled { color: var(--shadow); text-shadow: 1px 1px 0 var(--white); }

input.w95, textarea.w95, select.w95 {
  font-family: var(--font);
  font-size: 12px;
  background: var(--white);
  color: #000;
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark), inset -1px -1px 0 var(--face-light);
  padding: 2px 3px;
  outline: none;
}
textarea.w95 { resize: none; }

/* Notepad's page. A <textarea> can only hold characters, so a text file
   carrying an  image:  gets this editable div instead - same sunken
   chrome, but a picture can sit inline among the lines. */
.np-page {
  background: var(--white);
  color: #000;
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark), inset -1px -1px 0 var(--face-light);
  white-space: pre-wrap;
  overflow: auto;
  outline: none;
}
.np-page img { display: block; max-width: 100%; margin: 2px 0; cursor: pointer; }
.np-page .np-broken { color: var(--shadow); }

fieldset.w95 {
  border: 1px solid var(--shadow);
  border-right-color: var(--white);
  border-bottom-color: var(--white);
  margin: 0 0 10px;
  padding: 10px;
}
fieldset.w95 legend { padding: 0 4px; }

label.w95 { display: inline-flex; align-items: center; gap: 5px; cursor: default; }

/* scrollbars */
.scroll { overflow: auto; }
.scroll::-webkit-scrollbar { width: 16px; height: 16px; }
.scroll::-webkit-scrollbar-track {
  background-color: var(--face);
  background-image:
    linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%),
    linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%);
  background-size: 2px 2px;
  background-position: 0 0, 1px 1px;
}
.scroll::-webkit-scrollbar-thumb {
  background: var(--face);
  border: 1px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  box-shadow: inset 1px 1px 0 var(--face-light), inset -1px -1px 0 var(--shadow);
}
.scroll::-webkit-scrollbar-corner { background: var(--face); }

/* ---------- taskbar ---------- */
#taskbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--taskbar-h);
  background: var(--face);
  border-top: 1px solid var(--white);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 3px;
  z-index: 9000;
}
#startbtn {
  display: flex; align-items: center; gap: 4px;
  font-weight: bold; font-size: 12px;
  padding: 2px 6px 3px 3px;
  min-width: 0;
  flex: 0 0 auto;
}
#startbtn svg { width: 18px; height: 18px; }
#tasklist { flex: 1 1 auto; display: flex; gap: 3px; overflow: hidden; }
.taskbtn {
  flex: 0 1 160px;
  min-width: 40px;
  display: flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  font-size: 11px;
  text-align: left;
  overflow: hidden; white-space: nowrap;
}
.taskbtn svg { width: 16px; height: 16px; flex: 0 0 16px; }
.taskbtn span { overflow: hidden; text-overflow: ellipsis; }
.taskbtn.active {
  border-color: var(--dark) var(--white) var(--white) var(--dark);
  box-shadow: inset 1px 1px 0 var(--shadow);
  background-color: var(--face);
  background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%),
                    linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%);
  background-size: 2px 2px; background-position: 0 0, 1px 1px;
  font-weight: bold;
}
#tray {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 2px 6px;
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  height: 22px;
}
#tray .tray-ico { width: 16px; height: 16px; cursor: default; }
#clock {
  font-size: 11px;
  text-align: center;
  cursor: default;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}
#clock .ctime { min-width: 54px; }
/* the date is the first thing to go when the taskbar runs out of room */
@media (max-width: 430px) {
  #clock .cdate { display: none; }
}

/* ---------- start menu ---------- */
#startmenu {
  position: absolute;
  left: 2px;
  bottom: var(--taskbar-h);
  width: 210px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: inset 1px 1px 0 var(--white), inset -1px -1px 0 var(--shadow);
  display: none;
  z-index: 9500;
  padding: 2px;
}
#startmenu.open { display: flex; }
#startmenu .banner {
  width: 26px;
  background: linear-gradient(180deg, #000080, #1084d0 70%, #7a7aff);
  position: relative;
  flex: 0 0 26px;
}
#startmenu .banner span {
  position: absolute;
  bottom: 8px; left: 0; right: 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin: 0 auto;
  color: #c0c0c0;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  white-space: nowrap;
}
#startmenu .banner span b { color: #fff; font-size: 16px; }
#startmenu .items { flex: 1 1 auto; }

.menu {
  background: var(--face);
  border: 1px solid;
  border-color: var(--face-light) var(--dark) var(--dark) var(--face-light);
  box-shadow: inset 1px 1px 0 var(--white), inset -1px -1px 0 var(--shadow);
  padding: 2px;
  min-width: 150px;
}
.menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 20px 4px 4px;
  cursor: default;
  white-space: nowrap;
  position: relative;
  font-size: 12px;
}
#startmenu .menu-item { padding: 5px 20px 5px 4px; }
.menu-item .mico { width: 24px; height: 24px; flex: 0 0 24px; }
.menu.compact .menu-item .mico { width: 16px; height: 16px; flex: 0 0 16px; }
.menu-item:hover, .menu-item.hl { background: var(--sel); color: var(--sel-text); }
.menu-item.disabled { color: var(--shadow); text-shadow: 1px 1px 0 var(--white); }
.menu-item.disabled:hover { background: transparent; color: var(--shadow); }
.menu-item .sub-arrow { position: absolute; right: 5px; }
.menu-item .accel { margin-left: auto; padding-left: 24px; opacity: .75; font-size: 11px; }
.menu-sep { height: 1px; margin: 3px 2px; border-top: 1px solid var(--shadow); border-bottom: 1px solid var(--white); }

#menulayer { position: absolute; inset: 0; z-index: 9600; display: none; }
#menulayer.on { display: block; }
#menulayer .menu { position: absolute; }
/* Start-menu submenus float above the Start menu, so the layer itself must
   not eat hover events - otherwise the row underneath can never be reached. */
#menulayer.passthrough { pointer-events: none; }
#menulayer.passthrough .menu { pointer-events: auto; }

/* ---------- listviews / explorer ---------- */
.lv {
  flex: 1 1 auto;
  background: var(--white);
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dark), inset -1px -1px 0 var(--face-light);
  overflow: auto;
  padding: 4px;
  min-height: 0;
}
.lv.icons { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 2px; }
.lv-item {
  width: 84px;
  padding: 4px 2px 5px;
  text-align: center;
  cursor: default;
}
.lv-item svg, .lv-item img { width: 32px; height: 32px; display: block; margin: 0 auto 3px; }
.lv-item .lbl { font-size: 11px; padding: 1px 2px; display: inline-block; word-break: break-word; }
.lv-item.sel .lbl { background: var(--sel); color: #fff; }
.lv-item.sel svg, .lv-item.sel img { opacity: .7; }

.lv.list { display: block; }
.lv.list .lv-item {
  width: auto; display: flex; align-items: center; gap: 6px;
  text-align: left; padding: 1px 3px;
}
.lv.list .lv-item svg, .lv.list .lv-item img { width: 16px; height: 16px; margin: 0; }
.lv.list .lv-item .meta { margin-left: auto; color: #555; font-size: 11px; padding-left: 16px; }
.lv.list .lv-item.sel .meta { color: #cfcfcf; }

/* tree */
.tree { font-size: 12px; }
.tree .node { padding-left: 14px; }
.tree .row { display: flex; align-items: center; gap: 4px; padding: 1px 2px; cursor: default; }
.tree .row.sel { background: var(--sel); color: #fff; }
.tree .row svg { width: 16px; height: 16px; }

/* toolbar */
.toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 3px;
  padding: 2px;
  border-bottom: 1px solid var(--shadow);
  box-shadow: 0 1px 0 var(--white);
  margin-bottom: 3px;
}
.tool {
  width: 24px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
  cursor: default;
}
.tool:hover { border-color: var(--white) var(--shadow) var(--shadow) var(--white); }
.tool:active { border-color: var(--shadow) var(--white) var(--white) var(--shadow); }
.tool.disabled { opacity: .4; pointer-events: none; }
.toolbar .addr { flex: 1 1 auto; display: flex; align-items: center; gap: 4px; padding-left: 6px; }
.toolbar .addr input { flex: 1 1 auto; }
.tb-sep { width: 1px; height: 20px; border-left: 1px solid var(--shadow); border-right: 1px solid var(--white); margin: 0 2px; }

/* ---------- dialogs ---------- */
.dlg-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.dlg-row .dlg-ico { width: 32px; height: 32px; flex: 0 0 32px; }
.dlg-btns { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }
.dlg-text { line-height: 1.5; }

/* ---------- CRT overlay ---------- */
#crt { position: fixed; inset: 0; pointer-events: none; z-index: 20000; }
#crt::before {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,.16) 50%),
    linear-gradient(90deg, rgba(255,0,0,.05), rgba(0,255,0,.02), rgba(0,0,255,.05));
  background-size: 100% 3px, 3px 100%;
  opacity: .6;
}
#crt::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(18,16,16,.05);
  animation: crtflicker .15s infinite;
}
@keyframes crtflicker {
  0%{opacity:.28} 15%{opacity:.9} 25%{opacity:.34} 40%{opacity:.26}
  55%{opacity:.86} 70%{opacity:.53} 85%{opacity:.7} 100%{opacity:.24}
}
#crt .vig { position: absolute; inset: 0; box-shadow: inset 0 0 120px rgba(0,0,0,.5); }
body.no-crt #crt { display: none; }
body.no-vignette #crt .vig { display: none; }

@media (prefers-reduced-motion: reduce) {
  #crt::after { animation: none; opacity: .3; }
}

/* ---------- misc ---------- */
.mono { font-family: "Lucida Console", "Courier New", monospace; }
.hidden { display: none !important; }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

#bootscreen {
  position: fixed; inset: 0; z-index: 19000;
  background: #000; color: #c0c0c0;
  font-family: "Lucida Console", monospace; font-size: 14px;
  padding: 24px; white-space: pre-wrap; display: none;
}
#bootscreen.on { display: block; }

#shutdownscreen {
  position: fixed; inset: 0; z-index: 19500;
  background: #000; color: #ffb000;
  font-family: "Lucida Console", monospace; font-size: 22px;
  display: none; align-items: center; justify-content: center; text-align: center;
}
#shutdownscreen.on { display: flex; }

#bsod {
  position: fixed; inset: 0; z-index: 21000;
  background: #0000aa; color: #fff;
  font-family: "Lucida Console", monospace;
  font-size: 15px; line-height: 1.5;
  padding: 8vh 8vw; display: none;
}
#bsod.on { display: block; }
#bsod .hd { background: #c0c0c0; color: #0000aa; padding: 0 8px; display: inline-block; }

/* ---------- mobile ---------- */
@media (max-width: 620px) {
  :root { --taskbar-h: 34px; }
  .dicon { width: 66px; }
  .dicon .lbl { font-size: 10px; }
  .taskbtn { flex: 1 1 40px; }
  .taskbtn span { display: none; }
  #startmenu { width: 200px; }
}
