/* ═══════════════════════════════════════════════════════════════════════════
   Win98 Desktop Layout — icons, windows, taskbar
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Full-screen container ─────────────────────────────────────────────── */

#desktop {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#desktop-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ── Icon grid ─────────────────────────────────────────────────────────── */

#icon-grid {
  position: absolute;
  inset: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, 86px);
  grid-auto-rows: 82px;
  align-content: start;
  gap: 4px;
}

.desktop-icon {
  width: 86px;
  height: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.icon-image-wrap {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.desktop-icon img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  pointer-events: none;
}

.desktop-icon-label {
  font-size: 13px;
  text-align: center;
  color: #fff;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.9);
  max-width: 80px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.2;
  margin-top: 2px;
  padding: 1px 3px;
}

.desktop-icon.selected .desktop-icon-label {
  background: #000080;
  text-shadow: none;
}

.desktop-icon.selected .icon-image-wrap {
  background: rgba(0, 0, 128, 0.35);
}

/* ── Window ────────────────────────────────────────────────────────────── */

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #c0c0c0;
  padding: 3px;
  min-width: 150px;
  min-height: 100px;
}

.window.minimized {
  display: none;
}

/* ── Resize grip ───────────────────────────────────────────────────────── */

.window-resize-grip {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 10;
  background:
    linear-gradient(135deg,
      transparent 0%, transparent 30%,
      #808080 30%, #808080 35%,
      transparent 35%, transparent 45%,
      #808080 45%, #808080 50%,
      transparent 50%, transparent 60%,
      #808080 60%, #808080 65%,
      transparent 65%
    );
}

.window-focus-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  cursor: default;
}

.window.maximized .window-resize-grip {
  display: none;
}

.window.maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

.window-titlebar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  height: 28px;
  background: #000080;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  cursor: move;
  flex-shrink: 0;
}

.window-titlebar.inactive {
  background: #808080;
}

.window-titlebar img {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.window-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: bold;
}

.title-buttons {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-left: auto;
  flex-shrink: 0;
}

.title-buttons .spacer {
  width: 2px;
}

/* ── Window menu bar ───────────────────────────────────────────────────── */

.window-menubar {
  display: flex;
  align-items: center;
  height: 26px;
  background: #c0c0c0;
  border-bottom: 1px solid #808080;
  padding: 0 6px;
  gap: 8px;
  flex-shrink: 0;
}

.menu-item {
  position: relative;
}

.menu-item-btn {
  height: 20px;
  padding: 0 4px;
  font-size: 13px;
  font-family: inherit;
  background: none;
  border: none;
  cursor: default;
}

.menu-item-btn:hover {
  box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #ffffff;
}

.menu-item-btn.active {
  box-shadow: inset -1px -1px 0 #ffffff, inset 1px 1px 0 #808080;
}

/* ── Menu dropdown ─────────────────────────────────────────────────────── */

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 200;
  background: #c0c0c0;
  min-width: 180px;
  padding: 3px 0;
}

.menu-dropdown-item {
  width: 100%;
  text-align: left;
  padding: 4px 24px;
  font-size: 13px;
  font-family: inherit;
  border: none;
  background: none;
  cursor: default;
  display: block;
}

.menu-dropdown-item:hover {
  background: #000080;
  color: #fff;
}

.menu-dropdown-item.disabled {
  color: #808080;
}

.menu-dropdown-item.disabled:hover {
  background: none;
  color: #808080;
}

.menu-dropdown-divider {
  margin: 2px;
  height: 0;
  border-top: 1px solid #808080;
  border-bottom: 1px solid #fff;
}

/* ── Window body ───────────────────────────────────────────────────────── */

.window-body {
  flex: 1;
  overflow: auto;
  background: #fff;
  margin-top: 2px;
  padding: 4px;
}

/* ── Print bar ─────────────────────────────────────────────────────────── */

.print-bar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 6px;
  border-top: 1px solid #808080;
  background: #c0c0c0;
  flex-shrink: 0;
}

/* ── Folder view inside a window ───────────────────────────────────────── */

.folder-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, 86px);
  grid-auto-rows: 82px;
  gap: 4px;
  padding: 4px;
}

.folder-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  cursor: default;
  user-select: none;
}

.folder-item img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  pointer-events: none;
}

.folder-item span {
  font-size: 12px;
  text-align: center;
  max-width: 80px;
  word-wrap: break-word;
  line-height: 1.2;
  margin-top: 2px;
}

.folder-item:hover {
  background: rgba(0, 0, 128, 0.1);
}

.folder-item.selected span {
  background: #000080;
  color: #fff;
}

/* ── Text content styling ──────────────────────────────────────────────── */

.text-content {
  font-size: 14px;
  line-height: 1.5;
  padding: 6px;
}

.text-content h1 { font-size: 18px; font-weight: bold; margin-bottom: 8px; }
.text-content h2 { font-size: 16px; font-weight: bold; margin-bottom: 6px; }
.text-content h3 { font-size: 14px; font-weight: bold; margin-bottom: 4px; }
.text-content p { margin-bottom: 6px; }
.text-content ul { list-style: disc; margin-left: 18px; }
.text-content ol { list-style: decimal; margin-left: 18px; }
.text-content li { margin-bottom: 4px; }
.text-content b { font-weight: bold; }
.text-content i { font-style: italic; }

/* ── Taskbar ───────────────────────────────────────────────────────────── */

#taskbar {
  height: 40px;
  flex-shrink: 0;
  background: #c0c0c0;
  display: flex;
  align-items: center;
  padding: 0 3px;
  gap: 3px;
  box-shadow: inset 0 1px 0 #fff;
  position: relative;
}

