@import url("https://fonts.googleapis.com/css2?family=Work+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

@font-face {
  font-family: "Microsoft Sans Serif Web";
  font-style: normal;
  font-weight: 400;
  src: url("../assets/fonts/ms-sans-regular.woff2") format("woff2");
}
@font-face {
  font-family: "Microsoft Sans Serif Web";
  font-style: normal;
  font-weight: 700;
  src: url("../assets/fonts/ms-sans-bold.woff2") format("woff2");
}

:root {
  --face: #c0c0c0;
  --face-light: #dfdfdf;
  --shadow: #808080;
  --dark-shadow: #0a0a0a;
  --highlight: #ffffff;
  --desktop: #0066ff;
  --title-active-1: #000080;
  --title-active-2: #1084d0;
  --title-inactive-1: #808080;
  --title-inactive-2: #b5b5b5;
  --title-text: #ffffff;
  --selection: #000080;
  --selection-text: #ffffff;
  --link: #0000ee;
  --ui-font: "Microsoft Sans Serif Web", "Work Sans", Tahoma, Arial, sans-serif;
  --body-font: "Microsoft Sans Serif Web", "Work Sans", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--desktop);
  color: #000;
  font-family: var(--body-font);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

button, input, select, .win-window, .win-titlebar, .start-menu, .taskbar {
  font-family: var(--body-font);
}

/* Mobile Safari/Chrome will delay taps (waiting to see if it's a double-tap
   to zoom) or hand them to text-selection/callout gestures instead of
   firing a click, unless we opt out on interactive chrome. */
button,
.desktop-icon,
.file-tile,
.win-btn,
.taskbar-app,
.start-menu li,
.start-button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.win-titlebar, .start-button, .start-menu-side {
  font-weight: 700;
}

/* ---------- 3D bevel utilities ---------- */

.bevel-out {
  box-shadow:
    inset -1px -1px 0 var(--dark-shadow),
    inset 1px 1px 0 var(--highlight),
    inset -2px -2px 0 var(--shadow),
    inset 2px 2px 0 var(--face-light);
}

.bevel-in {
  box-shadow:
    inset 1px 1px 0 var(--dark-shadow),
    inset -1px -1px 0 var(--highlight),
    inset 2px 2px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light);
}

.bevel-field {
  box-shadow:
    inset -1px -1px 0 var(--highlight),
    inset 1px 1px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light),
    inset 2px 2px 0 var(--dark-shadow);
  background: #fff;
}

/* ---------- Desktop ---------- */

.desktop {
  position: relative;
  height: 100%;
  width: 100%;
  padding: 14px;
}

.desktop-icons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 84px;
}

.desktop-icon {
  background: none;
  border: 1px solid transparent;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 84px;
  padding: 6px 2px;
  cursor: pointer;
  font-family: var(--ui-font);
  font-size: 11px;
  line-height: 1.3;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.6);
}

.desktop-icon svg,
.desktop-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
}

.desktop-icon span {
  text-align: center;
  word-break: break-word;
}

.desktop-icon:hover span,
.desktop-icon:focus span {
  background: rgba(0, 0, 128, 0.5);
}

.desktop-icon:active svg {
  transform: translateY(1px);
}

.win-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.win-layer .win-window {
  pointer-events: auto;
}

/* ---------- Window chrome ---------- */

.win-window {
  position: absolute;
  background: var(--face);
  min-width: 260px;
  display: flex;
  flex-direction: column;
  padding: 3px;
  box-shadow:
    inset -1px -1px 0 var(--dark-shadow),
    inset 1px 1px 0 var(--face-light),
    inset -2px -2px 0 var(--shadow),
    inset 2px 2px 0 var(--highlight),
    3px 3px 8px rgba(0,0,0,0.4);
}

.win-window.minimized {
  display: none;
}

