/* pnw.ad · First Chair: the game stage, its HUD and cards, and the postcards below it. */

.play .bar {
  position: relative;
  z-index: 5;
}

.stage {
  position: relative;
  height: calc(100svh - 64px);
  min-height: 540px;
  max-height: 1100px;
  overflow: hidden;
  background: #0d1b2e;
  color: var(--snow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
}
.stage:focus-visible {
  box-shadow: inset 0 0 0 3px var(--focus);
}
.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.fallback-art {
  position: absolute;
  inset: 0;
  display: none;
}
.fallback-art canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.fallback-art .ghost {
  display: none;
}
.stage.no-webgl .fallback-art {
  display: block;
}
.stage.no-webgl .hud,
.stage.no-webgl .game-buttons,
.stage.no-webgl .hints {
  display: none;
}

/* HUD */
.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  z-index: 2;
  pointer-events: none;
  font: 600 13px/1.2 var(--sans);
  text-shadow: 0 1px 6px rgba(4, 10, 20, 0.55);
  opacity: 0;
  transition: opacity 0.4s ease;
}
/* a soft shade along the top while riding, so the white HUD reads over a bright morning sky */
.stage::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 1;
  height: 130px;
  background: linear-gradient(rgba(6, 14, 26, 0.42), rgba(6, 14, 26, 0));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.stage.playing::after {
  opacity: 1;
}
/* nothing to pause until the run starts */
.stage:not(.playing) [data-action="pause"] {
  display: none;
}
.stage.playing .hud {
  opacity: 1;
}
.hud-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}
.hud-total {
  font: 600 30px/1 var(--serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.hud-pending {
  display: block;
  color: #ffd2b8;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}
.hud-stretch {
  justify-self: center;
  text-align: center;
  width: min(220px, 100%);
}
.hud-bar {
  display: block;
  height: 4px;
  margin-top: 6px;
  border-radius: 4px;
  background: rgba(251, 247, 239, 0.25);
  overflow: hidden;
}
.hud-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--salmon);
  border-radius: 4px;
}
.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-right: 140px;
}
.hud-speed strong {
  font: 600 22px/1 var(--serif);
  font-variant-numeric: tabular-nums;
}
.hud-spotted {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-buttons {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 3;
}
.icon-button {
  min-width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(251, 247, 239, 0.35);
  background: rgba(8, 16, 30, 0.42);
  color: var(--snow);
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  font: 650 12px/1 var(--sans);
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.icon-button svg {
  width: 20px;
  height: 20px;
}
.icon-button[aria-pressed="false"] .waves,
.icon-button[aria-pressed="true"] .mute {
  display: none;
}

/* toasts */
.toast {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translate(-50%, 0);
  margin: 0;
  padding: 10px 18px;
  background: rgba(8, 16, 30, 0.55);
  font: 600 19px/1.2 var(--serif);
  width: max-content;
  max-width: calc(100% - 48px);
  text-align: center;
  text-wrap: balance;
  border-radius: 22px;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.toast.show {
  animation: toast 2.2s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.toast.crash {
  background: rgba(120, 30, 20, 0.6);
}
@keyframes toast {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.96);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}
.spotted-flash {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  margin: 0;
  font: 700 clamp(44px, 12vw, 96px)/1 var(--serif);
  font-style: italic;
  color: #ffe0b8;
  text-shadow: 0 4px 30px rgba(240, 138, 93, 0.8), 0 1px 0 #6b2a14;
  opacity: 0;
  pointer-events: none;
}
.spotted-flash.show {
  animation: spotted 2.4s ease both;
}
@keyframes spotted {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6) rotate(-6deg);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06) rotate(-3deg);
  }
  75% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(-3deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(1) rotate(-3deg);
  }
}

