:root {
  --fg: rgba(255, 255, 255, 0.94);
  --dim: rgba(255, 255, 255, 0.66);
  --edge: clamp(20px, 3vw, 36px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8c9296;
  color: var(--fg);
  font: 300 18px/1.5 "Newsreader", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  text-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-shadow: inherit;
}

a { color: inherit; text-decoration: none; }

:focus-visible { outline: 1px solid var(--dim); outline-offset: 4px; }

/* ——— The scene ——— */

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

/* Fallback when WebGL2 isn't available */
.no-gl .world { display: none; }
.no-gl {
  background-size: cover;
  background-position: center;
}

/* ——— Interface ——— */

.top,
.ui {
  position: fixed;
  left: var(--edge);
  right: var(--edge);
  z-index: 3;
  pointer-events: none;
}
.top {
  top: max(var(--edge), env(safe-area-inset-top));
  display: flex;
  justify-content: flex-end;
}
.ui {
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
}
.top > *, .ui > * { pointer-events: auto; }

.sound {
  font-size: 15px;
  color: var(--dim);
}

.time {
  justify-self: start;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.change {
  justify-self: end;
  color: var(--dim);
}

.sound, .time, .change {
  transition: color 0.3s, opacity 0.8s var(--ease);
}
.sound:hover, .change:hover { color: var(--fg); }

.title {
  display: inline-grid;
  justify-items: center;
}
.title > span {
  grid-area: 1 / 1;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.title-alt { opacity: 0; transform: translateY(6px); }

@media (hover: hover) {
  .title:hover .title-main { opacity: 0; transform: translateY(-6px); }
  .title:hover .title-alt  { opacity: 1; transform: none; }
}

.is-walking .change { opacity: 0; pointer-events: none; }

/* ——— Quote ——— */

.quote {
  position: fixed;
  top: max(var(--edge), env(safe-area-inset-top));
  left: var(--edge);
  z-index: 3;
  margin: 0;
  max-width: 23rem;
  font-size: 15px;
  line-height: 1.6;
  color: var(--dim);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 2s var(--ease), transform 2s var(--ease);
}

/* A soft shadow of air behind the words so they read over pale mist. */
.quote::before {
  content: "";
  position: absolute;
  inset: -70px -90px -70px -70px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(20, 24, 28, 0.2), transparent);
}

.quote blockquote { margin: 0; }
.quote p { margin: 0; text-wrap: pretty; }
.quote em { font-style: normal; color: var(--fg); }
.quote figcaption { margin-top: 0.8em; font-style: italic; }
.quote figcaption::before { content: "— "; }

.is-ready .quote { opacity: 1; transform: none; }

/* ——— Centered whispers ——— */

.walking,
.hint {
  position: fixed;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  z-index: 2;
  pointer-events: none;
  color: var(--fg);
  opacity: 0;
  transition: opacity 1.2s var(--ease);
}
.is-walking .walking { opacity: 1; }

.hint { font-style: italic; }
.hint.is-shown { opacity: 1; }
.is-walking .hint { opacity: 0; }

.dots::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: dots 1.4s steps(4) infinite;
}
@keyframes dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

/* ——— About ——— */

.about {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--edge);
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s var(--ease), visibility 0s 0.9s;
}

.about-inner { max-width: 27rem; }

.about p {
  margin: 0 0 1.1em;
  text-wrap: pretty;
}

.about p,
.links {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: calc(var(--i, 0) * 90ms + 350ms);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em 1.25em;
  margin-top: 2em;
  color: var(--dim);
}
.links a { transition: color 0.3s; }
.links a:hover { color: var(--fg); }

.is-open .about {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.9s var(--ease), visibility 0s;
}
.is-open .about p,
.is-open .links { opacity: 1; transform: none; }

.is-open .quote,
.is-open .time,
.is-open .change,
.is-open .hint { opacity: 0; pointer-events: none; }
.is-open .quote { transition-duration: 0.7s; }

.is-open .title-main { opacity: 0; transform: translateY(-6px); }
.is-open .title-alt  { opacity: 1; transform: none; }

/* ——— Right-click menu ——— */

.context {
  position: fixed;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 16px;
}
.context[hidden] { display: none; }
.context a, .context button {
  text-align: left;
  color: var(--dim);
  transition: color 0.2s;
}
.context a:hover, .context button:hover { color: var(--fg); }

/* ——— Small screens ——— */

@media (max-height: 640px) and (min-width: 561px) {
  .quote { font-size: 13.5px; max-width: 21rem; }
}

@media (max-width: 560px) {
  html, body { font-size: 16px; }
  .sound { font-size: 14px; }
  .quote {
    top: calc(max(var(--edge), env(safe-area-inset-top)) + 2.2em);
    right: var(--edge);
    max-width: none;
    font-size: 13.5px;
    line-height: 1.55;
  }
}
