/* The Win98 desktop that stands in front of pixelsats until it opens.
 *
 * Standalone on purpose. This page must render before, and independently of, the
 * application bundle -- it is what a stranger sees, and it should not be able to break
 * because something in the app did. No build step, no imports, no framework.
 *
 * The palette is the one in src/styles/design-tokens.css, repeated here rather than
 * shared for the same reason. If they ever disagree, this file is the one a visitor
 * sees first.
 */

:root {
  --desktop: #008080;   /* p05 */
  --face:    #C0C0C0;   /* p15 */
  --light:   #FFFFFF;   /* p14 */
  --shadow:  #808080;   /* p01 */
  --dark:    #000000;   /* p00 */
  --title:   #000080;   /* p06 */
  --title-2: #1084D0;
  --orange:  #F7931A;   /* p27 */
  --ui: "MS Sans Serif", "Pixelated MS Sans Serif", Tahoma, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--ui);
  font-size: 12px;
  color: var(--dark);
  background: var(--desktop);
  /* Win98 rendered text unhinted at small sizes; this keeps it crisp rather than fuzzy. */
  -webkit-font-smoothing: none;
}

.desktop {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px 16px 56px;   /* room for the taskbar */
}

/* ---------------------------------------------------------------- bevels
 *
 * Two rules do all the Win98 chrome. `raised` for things that stick out (windows,
 * buttons), `sunken` for things pressed in (the countdown well, the tray). The order
 * of the four colours is the whole illusion: light top-left, dark bottom-right.
 */

.raised, .window, .btn, .start, .task {
  border: 1px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.7), inset -1px -1px 0 var(--shadow);
  background: var(--face);
}

.sunken, .well, .tray {
  border: 1px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  box-shadow: inset 1px 1px 0 rgba(0,0,0,.35);
  background: var(--face);
}

/* ---------------------------------------------------------------- icons */

.icons {
  position: fixed;
  top: 12px;
  left: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shortcut {
  /* Some icons are links and some are buttons; both must look identical. */
  appearance: none;
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 84px;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--light);
}

.shortcut svg { width: 32px; height: 32px; }

.shortcut span {
  /* The authentic look: white label on the desktop, with a hard shadow so it stays
     readable over any wallpaper. */
  text-shadow: 1px 1px 0 rgba(0,0,0,.8);
  text-align: center;
  line-height: 1.25;
  padding: 1px 3px;
}

.shortcut:hover span,
.shortcut:focus-visible span {
  background: var(--title);
  outline: 1px dotted var(--light);
  outline-offset: -1px;
}

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

/* The window already open on this desktop: marked as selected rather than linked back
   to itself. Same treatment as .desktop-icons .here in the application, where --title
   is the same #000080 that --p06 is here. */
.shortcut.here { cursor: default; }
.shortcut.here span { background: var(--title); }

/* ---------------------------------------------------------------- window */

.window {
  width: min(460px, calc(100vw - 32px));
  padding: 3px;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.7), inset -1px -1px 0 var(--shadow),
              2px 2px 0 rgba(0,0,0,.35);
}

.window[hidden] { display: none; }

.titlebar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 3px 3px 4px;
  background: linear-gradient(90deg, var(--title), var(--title-2));
  color: var(--light);
}

.titlebar-icon { width: 16px; height: 16px; flex: none; }

.titlebar h1 {
  flex: 1;
  margin: 0;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: .01em;
}

.titlebar-buttons { display: flex; gap: 2px; }

