/* Mempire 95. No external fonts or assets. */
:root {
  --face: #c0c0c0;
  --hilite: #ffffff;
  --light: #dfdfdf;
  --shadow: #808080;
  --dark: #000000;
  --title-a: #000080;
  --title-b: #1084d0;
  --title-off-a: #808080;
  --title-off-b: #b5b5b5;
  --desk: #008080;
  --sel: #000080;
  --taskbar-h: 30px;
  --font: 12px "MS Sans Serif", "Microsoft Sans Serif", Tahoma, Geneva, Verdana, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--desk); overscroll-behavior: none; }
/* Sized to the *visible* viewport (set from JS) so a phone keyboard never covers the typing box. */
body {
  position: fixed;
  left: 0;
  top: var(--app-top, 0px);
  width: 100%;
  height: var(--app-h, 100%);
  margin: 0;
  background: var(--desk);
  color: #000;
  font: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: none;
}
img { image-rendering: pixelated; }
button, input, textarea { font: inherit; color: inherit; }
p { margin: 0; }

/* ---- Bevels ----------------------------------------------------------- */
.raised, .window, .btn, .task, #start, .title-button {
  background: var(--face);
  border: 2px solid;
  border-color: var(--hilite) var(--dark) var(--dark) var(--hilite);
  box-shadow: inset -1px -1px var(--shadow), inset 1px 1px var(--light);
}
.sunken {
  background: #fff;
  border: 2px solid;
  border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow);
  box-shadow: inset 1px 1px var(--dark), inset -1px -1px var(--light);
}
.btn:active, .task.pressed, #start.pressed, .title-button:active {
  border-color: var(--dark) var(--hilite) var(--hilite) var(--dark);
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--light);
}
button:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
.btn { min-width: 75px; height: 23px; padding: 0 10px; cursor: pointer; }

/* ---- Desktop ---------------------------------------------------------- */
#desktop {
  position: absolute;
  inset: 0 0 calc(var(--taskbar-h) + env(safe-area-inset-bottom)) 0;
  overflow: hidden;
}
#icons {
  position: absolute;
  inset: 8px;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 76px);
  grid-auto-columns: 76px;
  gap: 4px;
  align-content: start;
}
.desk-icon, .icon-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 2px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: center;
}
.desk-icon .icon-label {
  color: #fff;
  padding: 1px 2px;
  line-height: 1.2;
  word-break: break-word;
}
.desk-icon.selected img, .icon-cell.selected img { filter: brightness(0.6) sepia(1) hue-rotate(190deg) saturate(4); }
.desk-icon.selected .icon-label, .icon-cell.selected .icon-label {
  background: var(--sel);
  color: #fff;
  outline: 1px dotted #ff0;
}

