/* The word with handles */
:root {
  --blue: #2343e6;
  --blue-deep: #1a31b4;
  --paper: #f7f5ee;
  --ink: #0e1440;
  --yellow: #ffd21f;
  --coral: #ff5b4a;
  --grid: rgba(255, 255, 255, 0.12);
  --ruler: 28px;
  --edge: 20px;
  /* the script writes here where the frame is on the board: left, top, width, height */
  --ox: 200px;
  --oy: 200px;
  --fw: 400px;
  --fh: 120px;
}

* { box-sizing: border-box; }
html,
body {
  margin: 0;
  height: 100%;
}
body {
  overflow: hidden;
  background: var(--blue);
  color: var(--paper);
  font-family: 'Geist Mono Variable', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ---- the board: one screen of squared blueprint ---- */
.board {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 420px;
  overflow: hidden;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: var(--ruler) var(--ruler);
  user-select: none;
  -webkit-user-select: none;
}

/* ---- the rulers: they count from the frame's corner, and a band shades the frame's size ---- */
.ruler {
  position: absolute;
  z-index: 3;
  overflow: hidden;
  background-color: var(--blue-deep);
  background-repeat: repeat-x;
  color: rgba(247, 245, 238, 0.72);
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
}
.ruler--x {
  left: 0;
  right: 0;
  top: 0;
  height: var(--ruler);
  border-bottom: 1px solid rgba(247, 245, 238, 0.3);
  background-image:
    linear-gradient(90deg, rgba(247, 245, 238, 0.9) 1px, transparent 1px),
    linear-gradient(90deg, rgba(247, 245, 238, 0.6) 1px, transparent 1px),
    linear-gradient(90deg, rgba(247, 245, 238, 0.38) 1px, transparent 1px);
  background-size: 100px 13px, 50px 9px, 10px 5px;
  background-position: var(--ox) 100%, var(--ox) 100%, var(--ox) 100%;
}
.ruler--y {
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--ruler);
  border-right: 1px solid rgba(247, 245, 238, 0.3);
  background-repeat: repeat-y;
  background-image:
    linear-gradient(rgba(247, 245, 238, 0.9) 1px, transparent 1px),
    linear-gradient(rgba(247, 245, 238, 0.6) 1px, transparent 1px),
    linear-gradient(rgba(247, 245, 238, 0.38) 1px, transparent 1px);
  background-size: 13px 100px, 9px 50px, 5px 10px;
  background-position: 100% var(--oy), 100% var(--oy), 100% var(--oy);
}
.ruler__band {
  position: absolute;
  background: rgba(255, 210, 31, 0.42);
}
.ruler--x .ruler__band {
  top: 0;
  bottom: 0;
  left: var(--ox);
  width: var(--fw);
  box-shadow: inset 1px 0 var(--yellow), inset -1px 0 var(--yellow);
}
.ruler--y .ruler__band {
  left: 0;
  right: 0;
  top: var(--oy);
  height: var(--fh);
  box-shadow: inset 0 1px var(--yellow), inset 0 -1px var(--yellow);
}
.ruler__numbers b {
  position: absolute;
  font-weight: 500;
}
.ruler--x .ruler__numbers b {
  top: 4px;
  left: calc(var(--ox) + var(--n) * 100px + 4px);
}
.ruler--y .ruler__numbers b {
  left: 3px;
  top: calc(var(--oy) + var(--n) * 100px + 4px);
}
/* a hairline on each ruler follows the pointer */
.ruler__mark {
  position: absolute;
  left: 0;
  top: 0;
  background: var(--coral);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ruler--x .ruler__mark {
  width: 1.5px;
  height: 100%;
}
.ruler--y .ruler__mark {
  width: 100%;
  height: 1.5px;
}
.board.has-pointer .ruler__mark {
  opacity: 1;
}
.ruler__corner {
  position: absolute;
  z-index: 4;
  left: 0;
  top: 0;
  width: var(--ruler);
  height: var(--ruler);
  border-right: 1px solid rgba(247, 245, 238, 0.3);
  border-bottom: 1px solid rgba(247, 245, 238, 0.3);
  background: var(--blue-deep);
}

/* ---- the studio's line, top left ---- */
.top {
  position: absolute;
  z-index: 2;
  left: calc(var(--ruler) + var(--edge));
  top: calc(var(--ruler) + var(--edge));
}
.brand {
  margin: 0 0 4px;
  font-family: 'Anybody Variable', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.01em;
}
.top__line {
  margin: 0;
  font-size: 12px;
  font-weight: 450;
  opacity: 0.82;
}

/* ---- dashed guides along the frame's edges, while a corner is pulled ---- */
.guide {
  position: absolute;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.guide--left,
.guide--right {
  top: var(--ruler);
  bottom: 0;
  border-left: 1px dashed rgba(255, 210, 31, 0.55);
}
.guide--top,
.guide--bottom {
  left: var(--ruler);
  right: 0;
  border-top: 1px dashed rgba(255, 210, 31, 0.55);
}
.guide--left { left: var(--ox); }
.guide--right { left: calc(var(--ox) + var(--fw)); }
.guide--top { top: var(--oy); }
.guide--bottom { top: calc(var(--oy) + var(--fh)); }
.board.is-pulling .guide {
  opacity: 1;
}

/* ---- the frame and its word ---- */
.frame {
  position: absolute;
  z-index: 2;
  left: 0;
  top: 0;
  width: var(--fw);
  height: var(--fh);
  transform: translate(var(--ox), var(--oy));
}
.word {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  color: var(--paper);
  font-family: 'Anybody Variable', system-ui, sans-serif;
  font-weight: 780;
  white-space: nowrap;
  transform-origin: 0 0;
  visibility: hidden;
}
.board.is-ready .word {
  visibility: visible;
}
.word__letter {
  display: inline-block;
  transform-origin: 50% 100%;
  will-change: transform;
}
.frame__edge {
  position: absolute;
  background: var(--yellow);
}
.frame__edge--top,
.frame__edge--bottom {
  left: 0;
  right: 0;
  height: 1.5px;
  transform-origin: 0 50%;
}
.frame__edge--left,
.frame__edge--right {
  top: 0;
  bottom: 0;
  width: 1.5px;
  transform-origin: 50% 0;
}
.frame__edge--top { top: -0.75px; }
.frame__edge--bottom { bottom: -0.75px; }
.frame__edge--left { left: -0.75px; }
.frame__edge--right { right: -0.75px; }

/* the handles: small squares, with a finger-sized area around them */
.handle {
  position: absolute;
  z-index: 1;
  width: 12px;
  height: 12px;
  margin: -6px;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 1px;
  background: var(--paper);
  appearance: none;
  touch-action: none;
}
.handle::after {
  content: '';
  position: absolute;
  inset: -17px;
}
.handle--nw { left: 0; top: 0; cursor: nwse-resize; }
.handle--ne { left: 100%; top: 0; cursor: nesw-resize; }
.handle--sw { left: 0; top: 100%; cursor: nesw-resize; }
.handle--se { left: 100%; top: 100%; cursor: nwse-resize; }
.handle.is-held {
  background: var(--yellow);
}
/* only where a pointer can hover: after a touch, :hover would stay on */
@media (hover: hover) {
  .handle:hover {
    background: var(--yellow);
  }
  .replay:hover {
    background: var(--yellow);
  }
}
.handle:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 4px;
}

/* the frame's size and the width the font ended up with */
.frame__size {
  position: absolute;
  left: 50%;
  top: calc(100% + 14px);
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 5px 9px;
  border-radius: 4px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
  transform: translateX(-50%);
}
.frame__axis {
  opacity: 0.66;
}

/* ---- the colleague: cursor, name, and the bubble where the greeting is typed ---- */
.peer {
  position: absolute;
  z-index: 5;
  left: 0;
  top: 0;
  pointer-events: none;
  visibility: hidden;
}
.peer__arrow {
  display: block;
  overflow: visible;
  transform-origin: 2px 2px;
}
.peer__arrow path {
  fill: var(--yellow);
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.peer__name {
  position: absolute;
  left: 17px;
  top: 22px;
  padding: 3px 8px 4px;
  border-radius: 0 8px 8px 8px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
}
.peer__bubble {
  position: absolute;
  left: 17px;
  top: 48px;
  min-height: 36px;
  padding: 9px 13px;
  border-radius: 0 13px 13px 13px;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  white-space: pre;
  transform-origin: 0 0;
  box-shadow: 0 10px 24px rgba(14, 20, 64, 0.28);
}
.peer__caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 1px;
  background: var(--ink);
  vertical-align: -0.16em;
}

/* ---- the hint and the replay button, at the bottom ---- */
.hint {
  position: absolute;
  z-index: 2;
  left: calc(var(--ruler) + var(--edge));
  bottom: var(--edge);
  max-width: 36ch;
  margin: 0;
  font-size: 12px;
  font-weight: 450;
  line-height: 1.45;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.board.is-done .hint {
  opacity: 0.86;
}
.replay {
  position: absolute;
  z-index: 2;
  right: var(--edge);
  bottom: var(--edge);
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.16s ease-out;
}
.replay:active {
  transform: scale(0.96);
}
.replay:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

/* ---- phones: one ruler, everything a little closer ---- */
@media (max-width: 700px) {
  :root {
    --ruler: 22px;
    --edge: 16px;
  }
  .ruler--y,
  .ruler__corner {
    display: none;
  }
  .top {
    left: var(--edge);
  }
  .brand {
    font-size: 19px;
  }
  .guide--top,
  .guide--bottom {
    left: 0;
  }
  .hint {
    left: var(--edge);
    right: calc(var(--edge) + 96px);
    max-width: none;
    font-size: 11px;
  }
  .peer__bubble {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ruler__mark,
  .guide,
  .hint,
  .replay {
    transition: none;
  }
}
