/* OpsMill brand colours (Brand Guide, Apr 2026). */
:root {
  --om-purple: #231556;
  --om-purple-65: #706791;
  --om-blue: #426DB1;
  --om-blue-hover: #375E9C;
  --om-yellow: #FED34C;

  --bg: var(--om-purple);
  --text: #ffffff;
  --glow: rgb(254 211 76 / 0.7);
  --button-bg: var(--om-blue);
  --button-hover: var(--om-blue-hover);
  --control: rgb(255 255 255 / 0.08);
  --control-hover: rgb(255 255 255 / 0.16);
  --panel: #2F2263;
  --panel-line: var(--om-purple-65);
  --highlight: var(--om-yellow);
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#topology {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}

/* At least 10rem clear at the bottom so a two-line quote never meets the
   controls or the menu hint on short screens. */
#stage.playing {
  justify-content: flex-end;
  padding: 0 2.5rem max(15vh, 10rem);
}

#enter {
  cursor: pointer;
  border: 0;
  border-radius: 0;
  background: var(--button-bg);
  color: var(--text);
  padding: 1rem 2rem;
  font-size: 1.125rem;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: background-color 0.25s;
}

#enter:hover,
#enter:focus-visible {
  background: var(--button-hover);
}

.quote {
  margin: 0;
  max-width: 28em;
  text-align: center;
  font-family: Papyrus, "Herculanum", fantasy;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  line-height: 1.15;
  color: var(--text);
  text-shadow: 0 0 20px #ffffff, 0 0 20px var(--glow);
  z-index: 10;
}

.quote.reveal {
  animation:
    fade-in 4s ease forwards,
    diamond-in 2.5s cubic-bezier(0.25, 1, 0.3, 1) forwards;
}

.quote.leave {
  animation: fade-out 1.2s ease forwards;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes diamond-in {
  from { clip-path: polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%); }
  to { clip-path: polygon(50% -150%, 250% 50%, 50% 250%, -150% 50%); }
}

/* Top-right link to quotes.md on GitHub, where people can open a PR. */
.suggest {
  position: fixed;
  top: 1.5rem;
  right: 2.5rem;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 2.25rem;
  padding: 0 0.9rem;
  border-radius: 1.125rem;
  background: var(--control);
  color: var(--text);
  font-size: 0.8rem;
  text-decoration: none;
  opacity: 0.75;
  transition: opacity 0.2s, background-color 0.2s;
}

.suggest:hover,
.suggest:focus-visible {
  opacity: 1;
  background: var(--control-hover);
}

.suggest:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.suggest svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

@media (max-width: 639px) {
  .suggest {
    top: 16px;
    right: 16px;
  }
}

.footer {
  position: fixed;
  bottom: 2.5rem;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 100;
  opacity: 0.8;
  z-index: 20;
}

.footer a {
  color: var(--text);
  text-decoration: none;
}

.footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.footer .brand {
  height: 1.5em;
  width: auto;
  display: block;
}

.controls {
  position: fixed;
  bottom: 2rem;
  left: 2.5rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls[hidden] {
  display: none;
}

.mute {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--control);
  color: var(--text);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.25s, background-color 0.25s;
}

.mute:hover,
.mute:focus-visible {
  opacity: 1;
  background: var(--control-hover);
}

.mute svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.mute .wave {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.mute .icon-muted,
.mute[aria-pressed="true"] .icon-sound {
  display: none;
}

.mute[aria-pressed="true"] .icon-muted {
  display: block;
}

.ambience-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.5rem;
  max-width: 15rem;
  padding: 0 2.2rem 0 0.8rem;
  border: 0;
  border-radius: 1.25rem;
  background: var(--control);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.25s, background-color 0.25s;
}

.ambience-button:hover,
.ambience-button:focus-visible,
.ambience-button[aria-expanded="true"] {
  opacity: 1;
  background: var(--control-hover);
}

.ambience-button:disabled {
  cursor: progress;
}