.tb {
  width: 17px;
  height: 15px;
  padding: 0;
  border: 1px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  background: var(--face);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tb:active { border-color: var(--dark) var(--light) var(--light) var(--dark); }

.tb .min { width: 7px; height: 2px; background: var(--dark); margin-top: 5px; }
.tb .max { width: 9px; height: 8px; border: 1px solid var(--dark); border-top-width: 2px; }
.tb .x   { width: 8px;  height: 8px; position: relative; }
.tb .x::before, .tb .x::after {
  content: ""; position: absolute; left: 0; top: 3px;
  width: 9px; height: 1.5px; background: var(--dark);
}
.tb .x::before { transform: rotate(45deg); }
.tb .x::after  { transform: rotate(-45deg); }

.window-body { padding: 14px 14px 12px; }

.lead {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: bold;
}

.body-text { margin: 12px 0; line-height: 1.5; }

/* ---------------------------------------------------------------- countdown */

.well { padding: 12px 10px 8px; text-align: center; }

.clock {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
}

.unit { display: grid; justify-items: center; min-width: 46px; }

.unit b {
  font-family: "Courier New", monospace;
  font-size: 26px;
  line-height: 1;
  letter-spacing: .02em;
  /* Tabular figures: without this the digits jitter as they change, which on a clock
     is the difference between a countdown and a fidget. */
  font-variant-numeric: tabular-nums;
}

.unit i {
  font-style: normal;
  font-size: 10px;
  color: #404040;
  text-transform: lowercase;
  margin-top: 3px;
}

.colon {
  font-family: "Courier New", monospace;
  font-size: 24px;
  line-height: 1;
  padding-top: 1px;
  color: var(--shadow);
}

/* Frozen: the clock is a placeholder, and saying so in colour costs nothing. */
#countdown[data-state="pending"] .unit b { color: var(--shadow); }
#countdown[data-state="running"] .unit b { color: var(--dark); }
#countdown[data-state="open"] .unit b { color: var(--orange); }

.clock-note { margin: 10px 0 0; font-size: 11px; color: #404040; }

/* ---------------------------------------------------------------- sign-up
 *
 * A Win98 field: sunken, white, one line. The button sits beside it on a desktop and
 * drops under it when there is not room for both, which on a 390px screen there is not
 * once the field is wide enough to read your own address in.
 */

.signup { margin-top: 14px; display: grid; gap: 6px; }

/* Any `display` on a class beats the hidden attribute's UA `display: none`, so
   `form.hidden = true` in gate.js was setting an attribute that changed nothing and
   the sign-up box rendered anyway — over a subscribe() that does not exist yet. The
   window and the start menu below both carry this line; this one was missed. */
.signup[hidden] { display: none; }
.signup label { font-size: 11px; }

.signup-row { display: flex; gap: 6px; flex-wrap: wrap; }

.signup input {
  flex: 1 1 180px;
  min-width: 0;
  font: inherit;
  min-height: 34px;
  padding: 4px 6px;
  color: var(--dark);
  background: var(--light);
  border: 1px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  box-shadow: inset 1px 1px 0 rgba(0,0,0,.35);
}
.signup input:focus { outline: 1px dotted var(--dark); outline-offset: -3px; }

/* The button is flex:1 from .btn, which would make it half the row. It only needs to
   be as wide as the word. */
.signup .btn { flex: 0 0 auto; min-width: 76px; }

/* Empty until there is something to say, so it takes no room on arrival. */
.signup-note { margin: 0; font-size: 11px; color: #404040; min-height: 0; }
.signup-note:empty { display: none; }

/* ---------------------------------------------------------------- actions */

.actions { display: flex; gap: 8px; margin-top: 14px; }

/* The little message box the desktop icons open. */
.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100vw - 32px));
  z-index: 10;
}
.dialog .actions { justify-content: flex-end; }
.dialog .btn { flex: 0 0 90px; }

.btn {
  flex: 1;
  appearance: none;
  font: inherit;
  padding: 6px 10px;
  text-align: center;
  text-decoration: none;
  color: var(--dark);
  cursor: pointer;
  /* 34px tall at this padding: a touch target that survives a thumb. */
  min-height: 34px;
  display: grid;
  place-items: center;
}

.btn:active { border-color: var(--dark) var(--light) var(--light) var(--dark); }
/* .btn sets colour and cursor, which overrides the browser's own greying, so a
   disabled button looked and felt live while the request was in flight. */
.btn:disabled { color: var(--shadow); cursor: default; text-shadow: 1px 1px 0 var(--light); }
.btn:disabled:active { border-color: var(--light) var(--dark) var(--dark) var(--light); }
.btn:focus-visible { outline: 1px dotted var(--dark); outline-offset: -4px; }
.btn.primary { font-weight: bold; }

.fine { margin: 12px 0 0; font-size: 11px; color: #404040; line-height: 1.45; }

/* ---------------------------------------------------------------- taskbar */

.taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  background: var(--face);
  border-top: 1px solid var(--light);
  box-shadow: 0 -1px 0 var(--shadow);
}

.start {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 5px;
  min-height: 30px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 12px;
}

.start svg { width: 16px; height: 16px; }
.start[aria-expanded="true"] { border-color: var(--dark) var(--light) var(--light) var(--dark); }

