/* JUST APE ($JUSTAPE) -- a lost Windows XP computer for apes -------------- */

:root {
  --xp-title-1: #3a6ea5;
  --xp-title-2: #0a246a;
  --xp-body: #ece9d8;
  --xp-border: #0a246a;
  --xp-btn-shadow: #8a8a6f;
  --taskbar: #1653c7;
  --taskbar-dark: #0a3ba8;
  --start-green-1: #4ea741;
  --start-green-2: #1e6b17;
  --ink: #101418;
  --white: #ffffff;
  --tooltip-bg: #ffffe1;
  --danger: #c00;
  --ui-font: Tahoma, Verdana, "Segoe UI", "MS Sans Serif", Geneva, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--ui-font);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  height: 100svh;
  height: 100vh;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
h1, p { margin: 0; }

/* ---------- the Bliss desktop background (real photo, no CSS hills) ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url("assets/bliss.jpg");
  background-size: cover;
  background-position: center 60%;
  background-repeat: no-repeat;
}

/* ---------- desktop surface ---------- */
.desktop {
  position: fixed;
  inset: 0;
  bottom: 34px;
  z-index: 1;
  overflow: hidden;
}

/* ---------- desktop icons ---------- */
.icons {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dicon {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 4px;
  width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: 2px;
}
.dicon:hover, .dicon:focus-visible { background: rgba(20, 60, 140, 0.28); border: 1px dotted rgba(255,255,255,0.6); outline: none; }
.dicon-art {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5));
}
.dicon-art--ape img { width: 38px; height: 38px; object-fit: cover; object-position: top; border-radius: 3px; }
.dicon-label {
  color: #fff;
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  text-shadow: 1px 1px 1px #000, 0 0 3px #000;
}

