@tailwind base;
@tailwind components;
@tailwind utilities;

* {
  color: #000000;
}

body, button, input, select, textarea {
  font-family: "VT323", monospace;
  font-size: 18px; /* Pixel fonts are small, so we size them up */
}

/* Core window style */
.window {
  position: absolute;
  background-color: #c0c0c0; /* Window background */
  overflow: hidden; /* Prevent content from overflowing */
  display: flex;
  flex-direction: column;
}

/* The main "outset" 3D button/window style */
.win95-outset {
  border: 2px solid;
  border-color: #fefefe #808080 #808080 #fefefe;
  box-shadow: 1px 1px 0px #000;
}

/* The "inset" 3D style for fields, screens, etc. */
.win95-inset {
  border: 2px solid;
  border-color: #808080 #fefefe #fefefe #808080;
  background-color: #ffffff;
}

/* Active (pressed) button state */
.win95-button:active, .win95-tab.active, #start-button.active {
  border-color: #808080 #fefefe #fefefe #808080;
  box-shadow: none;
  transform: translate(1px, 1px);
}

/* Window title bar - keep white text */
.win95-title-bar {
  background: linear-gradient(to right, #000080, #1084d0);
  color: #ffffff !important;
  padding: 3px 5px 3px 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: move; /* Add move cursor to title bar */
  flex-shrink: 0; /* Prevent title bar from shrinking */
  min-width: 0; /* Allow flex children to shrink */
}

/* Title bar text - prevent overflow */
.win95-title-bar > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Title bar buttons container */
.win95-title-bar > div {
  flex-shrink: 0; /* Prevent buttons from shrinking */
}

/* Menu bars and toolbars - prevent overflow */
.window > div:not(.win95-title-bar) > div:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 0;
}

/* Window content area - flexible container for apps */
.window > div:last-child {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0; /* allow nested flex layouts to shrink/scroll instead of cropping */
}

/* Ensure flex containers in windows handle overflow */
.window > div {
  min-width: 0;
}

.window .flex {
  min-width: 0;
}

/* Ensure all text in title bar is white */
.win95-title-bar,
.win95-title-bar span {
  color: #ffffff !important;
}

/* Window control buttons (Min, Max, Close) */
.win95-title-bar-button {
  background-color: #c0c0c0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  line-height: 1;
  padding-bottom: 2px;
  box-sizing: border-box;
  cursor: default; /* Reset cursor for buttons */
}

/* Specific styling for the close button text */
.win95-title-bar-button span {
  margin-top: -2px;
}

/* Desktop icon styles - keep white text */
.desktop-icon {
  color: #ffffff !important;
  text-align: center;
  width: 90px;
  padding: 4px;
  cursor: pointer;
}
.desktop-icon:focus {
  background-color: rgba(0, 0, 128, 0.5); /* Selection effect */
  outline: 1px dotted #ffffff;
}
.desktop-icon svg, .desktop-icon img {
  width: 48px;
  height: 48px;
  margin: 0 auto 4px;
}
.desktop-icon span {
  padding: 0 2px;
  line-height: 1.2;
  word-break: break-word;
  color: #ffffff !important;
}
/* Keep Minesweeper label on one line */
#minesweeper.desktop-icon span {
  white-space: nowrap;
  word-break: normal;
}
/* When icon text is "selected" */
.desktop-icon:focus span {
  background-color: #000080;
  color: #ffffff !important;
}

/* Taskbar styles */
.taskbar {
  background-color: #c0c0c0;
  padding: 3px;
  box-sizing: border-box;
}

.taskbar-tab {
  height: 30px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  flex-grow: 1;
  max-width: 150px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Clock text color */
#clock {
  color: #000000;
}

/* Taskbar tab and start button text color */
.taskbar-tab,
#start-button {
  color: #000000;
}

/* Window content text colors */
.win95-inset {
  color: #000000;
}

#portfolio-content {
  color: #000000;
}

.tree-view {
  color: #000000;
}

.tree-view li {
  color: #000000;
}

/* Menu bar text - targets the first div after title bar in windows */
.window > div:nth-child(2) > div:first-child {
  color: #000000;
}

/* Window control buttons text - black text (override title bar white) */
.win95-title-bar-button span {
  color: #000000 !important;
}

/* Buttons and inputs inherit black text by default */
button, input, select, textarea {
  color: #000000;
}

/* Play Again button - ensure black text and proper background */
#snake-play-again-btn {
  color: #000000 !important;
  background-color: #c0c0c0 !important;
}

/* Center canvas in snake game window */
#snake-canvas-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  overflow: hidden; /* Prevent canvas from overflowing */
  flex: 1; /* Allow container to grow and fill available space */
}

/* Ensure canvas fits within container */
#snake-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain; /* Maintain aspect ratio */
}

/* Custom scrollbar for chat + generic window scroll containers */
.win95-scroll::-webkit-scrollbar {
  width: 16px;
}
.win95-scroll::-webkit-scrollbar-track {
  background: #dfdfdf;
  border: 1px solid #808080;
}
.win95-scroll::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fefefe #808080 #808080 #fefefe;
}

/* Simple tree-view for portfolio */
.tree-view ul {
  padding-left: 20px;
  border-left: 1px dotted #808080;
  margin-left: 8px;
}
.tree-view li {
  padding: 2px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tree-view li:hover, .tree-view li.selected {
  background-color: #000080;
  color: #ffffff;
}

/* Start Menu */
#start-menu {
  position: absolute;
  bottom: 40px; /* Height of taskbar */
  left: 0;
  width: 200px;
  background-color: #c0c0c0;
  z-index: 100;
  padding: 3px;
}
#start-menu-items {
  background-color: #c0c0c0;
  padding: 0;
  margin: 0;
}
.start-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  list-style: none;
}
/* Start menu items - black text by default, white on hover */
.start-menu-item {
  color: #000000;
}

.start-menu-item:hover {
  background-color: #000080;
  color: #ffffff !important;
}

.start-menu-item:hover span {
  color: #ffffff !important;
}
.start-menu-separator {
  border-top: 1px solid #808080;
  border-bottom: 1px solid #fefefe;
  margin: 4px 0;
}

/* Prevent double-tap zoom - apply to document but allow interactions */
html {
  touch-action: manipulation;
  -ms-touch-action: manipulation;
}

html,
body {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  overflow-y: hidden;
  overscroll-behavior: none;
}

#desktop {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

@supports (height: 100dvh) {
  body,
  #desktop {
    min-height: 100dvh;
    max-height: 100dvh;
    height: 100dvh;
  }
}

/* Ensure interactive elements can still receive touches */
button,
a,
[data-icon],
[data-menu-app],
.desktop-icon,
.start-menu-item,
.win95-button,
input,
textarea,
select,
.window {
  touch-action: auto;
}

#snake-canvas-container,
#snake-canvas {
  touch-action: none;
}
