/* Lab 04: The Garden – a small white isometric landscape drawn in black lines, where the clock man sows
   his field and harvests the projects that grow from it */

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* the page never scrolls – scrolling and pinching zoom */
  overscroll-behavior: none;
  background: #ffffff;
}

.garden {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* A harvested project's title in a box, with its points beside it, rising and fading away. Placed
   and moved from script.js; the middle of the two is at the element's position */
.clouds {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.cloud {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

/* The title and its points side by side; more about the project (once bought) in boxes below */
.cloud-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

/* Z z z – floating up from the roof while he sleeps */
.snore {
  position: absolute;
  top: 0;
  left: 0;
  font-family: "Suisse Intl", sans-serif;
  color: #eeeeee;
}

/* The cursor: the site's black dot by day, a light one at night */
html.lab-dark {
  --cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Ccircle cx='4' cy='4' r='4' fill='%23EEEEEE'/%3E%3C/svg%3E") 4 4, auto;
  --cursor-clickable: var(--cursor);
}

/* The game's own boxes – the points and happiness on the left, messages, a harvest's title and points, the
   machine's panel – look like the buttons at the top: square, frosted, Suisse Intl Medium.
   At night they turn dark grey with light text, like the buttons */
.tally p,
.speech-text,
.speech-button,
.field-count,
.machine-count,
.message,
.cloud-title,
.cloud-points,
.machine-box {
  margin: 0;
  padding: 4px 10px; /* 26px high for a line, like the buttons */
  background: rgb(220 220 220 / 50%);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font: 500 14px/18px "Suisse Intl", sans-serif;
  letter-spacing: -0.01em;
  color: #121212;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.6s ease, color 0.6s ease;
}

.lab-dark .tally p,
.lab-dark .speech-text,
.lab-dark .field-count:not(.is-full),
.lab-dark .message,
.lab-dark .cloud-title,
.lab-dark .machine-box {
  background: #474747;
  color: #eeeeee;
}

.tally {
  position: fixed;
  top: 50%;
  left: 4px;
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.message {
  width: max-content;
  max-width: 320px; /* longer messages wrap */
  white-space: normal;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease, background-color 0.6s ease, color 0.6s ease;
}

/* The logo, in the middle until you click to start, then fading away */
.logo {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 30;
  width: min(72vw, 1100px);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.logo svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible; /* the line round the edge letters */
}

/* Drawn in outline, the same 1px line as the landscape: a 2px line behind, half of it hidden by the
   white letters on top – so only the outer edge shows, and overlapping letters run together */
.logo path {
  fill: #000000;
  stroke: #000000;
  stroke-width: 2px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.logo .logo-fill {
  fill: #ffffff;
  stroke: none;
}

.logo.is-gone {
  opacity: 0;
}

/* "Click to start": black, like the points */
.message.is-start {
  background: #121212;
  color: #eeeeee;
}

/* A message sits where the pointer is, in its place (moved by script.js): the dot is hidden meanwhile.
   Until the pointer has moved, nobody knows where that is: hidden */
.message:not(.is-following) {
  visibility: hidden;
}

html.is-messaging:not(.is-off-game),
html.is-messaging:not(.is-off-game) * {
  cursor: none !important;
}

/* Over the menu at the top, or out of the window, the message goes – and comes back over the game */
html.is-off-game .message {
  visibility: hidden;
}

/* While he speaks, the pointer's messages wait and the dot shows, so the button is easy to hit */
html.is-speaking .message {
  visibility: hidden;
}

html.is-speaking.is-messaging,
html.is-speaking.is-messaging * {
  cursor: var(--cursor) !important;
}

html.is-speaking.is-messaging .speech-button {
  cursor: var(--cursor-clickable) !important;
}

.tally.is-shown,
.message.is-shown {
  opacity: 1;
}

/* The points, then his mood – a face (face happy/neutral/sad.svg: black, light at night) beside the
   happiness – then a black button opening the list of what makes it up, in grey boxes */
.mood,
.happiness-reasons {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.mood[hidden],
.happiness-reasons[hidden] {
  display: none;
}

.mood-row {
  display: flex;
  gap: 2px;
}

.mood-face {
  display: block;
  width: 26px;
  height: 26px;
  transition: filter 0.6s ease;
}

.lab-dark .mood-face {
  filter: invert(1) brightness(0.93); /* #121212 on #eeeeee */
}

.effects-button {
  margin: 0;
  padding: 4px 10px;
  border: 0;
  background: #121212;
  font: 500 14px/18px "Suisse Intl", sans-serif;
  letter-spacing: -0.01em;
  color: #eeeeee;
  -webkit-font-smoothing: antialiased;
  pointer-events: auto; /* the panel round it lets clicks through */
  cursor: var(--cursor-clickable);
}

@media (hover: hover) {
  .effects-button:hover {
    background: #00ff59;
    color: #121212;
  }
}

.lab-dark .effects-button {
  background: #eeeeee;
  color: #121212;
}

/* Over each field: how much is sown against what it holds – grey, black when full (light at night) */
.field-count {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.field-count.is-shown {
  opacity: 1;
}

.field-count.is-full {
  background: #121212;
  color: #eeeeee;
}

.lab-dark .field-count.is-full {
  background: #eeeeee;
  color: #121212;
}

/* What he says, over his head: the words in grey, the button in black (green under the pointer, like
   the buttons at the top), light at night */
.speech {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

.speech[hidden] {
  display: none;
}

/* Over the game while he speaks, under the speech itself and the menu at the top */
.speech-shield {
  position: fixed;
  inset: 0;
  z-index: 55;
}

.speech-shield[hidden] {
  display: none;
}

/* Longer words wrap, at 300px – the button stays at the top on the right */
.speech-text {
  width: max-content;
  max-width: 300px;
  white-space: normal;
}

.speech-button {
  border: 0;
  background: #121212;
  color: #eeeeee;
  cursor: var(--cursor-clickable);
}

@media (hover: hover) {
  .speech-button:hover {
    background: #00ff59;
    color: #121212;
    transition: none;
  }
}

.lab-dark .speech-button {
  background: #eeeeee;
  color: #121212;
}

/* −Value at the office, and the points lost on a harvest, on a bad day */
.cloud .is-lost {
  background: #fe0000;
  color: #ffffff;
}

/* Over the machine: how many things it has for you, in a black box like the points a harvest gives */
.machine-count {
  position: absolute;
  top: 0;
  left: 0;
  background: #121212;
  color: #eeeeee;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.machine-count.is-shown {
  opacity: 1;
}

/* The points a harvest gave: black beside the title, light at night so it still stands out */
.cloud-points {
  background: #121212;
  color: #eeeeee;
}

.lab-dark .cloud-points {
  background: #eeeeee;
  color: #121212;
}

/* The symbol for something bought in the webshop, before its name */
.cloud-icon {
  width: 14px;
  height: 14px;
  margin: 0 6px -2px 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

/* Long titles wrap */
.cloud-title {
  width: max-content;
  max-width: 320px;
  white-space: normal;
}

/* The machine's panel, beside the machine: a title, then a row per upgrade – what it is and costs in
   one box, and a dark + Buy box beside it */
.machine {
  position: fixed;
  top: 50%;
  right: calc(50% + 60px);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.machine.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%);
}

.machine-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

.machine-buy {
  height: 26px;
  padding: 0 10px;
  border: 0;
  background: #121212;
  font: 500 14px/18px "Suisse Intl", sans-serif;
  letter-spacing: -0.01em;
  color: #eeeeee;
  white-space: nowrap;
}

.lab-dark .machine-buy {
  background: #eeeeee;
  color: #121212;
}

@media (hover: hover) {
  .machine-buy:not(:disabled):hover {
    background: #00ff59;
    color: #121212;
  }
}

/* Not enough points yet */
.machine-buy:disabled {
  opacity: 0.35;
}

/* The end: the farm is sold – the boxes go, and as he walks out of the picture it goes black */
.is-leaving .tally,
.is-leaving .message,
.is-leaving .field-count,
.is-leaving .machine-count,
.is-leaving .shop-count {
  visibility: hidden;
}

.the-end {
  position: fixed;
  inset: 0;
  z-index: 1000; /* over everything, the site's menu too */
  background: #000000;
  opacity: 0;
  transition: opacity 2.4s ease;
  pointer-events: none;
}

.the-end.is-shown {
  opacity: 1;
}

/* How far along he is: a grey line, 200 × 8, filling with black from the left */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  width: 200px;
  height: 8px;
  background: #d9d9d9;
  pointer-events: none;
}

.progress[hidden] {
  display: none;
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: #121212;
  transform: scaleX(0);
  transform-origin: left;
}

/* At night, like the other boxes: dark grey, filling with light grey */
.lab-dark .progress {
  background: #474747;
}

.lab-dark .progress-fill {
  background: #eeeeee;
}

/* While a box he speaks in waits to be closed, everything else steps back to half (a filter, so it goes
   with what the boxes' own opacity does). The landscape too, all but him – done in script.js */
.is-speaking .machine,
.is-speaking .tally,
.is-speaking .message,
.is-speaking .clouds,
.is-speaking .progress,
.is-speaking .lab-header {
  filter: opacity(50%);
}
