/* Project 3008: shared desktop, windows, dialogs, taskbar and balloon tips.
   Everything is drawn with CSS. No images, no web fonts, no requests. */

:root {
  --desk-top: #0b1f8c;
  --desk-bottom: #000010;
  --face: #d4d0c8;
  --hi: #ffffff;
  --lite: #dfdfdf;
  --shadow: #808080;
  --dark: #404040;
  --ink: #000000;
  --title-a: #0a246a;
  --title-b: #a6caf0;
  --title-in-a: #808080;
  --title-in-b: #c0c0c0;
  --select: #0a246a;
  --balloon: #ffffe1;
  --ui: Tahoma, Verdana, "Segoe UI", sans-serif;
  --serif: "Times New Roman", Times, serif;
  --mono: "Lucida Console", "Courier New", monospace;

  --raised: inset -1px -1px var(--dark), inset 1px 1px var(--face),
    inset -2px -2px var(--shadow), inset 2px 2px var(--hi);
  --button: inset -1px -1px var(--dark), inset 1px 1px var(--hi),
    inset -2px -2px var(--shadow), inset 2px 2px var(--lite);
  --pressed: inset -1px -1px var(--hi), inset 1px 1px var(--dark),
    inset -2px -2px var(--lite), inset 2px 2px var(--shadow);
  --sunken: inset -1px -1px var(--hi), inset 1px 1px var(--shadow),
    inset -2px -2px var(--lite), inset 2px 2px var(--dark);
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font: 14px/1.45 var(--ui);
  color: var(--ink);
  background: linear-gradient(180deg, var(--desk-top) 0%, #061266 45%, var(--desk-bottom) 100%) fixed;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ---------- Desktop ---------- */

.setup-title {
  padding: 22px 32px 0;
  color: var(--hi);
  pointer-events: none;
  user-select: none;
}
.setup-title h1 {
  margin: 0;
  font: italic bold clamp(30px, 5.4vw, 62px)/1 var(--serif);
  text-shadow: 4px 4px 0 var(--ink);
  letter-spacing: -0.01em;
}
.setup-title p {
  margin: 6px 0 0 4px;
  font: italic clamp(15px, 1.6vw, 20px)/1.2 var(--serif);
  color: #c9d3ff;
  text-shadow: 2px 2px 0 var(--ink);
}

.desk {
  position: relative;
  min-height: 0;
}

.disclaimer a { color: #c9d3ff; pointer-events: auto; }
.disclaimer {
  position: absolute;
  left: 32px;
  bottom: 10px;
  margin: 0;
  max-width: 46ch;
  font-size: 12px;
  color: #93a3e6;
  pointer-events: none;
}

/* ---------- Windows ---------- */

.window {
  --dx: 0px;
  --dy: 0px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)));
  width: min(640px, calc(100vw - 16px));
  max-height: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  padding: 3px;
  background: var(--face);
  box-shadow: var(--raised), 2px 2px 0 rgba(0, 0, 0, 0.35);
}
.window.returning { transition: transform 450ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.window.maximized {
  left: 0;
  top: 0;
  transform: none;
  width: 100%;
  height: 100%;
  max-height: none;
}

.title-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 2px 0 4px;
  color: var(--hi);
  background: linear-gradient(90deg, var(--title-in-a), var(--title-in-b));
  font-weight: bold;
  font-size: 13px;
  user-select: none;
  touch-action: none;
  cursor: default;
}
.window.active .title-bar { background: linear-gradient(90deg, var(--title-a), var(--title-b)); }
.title-bar .title-icon { width: 16px; height: 16px; flex: none; }
.title-bar .title-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.title-bar .controls { display: flex; gap: 0; }
.title-bar .controls button {
  width: 16px;
  height: 14px;
  min-width: 0;
  padding: 0;
  margin-left: 2px;
  font: bold 9px/1 var(--ui);
  display: grid;
  place-items: center;
}
.title-bar .controls button[data-action="close"] { margin-left: 2px; }

