@font-face {
  font-family: "Fira Code";
  src: url("../assets/fonts/FiraCode-VF.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: only light;
  --ink: #281e28;
  --cream: #fff4c2;
  --rose: #ef668d;
  --rose-dark: #a93961;
  --teal: #193f46;
  --water: #3d9eb5;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 3vw, 2rem);
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(#173b43 0 4px, transparent 4px),
    repeating-linear-gradient(90deg, #173b43 0 3px, #22545a 3px 6px);
  font-family: "Fira Code", ui-monospace, monospace;
}

.experiment {
  position: relative;
  container-type: inline-size;
  width: min(100%, 640px);
  filter: drop-shadow(0 10px 0 rgb(20 29 35 / 35%));
}

.title-card {
  position: absolute;
  z-index: 3;
  top: clamp(0.45rem, 3cqw, 1rem);
  left: clamp(0.55rem, 3cqw, 1.15rem);
  display: grid;
  pointer-events: none;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink);
  transform: rotate(-2deg);
}

.title-card span {
  font-size: clamp(0.55rem, 2.1cqw, 0.8rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.title-card strong {
  color: #ffcf4f;
  font-size: clamp(0.9rem, 4cqw, 1.55rem);
  line-height: 0.95;
}

.scene {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M4 2h6v4h4v4h4v8h-4v4H8v-4H4z' fill='%23fff4c2' stroke='%23281e28' stroke-width='2'/%3E%3C/svg%3E") 4 2, pointer;
  border: 4px solid var(--ink);
  border-radius: 2px;
  background: var(--water);
  box-shadow: inset 0 0 0 3px #fff4c2, 0 0 0 3px #c44f70;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgb(40 30 40 / 7%) 0 1px, transparent 1px 4px);
  mix-blend-mode: multiply;
}

.scene:focus-visible {
  outline: 4px solid #fff6a7;
  outline-offset: 7px;
}

.scene:disabled { cursor: wait; }

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 420;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.click-cue {
  position: absolute;
  z-index: 2;
  right: 8.5%;
  bottom: 8%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.55rem;
  border: 2px solid var(--ink);
  background: var(--cream);
  box-shadow: 3px 3px 0 var(--ink);
  font: 700 clamp(0.48rem, 1.8cqw, 0.7rem)/1 "Fira Code", monospace;
  text-transform: uppercase;
  transition: opacity 120ms linear, transform 120ms steps(2, end);
}

.click-cue i {
  width: 0;
  height: 0;
  border-block: 5px solid transparent;
  border-left: 8px solid var(--rose-dark);
}

.scene:hover .click-cue,
.scene:focus-visible .click-cue { transform: translate(-3px, -2px); }
.scene:disabled .click-cue { opacity: 0; }

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.7rem 0.85rem;
  border: 4px solid var(--ink);
  border-top: 0;
  background: var(--cream);
  box-shadow: inset 0 -3px #d4b85f;
}

.controls p {
  margin: 0;
  font-size: clamp(0.6rem, 2.3cqw, 0.78rem);
  line-height: 1.35;
}

.controls button {
  flex: none;
  padding: 0.45rem 0.65rem;
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--rose-dark);
  box-shadow: 2px 2px 0 var(--ink);
  font: 700 clamp(0.58rem, 2cqw, 0.72rem)/1 "Fira Code", monospace;
  cursor: pointer;
}

.controls button:hover:not(:disabled) { background: var(--rose); }
.controls button:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.controls button:focus-visible { outline: 3px solid var(--rose); outline-offset: 3px; }
.controls button:disabled { opacity: 0.45; cursor: wait; }

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

@media (max-width: 480px) {
  .controls { align-items: flex-start; }
  .controls p { max-width: 66%; }
  .click-cue span { display: none; }
  .click-cue { padding: 0.4rem 0.35rem 0.4rem 0.45rem; }
}

@media (prefers-reduced-motion: reduce) {
  .experiment { filter: none; }
  .click-cue { transition: none; }
  .scene::after { display: none; }
}

.controls button { min-height: 44px; }
html.embedded body { display: flex; min-height: 100svh; padding: 8px; }
html.embedded .experiment { width: min(100%, 800px, calc((100svh - 100px) * 1.5238)); margin: auto; flex: none; }
