/*
 * Act 1: the 1995 desktop.
 *
 * Hand-built chrome rather than 98.css or React95, so the palette is ours and
 * every control is keyboard complete. No Microsoft marks, names or sounds are
 * used anywhere in this layer.
 */

.retro {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--desktop-teal);
  font-family: var(--font-retro);
  font-size: 13px;
  line-height: 1.35;
  color: #000;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: none;
}

.retro[hidden] { display: none; }

/* Faint CRT texture. Cheap, and it does a lot of work. */
.retro::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.055) 0px,
    rgba(0, 0, 0, 0.055) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 50;
}

/* Desktop icons */
.desktop-icons {
  position: absolute;
  top: 14px;
  left: 14px;
  display: grid;
  gap: 6px;
  width: 92px;
}

.icon {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 6px 3px;
  background: none;
  border: 1px dotted transparent;
  cursor: pointer;
  font: inherit;
  color: #fff;
  text-align: center;
  width: 100%;
}

.icon:hover .icon__glyph { filter: brightness(1.12); }

.icon:focus-visible { outline: none; border-color: #fff; }

.icon[aria-pressed="true"] { border-color: #fff; background: rgba(0, 0, 60, 0.42); }

.icon__label {
  font-size: 11px;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.75);
  word-break: break-word;
  padding: 1px 2px;
}

.icon[aria-pressed="true"] .icon__label { background: var(--title-active-a); }

.icon__glyph { width: 34px; height: 34px; image-rendering: pixelated; }

/* Frames */
.win {
  position: absolute;
  min-width: 240px;
  background: var(--chrome);
  border: 1px solid var(--chrome-dark);
  border-top-color: var(--chrome-light);
  border-left-color: var(--chrome-light);
  box-shadow: inset -1px -1px 0 var(--chrome-mid), inset 1px 1px 0 var(--chrome-light),
    2px 2px 0 rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  padding: 2px;
}

.win[hidden] { display: none; }

.win__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 2px 2px 4px;
  background: linear-gradient(90deg, var(--title-active-a), var(--title-active-b));
  color: #fff;
  cursor: grab;
  touch-action: none;
}

.win:not(.is-active) .win__bar {
  background: linear-gradient(90deg, var(--title-inactive-a), var(--title-inactive-b));
}

.win__bar:active { cursor: grabbing; }

.win__title {
  font-weight: 700;
  font-size: 12px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win__controls { display: flex; gap: 2px; }

.btn95 {
  font: inherit;
  font-size: 11px;
  min-width: 17px;
  height: 15px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  background: var(--chrome);
  color: #000;
  border: 1px solid var(--chrome-dark);
  border-top-color: var(--chrome-light);
  border-left-color: var(--chrome-light);
  box-shadow: inset -1px -1px 0 var(--chrome-mid), inset 1px 1px 0 var(--chrome-light);
  cursor: pointer;
  line-height: 1;
}

.btn95:active {
  border-color: var(--chrome-light);
  border-top-color: var(--chrome-dark);
  border-left-color: var(--chrome-dark);
  box-shadow: inset 1px 1px 0 var(--chrome-mid);
  padding: 1px 3px 0 5px;
}

.btn95:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

.win__body {
  flex: 1;
  overflow: auto;
  margin-top: 2px;
}

.win__status {
  margin-top: 2px;
  padding: 3px 6px;
  font-size: 11px;
  box-shadow: inset 1px 1px 0 var(--chrome-mid), inset -1px -1px 0 var(--chrome-light);
}

/* Notepad window */
.notepad {
  background: #fff;
  height: 100%;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
  box-shadow: inset 1px 1px 0 var(--chrome-mid);
  user-select: text;
}

/* Explorer style list */
.explorer {
  background: #fff;
  height: 100%;
  padding: 4px;
  overflow: auto;
  box-shadow: inset 1px 1px 0 var(--chrome-mid);
}

.explorer li { margin: 0; }

.explorer a, .explorer span.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px;
  color: #000;
  text-decoration: none;
  font-size: 12px;
}

.explorer a:hover, .explorer a:focus-visible {
  background: var(--title-active-a);
  color: #fff;
  outline: none;
}

