/* TOMRULEZ.WIN — desktop, windows, taskbar, start menu */

#os {
  position: absolute;
  inset: 0;
  display: none;
  background: var(--desktop);
}

#os.active {
  display: block;
}

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

#desktop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--taskbar-h);
  left: 0;
  padding: 10px;
  overflow: hidden;
}

.desk-icon {
  position: absolute;
  width: 88px;
  padding: 6px 2px 4px;
  color: var(--hi);
  text-align: center;
  background: transparent;
  border: 1px dotted transparent;
}

.desk-icon:hover {
  background: rgba(0, 0, 128, 0.25);
}

.desk-icon.selected {
  background: rgba(0, 0, 128, 0.55);
  border-color: rgba(255, 255, 255, 0.6);
}

.desk-icon .glyph {
  display: block;
  margin-bottom: 4px;
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.6));
}

.desk-icon .label {
  display: block;
  font-size: 15px;
  line-height: 1.1;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ *
 * Windows
 * ------------------------------------------------------------------ */

#windows {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--taskbar-h);
  left: 0;
  pointer-events: none;
}

.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
  box-shadow: inset -1px -1px 0 var(--lo), inset 1px 1px 0 var(--face);
}

.win.minimized {
  display: none;
}

.win-title {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: var(--titlebar-h);
  padding: 0 2px 0 4px;
  color: var(--title-inactive-2);
  cursor: default;
  background: linear-gradient(90deg, var(--title-inactive), var(--title-inactive-2));
  user-select: none;
}

.win.focused .win-title {
  color: var(--hi);
  background: linear-gradient(90deg, var(--title), var(--title-2));
}

.win-title .t-glyph {
  flex: none;
  font-size: 14px;
  line-height: 1;
}

.win-title .t-text {
  flex: 1;
  overflow: hidden;
  font-size: 15px;
  line-height: var(--titlebar-h);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.win-btn {
  flex: none;
  width: 17px;
  height: 15px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 11px;
  color: #000;
  text-align: center;
  background: var(--face);
  border-top: 1px solid var(--hi);
  border-left: 1px solid var(--hi);
  border-right: 1px solid var(--shadow);
  border-bottom: 1px solid var(--shadow);
}

.win-btn:active {
  border-color: var(--shadow) var(--hi) var(--hi) var(--shadow);
}

.win-menu {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 1px 2px;
  font-size: 15px;
  color: #000;
  border-bottom: 1px solid var(--lo);
}

.win-menu button {
  padding: 0 7px;
  color: #000;
}

.win-menu button:hover {
  color: var(--hi);
  background: var(--title);
}

.win-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  color: #000;
}

.win-status {
  display: flex;
  flex: none;
  gap: 4px;
  padding: 2px;
  font-size: 14px;
  color: #000;
}

.win-status span {
  padding: 1px 6px;
  border-top: 1px solid var(--lo);
  border-left: 1px solid var(--lo);
  border-right: 1px solid var(--hi);
  border-bottom: 1px solid var(--hi);
}

.win-status span:first-child {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

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

#taskbar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 8000;
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--taskbar-h);
  padding: 3px 4px;
  background: var(--face);
  border-top: 2px solid var(--hi);
}

#start-btn {
  display: flex;
  flex: none;
  gap: 5px;
  align-items: center;
  height: 100%;
  padding: 0 8px;
  font-size: 16px;
  font-weight: bold;
  color: #000;
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
}

#start-btn.open {
  border-color: var(--shadow) var(--hi) var(--hi) var(--shadow);
}

#task-buttons {
  display: flex;
  flex: 1;
  gap: 3px;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.task-btn {
  display: flex;
  flex: 0 1 160px;
  gap: 5px;
  align-items: center;
  min-width: 34px;
  padding: 0 7px;
  overflow: hidden;
  font-size: 15px;
  color: #000;
  text-align: left;
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
}

.task-btn .label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.task-btn.active {
  background: repeating-conic-gradient(var(--face) 0% 25%, var(--hi) 0% 50%) 0 0 / 3px 3px;
  border-color: var(--shadow) var(--hi) var(--hi) var(--shadow);
}

#tray {
  display: flex;
  flex: none;
  gap: 5px;
  align-items: center;
  height: 100%;
  padding: 0 6px;
  font-size: 15px;
  color: #000;
  border-top: 1px solid var(--lo);
  border-left: 1px solid var(--lo);
  border-right: 1px solid var(--hi);
  border-bottom: 1px solid var(--hi);
}

.tray-btn {
  padding: 0 2px;
  font-size: 15px;
  line-height: 1;
  color: #000;
}