.ambience-button svg {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.ambience-button svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.ambience-current {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ambience-button::after {
  content: "";
  position: absolute;
  right: 0.95rem;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: translateY(-25%) rotate(45deg);
  transition: transform 0.2s;
}

.ambience-button[aria-expanded="true"]::after {
  transform: translateY(-75%) rotate(225deg);
}

/* The one-time nudge that the menu exists. Sits above the pill, which starts
   3rem in from the left edge of .controls (the mute button plus the gap). */
.ambience-hint {
  position: absolute;
  left: 3rem;
  bottom: calc(100% + 0.75rem);
  width: max-content;
  max-width: min(19rem, calc(100vw - 32px - 3rem));
  padding: 0.5rem 0.8rem;
  border: 1px solid rgb(254 211 76 / 0.45);
  border-radius: 0.8rem;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 0 18px rgb(254 211 76 / 0.2);
  animation: hint-in 0.6s ease forwards;
  transition: opacity 0.4s;
}

.ambience-hint[hidden] {
  display: none;
}

.ambience-hint::after {
  content: "";
  position: absolute;
  left: 1.4rem;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgb(254 211 76 / 0.45);
  border-bottom: 1px solid rgb(254 211 76 / 0.45);
  background: var(--panel);
  transform: rotate(45deg);
}

.ambience-hint.leaving {
  opacity: 0;
}

.ambience.hinting .ambience-button {
  opacity: 1;
  animation: hint-glow 2.4s ease-in-out 2;
}

@keyframes hint-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes hint-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgb(254 211 76 / 0); }
  50% { box-shadow: 0 0 16px 2px rgb(254 211 76 / 0.5); }
}

/* Positioned against .controls so it can use the full width on a phone. */
.ambience-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.6rem);
  width: min(23rem, calc(100vw - 32px));
  padding: 0.5rem;
  border: 1px solid var(--panel-line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: 0 0 40px rgb(254 211 76 / 0.12), 0 12px 32px rgb(0 0 0 / 0.35);
  animation: fade-in 0.2s ease;
}

.ambience-menu[hidden] {
  display: none;
}

.ambience-title {
  margin: 0;
  padding: 0.5rem 0.75rem 0;
  font-family: Papyrus, "Herculanum", fantasy;
  font-size: 1.2rem;
  line-height: 1.2;
  text-shadow: 0 0 12px #ffffff, 0 0 12px var(--glow);
}

.ambience-subtitle {
  margin: 0.25rem 0 0.4rem;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  opacity: 0.6;
}

.ambience-menu ul {
  max-height: min(55vh, 26rem);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  outline: none;
  scrollbar-color: var(--panel-line) transparent;
  scrollbar-width: thin;
}

.ambience-menu li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border-radius: 0.6rem;
  cursor: pointer;
}

.ambience-menu li.active {
  background: rgb(255 255 255 / 0.09);
}

.ambience-menu ul:focus-visible li.active {
  outline: 1px solid rgb(255 255 255 / 0.5);
}

.ambience-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.ambience-tagline {
  font-size: 0.8rem;
  opacity: 0.65;
}

.ambience-menu li[aria-selected="true"] .ambience-name {
  color: var(--highlight);
}

.ambience-menu li[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 0.85rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--highlight);
  box-shadow: 0 0 8px var(--highlight);
  transform: translateY(-50%);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* On phones the controls sit above the footer instead of beside it. */
@media (max-width: 639px) {
  .controls {
    left: 16px;
    right: 16px;
    bottom: 4.25rem;
  }

  .footer {
    bottom: 1.5rem;
  }

  #stage.playing {
    padding-bottom: max(26vh, 12rem);
  }
}

@media (min-width: 640px) {
  .footer {
    left: auto;
    right: 2.5rem;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .quote.reveal {
    animation: fade-in 1.5s ease forwards;
  }

  .ambience-hint {
    animation: fade-in 0.6s ease forwards;
  }

  .ambience.hinting .ambience-button {
    animation: none;
    box-shadow: 0 0 12px 1px rgb(254 211 76 / 0.4);
  }
}