.start-menu {
  position: fixed;
  bottom: 40px;
  left: 4px;
  margin: 0;
  padding: 3px;
  list-style: none;
  min-width: 168px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  box-shadow: 2px 2px 0 rgba(0,0,0,.35);
}

.start-menu[hidden] { display: none; }
.start-menu a {
  display: block;
  padding: 6px 22px 6px 10px;
  text-decoration: none;
  color: var(--dark);
}
.start-menu a:hover, .start-menu a:focus-visible {
  background: var(--title);
  color: var(--light);
  outline: none;
}
.start-menu .sep { height: 1px; margin: 3px 2px; background: var(--shadow); border-bottom: 1px solid var(--light); }

.tasks { flex: 1; display: flex; gap: 3px; overflow: hidden; }

.task {
  min-width: 140px;
  max-width: 190px;
  min-height: 30px;
  padding: 3px 8px;
  text-align: left;
  font-family: var(--ui);
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task.active { border-color: var(--dark) var(--light) var(--light) var(--dark); font-weight: bold; }

.tray {
  padding: 5px 9px;
  min-height: 30px;
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- small screens
 *
 * A 1998 desktop on a phone is a joke that stops being funny when nobody can read it.
 * Below 560px the icons move out of the corner and into a row, and the window takes
 * the width it needs.
 */

@media (max-width: 560px) {
  .desktop { padding: 96px 10px 56px; place-items: start center; }
  .icons { flex-direction: row; top: 10px; left: 10px; right: 10px; gap: 2px; }
  .shortcut { width: 74px; }
  .task { min-width: 0; }
  .unit { min-width: 40px; }
  .unit b { font-size: 22px; }
}

/* Same again for the narrowest phones: four across at 74px overruns 320. */
@media (max-width: 380px) {
  .shortcut { width: 68px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- app windows
 *
 * My Computer and the Recycle Bin. Both are Explorer: a sunken list with column
 * headers and a status bar, which is what Win98 gave you for looking at anything.
 */

.app-window {
  position: fixed;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
}

.app-window.focused { z-index: 6; }

/* An unfocused title bar went grey. It is the only cue that says which window is
   listening to the keyboard. */
.app-window:not(.focused) .titlebar {
  background: linear-gradient(90deg, var(--shadow), #B5B5B5);
}

.app-window .window-body { padding: 3px; }

.explorer {
  border: 1px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  background: var(--light);
  max-height: 320px;
  overflow: auto;
}

.listing {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  white-space: nowrap;
}

.listing th {
  position: sticky;
  top: 0;
  background: var(--face);
  border: 1px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
  padding: 3px 6px;
  text-align: left;
  font-weight: normal;
}

.listing td {
  padding: 3px 6px;
  border-bottom: 1px solid #EFEFEF;
}

.listing tbody tr:hover { background: var(--title); color: var(--light); }

/* Two tiny icons, drawn in CSS so the window needs no image files. */
.ico-drive, .ico-file {
  display: inline-block;
  width: 12px;
  height: 11px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 1px solid var(--dark);
}
.ico-drive { background: var(--face); box-shadow: inset 0 -3px 0 var(--shadow); }
.ico-file  { background: var(--light); box-shadow: inset -3px 3px 0 var(--face); }

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
  font-size: 11px;
}

.statusbar span {
  flex: 1;
  padding: 3px 6px;
  border: 1px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

@media (max-width: 560px) {
  .app-window { top: 8%; }
  .explorer { max-height: 240px; }
  .listing th:nth-child(4), .listing td:nth-child(4),
  .listing th:nth-child(5), .listing td:nth-child(5) { display: none; }
}

/* ---------------------------------------------------------------- Netscape */

.nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  background: var(--face);
}

.nav-site {
  padding: 4px 10px;
  min-height: 26px;
  font: inherit;
  cursor: pointer;
  background: var(--face);
  border: 1px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
}

.nav-site[aria-current] { border-color: var(--dark) var(--light) var(--light) var(--dark); font-weight: bold; }

.nav-url {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  font-size: 11px;
}

.nav-url input {
  flex: 1;
  font: inherit;
  padding: 3px 5px;
  background: var(--light);
  border: 1px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

.nav-view {
  border: 1px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  background: var(--light);
  height: min(460px, 56vh);
}

.nav-view iframe { width: 100%; height: 100%; border: 0; display: block; }
