:root {
  /* Same values as the portal's tokens, so the two read as one site. */
  --ink: #1b1b1b;
  --paper: #fff;
  --text: #68655e;
  --line: #e1dedb;
  --line-strong: #ccc9c5;
  --surface: #faf7f4;
  --surface-strong: #ece8e6;
  --sand: #dec3b1;
  --spike: #eb6834;
  --water: #2a78d6;
  --pattern-stone: #d6d2ce;
  --pattern-sand: #e3cdbd;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* The frame's height follows this element, so nothing here may depend on the frame's height. */
#stage {
  padding: 14px;
}

h2,
p,
ol,
figure {
  margin: 0;
}

a {
  color: inherit;
  text-underline-offset: 4px;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  /* Repeated taps on a button must not zoom the page on iOS. */
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

::selection {
  background: var(--sand);
}

[hidden] {
  display: none !important;
}

.label {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

/* ─────────── Play area ─────────── */
.play {
  display: grid;
  gap: 24px;
  padding-bottom: 20px;
}

.panel {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
}

.bucket {
  padding: 16px;
  border-radius: 4px;
  background: var(--surface);
}

.bucket svg {
  display: block;
  width: 100%;
  max-width: 320px;
  margin-inline: auto;
}

.bucket text {
  font-family: var(--sans);
}

.drips circle {
  visibility: hidden;
}

.drips.running circle {
  visibility: visible;
  animation: drip 0.9s linear infinite;
}

.drips.running circle:nth-child(2) {
  animation-delay: 0.3s;
}

.drips.running circle:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes drip {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(44px);
    opacity: 0;
  }
}

.pour {
  display: grid;
  gap: 6px;
}

.pour-label {
  font-size: 1.125rem;
  font-weight: 500;
}

.pour-ends {
  display: flex;
  justify-content: space-between;
  color: var(--text);
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
  touch-action: pan-y;
}

.readout {
  color: var(--text);
  font-size: 15px;
}

.readout strong {
  color: var(--ink);
  font-size: 2.75rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
}

.caption {
  min-height: 4.5em;
  font-size: 15px;
}

.button {
  width: fit-content;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 500;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.stack {
  display: grid;
  gap: 6px;
}

.stack .button {
  width: 100%;
  text-align: left;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-block: 12px 24px;
}

/* ─────────── Goals ─────────── */
.goals {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.goals ol {
  display: grid;
  gap: 6px;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.goals li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.goals .done {
  color: var(--text);
}

.done .check {
  border-color: var(--ink);
  background: var(--ink);
  background-image: linear-gradient(
    135deg,
    transparent 44%,
    var(--paper) 44% 56%,
    transparent 56%
  );
  box-shadow: inset 0 0 0 3px var(--ink);
}

/* ─────────── Traces ─────────── */
.trace {
  min-width: 0;
}

.trace figcaption {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
}

.scope {
  display: block;
  width: 100%;
  height: 180px;
  border-radius: 2px;
}

.monitor .scope {
  height: 200px;
}

.scene .scope {
  height: 240px;
}

.chart-key {
  display: flex;
  gap: 16px;
  margin: 8px 0 0;
  font-size: 13px;
}

.chart-key span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.key {
  display: inline-block;
  width: 16px;
  height: 2px;
  border-radius: 1px;
}

.key-now {
  background: var(--spike);
}

.key-first {
  background: #b0aca7;
}

/* ─────────── Part 2 ─────────── */
.personas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding-top: 8px;
}

.persona-blurb {
  min-height: 4.5em;
  padding-block: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

.persona {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  text-align: left;
  transition: border-color 0.2s;
}

.persona[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.persona strong {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
}

.persona span {
  display: none;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

/* On phones the neuron shrinks to sit beside the caption, keeping the trace near the cards. */
.monitor {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 16px;
}

.monitor .trace {
  display: contents;
}

.monitor figcaption {
  margin: 0;
}

.monitor .scope {
  grid-column: 1 / -1;
}

.cell {
  padding: 4px;
  border-radius: 4px;
  background: var(--surface);
}

.cell svg {
  display: block;
  width: 100%;
  max-width: 220px;
  margin-inline: auto;
}

/* ─────────── Part 3 ─────────── */
.scene {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.dog {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dog-face {
  flex-shrink: 0;
  font-size: 48px;
  line-height: 1;
}

.bubble {
  flex: 1;
  min-height: 3.1em;
  padding: 10px 14px;
  border-radius: 4px;
  background: var(--surface-strong);
  font-size: 1.0625rem;
  line-height: 1.3;
}

.meter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  font-size: 14px;
}

.meter-label {
  grid-column: 1;
  grid-row: 1;
}

.meter-value {
  grid-column: 2;
  grid-row: 1;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.meter-track {
  position: relative;
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 2px;
  background: var(--surface-strong);
}

.meter-zero {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 1px;
  background: var(--ink);
}

.meter-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--spike);
  transition:
    width 0.25s,
    left 0.25s;
}

.meter-bar.negative {
  background: #1c5cab;
}

/* ─────────── Wider frames ─────────── */
/* These answer to the iframe's width, which is the text column on large screens. */
@media (min-width: 40rem) {
  .play {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
  .play-wide {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  }
  .personas {
    padding-bottom: 20px;
  }
  .persona {
    padding: 14px 16px;
  }
  .persona strong {
    font-size: 1.0625rem;
  }
  .persona span {
    display: block;
  }
  .persona-blurb {
    display: none;
  }
  .monitor {
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 16px;
  }
  .monitor .trace {
    display: block;
  }
  .monitor figcaption {
    margin-bottom: 8px;
  }
  .cell {
    padding: 12px;
  }
  .scene .scope {
    height: 300px;
  }
}

/* Only real pointers get hover styles, or a tapped control stays highlighted on touch screens. */
@media (hover: hover) {
  .button:hover:not(:disabled),
  .persona:hover {
    border-color: var(--ink);
  }
  .button-primary:hover:not(:disabled) {
    background: #3a3836;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
