/* === DOS VGA Font (for BIOS boot + mobile DOS view) === */
@font-face {
  font-family: "Perfect DOS VGA 437";
  src: url("vendor/PerfectDOSVGA437.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* === Custom Properties === */
:root {
  --win98-teal: #008080;
  --win98-silver: #c0c0c0;
  --win98-navy: #000080;
  --win98-white: #ffffff;
  --win98-black: #000000;
  --win98-grey: grey;
  --win98-dark: #0a0a0a;
  --win98-light: #dfdfdf;
  --taskbar-height: 28px;
  --icon-size: 48px;
  --icon-cell-width: 75px;
  --icon-cell-height: 80px;
}

/* === Win98 Cursors === */
body {
  cursor: url('img/cursors/arrow.png') 0 0, default;
}

a, [role="menuitem"] {
  cursor: url('img/cursors/pointer.png') 6 0, pointer;
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  zoom: 1.5; /* Scale everything 150% to mimic 1024x768-era low-res feel */
}

/* === Screen Reader Only === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Skip Navigation === */
.skip-links a {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100000;
  padding: 8px 16px;
  background: var(--win98-navy);
  color: var(--win98-white);
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  text-decoration: none;
}

.skip-links a:focus {
  left: 0;
}

/* === Desktop === */
#desktop {
  background: var(--win98-teal);
  background-image: url('img/clouds.webp');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* === Icon Grid === */
#icon-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, var(--icon-cell-height));
  gap: 4px;
  padding: 8px;
  height: calc(100% - var(--taskbar-height));
  align-content: start;
  justify-content: start;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: var(--icon-cell-width);
  padding: 4px;
  cursor: default;
  user-select: none;
  border: 1px solid transparent;
  text-decoration: none;
}

.desktop-icon img {
  width: var(--icon-size);
  height: var(--icon-size);
  image-rendering: pixelated;
  pointer-events: none;
}

.desktop-icon-label {
  color: var(--win98-white);
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  text-align: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9);
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  margin-top: 2px;
  padding: 1px 2px;
}

.desktop-icon[data-selected="true"] {
  outline: 1px dotted var(--win98-white);
  outline-offset: -1px;
}

.desktop-icon[data-selected="true"] .desktop-icon-label {
  background: var(--win98-navy);
  color: var(--win98-white);
  text-shadow: none;
}

.desktop-icon:focus-visible {
  outline: 1px dotted var(--win98-white);
  outline-offset: -1px;
}

/* === Windows === */
.window {
  position: absolute;
  display: none;
  min-width: 300px;
  min-height: 200px;
  max-width: calc(100% - 8px);
  max-height: calc(100% - var(--taskbar-height) - 8px);
}

.window[data-state="open"],
.window[data-state="maximized"] {
  display: block;
}

.window[data-state="maximized"] {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: calc(100% - var(--taskbar-height)) !important;
  transform: none !important;
}

.window .title-bar {
  cursor: default;
}

.window .window-body {
  overflow: auto;
  background: var(--win98-white);
}

/* === Project Window Content === */
.project-screenshot {
  width: 100%;
  max-width: 640px;
  height: auto;
  display: block;
  margin-bottom: 8px;
  border: 1px solid var(--win98-grey);
}

.project-description {
  margin: 8px 0;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  line-height: 1.5;
}

.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0;
}

.tech-pill {
  background: var(--win98-silver);
  border: 1px solid;
  border-color: var(--win98-white) var(--win98-dark) var(--win98-dark) var(--win98-white);
  box-shadow: inset 1px 1px var(--win98-light), inset -1px -1px var(--win98-grey);
  padding: 1px 6px;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 10px;
}

.project-links {
  margin: 8px 0;
}

.project-links a {
  margin-right: 12px;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
}