.win-titlebar {
  background: linear-gradient(90deg, var(--title-active-1), var(--title-active-2));
  color: var(--title-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 3px 3px 6px;
  font-family: var(--ui-font);
  font-size: 12px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  flex-shrink: 0;
}

.win-window.inactive .win-titlebar {
  background: linear-gradient(90deg, var(--title-inactive-1), var(--title-inactive-2));
}

.win-title {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.win-title svg,
.win-title img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.win-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.win-btn {
  width: 16px;
  height: 14px;
  background: var(--face);
  border: none;
  color: transparent;
  line-height: 1;
  display: block;
  cursor: pointer;
  padding: 0;
  background-repeat: no-repeat;
  box-shadow:
    inset -1px -1px 0 var(--dark-shadow),
    inset 1px 1px 0 var(--highlight),
    inset -2px -2px 0 var(--shadow),
    inset 2px 2px 0 var(--face-light);
}

.win-btn:active {
  box-shadow:
    inset -1px -1px 0 var(--highlight),
    inset 1px 1px 0 var(--dark-shadow),
    inset -2px -2px 0 var(--face-light),
    inset 2px 2px 0 var(--shadow);
}

.win-btn[data-win-action="min"] {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='6' height='2' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23000' d='M0 0h6v2H0z'/%3E%3C/svg%3E");
  background-position: bottom 3px left 4px;
}

.win-btn[data-win-action="max"] {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='9' height='9' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9 0H0v9h9V0zM8 2H1v6h7V2z' fill='%23000'/%3E%3C/svg%3E");
  background-position: top 2px left 3px;
}

.win-btn[data-win-action="close"] {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='8' height='7' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M0 0h2v1h1v1h2V1h1V0h2v1H7v1H6v1H5v1h1v1h1v1h1v1H6V6H5V5H3v1H2v1H0V6h1V5h1V4h1V3H2V2H1V1H0V0z' fill='%23000'/%3E%3C/svg%3E");
  background-position: top 3px left 4px;
}

.win-menubar {
  display: flex;
  gap: 14px;
  padding: 3px 8px;
  font-size: 12px;
  border-bottom: 1px solid var(--shadow);
  flex-shrink: 0;
}

.win-menubar span {
  cursor: default;
}
.win-menubar span:hover {
  background: var(--selection);
  color: var(--selection-text);
  padding: 0 2px;
  margin: 0 -2px;
}

.win-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--shadow);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.win-toolbar .addr-label {
  font-size: 11px;
  flex-shrink: 0;
}

.win-toolbar .addr-field {
  flex: 1;
  min-width: 140px;
  padding: 3px 6px;
  font-size: 11px;
  font-family: var(--body-font);
  background: #fff;
  box-shadow:
    inset -1px -1px 0 var(--highlight),
    inset 1px 1px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light),
    inset 2px 2px 0 var(--dark-shadow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-body {
  flex: 1;
  overflow: auto;
  padding: 10px;
  min-height: 0;
  background: #fff;
}

.win-statusbar {
  display: flex;
  justify-content: space-between;
  padding: 3px 8px;
  font-size: 11px;
  border-top: 1px solid var(--shadow);
  flex-shrink: 0;
}

.win-statusbar span {
  padding: 1px 8px;
}

.win-statusbar span + span {
  box-shadow:
    inset 1px 1px 0 var(--shadow),
    inset -1px -1px 0 var(--highlight);
}

/* ---------- Buttons / filter toolbar ---------- */

.btn98 {
  background: var(--face);
  border: none;
  font-family: var(--body-font);
  font-size: 12px;
  padding: 5px 12px;
  cursor: pointer;
  box-shadow:
    inset -1px -1px 0 var(--dark-shadow),
    inset 1px 1px 0 var(--highlight),
    inset -2px -2px 0 var(--shadow),
    inset 2px 2px 0 var(--face-light);
}

.btn98:disabled {
  color: var(--shadow);
  cursor: default;
}

.btn98:active {
  box-shadow:
    inset 1px 1px 0 var(--dark-shadow),
    inset -1px -1px 0 var(--highlight),
    inset 2px 2px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light);
  padding-top: 6px;
  padding-left: 13px;
  padding-bottom: 4px;
  padding-right: 11px;
}

.btn98.pressed {
  box-shadow:
    inset 1px 1px 0 var(--dark-shadow),
    inset -1px -1px 0 var(--highlight),
    inset 2px 2px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light);
  background: var(--face-light);
}

/* ---------- Explorer icon grid ---------- */

.explorer-pane {
  flex: 1;
  overflow: auto;
  padding: 10px;
  background: #fff;
  min-height: 200px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 4px;
}

.file-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border: 1px dotted transparent;
  cursor: pointer;
  text-align: center;
}

.file-tile:hover {
  border-color: #000;
}

.file-tile:active,
.file-tile.selected {
  background: var(--selection);
  color: var(--selection-text);
}

