/* Retro desktop on top of 98.css. Colors stay fixed (a Win98 desktop has no dark mode). */
:root {
  --desk: #008080;
  --face: #c0c0c0;
  --shadow: #808080;
  --navy: #000080;
  --taskbar-h: 30px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--desk);
  overflow: hidden;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  -webkit-font-smoothing: none;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: -999px; top: 4px; z-index: 9999; background: #fff; padding: 4px; }
.skip-link:focus { left: 4px; }

/* ---------- Desktop + icons ---------- */
#desktop {
  position: fixed; inset: 0 0 var(--taskbar-h) 0;
  outline: none;
}
#icons {
  list-style: none; margin: 0; padding: 12px 8px;
  display: grid; grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 84px);
  grid-auto-columns: 84px; gap: 6px 10px;
  height: 100%;
}
.icon {
  all: unset;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 84px; padding: 4px 2px; cursor: pointer; text-align: center;
  color: #fff; font-size: 11px; line-height: 1.2;
}
.icon svg { width: 32px; height: 32px; image-rendering: pixelated; }
.icon span { padding: 1px 2px; text-shadow: 1px 1px 0 #000; word-break: break-word; }
.icon:focus-visible span, .icon[aria-current="true"] span {
  background: var(--navy); outline: 1px dotted #fff; text-shadow: none;
}
.icon:focus-visible svg, .icon[aria-current="true"] svg { filter: brightness(.6) sepia(1) hue-rotate(190deg) saturate(4); }

/* ---------- Windows ---------- */
.window.app {
  position: absolute; display: flex; flex-direction: column;
  min-width: 260px; max-width: calc(100vw - 16px);
  max-height: calc(100vh - var(--taskbar-h) - 16px);
}
.window.app[hidden] { display: none; }
.window.app.maximized {
  left: 0 !important; top: 0 !important;
  width: 100% !important; height: 100% !important; max-height: none; max-width: none;
}
.window.app .title-bar { cursor: grab; user-select: none; touch-action: none; }
.window.app.dragging .title-bar { cursor: grabbing; }
.window.app:not(.active) .title-bar { background: linear-gradient(90deg, #808080, #b5b5b5); }
.window.app .window-body {
  margin: 0; padding: 12px 14px; overflow: auto; flex: 1;
  background: var(--face); font-size: 12px; line-height: 1.5;
  overscroll-behavior: contain;
}
.window-body h2 { font-size: 16px; margin: 0 0 4px; }
.window-body h3 { font-size: 13px; margin: 16px 0 6px; }
.window-body p { margin: 0 0 8px; }
.window-body ul { margin: 0 0 8px; padding-left: 18px; }
.window-body a { color: #0000ee; }
.window-body a:visited { color: #551a8b; }
.tagline { color: #333; font-style: italic; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 10px; padding: 0; list-style: none; }
.chips li {
  padding: 1px 6px; background: #fff;
  box-shadow: inset -1px -1px #fff, inset 1px 1px var(--shadow);
}
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 0 0 8px; }
.meta dt { font-weight: bold; }
.meta dd { margin: 0; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.links a.button-link {
  display: inline-block; padding: 4px 12px; color: #000; text-decoration: none;
  background: var(--face);
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px var(--shadow), inset 2px 2px #dfdfdf;
}
.links a.button-link:active { box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px var(--shadow); }
.note {
  padding: 6px 8px; margin: 8px 0; background: #ffffe1; border: 1px solid #000;
}

/* Sunken frame around screenshots / videos */
.frame {
  margin: 8px 0; padding: 2px; background: #fff;
  box-shadow: inset -1px -1px #fff, inset 1px 1px var(--shadow), inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
}
.frame img, .frame video { display: block; width: 100%; height: auto; background: #000; }
figure { margin: 0; }
figcaption { font-size: 11px; color: #333; margin-top: 2px; }

/* Screenshot slideshow */
.gallery-controls { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

/* Phone clips (Where2Go) */
.phones { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 8px 0; }
.phone {
  background: #111; border-radius: 18px; padding: 8px 6px;
  box-shadow: 2px 2px 0 #000, inset 0 0 0 2px #444;
}
.phone video, .phone img { display: block; width: 100%; height: auto; border-radius: 10px; background: #000; }
.phone + figcaption, .phones figcaption { text-align: center; }

/* Illustrative terminal (agent) */
.terminal {
  background: #000; color: #c0c0c0; font-family: "Courier New", monospace; font-size: 12px;
  padding: 8px; min-height: 180px; white-space: pre-wrap; margin: 8px 0;
  box-shadow: inset -1px -1px #fff, inset 1px 1px var(--shadow), inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
}
.terminal .t-tool { color: #ffff55; }
.terminal .t-ok { color: #55ff55; }
.terminal .t-ai { color: #55ffff; }
.cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.confidential {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px; margin: 8px 0; background: #fff; border: 1px solid var(--shadow);
}
.confidential svg { flex: none; width: 32px; height: 32px; }

/* ---------- Taskbar ---------- */
#taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--taskbar-h);
  display: flex; align-items: center; gap: 4px; padding: 2px;
  background: var(--face); box-shadow: inset 0 1px #dfdfdf, inset 0 2px #fff;
  z-index: 10000;
}
#start-btn { font-weight: bold; display: flex; align-items: center; gap: 4px; min-width: 0; padding: 0 6px; height: 24px; }
.start-logo {
  width: 16px; height: 16px; display: inline-block;
  background:
    linear-gradient(#ff0000, #ff0000) 0 0 / 7px 7px no-repeat,
    linear-gradient(#00a000, #00a000) 8px 0 / 7px 7px no-repeat,
    linear-gradient(#0000ff, #0000ff) 0 8px / 7px 7px no-repeat,
    linear-gradient(#ffd000, #ffd000) 8px 8px / 7px 7px no-repeat;
}
#task-buttons { flex: 1; display: flex; gap: 3px; overflow: hidden; }
#task-buttons button {
  min-width: 0; max-width: 160px; flex: 1 1 160px; height: 24px; padding: 0 6px;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
#task-buttons button svg { width: 16px; height: 16px; flex: none; }
#task-buttons button[aria-pressed="true"] {
  font-weight: bold;
  box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px var(--shadow);
  background: repeating-conic-gradient(#fff 0 25%, var(--face) 0 50%) 0 0 / 2px 2px;
}
#tray { flex: none; display: flex; align-items: center; gap: 10px; height: 24px; padding: 0 8px; font-size: 11px; }
#counter { font-family: "Courier New", monospace; background: #000; color: #55ff55; padding: 0 4px; letter-spacing: 1px; }

/* ---------- Start menu ---------- */
#start-menu {
  position: fixed; left: 2px; bottom: calc(var(--taskbar-h) - 2px);
  display: flex; z-index: 10001; padding: 3px; min-width: 200px;
}
#start-menu[hidden] { display: none; }
.start-side {
  width: 22px; background: linear-gradient(0deg, var(--navy), #1084d0);
  color: #c0c0c0; display: flex; align-items: flex-end; justify-content: center;
}
.start-side span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 16px; padding: 6px 0; letter-spacing: 1px; }
.start-side b { color: #fff; }
#start-items { list-style: none; margin: 0; padding: 0; flex: 1; }
#start-items li[role="separator"] { height: 0; margin: 3px 2px; border-top: 1px solid var(--shadow); border-bottom: 1px solid #fff; }
#start-items .start-item {
  all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 4px 18px 4px 6px; cursor: pointer; font-size: 12px; color: #000;
}
#start-items .start-item svg { width: 24px; height: 24px; }
#start-items .start-item:hover, #start-items .start-item:focus-visible { background: var(--navy); color: #fff; }

/* ---------- Boot + shutdown screens ---------- */
#boot {
  position: fixed; inset: 0; z-index: 20000; background: #000; color: #c0c0c0;
  font-family: "Courier New", monospace; font-size: 14px; padding: 24px; cursor: pointer;
}
#boot[hidden] { display: none; }
#boot pre { margin: 0; padding: 0; white-space: pre-wrap; background: none; box-shadow: none; border: 0; color: inherit; font: inherit; }
.boot-skip { position: absolute; bottom: 16px; left: 24px; color: #808080; margin: 0; }
#shutdown {
  position: fixed; inset: 0; z-index: 20000; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
}
#shutdown[hidden] { display: none; }
#shutdown p { color: #ff8c00; font-size: 28px; font-family: Arial, sans-serif; margin: 0; text-align: center; padding: 0 16px; }

/* ---------- Window open/close "zoom" outline (classic Win95 effect) ---------- */
.zoom-outline {
  position: fixed; z-index: 15000; pointer-events: none;
  border: 2px solid #808080; outline: 1px solid #fff;
}

/* ---------- Scroll-reveal inside windows ---------- */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .reveal {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 70%;
    }
  }
  /* Fallback for browsers without scroll-driven animations: JS toggles .in */
  .reveal.js-reveal { opacity: 0; transform: translateY(16px); transition: opacity .4s, transform .4s steps(4); }
  .reveal.js-reveal.in { opacity: 1; transform: none; }

  .window.app.opening { animation: pop .14s steps(3) both; }
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(18px); clip-path: inset(0 0 100% 0); }
  to { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }
}
@keyframes pop { from { transform: scale(.92); opacity: .4; } to { transform: none; opacity: 1; } }

/* Subtle CRT scanlines over the desktop */
#desktop::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 14000;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.06) 0 1px, transparent 1px 3px);
}

/* ---------- Phones: windows become full screen, no dragging ---------- */
@media (max-width: 640px) {
  #icons { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, 84px); grid-template-rows: none; grid-auto-rows: 84px; justify-content: space-evenly; padding: 16px; }
  .window.app {
    left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important;
    max-width: none; max-height: none; min-width: 0;
  }
  .window.app .title-bar { cursor: default; }
  .title-bar-controls button[aria-label="Maximize"], .title-bar-controls button[aria-label="Restore"] { display: none; }
  #task-buttons button { flex-basis: 40px; }
  #task-buttons button .tb-text { display: none; }
  #tray #counter { display: none; }
}

.noscript { background: #fff; padding: 16px; margin: 16px; font-family: Arial, sans-serif; }