.glyph-folder {
  width: 32px; height: 24px;
  position: relative;
  background: linear-gradient(180deg, #ffd75e, #f0a92a);
  border: 1px solid #8a5a00;
  border-radius: 0 2px 2px 2px;
}
.glyph-folder::before {
  content: "";
  position: absolute;
  top: -6px; left: 0;
  width: 16px; height: 6px;
  background: #ffd75e;
  border: 1px solid #8a5a00;
  border-bottom: none;
  border-radius: 2px 2px 0 0;
}

.glyph-note {
  width: 26px; height: 32px;
  background: #fff;
  border: 1px solid #666;
  position: relative;
  box-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}
.glyph-note::before {
  content: "";
  position: absolute;
  top: 6px; left: 4px; right: 4px;
  height: 2px;
  background: repeating-linear-gradient(180deg, #bcd, #bcd 2px, transparent 2px, transparent 6px);
  height: 18px;
}

.glyph-globe {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #7fd0ff, #1568c0 60%, #0a3f82);
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: bold;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.glyph-bin {
  width: 26px; height: 24px;
  position: relative;
  background: linear-gradient(180deg, #d8dce2, #9aa1ac);
  border: 1px solid #5a606a;
  clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%);
}
.glyph-bin::before {
  content: "";
  position: absolute;
  top: -4px; left: -2px; right: -2px;
  height: 4px;
  background: #b7bcc4;
  border: 1px solid #5a606a;
}
.recycle-empty .glyph-bin { background: linear-gradient(180deg, #eef0f3, #c7ccd3); }

/* ---------- hero content (first viewport, must already feel right) ---------- */
.hero-content {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 24px;
  max-width: 900px;
  margin: 0 auto;
}
.hero-title {
  grid-column: 1;
  grid-row: 1;
  font-family: var(--ui-font);
  font-weight: bold;
  font-size: clamp(2.4rem, 8vw, 4.6rem);
  color: #fff;
  line-height: 0.95;
  text-shadow: 2px 2px 3px rgba(0,0,0,0.55), 0 0 22px rgba(0,0,0,0.25);
  letter-spacing: -0.01em;
  align-self: end;
}
.ticker {
  grid-column: 1;
  grid-row: 2;
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.75rem, 2vw, 0.95rem);
  color: #fff;
  opacity: 0.9;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
  letter-spacing: 0.03em;
}
.ape-wrap {
  grid-column: 2;
  grid-row: 1 / span 4;
  position: relative;
  align-self: center;
  touch-action: manipulation;
}
.hero-ape {
  width: clamp(150px, 26vw, 320px);
  height: auto;
  filter: drop-shadow(0 14px 16px rgba(0,0,0,0.4));
  cursor: pointer;
  user-select: none;
  transform-origin: 50% 85%;
  will-change: transform;
}
.golden-ape { filter: drop-shadow(0 0 20px #ffd93d) drop-shadow(0 0 38px #ff8c00) drop-shadow(0 14px 16px rgba(0,0,0,0.4)) saturate(1.5); }

.ape-tip {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translate(-50%, -100%);
  background: var(--tooltip-bg);
  color: #000;
  border: 1px solid #000;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 10;
}

.hero-sub {
  grid-column: 1;
  grid-row: 3;
  color: #fff;
  font-size: clamp(0.95rem, 2.6vw, 1.2rem);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
  line-height: 1.3;
  margin-top: 6px;
}
.ape-btn {
  grid-column: 1;
  grid-row: 4;
  justify-self: start;
  margin-top: 10px;
  font-family: var(--ui-font);
  font-weight: bold;
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: #000;
  background: linear-gradient(180deg, #fdfdfd, #ece9d8 55%, #d8d5c4);
  border: 1px solid #48494d;
  border-radius: 3px;
  padding: 8px 34px;
  box-shadow: inset 0 1px 0 #fff, 1px 2px 4px rgba(0,0,0,0.45);
}
.ape-btn:active {
  background: linear-gradient(180deg, #d8d5c4, #ece9d8);
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.4);
  transform: translateY(1px);
}
.counter {
  grid-column: 1;
  grid-row: 5;
  color: #fff;
  font-size: clamp(0.85rem, 2vw, 1rem);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.counter.bump { animation: bump 220ms ease; }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ---------- stage: layer that catches spawned random-event apes ---------- */
.stage {
  position: fixed;
  inset: 0;
  bottom: 34px;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}
.mini-ape {
  position: absolute;
  width: 60px;
  height: auto;
  pointer-events: none;
  will-change: transform, opacity;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.35));
}

/* ---------- windows (Explorer / Properties / Notepad / IE / Recycle) ---------- */
.windows-layer { position: fixed; inset: 0; bottom: 34px; z-index: 40; pointer-events: none; }
.win {
  position: absolute;
  width: min(360px, 88vw);
  background: var(--xp-body);
  border: 1px solid var(--xp-border);
  border-radius: 6px 6px 2px 2px;
  box-shadow: 3px 5px 16px rgba(0,0,0,0.5);
  pointer-events: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.win.maxed { width: min(640px, 92vw); }
.win-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, var(--xp-title-1), var(--xp-title-2));
  color: #fff;
  font-weight: bold;
  font-size: 12px;
  padding: 4px 4px 4px 8px;
  cursor: grab;
  user-select: none;
}
.win-bar-title { flex: 1; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-bar-btns { display: flex; gap: 2px; }
.win-bar-btn {
  width: 18px; height: 17px;
  border: 1px solid rgba(0,0,0,0.4);
  border-radius: 2px;
  background: linear-gradient(180deg, #6d99e0, #2f5fb0);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  font-weight: bold;
}
.win-bar-btn--close { background: linear-gradient(180deg, #f08a78, #d9432c); }
.win-menu {
  display: flex;
  gap: 12px;
  padding: 3px 10px;
  font-size: 11px;
  color: #333;
  border-bottom: 1px solid #b9b6a2;
  background: var(--xp-body);
}
.win-body {
  padding: 12px 14px;
  font-size: 13px;
  overflow: auto;
  max-height: 52vh;
}
.win-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 8px 12px 12px;
  border-top: 1px solid #d6d3c2;
}
.xp-btn {
  background: var(--xp-body);
  border: 1px solid #767662;
  border-radius: 3px;
  padding: 5px 16px;
  font-size: 12px;
  font-weight: bold;
  box-shadow: inset 0 1px 0 #fff;
}
.xp-btn:hover { background: #fff8dc; }
.xp-btn:active { box-shadow: inset 1px 1px 2px rgba(0,0,0,0.35); }

/* explorer file grid (My Ape) */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; }
.file-item { background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border-radius: 2px; }
.file-item:hover { background: #d9e4fb; }
.file-item img { width: 42px; height: 42px; object-fit: cover; border: 1px solid #8a8a6f; border-radius: 2px; }
.file-item span { font-size: 10.5px; text-align: center; word-break: break-all; }

/* token properties */
.prop-rows { display: flex; flex-direction: column; }
.prop-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; border-bottom: 1px dotted #a9a68b; font-size: 13px; }
.prop-row:last-child { border-bottom: none; }
.prop-row dt, .prop-row .k { font-weight: bold; color: #333; }
.prop-row dd, .prop-row .v { margin: 0; font-family: "Courier New", Courier, monospace; text-align: right; }
.ca-row { display: flex; align-items: center; gap: 6px; }
.ca-row .v { font-size: 11px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.copy-btn { font-size: 10px; padding: 2px 8px; }

/* notepad */
.notepad-body {
  background: #fff;
  border: 1px inset #999;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  padding: 8px 10px;
  margin: -2px 0 0;
}

/* internet explorer */
.ie-address {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid #b9b6a2;
  font-size: 11px;
}
.ie-address input {
  flex: 1;
  font-family: var(--ui-font);
  font-size: 11px;
  border: 1px inset #999;
  padding: 3px 6px;
  background: #fff;
  color: #555;
}
.ie-page { padding: 14px; text-align: center; }
.ie-search-row { display: flex; gap: 6px; margin-top: 10px; justify-content: center; }
.ie-search-row input {
  font-family: var(--ui-font);
  font-size: 13px;
  border: 1px inset #999;
  padding: 5px 8px;
  width: 65%;
}
.ie-result { margin-top: 14px; font-size: 13px; min-height: 18px; }
.ie-result b { font-family: "Courier New", Courier, monospace; }

/* recycle bin window */
.recycle-file { display: flex; align-items: center; gap: 10px; padding: 6px 2px; }
.recycle-file .glyph-exe { width: 24px; height: 24px; background: linear-gradient(180deg,#c9cdd4,#8f95a0); border: 1px solid #5a606a; border-radius: 3px; flex: none; }
.recycle-actions { display: flex; gap: 8px; margin-top: 10px; }
.recycle-empty-msg { text-align: center; padding: 6px 0; }

/* generic tiny system dialog icons */
.sys-icon { width: 22px; height: 22px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #fff; font-size: 14px; }
.sys-icon--error { background: radial-gradient(circle at 35% 30%, #ff6b5a, #c0281a); }
.sys-icon--warn { background: #f4c430; color: #4a3800; clip-path: polygon(50% 6%, 95% 92%, 5% 92%); font-size: 13px; padding-top: 6px; }
.sys-icon--info { background: radial-gradient(circle at 35% 30%, #6ea8f5, #1b4fa0); }
.dialog-body-row { display: flex; gap: 10px; align-items: flex-start; }

/* ---------- fake XP dialogs (small popups) ---------- */
.dialog-layer { position: fixed; inset: 0; bottom: 34px; z-index: 950; pointer-events: none; }
.win-dialog {
  position: absolute;
  width: min(300px, 84vw);
  background: var(--xp-body);
  border: 1px solid var(--xp-border);
  border-radius: 6px 6px 2px 2px;
  box-shadow: 4px 6px 18px rgba(0,0,0,0.5);
  pointer-events: auto;
  overflow: hidden;
}
.win-dialog-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, var(--xp-title-1), var(--xp-title-2));
  color: #fff; font-weight: bold; font-size: 12px; padding: 4px 4px 4px 8px;
}
.win-dialog-close { background: linear-gradient(180deg, #f08a78, #d9432c); color: #fff; border: 1px solid rgba(0,0,0,0.4); border-radius: 2px; width: 18px; height: 17px; line-height: 1; font-size: 11px; font-weight: bold; padding: 0; }
.win-dialog-body { display: flex; gap: 10px; align-items: flex-start; padding: 14px 14px 8px; font-size: 12.5px; }
.win-dialog-actions { display: flex; gap: 8px; justify-content: center; padding: 0 14px 14px; }

/* ---------- start menu ---------- */
.start-menu {
  position: fixed;
  left: 0;
  bottom: 34px;
  z-index: 60;
  width: 190px;
  background: var(--xp-body);
  border: 1px solid var(--xp-border);
  border-radius: 6px 6px 0 0;
  box-shadow: 2px -2px 14px rgba(0,0,0,0.5);
  overflow: hidden;
}
.start-menu[hidden] { display: none; }
.start-menu-header {
  background: linear-gradient(90deg, var(--start-green-1), var(--start-green-2));
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  padding: 10px 12px;
}
.start-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
}
.start-item:hover { background: #2f5fb0; color: #fff; }
.start-sep { height: 1px; background: #b9b6a2; margin: 4px 0; }

/* ---------- tray balloon notification ---------- */
.balloon {
  position: fixed;
  right: 10px;
  bottom: 42px;
  z-index: 900;
  width: min(230px, 70vw);
  background: var(--tooltip-bg);
  border: 1px solid #6b6b3f;
  padding: 8px 10px;
  box-shadow: 2px 3px 10px rgba(0,0,0,0.4);
}
.balloon[hidden] { display: none; }
.balloon-title { font-weight: bold; font-size: 12px; margin-bottom: 3px; }
.balloon-body { font-size: 12px; }
.balloon.show { animation: balloon-in-out 3.2s ease forwards; }
@keyframes balloon-in-out {
  0% { opacity: 0; transform: translateY(10px); }
  10% { opacity: 1; transform: translateY(0); }
  88% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(4px); }
}

/* ---------- taskbar ---------- */
.taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 500;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  background: linear-gradient(180deg, var(--taskbar), var(--taskbar-dark));
  border-top: 1px solid #6ea3ff;
}
.start-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 12px 0 6px;
  background: linear-gradient(180deg, var(--start-green-1), var(--start-green-2));
  color: #fff;
  font-weight: bold;
  font-style: italic;
  font-size: 13px;
  border: 1px solid #1b4a14;
  border-radius: 4px;
  text-transform: lowercase;
}
.start-flag {
  width: 14px; height: 14px;
  background: repeating-linear-gradient(45deg, #f25022 0 6px, #7fba00 6px 12px, #00a4ef 12px 18px, #ffb900 18px 24px);
  border-radius: 2px;
}
.quicklaunch { display: flex; align-items: center; gap: 4px; padding-left: 4px; border-left: 1px solid rgba(255,255,255,0.3); height: 22px; }
.ql-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  background: var(--xp-body);
  border: 1px solid #0a3ba8;
  border-radius: 2px;
  color: #0a246a;
  font-weight: bold;
  font-size: 11px;
  text-decoration: none;
}
.ql-chart { flex-direction: row; gap: 1.5px; }
.ql-chart span { display: inline-block; width: 3px; background: #1e6b17; }
.ql-chart span:nth-child(1) { height: 6px; }
.ql-chart span:nth-child(2) { height: 10px; }
.ql-chart span:nth-child(3) { height: 14px; }
.taskbar-mid { flex: 1; display: flex; gap: 4px; overflow: hidden; }
.taskbar-chip {
  height: 24px;
  max-width: 150px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  background: linear-gradient(180deg, #4b7cd6, #2c56b0);
  border: 1px solid #163d80;
  border-radius: 3px;
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tray {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 8px;
  background: linear-gradient(180deg, #1b5fd0, #0a3ba8);
  border: 1px solid #072a7a;
  border-radius: 3px 0 0 3px;
  color: #fff;
  font-size: 11px;
}
.tray-canary { opacity: 0.85; }
.tray-sound {
  background: var(--xp-body);
  color: #0a246a;
  border: 1px solid #0a246a;
  border-radius: 2px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: bold;
}
.tray-sound[aria-pressed="true"] { background: #f4c430; }
.tray-clock { font-variant-numeric: tabular-nums; }

/* ---------- critical error freeze ---------- */
.crit-flash {
  position: fixed;
  inset: 0;
  bottom: 34px;
  z-index: 970;
  background: #000;
  pointer-events: none;
  opacity: 0;
}
.crit-flash.show { animation: crit-flicker 240ms steps(2) 3; opacity: 1; }
@keyframes crit-flicker { 0%, 100% { opacity: 0.85; } 50% { opacity: 0.1; } }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .counter.bump { animation: none !important; }
  .balloon.show { animation: none !important; opacity: 1 !important; }
  .hero-ape, .mini-ape { transition: none !important; }
  .crit-flash.show { animation: none !important; }
}

/* ---------- mobile: preserve the world, shrink the chrome ---------- */
@media (max-width: 640px) {
  .icons { top: 8px; left: 8px; flex-direction: row; flex-wrap: wrap; width: 148px; }
  .dicon { width: 66px; }
  .dicon-art, .dicon-art--ape img { width: 30px; height: 30px; }
  .glyph-globe { width: 26px; height: 26px; font-size: 16px; }
  .hero-content {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    top: 56%;
  }
  .hero-title, .ticker, .hero-sub, .ape-btn, .counter { grid-column: 1; justify-self: center; }
  .ape-wrap { grid-row: 1; margin-bottom: 6px; }
  .hero-title { grid-row: 2; align-self: auto; }
  .ticker { grid-row: 3; }
  .hero-sub { grid-row: 4; }
  .ape-btn { grid-row: 5; }
  .counter { grid-row: 6; }
  .win { width: 94vw; }
  .win.maxed { width: 96vw; }
  .taskbar-mid { display: none; }
}