.window-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Controls ---------- */

button, .button {
  font: 13px/1 var(--ui);
  color: var(--ink);
  background: var(--face);
  border: 0;
  border-radius: 0;
  box-shadow: var(--button);
  min-width: 75px;
  min-height: 23px;
  padding: 4px 12px;
  cursor: default;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:active:not(:disabled), .button:active { box-shadow: var(--pressed); padding: 5px 11px 3px 13px; }
button:focus-visible, .button:focus-visible {
  outline: 1px dotted var(--ink);
  outline-offset: -5px;
}
button.default { box-shadow: inset 0 0 0 1px var(--ink), inset -2px -2px var(--dark), inset 2px 2px var(--hi), inset -3px -3px var(--shadow), inset 3px 3px var(--lite); }
button:disabled { color: var(--shadow); text-shadow: 1px 1px 0 var(--hi); }

.sunken { background: var(--hi); box-shadow: var(--sunken); }

hr.etched {
  height: 2px;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--shadow);
  border-bottom: 1px solid var(--hi);
}

input[type="radio"], input[type="checkbox"] { accent-color: var(--select); margin: 0 6px 0 0; }

a { color: var(--select); }

.mono { font-family: var(--mono); }

/* ---------- Dialogs ---------- */

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: transparent;
}
.dialog { width: min(420px, calc(100vw - 16px)); z-index: 51; }
.dialog .dialog-body {
  display: flex;
  gap: 14px;
  padding: 16px 14px 8px;
}
.dialog .dialog-body .icon { flex: none; width: 32px; height: 32px; }
.dialog .dialog-text p { margin: 0 0 8px; }
.dialog .dialog-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px 12px;
}

/* ---------- Taskbar ---------- */

.taskbar {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 2px 2px 2px 4px;
  background: var(--face);
  box-shadow: inset 0 1px var(--lite), inset 0 2px var(--hi);
}
.task-buttons { flex: 1; display: flex; gap: 3px; min-width: 0; }
.task-buttons button {
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  width: 190px;
  max-width: 40vw;
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
}
.task-buttons button.on { box-shadow: var(--pressed); background: repeating-conic-gradient(var(--face) 0 25%, var(--hi) 0 50%) 0 0 / 2px 2px; font-weight: bold; }
.task-buttons button span { overflow: hidden; text-overflow: ellipsis; }
.task-buttons svg { flex: none; }

.tray {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 8px 0 4px;
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--hi);
  font-size: 12px;
}
.tray-secrets, .tray-sound {
  min-width: 0;
  min-height: 0;
  height: 20px;
  padding: 0 4px;
  gap: 5px;
  box-shadow: none;
  background: transparent;
  font-size: 12px;
}
.tray-secrets:active:not(:disabled), .tray-sound:active:not(:disabled) { box-shadow: none; padding: 0 4px; }
.tray-secrets:hover, .tray-sound:hover { box-shadow: var(--button); }
.tray-clock { min-width: 38px; text-align: right; }

/* ---------- Balloon tips ---------- */

