/* Montessori MCP: one page. The look is described in ../README.md. */

:root {
  --paper: #ffffff;
  --ink: #1b1b1b;
  --text: #333333;
  --muted: #6b6b6b;
  --rule: #d8d8d8;
  /* Moveable-alphabet red and blue, and golden-bead gold */
  --red: #d42a20;
  --blue: #1d4ea3;
  --gold: #e0a526;
  --gold-deep: #b98219;
  --steel: #8a8a8a;

  --letters: "Quicksand", "Varela Round", "Arial Rounded MT Bold", sans-serif;
  --sans: "Atkinson Hyperlegible Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --gutter: clamp(20px, 5vw, 64px);
  --width: 1240px;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

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

.c {
  color: var(--red);
}

.v {
  color: var(--blue);
}

/* ---------- Page ---------- */

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: var(--width);
  margin: 0 auto;
  padding: clamp(40px, 9vh, 104px) var(--gutter) clamp(48px, 8vh, 88px);
}

/* The name: moveable-alphabet letters, each a separate piece */
.name {
  margin: 0;
  font-family: var(--letters);
  font-size: clamp(3.4rem, 8.6vw, 7.5rem);
  font-weight: 700;
  line-height: 1.05;
}

.word {
  display: inline-block;
  white-space: nowrap;
  margin-right: 0.1em;
}

.word:last-child {
  margin-right: 0;
}

.word > span {
  display: inline-block;
  margin-right: 0.035em;
  transform: translateY(var(--y, 0)) rotate(var(--r, 0deg));
  /* A crisp shadow, as if each letter were a cut-out piece lying on the page */
  filter: drop-shadow(0 0.03em 0 rgba(0, 0, 0, 0.12));
}

.columns {
  margin-top: clamp(32px, 5vw, 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  align-items: center;
  gap: clamp(40px, 6vw, 96px);
}

.lede {
  margin: 0;
  max-width: 27em;
  color: var(--ink);
  font-size: clamp(1.25rem, 1.75vw, 1.5rem);
  line-height: 1.45;
}

/* ---------- Sign-up ---------- */

.signup {
  margin-top: 28px;
  max-width: 30rem;
  scroll-margin-top: 24px;
}

.signup > p:first-child {
  margin: 0 0 20px;
}

.signup-form {
  display: flex;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  overflow: hidden;
}

.signup-form:focus-within {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.signup-form input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
}

.signup-form input:focus {
  outline: none;
}

.signup-form input::placeholder {
  color: #8f8f8f;
}

.signup-form button {
  flex: none;
  padding: 0 20px;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

.signup-form button:hover,
.signup-form button:focus-visible {
  background: var(--blue);
  outline: none;
}

.signup-form button:disabled {
  cursor: progress;
  background: var(--muted);
}

.form-status {
  margin: 12px 0 0;
  min-height: 1.55em;
  color: var(--ink);
}

.form-status.is-error {
  color: var(--red);
}

.signup.is-done .signup-form {
  display: none;
}

.signup.is-done .form-status {
  margin-top: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

/* ---------- Diagram ---------- */

.diagram {
  margin: 0;
  width: 100%;
}

.diagram-canvas {
  position: relative;
  aspect-ratio: 640 / 400;
}

.diagram svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.agent {
  fill: var(--ink);
}

.prong {
  fill: var(--steel);
}

.neck {
  fill: var(--gold-deep);
}

.bead {
  fill: var(--gold);
}

.bead-label {
  fill: var(--ink);
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 1px;
}

.thread {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  opacity: 0.4;
}

.thread-dashed {
  stroke-dasharray: 3 5;
  opacity: 0.35;
}

/* Each zero-length dash with a round cap draws one bead. */
.beads {
  fill: none;
  stroke-width: 15;
  stroke-linecap: round;
  stroke-dasharray: 0 18;
  stroke-dashoffset: -10;
}

.beads-red {
  stroke: var(--red);
}

.beads-blue {
  stroke: var(--blue);
}

.beads-ring {
  stroke: #b5b5b5;
}

.beads-ring-hole {
  stroke: var(--paper);
  stroke-width: 10;
}

.loop {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  opacity: 0.5;
}

.node-label {
  position: absolute;
  font-size: clamp(0.8125rem, 1.25vw, 1.0625rem);
  font-weight: 600;
  line-height: 1.25;
}

.agent-label {
  left: 0;
  top: 29%;
  width: 23.44%;
  height: 42%;
  display: grid;
  place-items: center;
  padding: 0 4px;
  color: var(--paper);
  text-align: center;
}

.end-label {
  left: 73%;
  width: 27%;
  transform: translateY(-50%);
  color: var(--ink);
}

.more-label {
  color: var(--muted);
  font-weight: 400;
}

/* ---------- Header (404 page) and footer ---------- */

.site-header {
  width: 100%;
  max-width: var(--width);
  margin: 0 auto;
  padding: 28px var(--gutter) 0;
}

.wordmark {
  font-family: var(--letters);
  font-size: 1.75rem;
  font-weight: 700;
  text-decoration: none;
}

.site-footer {
  width: 100%;
  max-width: var(--width);
  margin: 0 auto;
  padding: 0 var(--gutter) 32px;
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.site-footer a:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

/* ---------- 404 ---------- */

.not-found {
  flex: 1;
  width: 100%;
  max-width: var(--width);
  margin: 0 auto;
  padding: clamp(64px, 14vh, 160px) var(--gutter);
}

.not-found h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
}

.not-found p {
  margin: 16px 0 0;
  font-size: 1.125rem;
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  /* Beads drift slowly along the two working wires. */
  .beads-red,
  .beads-blue {
    animation: flow 2.4s linear infinite;
  }

  .beads-blue {
    animation-duration: 2.9s;
  }

  /* The plug eases toward the agent and back: almost connected. */
  .plug {
    animation: nudge 5s ease-in-out infinite;
  }
}

@keyframes flow {
  from { stroke-dashoffset: -10; }
  to { stroke-dashoffset: -28; }
}

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-6px); }
}

/* ---------- Narrow screens ---------- */

@media (max-width: 900px) {
  .columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
  }

  .diagram {
    max-width: 560px;
  }
}

@media (max-width: 520px) {
  .signup-form button {
    padding: 0 16px;
  }
}