.tray-btn[aria-pressed='false'] {
  opacity: 0.45;
}

#tray-clock {
  min-width: 74px;
  text-align: center;
}

.tray-meter {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 13px;
}

.tray-meter .bar {
  width: 42px;
  height: 9px;
  overflow: hidden;
  background: #000;
  border-top: 1px solid var(--lo);
  border-left: 1px solid var(--lo);
  border-right: 1px solid var(--hi);
  border-bottom: 1px solid var(--hi);
}

.tray-meter .fill {
  height: 100%;
  background: linear-gradient(90deg, #00c000, #7fff00);
  transition: width 400ms linear;
}

.tray-meter.low .fill {
  background: linear-gradient(90deg, #c04000, #ffb000);
}

.tray-meter.critical .fill {
  background: linear-gradient(90deg, #a00000, #ff3030);
}

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

#start-menu {
  position: absolute;
  bottom: var(--taskbar-h);
  left: 0;
  z-index: 8100;
  display: none;
  width: 232px;
  padding: 3px;
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
}

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

.start-rail {
  flex: none;
  width: 26px;
  padding-bottom: 6px;
  background: linear-gradient(180deg, #000080, #1084d0);
}

.start-rail span {
  display: block;
  font-family: var(--pixel);
  font-size: 11px;
  color: var(--hi);
  white-space: nowrap;
  transform: rotate(180deg);
  writing-mode: vertical-rl;
}

.start-items {
  flex: 1;
  min-width: 0;
}

.start-item {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 4px 8px;
  font-size: 16px;
  color: #000;
  text-align: left;
}

.start-item:hover,
.start-item:focus-visible {
  color: var(--hi);
  background: var(--title);
}

.start-item .glyph {
  flex: none;
  width: 20px;
  font-size: 16px;
  text-align: center;
}

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

.start-sep {
  height: 2px;
  margin: 3px 2px;
  border-top: 1px solid var(--lo);
  border-bottom: 1px solid var(--hi);
}

.start-sub {
  position: absolute;
  z-index: 8200;
  display: none;
  min-width: 190px;
  padding: 3px;
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
}

.start-sub.open {
  display: block;
}

/* ------------------------------------------------------------------ *
 * Toasts (achievement / system balloons)
 * ------------------------------------------------------------------ */

#toasts {
  position: absolute;
  right: 8px;
  bottom: calc(var(--taskbar-h) + 8px);
  z-index: 8500;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  pointer-events: none;
}

.toast {
  width: 260px;
  padding: 8px 10px;
  color: #000;
  background: #ffffe1;
  border: 1px solid #000;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45);
  animation: toast-in 220ms ease-out;
}

.toast .t-head {
  margin-bottom: 2px;
  font-size: 15px;
  font-weight: bold;
}

.toast .t-body {
  font-size: 15px;
  line-height: 1.2;
}

.toast.trophy {
  color: #000;
  background: #fff3b0;
  border-color: #7a5c00;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ------------------------------------------------------------------ *
 * Modal dialogs (Abort/Retry/Fail, confirms, Run…)
 * ------------------------------------------------------------------ */

#modals {
  position: absolute;
  inset: 0;
  z-index: 9200;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.25);
}

#modals.open {
  display: grid;
}

.dialog {
  width: min(420px, 90vw);
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
}

.dialog .win-title {
  cursor: default;
}

.dialog-body {
  display: flex;
  gap: 12px;
  padding: 16px 14px;
  font-size: 16px;
  color: #000;
}

.dialog-body .d-glyph {
  flex: none;
  font-size: 28px;
  line-height: 1;
}

.dialog-body .d-text {
  line-height: 1.3;
}

.dialog-body input {
  width: 100%;
  margin-top: 8px;
  padding: 2px 4px;
  color: #000;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--hi);
  border-bottom: 2px solid var(--hi);
}

.dialog-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 0 14px 14px;
}

.btn95 {
  min-width: 82px;
  padding: 3px 12px;
  font-size: 16px;
  color: #000;
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
}

.btn95:active {
  border-color: var(--shadow) var(--hi) var(--hi) var(--shadow);
}

/* ------------------------------------------------------------------ *
 * Mobile: windows go maximized, desktop icons flow
 * ------------------------------------------------------------------ */

@media (max-width: 720px) {
  :root {
    --taskbar-h: 40px;
  }

  #desktop {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-content: flex-start;
  }

  .desk-icon {
    position: static !important;
    width: 76px;
  }

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

  .task-btn {
    flex-basis: 90px;
  }

  #tray {
    gap: 3px;
    padding: 0 3px;
  }

  #tray .tray-meter .bar {
    width: 26px;
  }
}
