/* Hamster Cam - retro desktop UI.
   Everything is laid out in the 2560x1440 coordinate space of the Canva
   design and scaled as a unit, so the live controls land exactly on the
   artwork underneath them at any window size. Every position below was
   measured off the exported artwork rather than eyeballed. */

/* PT Sans (Paratype) and Caveat (Impallari Type), both SIL Open Font License
   1.1. Self-hosted so the page has no font dependency on a third party at run
   time. PT Sans is the closest open face to the humanist sans Windows XP era
   UI was set in, which is what the artwork is imitating. */
@font-face {
  font-family: "PT Sans";
  src: url("assets/ptsans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PT Sans";
  src: url("assets/ptsans-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Caveat";
  src: url("assets/caveat-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --stage-w: 2560;
  --stage-h: 1440;
  --stage-scale: 1;

  --btn-face: #c0c0c0;
  --btn-light: #ffffff;
  --btn-shadow: #868686;
  --btn-ink: #000000;
  --win-blue: #0054e6;
  --menu-face: #ece9da;

  --ui-font: "PT Sans", Tahoma, Verdana, sans-serif;
  --label-font: "PT Sans", Tahoma, Arial, sans-serif;
  --mono: ui-monospace, "Lucida Console", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #10121a;
  color: #fff;
  font-family: var(--ui-font);
  overflow: hidden;
  overscroll-behavior: none;
}

/* Stage --------------------------------------------------------------- */

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #10121a;
}

/* The stage keeps the design's 16:9 shape, so on a differently shaped window
   there is space left over. Rather than show bars, the same artwork is blown
   up behind it, blurred, and the sharp stage sits on top - the page reads as
   full bleed while nothing along the design's edges gets cropped away. */
#viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.12) translate3d(var(--par-bx, 0px), var(--par-by, 0px), 0);
  filter: blur(34px) saturate(1.15) brightness(0.78);
}

#viewport.is-splash::before { background-image: url("assets/splash.webp"); }
#viewport.is-app::before { background-image: url("assets/main-bg.webp"); }

/* Centred with negative margins rather than by a flex/grid parent: the stage's
   layout box is a full 2560x1440 whatever the scale, and an overflowing grid
   item gets pinned to the start edge instead of centred. */
#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: calc(var(--stage-w) * -0.5px);
  margin-top: calc(var(--stage-h) * -0.5px);
  width: calc(var(--stage-w) * 1px);
  height: calc(var(--stage-h) * 1px);
  /* Parallax is applied to the whole stage, never to individual controls:
     the live elements only line up because they share the artwork's
     coordinate space, so anything that moves has to move all of it. */
  transform: translate3d(var(--par-x, 0px), var(--par-y, 0px), 0)
             rotate(var(--par-r, 0deg))
             scale(var(--stage-scale));
  transform-origin: center center;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
  will-change: transform;
}

.screen {
  position: absolute;
  inset: 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  visibility: hidden;
}

.screen.is-active { visibility: visible; }

#splash { background-image: url("assets/splash.webp"); }
#app { background-image: url("assets/main-bg.webp"); }

/* Hotspots: invisible buttons sitting on top of painted controls -------- */