/* === Taskbar === */
#taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--taskbar-height);
  background: var(--win98-silver);
  border-top: 1px solid var(--win98-white);
  box-shadow: inset 0 1px 0 var(--win98-light);
  display: flex;
  align-items: center;
  padding: 2px;
  gap: 2px;
  z-index: 9000;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
}

#start-button {
  font-weight: bold;
  font-size: 11px;
  min-width: 54px;
  height: 22px;
  padding: 0 6px;
  margin-left: 2px;
  display: flex;
  align-items: center;
  gap: 3px;
}

#taskbar-buttons {
  flex: 1;
  display: flex;
  gap: 2px;
  overflow: hidden;
}

.taskbar-window-btn {
  height: 22px;
  min-width: 60px;
  max-width: 160px;
  flex: 1 1 auto;
  padding: 0 6px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
}

.taskbar-window-btn[aria-pressed="true"] {
  font-weight: bold;
  box-shadow: inset -1px -1px var(--win98-white),
              inset 1px 1px var(--win98-dark),
              inset -2px -2px var(--win98-light),
              inset 2px 2px var(--win98-grey);
}

#system-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  height: 22px;
  border-left: 1px solid var(--win98-grey);
  box-shadow: inset 1px 0 0 var(--win98-white);
  margin-left: auto;
}

#visitor-counter,
#clock {
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
}

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

/* === Start Menu === */
#start-menu {
  position: fixed;
  bottom: var(--taskbar-height);
  left: 0;
  width: 180px;
  background: var(--win98-silver);
  border: 1px solid;
  border-color: var(--win98-white) var(--win98-dark) var(--win98-dark) var(--win98-white);
  box-shadow: inset 1px 1px var(--win98-light), inset -1px -1px var(--win98-grey);
  padding: 2px;
  z-index: 9500;
  display: none;
}

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

.start-menu-sidebar {
  position: absolute;
  left: 2px;
  top: 2px;
  bottom: 2px;
  width: 22px;
  background: linear-gradient(180deg, var(--win98-navy), #1084d0);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--win98-white);
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 18px;
  letter-spacing: 1px;
  padding: 8px 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.sidebar-windows { font-weight: normal; }
.sidebar-98 { font-weight: bold; }

.start-menu-items {
  margin-left: 24px;
  list-style: none;
  padding: 2px 0;
}

.start-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  cursor: default;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  height: 24px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--win98-black);
}

.start-menu-item:hover,
.start-menu-item:focus-visible {
  background: var(--win98-navy);
  color: var(--win98-white);
  outline: none;
}

.start-menu-separator {
  height: 1px;
  background: var(--win98-grey);
  margin: 2px 0 2px 24px;
  box-shadow: 0 1px 0 var(--win98-white);
}

/* === Cascading Submenus === */
.has-submenu {
  position: relative;
}

.start-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: -3px;
  min-width: 180px;
  background: var(--win98-silver);
  border: 1px solid;
  border-color: var(--win98-white) var(--win98-dark) var(--win98-dark) var(--win98-white);
  box-shadow: inset 1px 1px var(--win98-light), inset -1px -1px var(--win98-grey);
  padding: 2px;
  list-style: none;
  margin: 0;
  z-index: 9501;
}

.start-submenu .start-submenu {
  z-index: 9502;
}

.has-submenu.submenu-open > .start-submenu {
  display: block;
}

/* Top-level items: taller for 32x32 icons */
.start-menu-item-lg {
  height: 38px !important;
  padding: 3px 8px !important;
}