#start-btn {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  font-size: 15px;
  font-weight: bold;
  font-family: inherit;
  flex-shrink: 0;
}

#start-btn img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

#taskbar-separator {
  width: 2px;
  height: 32px;
  flex-shrink: 0;
  border-left: 1px solid #808080;
  border-right: 1px solid #fff;
}

#taskbar-window-area {
  flex: 1;
  display: flex;
  gap: 3px;
  overflow-x: hidden;
  min-width: 0;
}

.taskbar-btn {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  font-size: 14px;
  font-family: inherit;
  max-width: 180px;
  min-width: 0;
  overflow: hidden;
  border: none;
  cursor: default;
  background: #c0c0c0;
}

.taskbar-btn img {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.taskbar-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.taskbar-btn.active {
  font-weight: bold;
}

#taskbar-clock {
  height: 32px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ── Start Menu ────────────────────────────────────────────────────────── */

#start-menu {
  position: absolute;
  bottom: 40px;
  left: 3px;
  background: #c0c0c0;
  display: none;
  min-width: 240px;
  z-index: 9500;
}

#start-menu.open {
  display: flex;
}

.start-menu-banner {
  width: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  background: linear-gradient(to top, #000080, #1084d0);
}

.start-menu-banner span {
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 2px;
}

.start-menu-items {
  flex: 1;
  padding: 3px 0;
}

.start-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: default;
  border: none;
  background: none;
  text-align: left;
}

.start-menu-item:hover {
  background: #000080;
  color: #fff;
}

.start-menu-item img {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.start-menu-item .icon-placeholder {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.start-menu-item .arrow {
  margin-left: auto;
  font-size: 10px;
}

.start-menu-divider {
  margin: 3px 4px;
  height: 0;
  border-top: 1px solid #808080;
  border-bottom: 1px solid #fff;
}

/* Submenu */
.start-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background: #c0c0c0;
  min-width: 180px;
  padding: 3px 0;
  display: none;
}

.start-menu-item:hover .start-submenu {
  display: block;
}

.start-submenu .start-menu-item img {
  width: 20px;
  height: 20px;
}

/* ── Context Menu ──────────────────────────────────────────────────────── */

.context-menu {
  position: fixed;
  background: #c0c0c0;
  padding: 3px 0;
  min-width: 160px;
  z-index: 9000;
}

.context-menu-item {
  width: 100%;
  text-align: left;
  padding: 4px 24px;
  font-size: 13px;
  font-family: inherit;
  border: none;
  background: none;
  cursor: default;
  display: block;
}

.context-menu-item:hover {
  background: #000080;
  color: #fff;
}

.context-menu-divider {
  margin: 2px;
  height: 0;
  border-top: 1px solid #808080;
  border-bottom: 1px solid #fff;
}

/* ── Mobile: Tablet (max-width: 768px) ────────────────────────────────── */

@media (max-width: 768px) {
  #icon-grid {
    grid-template-columns: repeat(auto-fill, 72px);
    grid-auto-rows: 72px;
    padding: 6px;
    gap: 2px;
  }

  .desktop-icon {
    width: 72px;
    height: 72px;
  }

  .desktop-icon img {
    width: 40px;
    height: 40px;
  }

  .desktop-icon-label {
    font-size: 11px;
    max-width: 68px;
  }

  /* Taskbar: touch-friendly */
  #taskbar {
    height: 44px;
  }

  #start-btn {
    height: 36px;
    padding: 0 10px;
  }

  #taskbar-separator {
    height: 36px;
  }

  .taskbar-btn {
    height: 36px;
    max-width: 120px;
    padding: 0 6px;
  }

  #taskbar-clock {
    height: 36px;
    padding: 0 8px;
    font-size: 13px;
  }

  /* Start menu */
  #start-menu {
    bottom: 44px;
    min-width: 220px;
    max-width: 80vw;
  }

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

  /* Submenus drop below on mobile instead of flying right */
  .start-submenu {
    position: static;
    min-width: 0;
    border-top: 1px solid #808080;
  }

  /* Title buttons: larger touch targets */
  .title-buttons {
    gap: 4px;
  }

  /* Context menu items */
  .context-menu-item {
    padding: 10px 24px;
    font-size: 14px;
  }

  /* Menu dropdown items */
  .menu-dropdown-item {
    padding: 10px 24px;
    font-size: 14px;
  }

  /* Resize grip: bigger for touch */
  .window-resize-grip {
    width: 24px;
    height: 24px;
  }

  /* Folder view */
  .folder-view {
    grid-template-columns: repeat(auto-fill, 72px);
    grid-auto-rows: 72px;
  }

  .folder-item img {
    width: 40px;
    height: 40px;
  }
}

/* ── Mobile: Phone (max-width: 480px) ─────────────────────────────────── */

@media (max-width: 480px) {
  #icon-grid {
    grid-template-columns: repeat(auto-fill, 64px);
    grid-auto-rows: 68px;
    padding: 4px;
  }

  .desktop-icon {
    width: 64px;
    height: 68px;
  }

  .desktop-icon img {
    width: 36px;
    height: 36px;
  }

  .desktop-icon-label {
    font-size: 10px;
    max-width: 60px;
  }

  /* Start menu: full width */
  #start-menu {
    min-width: 0;
    max-width: none;
    width: calc(100vw - 6px);
    left: 0;
  }

  /* Taskbar buttons: icon only */
  .taskbar-btn span {
    display: none;
  }

  .taskbar-btn {
    max-width: 44px;
    padding: 0 6px;
    justify-content: center;
  }
}