.file-tile .thumb {
  width: 64px;
  height: 64px;
  background: var(--face);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow:
    inset -1px -1px 0 var(--highlight),
    inset 1px 1px 0 var(--shadow);
  position: relative;
}

.file-tile .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}

.file-tile .thumb .placeholder-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-tile .thumb .placeholder-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.file-tile .thumb-folder {
  background: transparent;
  box-shadow: none;
}

.file-tile .thumb-folder .placeholder-icon {
  width: 48px;
  height: 48px;
}

.file-tile .filename {
  font-size: 11px;
  font-family: var(--body-font);
  line-height: 1.25;
  max-width: 92px;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Detail window content ---------- */

.detail-hero {
  width: 100%;
  max-height: 320px;
  background: var(--face);
  box-shadow:
    inset -1px -1px 0 var(--highlight),
    inset 1px 1px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light),
    inset 2px 2px 0 var(--dark-shadow);
  padding: 4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.detail-hero img {
  max-width: 100%;
  max-height: 300px;
  display: block;
  object-fit: contain;
  cursor: zoom-in;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

.detail-hero .placeholder-icon {
  width: 64px;
  height: 64px;
}

.detail-thumbstrip {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.detail-thumbstrip img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  box-shadow:
    inset -1px -1px 0 var(--highlight),
    inset 1px 1px 0 var(--shadow);
}

.detail-thumbstrip img.active {
  box-shadow: 0 0 0 2px var(--selection);
}

.detail-caption {
  font-size: 11px;
  color: #444;
  margin: 0 0 12px;
}

.detail-meta {
  font-family: var(--body-font);
  font-size: 12px;
  color: #333;
  margin-bottom: 8px;
}

.detail-title {
  font-family: var(--ui-font);
  font-size: 15px;
  margin: 0 0 8px;
  line-height: 1.4;
}

.detail-desc {
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.email-window {
  background: #fff;
  box-shadow:
    inset -1px -1px 0 var(--highlight),
    inset 1px 1px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light),
    inset 2px 2px 0 var(--dark-shadow);
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 12px;
}

.email-window .row {
  display: flex;
  gap: 6px;
  padding: 2px 0;
}

.email-window .row + .row {
  border-top: 1px dotted var(--shadow);
}

.email-window .label {
  font-weight: bold;
  flex-shrink: 0;
  width: 60px;
}

.detail-facts {
  font-size: 12px;
  margin-bottom: 12px;
}

.detail-facts div {
  padding: 2px 0;
}

.detail-facts .fact-label {
  font-weight: bold;
}

/* ---------- About / Notepad window ---------- */

.notepad-body {
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.notepad-body .np-name {
  font-family: var(--ui-font);
  font-size: 16px;
  margin: 0 0 4px;
}

.notepad-body .np-tagline {
  color: #000080;
  margin: 0 0 14px;
}

.notepad-body a {
  color: var(--link);
  text-decoration: underline;
}

/* ---------- Doom ---------- */

.doom-body {
  flex: 1;
  padding: 0;
  background: #000;
  min-height: 0;
  overflow: hidden;
  display: flex;
}

.doom-mount {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.doom-loading {
  color: #999;
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

/* ---------- Taskbar ---------- */

.taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34px;
  background: var(--face);
  display: flex;
  align-items: center;
  padding: 3px 4px;
  gap: 6px;
  z-index: 5000;
  box-shadow:
    inset 0 1px 0 var(--highlight);
}

.start-button {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px;
  font-family: var(--body-font);
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  background: var(--face);
  border: none;
  box-shadow:
    inset -1px -1px 0 var(--dark-shadow),
    inset 1px 1px 0 var(--highlight),
    inset -2px -2px 0 var(--shadow),
    inset 2px 2px 0 var(--face-light);
}

.start-button.open,
.start-button:active {
  box-shadow:
    inset 1px 1px 0 var(--dark-shadow),
    inset -1px -1px 0 var(--highlight),
    inset 2px 2px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light);
}

.start-button svg,
.start-button img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
}

.taskbar-divider {
  width: 2px;
  height: 24px;
  box-shadow:
    inset 1px 0 0 var(--shadow),
    inset -1px 0 0 var(--highlight);
}

.taskbar-items {
  flex: 1;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  height: 26px;
}

.taskbar-app {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
  font-family: var(--body-font);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  background: var(--face);
  border: none;
  box-shadow:
    inset -1px -1px 0 var(--dark-shadow),
    inset 1px 1px 0 var(--highlight),
    inset -2px -2px 0 var(--shadow),
    inset 2px 2px 0 var(--face-light);
}

.taskbar-app.active {
  box-shadow:
    inset 1px 1px 0 var(--dark-shadow),
    inset -1px -1px 0 var(--highlight),
    inset 2px 2px 0 var(--shadow),
    inset -2px -2px 0 var(--face-light);
}

.taskbar-app svg,
.taskbar-app img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.taskbar-tray {
  height: 26px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  font-size: 11px;
  font-family: var(--body-font);
  box-shadow:
    inset 1px 1px 0 var(--shadow),
    inset -1px -1px 0 var(--highlight);
}

/* ---------- Start menu ---------- */

.start-menu {
  position: fixed;
  left: 3px;
  bottom: 37px;
  width: 220px;
  background: var(--face);
  z-index: 6000;
  display: flex;
  box-shadow:
    inset -1px -1px 0 var(--dark-shadow),
    inset 1px 1px 0 var(--highlight),
    inset -2px -2px 0 var(--shadow),
    inset 2px 2px 0 var(--face-light),
    3px 3px 8px rgba(0,0,0,0.4);
}

.start-menu[hidden] {
  display: none;
}

.start-menu-side {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  background: linear-gradient(180deg, var(--title-active-1), var(--title-active-2));
  color: #fff;
  font-family: var(--ui-font);
  font-weight: bold;
  font-size: 15px;
  padding: 10px 4px;
  letter-spacing: 1px;
}

.start-menu ul {
  list-style: none;
  margin: 0;
  padding: 3px;
  flex: 1;
}

.start-menu li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.start-menu li svg,
.start-menu li img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.start-menu li:hover {
  background: var(--selection);
  color: var(--selection-text);
}

.start-menu li.divider {
  height: 1px;
  padding: 0;
  margin: 4px 2px;
  box-shadow:
    inset 0 1px 0 var(--shadow),
    inset 0 -1px 0 var(--highlight);
  cursor: default;
}

.start-menu li.divider:hover {
  background: none;
}

/* ---------- Shutdown screen ---------- */

.shutdown-screen {
  position: fixed;
  inset: 0;
  background: #000;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--body-font);
  font-size: 18px;
  z-index: 9999;
  text-align: center;
  padding: 20px;
}

.shutdown-screen[hidden] { display: none; }

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 8000;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 88vh;
  display: block;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  padding: 8px 12px;
  font-size: 34px;
  line-height: 1;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- Empty state ---------- */

.empty-state {
  padding: 30px;
  text-align: center;
  color: #555;
  font-size: 12px;
}

/* ---------- Scrollbars (Chromium/WebKit) ---------- */

.win-body::-webkit-scrollbar,
.explorer-pane::-webkit-scrollbar {
  width: 16px;
}
.win-body::-webkit-scrollbar-track,
.explorer-pane::-webkit-scrollbar-track {
  background: var(--face);
  box-shadow: inset 1px 1px 0 var(--shadow);
}
.win-body::-webkit-scrollbar-thumb,
.explorer-pane::-webkit-scrollbar-thumb {
  background: var(--face);
  box-shadow:
    inset -1px -1px 0 var(--dark-shadow),
    inset 1px 1px 0 var(--highlight),
    inset -2px -2px 0 var(--shadow),
    inset 2px 2px 0 var(--face-light);
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .desktop { padding: 8px; }
  .desktop-icons { width: 72px; }
  .desktop-icon { width: 72px; font-size: 10px; }

  .win-window {
    position: fixed !important;
    left: 4px !important;
    right: 4px;
    top: 4px !important;
    bottom: 42px !important;
    width: auto !important;
    height: auto !important;
  }

  .icon-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }

  /* Window control buttons are 16x14 on desktop — far too small to tap
     reliably. Enlarge the tap target and re-center the icon (which is
     positioned via edge offsets tuned for the smaller size). */
  .win-controls {
    gap: 6px;
  }

  .win-btn {
    width: 36px;
    height: 32px;
    background-position: center !important;
    background-size: 16px 14px;
  }

  .file-tile {
    padding: 10px 6px;
  }

  .start-menu li {
    padding: 12px 10px;
    font-size: 14px;
  }

  .start-button,
  .taskbar-app {
    min-height: 36px;
  }
}