.balloons {
  position: fixed;
  right: 10px;
  bottom: 40px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.balloon {
  position: relative;
  width: min(330px, calc(100vw - 20px));
  padding: 9px 26px 10px 10px;
  background: var(--balloon);
  border: 1px solid var(--ink);
  border-radius: 7px;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: none;
  animation: balloon-in 180ms ease-out;
}
.balloon::after {
  content: "";
  position: absolute;
  right: 34px;
  bottom: -11px;
  border: 11px solid transparent;
  border-top-color: var(--ink);
  border-bottom: 0;
  border-right-width: 0;
}
.balloon::before {
  content: "";
  position: absolute;
  right: 35px;
  bottom: -9px;
  z-index: 1;
  border: 10px solid transparent;
  border-top-color: var(--balloon);
  border-bottom: 0;
  border-right-width: 0;
}
.balloons .balloon:not(:last-child)::before,
.balloons .balloon:not(:last-child)::after { display: none; }
.balloon .b-head { display: flex; align-items: center; gap: 6px; font-weight: bold; margin-bottom: 3px; }
.balloon .b-head svg { flex: none; }
.balloon .b-meta { font-weight: normal; color: #5b5b4f; font-size: 11.5px; margin-left: auto; padding-left: 8px; white-space: nowrap; }
.balloon .b-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 15px;
  height: 15px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  font-size: 10px;
  line-height: 1;
  border-radius: 2px;
  box-shadow: none;
  background: transparent;
  border: 1px solid #b8b49a;
  pointer-events: auto;
}
.balloon .b-close:active:not(:disabled) { padding: 0; box-shadow: none; }
.balloon.leaving { animation: balloon-out 160ms ease-in forwards; }

@keyframes balloon-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes balloon-out { to { opacity: 0; transform: translateY(4px); } }

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

.secrets-window { width: min(440px, calc(100vw - 16px)); height: min(520px, calc(100% - 16px)); z-index: 30; }
.secrets-window .window-body { padding: 10px; gap: 8px; }
.secrets-window .secrets-summary { margin: 0; }
.secrets-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 2px 0;
  list-style: none;
}
.secrets-list li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 2px 8px;
  padding: 6px 8px;
}
.secrets-list li + li { border-top: 1px dotted #c8c4bb; }
.secrets-list .check {
  width: 13px;
  height: 13px;
  margin-top: 2px;
  background: var(--hi);
  box-shadow: var(--sunken);
  position: relative;
}
.secrets-list li.found .check::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid var(--ink);
  border-width: 0 2px 2px 0;
  transform: rotate(40deg);
}
.secrets-list .s-title { font-weight: bold; }
.secrets-list .s-desc { grid-column: 2; color: #444; font-size: 12.5px; }
.secrets-list li.locked .s-title { color: var(--shadow); }
.secrets-list li.locked .s-desc { font-style: italic; color: #6b6b6b; }

/* ---------- Cheat effects ---------- */

.money-pop {
  position: fixed;
  left: 50%;
  top: 38%;
  z-index: 95;
  translate: -50% 0;
  font: italic bold clamp(28px, 5vw, 52px)/1 var(--serif);
  color: #3dff6a;
  text-shadow: 3px 3px 0 var(--ink);
  pointer-events: none;
  animation: money 2.6s ease-out forwards;
}
@keyframes money {
  0% { opacity: 0; transform: translateY(16px); }
  12% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-24px); }
}


/* ---------- Motion ---------- */

@keyframes shake {
  0%, 100% { translate: 0 0; }
  20% { translate: -7px 0; }
  40% { translate: 6px 0; }
  60% { translate: -4px 0; }
  80% { translate: 3px 0; }
}
.window.shake { animation: shake 320ms linear; }

@keyframes float-away {
  0% { translate: 0 0; }
  40% { translate: 0 -60px; }
  100% { translate: 0 0; }
}
.window.floating { animation: float-away 2.4s cubic-bezier(0.3, 0, 0.3, 1); }

/* ---------- Print: certificate of waiting ---------- */

.certificate { display: none; }

@media print {
  body { display: block; background: none; overflow: visible; }
  body > *:not(.certificate) { display: none !important; }
  .certificate {
    display: block;
    margin: 18mm auto;
    max-width: 170mm;
    padding: 14mm;
    border: 3px double #000;
    font-family: var(--serif);
    text-align: center;
  }
  .certificate h2 { font: italic bold 34pt/1.1 var(--serif); margin: 0 0 8mm; }
  .certificate p { font-size: 14pt; margin: 0 0 5mm; }
  .certificate .cert-fine { font-size: 10pt; margin-top: 12mm; }
}

/* ---------- Small screens ---------- */

@media (max-width: 700px) {
  .setup-title { padding: 14px 14px 0; }
  .disclaimer { display: none; }
  .task-buttons button { width: 150px; }
}

@media (max-height: 640px) {
  .setup-title p { display: none; }
  .setup-title { padding-top: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