.start-icon-32 {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.start-icon-16 {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.start-item-label {
  flex: 1;
}

.submenu-arrow {
  margin-left: auto;
  font-size: 8px;
  line-height: 1;
  padding-right: 4px;
}

.start-menu-item:hover .submenu-arrow,
.start-menu-item:focus-visible .submenu-arrow {
  color: var(--win98-white);
}

/* === Quick Launch === */
#quick-launch {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px;
  border-right: 1px solid var(--win98-grey);
  box-shadow: 1px 0 0 var(--win98-white);
  margin-right: 4px;
}

.quick-launch-btn {
  background: none;
  border: none;
  padding: 2px;
  min-width: auto;
  min-height: auto;
  box-shadow: none;
  cursor: default;
}

.quick-launch-btn:hover {
  box-shadow: inset -1px -1px var(--win98-dark), inset 1px 1px var(--win98-white);
}

.quick-launch-btn:active {
  box-shadow: inset 1px 1px var(--win98-dark), inset -1px -1px var(--win98-white);
}

.quick-launch-btn img {
  display: block;
  image-rendering: pixelated;
}

/* === Shutdown Overlay === */
#shutdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99998;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FF8C00;
  font-family: "Perfect DOS VGA 437", "Lucida Console", monospace;
  font-size: 20px;
  text-align: center;
  line-height: 1.6;
}

/* === Notepad Style === */
.notepad-menu-bar {
  display: flex;
  padding: 2px 4px;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  background: var(--win98-silver);
}

.notepad-menu-bar span {
  padding: 2px 6px;
  cursor: default;
}

.notepad-menu-bar span:hover {
  background: var(--win98-navy);
  color: var(--win98-white);
}

.notepad-content {
  background: var(--win98-white);
  padding: 4px;
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 200px;
  white-space: pre-wrap;
  overflow: auto;
}

/* === Guestbook === */
.guestbook-entry {
  border-bottom: 1px solid var(--win98-grey);
  padding: 8px 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 12px;
}

.guestbook-entry:last-child {
  border-bottom: none;
}

.guestbook-name {
  font-weight: bold;
  color: #0000ff;
}

.guestbook-date {
  color: var(--win98-grey);
  font-size: 10px;
  margin-left: 8px;
}

.guestbook-message {
  margin-top: 4px;
  line-height: 1.4;
}

/* === Mobile / Touch ===
   Only trigger mobile view for actual touch devices (no hover + coarse pointer).
   Desktop browsers keep the full experience at ANY window width. */
@media (hover: none) and (pointer: coarse) {
  html, body {
    height: auto;
    overflow: auto;
    zoom: 1;
  }

  #desktop {
    display: none !important;
  }

  #start-menu,
  #taskbar {
    display: none !important;
  }

  #mobile-view {
    display: block !important;
  }

  .desktop-notice {
    display: block !important;
  }
}

/* Desktop: always show desktop UI when hover+fine pointer (mouse) is available */
@media (hover: hover) and (pointer: fine) {
  #mobile-view {
    display: none !important;
  }

  .desktop-notice {
    display: none !important;
  }
}

/* === Mobile View (DOS Terminal) === */
#mobile-view {
  display: none;
}

#dos-terminal {
  background: #000000;
  color: #AAAAAA;
  font-family: "Perfect DOS VGA 437", "Lucida Console", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.4;
  padding: 16px;
  min-height: 100vh;
}

.dos-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.dos-file-entry {
  color: #FFFFFF;
  display: block;
  padding: 2px 0;
  text-decoration: none;
  white-space: pre;
}

.dos-file-entry:active {
  background: #0000AA;
  color: #FFFFFF;
}

.dos-blink {
  animation: dos-cursor-blink 1s step-end infinite;
}

@keyframes dos-cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.dos-easter-egg {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #333;
}

/* === Context Menus === */
.context-menu {
  position: fixed;
  display: none;
  background: var(--win98-silver);
  border: 1px solid;
  border-color: var(--win98-white) var(--win98-dark) var(--win98-dark) var(--win98-white);
  box-shadow: inset 1px 1px var(--win98-light), inset -1px -1px var(--win98-grey);
  padding: 2px;
  z-index: 9600;
  min-width: 140px;
}

.context-menu.open {
  display: block;
}

.context-menu-item {
  display: block;
  width: 100%;
  padding: 4px 24px 4px 8px;
  cursor: default;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  border: none;
  background: none;
  text-align: left;
  color: var(--win98-black);
}