/* ---- Windows ---------------------------------------------------------- */
#windows { position: absolute; inset: 0; pointer-events: none; }
.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  padding: 2px;
  min-width: 200px;
  pointer-events: auto;
}
.window.maximized { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; }
.titlebar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 2px 0 3px;
  background: linear-gradient(90deg, var(--title-off-a), var(--title-off-b));
  color: var(--light);
  font-weight: bold;
  flex: none;
  touch-action: none;
  cursor: default;
}
.window.active .titlebar { background: linear-gradient(90deg, var(--title-a), var(--title-b)); color: #fff; }
.title-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.title-buttons { display: flex; gap: 0; }
.title-button {
  width: 16px;
  height: 14px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.title-button:last-child { margin-left: 2px; }
.title-button.back { display: none; }
.glyph { display: block; position: relative; width: 8px; height: 7px; }
.glyph.min::after { content: ""; position: absolute; left: 0; bottom: 0; width: 6px; height: 2px; background: #000; }
.glyph.max { border: 1px solid #000; border-top-width: 2px; width: 9px; height: 8px; }
.glyph.restore::before, .glyph.restore::after { content: ""; position: absolute; width: 6px; height: 5px; border: 1px solid #000; border-top-width: 2px; background: var(--face); }
.glyph.restore::before { right: 0; top: -1px; }
.glyph.restore::after { left: 0; bottom: -1px; }
.glyph.close::before, .glyph.close::after {
  content: ""; position: absolute; left: 3px; top: -1px; width: 2px; height: 9px; background: #000;
}
.glyph.close::before { transform: rotate(45deg); }
.glyph.close::after { transform: rotate(-45deg); }
.window-body { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 2px 0 0; }
.resize-grip {
  position: absolute; right: 2px; bottom: 2px; width: 13px; height: 13px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 45%, var(--hilite) 45% 52%, var(--shadow) 52% 60%, transparent 60% 70%, var(--hilite) 70% 77%, var(--shadow) 77% 85%, transparent 85%);
}
.window.maximized .resize-grip { display: none; }

.menu-bar { display: flex; gap: 2px; padding: 1px 0 3px; flex: none; }
.menu-bar span { padding: 1px 6px; }
.menu-bar span::first-letter { text-decoration: underline; }
.status-bar { display: flex; gap: 2px; margin-top: 2px; flex: none; }
.status-cell {
  flex: 1; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid; border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow);
}
.status-cell:first-child { flex: 0 1 auto; min-width: 40%; }

/* ---- Folders & the launcher ------------------------------------------- */
.folder-view { flex: 1; overflow: auto; padding: 8px; min-height: 0; }
.icon-grid { display: flex; flex-wrap: wrap; gap: 8px 4px; align-content: flex-start; }
.icon-cell { width: 80px; }
.icon-cell .icon-label { padding: 1px 2px; line-height: 1.2; }
.icon-grid.large { gap: 12px; justify-content: center; padding: 8px 0; }
.icon-grid.large .icon-cell { width: 128px; padding: 8px 4px; }
.icon-grid.large .icon-label { font-weight: bold; }
.icon-blurb { color: var(--shadow); line-height: 1.2; }
.icon-grid.large .icon-cell:hover .icon-label { text-decoration: underline; }
.empty { color: var(--shadow); margin: 8px; }

.launcher-banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 4px;
  background: linear-gradient(90deg, #000, var(--title-a)); color: #fff; flex: none;
}
.launcher-banner strong { display: block; font-size: 16px; letter-spacing: 2px; }
.launcher-banner span { color: #c0c0ff; }

/* ---- Notepad, message boxes, dialogs ---------------------------------- */
.notepad textarea {
  flex: 1; resize: none; padding: 2px 4px; min-height: 0;
  font: 13px "Fixedsys", "Courier New", monospace; user-select: text; -webkit-user-select: text;
}
.msg { display: flex; gap: 14px; align-items: flex-start; padding: 12px 12px 4px; }
.msg img { flex: none; }
.msg-text { display: grid; gap: 2px; padding-top: 2px; min-height: 1em; user-select: text; -webkit-user-select: text; }
.msg-text p:empty { height: 8px; }
.msg-buttons { display: flex; justify-content: center; gap: 6px; padding: 10px 8px 8px; }
.about { padding: 10px 14px 0; display: grid; gap: 6px; align-content: start; }
.about-top { display: flex; gap: 14px; }
.about-top strong { font-size: 14px; }
.about hr { width: 100%; border: 0; border-top: 1px solid var(--shadow); border-bottom: 1px solid var(--hilite); }
.indent { padding-left: 16px; }
.shutdown-form { display: flex; gap: 14px; padding: 12px 12px 0; }
.shutdown-form fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 4px; }
.shutdown-form legend { padding: 0 0 6px; }
.shutdown-form label { display: flex; gap: 4px; align-items: center; cursor: pointer; }
body.dimmed #desktop::after, body.dimmed #taskbar::after {
  content: ""; position: absolute; inset: 0; z-index: 99999; pointer-events: none;
  background: repeating-conic-gradient(#000 0 25%, transparent 0 50%) 0 0 / 2px 2px; opacity: 0.5;
}
body.dimmed .window.dialog { z-index: 100000 !important; }

/* ---- Taskbar & Start menu --------------------------------------------- */
#taskbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--taskbar-h) + env(safe-area-inset-bottom));
  padding: 2px 2px calc(2px + env(safe-area-inset-bottom));
  display: flex; gap: 4px; align-items: stretch;
  border-width: 2px 0 0; box-shadow: inset 0 1px var(--light);
  z-index: 50000;
}
#start { display: flex; align-items: center; gap: 3px; padding: 0 5px 0 3px; cursor: pointer; flex: none; }
#tasks { flex: 1; display: flex; gap: 3px; min-width: 0; }
.task {
  display: flex; align-items: center; gap: 4px; padding: 0 6px; flex: 0 1 160px; min-width: 32px;
  cursor: pointer; overflow: hidden; white-space: nowrap;
}
.task span { overflow: hidden; text-overflow: ellipsis; }
.task.flash { background: var(--sel); color: #fff; }
.task.pressed { font-weight: bold; background: repeating-conic-gradient(var(--hilite) 0 25%, var(--face) 0 50%) 0 0 / 2px 2px; }
#tray { display: flex; align-items: center; padding: 0 10px; background: var(--face); border-width: 1px; box-shadow: none; flex: none; cursor: default; }

#start-menu {
  position: absolute; left: 2px; bottom: calc(var(--taskbar-h) - 2px + env(safe-area-inset-bottom));
  display: flex; padding: 2px; z-index: 50001; min-width: 190px;
}
.menu-banner {
  width: 22px; background: linear-gradient(0deg, var(--title-a), var(--title-b) 90%); color: var(--face);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px;
}
.menu-banner span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 17px; letter-spacing: 1px; color: #fff; }
.menu-banner b { color: var(--face); }
.menu-items, .submenu { list-style: none; margin: 0; padding: 0; flex: 1; }
.menu-items > li { position: relative; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 8px 4px 4px; min-height: 32px;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.menu-item span:not(.arrow) { flex: 1; white-space: nowrap; }
.menu-item span:not(.arrow)::first-letter { text-decoration: underline; }
.arrow { font-size: 8px; }
.menu-item:hover, .menu-item:focus-visible, li.open > .menu-item { background: var(--sel); color: #fff; outline: none; }
.separator { margin: 3px 2px; border-top: 1px solid var(--shadow); border-bottom: 1px solid var(--hilite); }
.submenu { display: none; position: absolute; left: 100%; top: -3px; padding: 2px; min-width: 170px; }
li.open > .submenu { display: block; }
.submenu .menu-item { min-height: 24px; padding: 2px 10px 2px 4px; }

/* ---- Boot, splash, shutdown ------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100001; background: #000; color: #aaa; cursor: default;
}
.bios { margin: 0; padding: 16px; font: 15px/1.35 "Courier New", monospace; white-space: pre-wrap; }
.bios-skip { position: absolute; left: 16px; bottom: 16px; font: 13px "Courier New", monospace; color: #666; }
.splash {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(180deg, #3a6fd8 0%, #7fb0f0 55%, #c9e2ff 100%); color: #000;
}
.splash-logo { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 0 16px; }
.splash-logo img { filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.35)); }
.splash-name { font: italic bold 44px Arial, Helvetica, sans-serif; letter-spacing: -1px; }
.splash-name b { color: #fff; font-size: 34px; margin-left: 6px; text-shadow: 2px 2px 0 #000; }
.splash-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 12px;
  background: linear-gradient(90deg, #000080, #1084d0, #ffd400, #d00000, #000080) 0 0 / 200% 100%;
  animation: slide 1.2s linear infinite;
}
@keyframes slide { to { background-position: -200% 0; } }
.shutting-down { font-size: 18px; }
.overlay.safe {
  display: grid; place-content: center; text-align: center; gap: 6px; cursor: pointer;
  color: #ff8000; font: bold 28px Arial, Helvetica, sans-serif; padding: 16px;
}
.safe-hint { font-size: 12px; color: #663300; margin-top: 24px; }
.noscript { position: fixed; inset: 40% 10% auto; padding: 16px; background: #fff; text-align: center; z-index: 100002; }

/* ---- Phones ------------------------------------------------------------ */
/* Keep in sync with PHONE_QUERY in dom.js. */
@media (max-width: 640px), (max-height: 500px) and (pointer: coarse) {
  :root { --taskbar-h: 40px; }
  body { font-size: 14px; }
  #icons { grid-template-rows: repeat(auto-fill, 84px); grid-auto-columns: 84px; }
  .window:not(.dialog) {
    left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important;
    max-height: 100%; min-width: 0; border-width: 0; box-shadow: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  }
  .window.dialog { left: 8px !important; width: calc(100% - 16px) !important; }
  .window:not(.dialog) .title-button[aria-label="Maximize"], .resize-grip { display: none; }
  .window:not(.dialog) .titlebar { height: 40px; font-size: 15px; }
  .window:not(.dialog) .title-button { width: 38px; height: 32px; }
  body.kb-open #taskbar { display: none; }
  body.kb-open #desktop { bottom: 0; }
  .window.has-back .title-button.min { display: none; }
  .title-button.back { display: grid; font: bold 22px/1 Arial, sans-serif; padding-bottom: 3px; }
  #tray { display: none; }
  .task { flex: 1 1 0; min-width: 36px; max-width: 160px; }
  .icon-grid.large .icon-cell { width: 45%; }
  .btn { height: 32px; }
  .submenu { position: static; box-shadow: none; border: 0; padding-left: 24px; min-width: 0; }
  #start-menu { right: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .splash-bar { animation: none; }
}