/* touch hints */
.hints {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.stage.playing .hints.on {
  opacity: 1;
}
.hint {
  margin: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(8, 16, 30, 0.5);
  font: 600 13px/1.2 var(--sans);
  transition: opacity 0.6s ease;
}
.hint.done {
  opacity: 0.25;
}
.hint-icon {
  display: inline-block;
  min-width: 1.2em;
  text-align: center;
  color: #ffd2b8;
}
.hint.keys,
.touch .hint.touch {
  display: block;
}
.hint.touch,
.touch .hint.keys {
  display: none;
}
.touch-only {
  display: none;
}
.touch .touch-only {
  display: inline;
}
.touch .keys-only {
  display: none;
}

/* cards over the game */
.card-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 64px 14px 18px;
  background: linear-gradient(180deg, rgba(8, 16, 30, 0.15), rgba(8, 16, 30, 0.55));
  overflow-y: auto;
  z-index: 4;
}
.card-layer[hidden] {
  display: none;
}
.card {
  width: min(560px, 100%);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  color: var(--ink);
  border-radius: 24px;
  padding: 24px 22px 22px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.card h1 {
  font-size: clamp(42px, 12vw, 64px);
  font-weight: 560;
  margin: 6px 0 10px;
}
.card h2 {
  font-size: clamp(28px, 7vw, 38px);
}
.card h2 .unit {
  font-style: italic;
  font-size: 0.6em;
  font-weight: 450;
}
.card-lede {
  color: var(--ink-2);
  font-size: 16px;
}
.how {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.how-title {
  font-size: 20px;
  font-weight: 560;
}
.how-grid {
  margin: 10px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.how-grid div {
  min-width: 0;
}
.how-grid dt {
  font-weight: 650;
  font-size: 13.5px;
}
.how-grid dd {
  margin: 0;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.35;
}
.how-note {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--ink-2);
  font-style: italic;
}
.card-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}
.best {
  color: var(--ink-2);
  font-size: 14px;
}
.best strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.small-card {
  width: min(420px, 100%);
}
.finish-line {
  margin-top: 8px;
  color: var(--ink-2);
}

/* postcards */
.postcards {
  padding: 72px var(--gutter) 96px;
}
.postcards-inner {
  max-width: 1120px;
  margin: 0 auto;
}
.postcards h2 {
  font-size: clamp(30px, 7vw, 46px);
  margin: 8px 0 28px;
}
.postcard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}
.postcard {
  position: relative;
  display: grid;
  grid-template-rows: 150px auto;
  border-radius: 20px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 1px 0 var(--rule), 0 20px 40px -30px rgba(0, 0, 0, 0.5);
}
.postcard-art {
  background-size: cover;
}
.postcard-art.baker {
  background: radial-gradient(120% 90% at 70% 120%, #fbf7ef 0 38%, transparent 39%), radial-gradient(60% 60% at 40% 100%, #dfe9f6 0 50%, transparent 51%), linear-gradient(180deg, #5b8fd6, #cfe1f4);
}
.postcard-art.paradise {
  background: radial-gradient(90% 70% at 50% 115%, #fff7ea 0 44%, transparent 45%), linear-gradient(180deg, #5375b8, #f6cf9e 80%);
}
.postcard-art.mission {
  background: radial-gradient(10px 10px at 30% 60%, #ffe2a6 0 40%, transparent 100%), radial-gradient(10px 10px at 55% 48%, #ffe2a6 0 40%, transparent 100%), radial-gradient(10px 10px at 78% 38%, #ffe2a6 0 40%, transparent 100%), radial-gradient(120% 70% at 40% 120%, #1b2a55 0 45%, transparent 46%), linear-gradient(180deg, #050b20, #1f3166);
}
.postcard-art.bigfoot {
  background: radial-gradient(14% 30% at 52% 70%, #2a1c14 0 60%, transparent 61%), radial-gradient(8% 9% at 52% 42%, #2a1c14 0 60%, transparent 61%), linear-gradient(180deg, #2f5a40, #10262a);
}
.postcard-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.postcard h3 {
  font-size: 24px;
  font-weight: 560;
}
.postcard-body p:not(.label) {
  color: var(--ink-2);
  font-size: 15.5px;
}
.postcard-body .maps-link {
  margin-top: 6px;
  font-weight: 600;
  color: var(--accent);
}
.postcard-lock {
  display: none;
}
.postcard.locked .postcard-body,
.postcard.locked .postcard-art {
  display: none;
}
.postcard.locked {
  grid-template-rows: auto;
  min-height: 150px;
  place-items: center;
  border: 1.5px dashed var(--rule);
  background: transparent;
  box-shadow: none;
}
.postcard.locked .postcard-lock {
  display: block;
  padding: 24px;
  text-align: center;
  color: var(--ink-2);
  font-weight: 600;
}
.question {
  display: block;
  font: 600 64px/1 var(--serif);
  color: var(--accent);
  margin-bottom: 6px;
}
.postcard.fresh {
  animation: fresh 1.4s ease;
}
@keyframes fresh {
  0% {
    transform: scale(0.96);
    box-shadow: 0 0 0 0 rgba(240, 138, 93, 0.7);
  }
  60% {
    box-shadow: 0 0 0 14px rgba(240, 138, 93, 0);
  }
  100% {
    transform: none;
  }
}

@media (min-width: 720px) {
  .postcard-list {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 1080px) {
  .postcard-list {
    grid-template-columns: repeat(4, 1fr);
  }
  .stage {
    height: calc(100vh - 72px);
  }
  .hud {
    top: 18px;
    left: 22px;
    right: 22px;
  }
  .card {
    padding: 32px 32px 28px;
  }
}
@media (max-width: 520px) {
  .hud-right {
    margin-right: 0;
    margin-top: 48px;
  }
  .hud-stretch {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  /* calm: the same messages, faded in and out without moving */
  .toast.show,
  .spotted-flash.show {
    animation-name: calm-fade;
  }
  .postcard.fresh {
    animation: none;
  }
}
@keyframes calm-fade {
  0%,
  100% {
    opacity: 0;
  }
  15%,
  80% {
    opacity: 1;
  }
}