.explorer .detail { color: #555; font-size: 11px; flex: none; }
.explorer a:hover .detail, .explorer a:focus-visible .detail { color: #cfe0ff; }

.explorer__note {
  margin-top: 8px;
  padding: 6px;
  font-size: 11px;
  background: #ffffe1;
  border: 1px solid #000;
}

/* Taskbar */
.taskbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  background: var(--chrome);
  border-top: 1px solid var(--chrome-light);
  box-shadow: 0 -1px 0 var(--chrome-mid);
  z-index: 40;
}

.start {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 8px 3px 5px;
  background: var(--chrome);
  border: 1px solid var(--chrome-dark);
  border-top-color: var(--chrome-light);
  border-left-color: var(--chrome-light);
  box-shadow: inset -1px -1px 0 var(--chrome-mid), inset 1px 1px 0 var(--chrome-light);
  cursor: pointer;
  font-family: inherit;
}

.start img { width: 17px; height: 17px; }
.start[aria-expanded="true"] {
  box-shadow: inset 1px 1px 0 var(--chrome-mid);
  border-color: var(--chrome-light);
  border-top-color: var(--chrome-dark);
  border-left-color: var(--chrome-dark);
}

/* Start menu */
.start-menu {
  position: absolute;
  left: 4px;
  bottom: 34px;
  width: 212px;
  background: var(--chrome);
  border: 1px solid var(--chrome-dark);
  border-top-color: var(--chrome-light);
  border-left-color: var(--chrome-light);
  box-shadow: inset -1px -1px 0 var(--chrome-mid), inset 1px 1px 0 var(--chrome-light),
    2px 2px 0 rgba(0, 0, 0, 0.35);
  padding: 2px;
  display: flex;
  z-index: 45;
}

.start-menu[hidden] { display: none; }

/* The vertical brand spine, as the era demanded. */
.start-menu__spine {
  width: 22px;
  flex: none;
  background: linear-gradient(180deg, var(--violet), var(--title-active-a));
  color: #fff;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 7px 3px;
}

.start-menu ul { flex: 1; }

.start-menu button, .start-menu a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 9px;
  font: inherit;
  font-size: 12px;
  background: none;
  border: 0;
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

.start-menu button:hover, .start-menu a:hover,
.start-menu button:focus-visible, .start-menu a:focus-visible {
  background: var(--title-active-a);
  color: #fff;
  outline: none;
}

.start-menu hr {
  border: 0;
  border-top: 1px solid var(--chrome-mid);
  border-bottom: 1px solid var(--chrome-light);
  margin: 3px 2px;
}

/* Taskbar window buttons and tray */
.tasks { display: flex; gap: 3px; flex: 1; overflow: hidden; }

.task {
  font: inherit;
  font-size: 11px;
  max-width: 150px;
  padding: 3px 8px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--chrome);
  border: 1px solid var(--chrome-dark);
  border-top-color: var(--chrome-light);
  border-left-color: var(--chrome-light);
  box-shadow: inset -1px -1px 0 var(--chrome-mid), inset 1px 1px 0 var(--chrome-light);
  cursor: pointer;
}

.task[aria-pressed="true"] {
  box-shadow: inset 1px 1px 0 var(--chrome-mid);
  border-color: var(--chrome-light);
  border-top-color: var(--chrome-dark);
  border-left-color: var(--chrome-dark);
  font-weight: 700;
}

.tray {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 7px;
  font-size: 11px;
  box-shadow: inset 1px 1px 0 var(--chrome-mid), inset -1px -1px 0 var(--chrome-light);
}

.tray button { background: none; border: 0; cursor: pointer; font: inherit; padding: 1px; }
.tray button:focus-visible { outline: 1px dotted #000; }

/* Boot splash, 1987 style */
.boot {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: var(--ega-blue);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  display: grid;
  align-content: center;
  justify-content: center;
  padding: var(--sp-4);
}

.boot[hidden] { display: none; }
.boot pre { margin: 0; }
.boot__cursor { animation: blink 1s steps(2) infinite; }

@keyframes blink { 50% { opacity: 0; } }

/* Setup wizard and dialogs */
.dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(430px, calc(100vw - 32px));
  z-index: 55;
}

.dialog__body { padding: 16px 14px 12px; }
.dialog__text { font-size: 12px; margin-bottom: 6px; font-weight: 700; }
.dialog__detail { font-size: 12px; color: #222; }

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 0 14px 14px;
}

.btn95--wide { min-width: 84px; height: 24px; font-size: 12px; }

/* Progress bar, segmented like the originals */
.progress {
  height: 19px;
  margin: 12px 0 8px;
  padding: 2px;
  background: #fff;
  box-shadow: inset 1px 1px 0 var(--chrome-mid), inset -1px -1px 0 var(--chrome-light);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    90deg,
    var(--title-active-a) 0px,
    var(--title-active-a) 10px,
    transparent 10px,
    transparent 13px
  );
  transition: width 0.18s linear;
}

.wizard__step {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #333;
  min-height: 1.4em;
}

.wizard__hint { font-size: 11px; color: #555; margin-top: 8px; }

/* Phones. A full desktop does not fit, so show one window plus the taskbar. */
@media (max-width: 767px) {
  .desktop-icons {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  /* Dialogs keep their own centred box; maximising them pushed them off-screen. */
  .win:not(.dialog) {
    inset: 104px 8px 42px 8px !important;
    width: auto !important;
    height: auto !important;
  }

  .win__bar { cursor: default; }

  /* Sideways scrolling a text file on a phone is authentic and nobody wants it. */
  .notepad { white-space: pre-wrap; }

  .mobile-cta {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 44px;
    z-index: 46;
  }
}

@media (min-width: 768px) {
  .mobile-cta { display: none; }
}

/* The upgrade button, given weight wherever it appears */
.upgrade-btn {
  width: 100%;
  height: 36px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.upgrade-btn img { width: 18px; height: 18px; }

/* The hero icon gets a slow pulse so the eye lands on it. */
.icon--exe .icon__glyph {
  animation: nudge 3.6s var(--ease-in-out) infinite;
}

@keyframes nudge {
  0%, 72%, 100% { transform: translateY(0); }
  80% { transform: translateY(-5px); }
  88% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .icon--exe .icon__glyph { animation: none; }
  .boot__cursor { animation: none; }
}

/* Hourglass while a window pretends to load */
.is-busy, .is-busy * { cursor: progress !important; }

/*
 * While Act 1 is up, the real page is sitting behind a fixed opaque overlay.
 * Without this, a scroll gesture moves a page the visitor cannot see.
 */
html[data-stage="boot"] body,
html[data-stage="desktop"] body,
html[data-stage="wizard"] body,
html[data-stage="switching"] body {
  overflow: hidden;
}