.hotspot {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hotspot:focus-visible {
  outline: 4px dotted #000;
  outline-offset: 3px;
}

.start-hotspot {
  left: 1062px;
  top: 824px;
  width: 435px;
  height: 111px;
  border-radius: 2px;
}

.start-hotspot:hover { background: rgba(255, 255, 255, 0.22); }
.start-hotspot:active {
  background: rgba(0, 0, 0, 0.18);
  transform: translate(2px, 2px);
}

.close-hotspot { left: 1231px; top: 445px; width: 42px; height: 42px; }
.close-hotspot:hover { background: rgba(255, 255, 255, 0.3); }

.play-hotspot { width: 74px; height: 74px; border-radius: 50%; }
.play-hotspot--cam { left: 615px; top: 1083px; }
.play-hotspot:hover { background: rgba(255, 255, 255, 0.28); }

.hamburger {
  left: 2146px;
  top: 134px;
  width: 112px;
  height: 82px;
  border-radius: 5px;
}

.hamburger:hover { background: rgba(78, 105, 255, 0.18); }
.hamburger:active { background: rgba(78, 105, 255, 0.32); }

/* Name badge ----------------------------------------------------------- */

.badge-field {
  position: absolute;
  left: 298px;
  top: 299px;
  width: 450px;
  height: 190px;
  display: grid;
  place-items: center;
  padding: 0 26px;
  border: 0;
  transform: rotate(-7.2deg);
  background: linear-gradient(158deg, #eef0fc 0%, #e8eaf7 55%, #dedfec 100%);
  border-radius: 12px;
  box-shadow: inset 0 2px 8px rgba(90, 100, 140, 0.2);
  overflow: hidden;
  cursor: pointer;
}

.badge-field:hover { background: linear-gradient(158deg, #f5f6fd, #e6e7f3); }
.badge-field:focus-visible { outline: 4px dotted #2b3a63; outline-offset: -10px; }

.badge-field span {
  display: block;
  width: 100%;
  font-family: var(--label-font);
  font-weight: 300;
  font-size: 85px;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: #111;
  text-align: center;
  text-transform: uppercase;
  overflow-wrap: break-word;
  transform: scale(var(--fit, 1));
  transform-origin: center;
}

/* A real name gets handwriting rather than the placeholder's plain caps. */
.badge-field span.is-name {
  font-family: "Caveat", "Segoe Script", "Bradley Hand", "Snell Roundhand", cursive;
  font-weight: 600;
  font-size: 146px;
  line-height: 0.92;
  text-transform: none;
  letter-spacing: 0;
  color: #14203c;
}

/* Window content areas ------------------------------------------------- */

.win-content {
  position: absolute;
  top: 569px;
  width: 665px;
  height: 457px;
  background: #fff;
  overflow: hidden;
}

.win-content--cam { left: 608px; display: block; }
.win-content--meme { left: 1330px; }

#memeStack img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  opacity: 0;
  transition: opacity 110ms linear;
}

#memeStack img.active { opacity: 1; }

.statusbar {
  position: absolute;
  top: 1028px;
  width: 665px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: #fff;
  color: #35507f;
  font-family: var(--ui-font);
  font-size: 27px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
}

.statusbar--cam { left: 608px; }
.statusbar--meme { left: 1330px; }
.statusbar b { font-style: normal; font-weight: 700; color: #14264a; }

.debug {
  position: absolute;
  left: 620px;
  top: 581px;
  width: 641px;
  margin: 0;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.72);
  color: #ffe98a;
  font-family: var(--mono);
  font-size: 25px;
  line-height: 1.45;
  white-space: pre-wrap;
  pointer-events: none;
  z-index: 4;
}

.debug.hidden { display: none; }

/* Camera window overlays ----------------------------------------------- */

.win-overlay {
  position: absolute;
  left: 608px;
  top: 569px;
  width: 665px;
  height: 457px;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  background: #fff;
  /* Above the debug readout, so an off/loading/error panel always covers it. */
  z-index: 5;
}

.win-overlay.hidden { display: none; }
.ov-panel.hidden { display: none; }

.ov-title {
  margin: 0 0 12px;
  font-size: 42px;
  font-weight: 700;
  color: #14264a;
}

.ov-body {
  margin: 0;
  font-size: 28px;
  line-height: 1.5;
  color: #4a5b7d;
}

.ov-spinner {
  display: block;
  width: 110px;
  height: 110px;
  margin: 0 auto 20px;
  image-rendering: pixelated;
  animation: spin 1s steps(8) infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .ov-spinner { animation-duration: 4s; }
  #memeStack img { transition: none; }
}

/* Win9x dialog inside the camera window */

.dialog {
  width: 620px;
  background: var(--btn-face);
  border: 4px solid #000;
  box-shadow: inset 4px 4px 0 var(--btn-light), inset -4px -4px 0 var(--btn-shadow);
  padding-bottom: 22px;
}

.dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: linear-gradient(180deg, #2f7bf0, #0044c8);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
}

.dialog-x {
  width: 38px;
  height: 38px;
  image-rendering: pixelated;
  cursor: pointer;
}

.dialog-body {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 22px 22px 18px;
  text-align: left;
}

.dialog-icon { width: 66px; height: 66px; flex: none; image-rendering: pixelated; }
.dialog-body p { margin: 0; font-size: 27px; line-height: 1.45; color: #000; }
.dialog-ok { position: static; width: 220px; height: 72px; margin: 0 auto; display: block; }

/* Win9x buttons -------------------------------------------------------- */

.win9x-btn {
  position: absolute;
  border: 8px solid var(--btn-ink);
  background: var(--btn-face);
  box-shadow: inset 8px 8px 0 var(--btn-light), inset -8px -8px 0 var(--btn-shadow);
  color: var(--btn-ink);
  font-family: var(--label-font);
  font-size: 44px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.win9x-btn:hover { background: #cdcdcd; }

.win9x-btn:active,
.win9x-btn.is-pressed {
  box-shadow: inset 8px 8px 0 var(--btn-shadow), inset -8px -8px 0 var(--btn-light);
  padding-top: 5px;
  padding-left: 5px;
}

.win9x-btn:focus-visible { outline: 4px dotted #000; outline-offset: 5px; }

.btn-camera { left: 922px; top: 1214px; width: 360px; height: 99px; }
.btn-skeleton { left: 1316px; top: 1214px; width: 360px; height: 99px; }

/* Menu bar ------------------------------------------------------------- */

.menubar { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }

.menu-item {
  position: absolute;
  left: var(--x);
  top: 492px;
  width: calc(var(--w) + 18px);
  height: 53px;
  margin-left: -9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
}

.menu-item:hover,
.menu-item.is-open { background: rgba(0, 84, 230, 0.22); }

.dropdown {
  position: absolute;
  left: var(--x);
  top: 545px;
  min-width: 400px;
  margin: 0;
  padding: 7px 0;
  list-style: none;
  background: var(--menu-face);
  border: 3px solid #000;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  z-index: 6;
}

.dropdown.hidden { display: none; }

.dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 26px 10px 14px;
  border: 0;
  background: transparent;
  color: #000;
  font-family: var(--ui-font);
  font-size: 32px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.dropdown button:hover { background: var(--win-blue); color: #fff; }

.tick {
  width: 30px;
  flex: none;
  font-size: 30px;
  line-height: 1;
}

.dropdown button.is-on .tick::before { content: "\2713"; }

/* Menu panel ----------------------------------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(12, 20, 46, 0.55);
  z-index: 10;
}

.overlay.hidden { display: none; }

.menu-panel {
  position: relative;
  width: 848px;
  height: 1200px;
  background: url("assets/menu.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 22px 50px rgba(0, 0, 0, 0.5));
}

/* Hotspots inside the panel are placed in the panel's own 794x1123 space,
   scaled by 848/794 = 1.068. */
.menu-panel > * { --k: 1.068; }

.menu-link {
  position: absolute;
  left: calc(64px * var(--k));
  top: calc(var(--y) * var(--k));
  width: calc(500px * var(--k));
  height: calc(var(--h) * var(--k));
  border-radius: 4px;
}

.menu-link:hover { background: rgba(0, 84, 230, 0.18); }
.menu-link:active { background: rgba(0, 84, 230, 0.32); }

/* Labels live in the artwork, so the anchors carry text for assistive tech
   only - without this it renders as blue underlined links over the design. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.menu-close,
.menu-x,
.menu-titlex {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.menu-close {
  left: calc(60px * var(--k));
  top: calc(696px * var(--k));
  width: calc(360px * var(--k));
  height: calc(104px * var(--k));
}

.menu-close:hover { background: rgba(0, 0, 0, 0.12); }

.menu-x {
  left: calc(424px * var(--k));
  top: calc(688px * var(--k));
  width: calc(64px * var(--k));
  height: calc(64px * var(--k));
  border-radius: 50%;
}

.menu-x:hover { background: rgba(255, 255, 255, 0.35); }

.menu-titlex {
  left: calc(742px * var(--k));
  top: calc(6px * var(--k));
  width: calc(46px * var(--k));
  height: calc(42px * var(--k));
}

.menu-titlex:hover { background: rgba(255, 255, 255, 0.4); }

/* Name dialog ---------------------------------------------------------- */

.name-win {
  width: 1010px;
  background: var(--btn-face);
  border: 7px solid #000;
  box-shadow: inset 7px 7px 0 var(--btn-light), inset -7px -7px 0 var(--btn-shadow),
    18px 18px 0 rgba(0, 0, 0, 0.32);
  padding-bottom: 34px;
}

.name-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  background: linear-gradient(180deg, #2f7bf0, #0044c8);
  color: #fff;
  font-size: 37px;
  font-weight: 700;
}

.name-x { width: 48px; height: 48px; image-rendering: pixelated; cursor: pointer; }

.name-body { padding: 34px 40px 10px; color: #000; }

.name-body label {
  display: block;
  margin-bottom: 16px;
  font-size: 35px;
  font-weight: 700;
}

#nameInput {
  width: 100%;
  padding: 16px 22px;
  border: 5px solid #000;
  box-shadow: inset 5px 5px 0 var(--btn-shadow);
  background: #fff;
  color: #000;
  font-family: "Caveat", var(--label-font), cursive;
  font-weight: 600;
  font-size: 70px;
  line-height: 1.1;
}

#nameInput:focus { outline: 4px dotted #0044c8; outline-offset: 5px; }
#nameInput::placeholder { color: #9aa3b8; }

.name-hint {
  margin: 18px 0 0;
  font-size: 27px;
  line-height: 1.45;
  color: #3c4a68;
}

.name-actions {
  display: flex;
  gap: 26px;
  justify-content: center;
  margin-top: 34px;
}

.name-actions .win9x-btn {
  position: static;
  width: 252px;
  height: 88px;
  font-size: 40px;
}

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

.about-win {
  position: relative;
  width: 1440px;
  max-height: 1170px;
  padding-bottom: 32px;
  background: var(--btn-face);
  border: 6px solid #000;
  box-shadow: inset 6px 6px 0 var(--btn-light), inset -6px -6px 0 var(--btn-shadow),
    16px 16px 0 rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.about-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: linear-gradient(180deg, #2f7bf0, #0044c8);
  color: #fff;
  font-size: 35px;
  font-weight: 700;
}

.about-x { width: 45px; height: 45px; image-rendering: pixelated; cursor: pointer; }

.about-body {
  flex: 1;
  overflow-y: auto;
  margin: 18px;
  padding: 24px 30px;
  background: #fff;
  border: 4px solid #000;
  box-shadow: inset 4px 4px 0 var(--btn-shadow);
  color: #000;
  font-size: 29px;
  line-height: 1.55;
}

.about-body p { margin: 0 0 18px; }
.about-body h3 { margin: 30px 0 14px; font-size: 35px; }

.gesture-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 30px;
}

.gesture-list li {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px;
  border: 3px solid transparent;
}

.gesture-list li.active { border-color: var(--win-blue); background: #eaf0ff; }

.gesture-list img {
  width: 78px;
  height: 78px;
  flex: none;
  object-fit: cover;
  border: 3px solid #000;
  background: #fff;
}

.gesture-list .how { font-size: 27px; }
.gesture-list .what { font-size: 23px; color: #4a5b7d; }

.credit { margin-top: 24px; font-size: 27px; color: #4a5b7d; }

.about-ok { position: static; align-self: center; width: 266px; height: 82px; font-size: 40px; }

/* Portrait phones ------------------------------------------------------ */

#rotateHint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 14px;
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: #9fb0d8;
  display: none;
}

@media (max-width: 820px) and (orientation: portrait) {
  #rotateHint { display: block; }
}

/* Discovery toast ------------------------------------------------------ */

.toast {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 24px);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 26px 16px 18px;
  background: var(--btn-face);
  border: 5px solid #000;
  box-shadow: inset 5px 5px 0 var(--btn-light), inset -5px -5px 0 var(--btn-shadow),
    12px 12px 0 rgba(0, 0, 0, 0.28);
  color: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 9;
}

.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast img { width: 72px; height: 72px; object-fit: cover; border: 3px solid #000; background: #fff; }
.toast .toast-title { font-size: 30px; font-weight: 700; }
.toast .toast-sub { font-size: 24px; color: #3c4a68; }

/* Gesture list: found / not yet found ---------------------------------- */

.gesture-list li:not(.found) img { filter: grayscale(1) contrast(0.75); opacity: 0.5; }
.gesture-list li.found .how::after { content: " ¹3"; color: #1d7a2e; font-weight: 700; }

.found-count {
  float: right;
  font-size: 26px;
  font-weight: 400;
  color: #3c4a68;
}

@media (prefers-reduced-motion: reduce) {
  #stage { transition: none; }
  .toast { transition: none; }
}