.context-menu-item:hover,
.context-menu-item:focus-visible {
  background: var(--win98-navy);
  color: var(--win98-white);
  outline: none;
}

.context-menu-separator {
  height: 1px;
  background: var(--win98-grey);
  margin: 2px 0;
  box-shadow: 0 1px 0 var(--win98-white);
}

/* === Selection Rectangle === */
#selection-rect {
  position: absolute;
  border: 1px dotted var(--win98-navy);
  background: rgba(0, 0, 128, 0.08);
  pointer-events: none;
  display: none;
  z-index: 5;
}

/* === Title Bar Icons === */
.title-bar-icon {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

/* === Firefox Scrollbar Compatibility === */
* {
  scrollbar-color: #dfdfdf silver;
  scrollbar-width: auto;
}

/* === Focus Indicators (Win98 dotted outline) === */
button:focus-visible,
a:focus-visible,
[role="menuitem"]:focus-visible {
  outline: 1px dotted var(--win98-black);
  outline-offset: -1px;
}

.desktop-icon:focus-visible {
  outline: 1px dotted var(--win98-white);
  outline-offset: -1px;
}

.window:focus-visible {
  outline: none;
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === High Contrast / Forced Colors === */
@media (forced-colors: active) {
  .desktop-icon-label {
    text-shadow: none;
    background: Canvas;
    color: CanvasText;
  }

  .desktop-icon[data-selected="true"] .desktop-icon-label {
    background: Highlight;
    color: HighlightText;
  }

  .start-menu-sidebar {
    background: Highlight;
  }
}

/* === System Properties Dialog === */
.sysprop-window {
  min-width: 360px;
  min-height: auto;
}

.sysprop-tabs {
  display: flex;
  gap: 0;
  padding: 0;
  margin: 0 0 -1px 0;
  list-style: none;
}

.sysprop-tabs [role="tab"] {
  padding: 4px 12px;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  cursor: default;
  background: var(--win98-silver);
  border: 1px solid var(--win98-grey);
  border-bottom: none;
  margin-right: 1px;
  position: relative;
  top: 1px;
  border-radius: 2px 2px 0 0;
}

.sysprop-tabs [role="tab"][aria-selected="true"] {
  background: var(--win98-white);
  border-bottom: 1px solid var(--win98-white);
  z-index: 1;
  font-weight: bold;
  top: 0;
  padding-top: 5px;
}

.sysprop-panel-area {
  background: var(--win98-white);
  border: 1px solid var(--win98-grey);
  min-height: 200px;
  padding: 12px;
}

.sysprop-panel {
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  line-height: 1.6;
}

.sysprop-general {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.sysprop-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.sysprop-monitor {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sysprop-monitor-screen {
  width: 72px;
  height: 56px;
  background: #000080;
  border: 3px solid #808080;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sysprop-flag {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  width: 28px;
  height: 28px;
  gap: 2px;
  transform: rotate(-8deg);
}

.flag-r { background: #ff0000; border-radius: 1px; }
.flag-g { background: #00a800; border-radius: 1px; }
.flag-b { background: #0000ff; border-radius: 1px; }
.flag-y { background: #ffff00; border-radius: 1px; }

.sysprop-monitor-stand {
  width: 30px;
  height: 6px;
  background: #808080;
  border-radius: 0 0 3px 3px;
  margin-top: -1px;
}

.sysprop-logo-text {
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 10px;
  text-align: center;
  color: var(--win98-black);
  line-height: 1.3;
}

.sysprop-info {
  flex: 1;
}

.sysprop-section {
  margin: 0;
}

.sysprop-hr {
  border: none;
  border-top: 1px solid var(--win98-grey);
  margin: 8px 0;
}

.sysprop-unavailable {
  text-align: center;
  color: var(--win98-grey);
  margin-top: 72px;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
}

.sysprop-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 8px;
}
