/* Runner Relay: one exchange board. Lamps, plates, a register, one key. */

@font-face {
  font-family: "Routed Gothic";
  src: url("/fonts/routed-gothic.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Routed Gothic Wide";
  src: url("/fonts/routed-gothic-wide.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --panel: #0b1411;
  --lamp: #ffd9a0;
  --lamp-core: #fff4dc;
  --plate: #ece3cc;
  --plate-lo: #d8ceb1;
  --ink: #15120c;
  --ink-2: #4a4333;
  --key: #d8281c;
  --pilot: #37c871;
  --bezel: #060908;
  --bezel-edge: #3a423d;

  --engrave: "Routed Gothic", "Helvetica Neue", Arial, sans-serif;
  --engrave-wide: "Routed Gothic Wide", "Routed Gothic", "Helvetica Neue", Arial, sans-serif;

  --gap: clamp(12px, 2.2vw, 28px);
  --seat: cubic-bezier(.16, 1, .3, 1);
}

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

html {
  background: var(--panel);
  color: var(--plate);
  scrollbar-color: #6f6447 var(--panel);
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
}
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--panel); }
::-webkit-scrollbar-thumb { background: #6f6447; border: 3px solid var(--panel); border-radius: 6px; }
::selection { background: var(--lamp); color: var(--ink); }

body {
  margin: 0;
  font-family: var(--engrave);
  font-size: clamp(1rem, .96rem + .2vw, 1.125rem);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* Without the board, the panel still shows its unlit lamps. */
  background-image: radial-gradient(circle at center, #1e1810 0 33%, transparent 36%);
  background-size: 12px 12px;
}
.lamps body { background-image: none; }

a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 2px; }

/* ---------- the board ---------- */

#board {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.lamps #board { display: block; }

.flash {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #fff1cf;
  opacity: 0;
  pointer-events: none;
}
.flash.go { animation: flash 640ms var(--seat); }
@keyframes flash {
  0% { opacity: 0; }
  10% { opacity: .96; }
  100% { opacity: 0; }
}

/* ---------- plates: engraved laminate, four screws ---------- */

.plate,
.note {
  --screw: #2b2618 0 1.6px, #8d8266 1.9px 2.9px, transparent 3.3px;
  color: var(--ink);
  background-color: var(--plate);
  background-image:
    radial-gradient(circle at 10px 10px, var(--screw)),
    radial-gradient(circle at calc(100% - 10px) 10px, var(--screw)),
    radial-gradient(circle at 10px calc(100% - 10px), var(--screw)),
    radial-gradient(circle at calc(100% - 10px) calc(100% - 10px), var(--screw)),
    linear-gradient(180deg, #f4ecd8, var(--plate) 38%, var(--plate-lo));
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .75),
    inset 0 -1px 0 rgba(70, 58, 24, .4),
    0 0 0 1px #04070a,
    0 10px 22px rgba(0, 0, 0, .5);
}

/* ---------- the rail: nameplate, register, key ---------- */

.rail {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 10px var(--gap);
  padding:
    max(var(--gap), env(safe-area-inset-top))
    max(var(--gap), env(safe-area-inset-right))
    0
    max(var(--gap), env(safe-area-inset-left));
  pointer-events: none;
}
.rail > * { pointer-events: auto; }

.nameplate {
  justify-self: start;
  padding: .62em 2em .56em;
  font-family: var(--engrave-wide);
  font-size: .95rem;
  line-height: 1.1;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  background-image:
    radial-gradient(circle at 11px 50%, var(--screw)),
    radial-gradient(circle at calc(100% - 11px) 50%, var(--screw)),
    linear-gradient(180deg, #f4ecd8, var(--plate) 38%, var(--plate-lo));
}

.register {
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: .22em;
  padding: .5em 1.7em .42em;
}
.register__label,
.register__foot {
  font-family: var(--engrave-wide);
  text-transform: uppercase;
  line-height: 1.1;
}
.register__label { font-size: .7rem; letter-spacing: .2em; }
.register__foot { font-size: .6rem; letter-spacing: .22em; color: var(--ink-2); }
.register__window {
  position: relative;
  display: inline-flex;
  padding: 3px 4px;
  border-radius: 2px;
  background: #090907;
  box-shadow: inset 0 2px 5px #000, 0 1px 0 rgba(255, 255, 255, .6);
  font-size: 1.15rem;
  line-height: 1.25;
  color: #f3ead2;
}
.register__window::after {
  /* the wheels are cylinders: they fall away at the top and bottom of the window */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .72), transparent 30%, transparent 70%, rgba(0, 0, 0, .72));
  pointer-events: none;
}
.wheel {
  width: .7em;
  height: 1.25em;
  overflow: hidden;
  text-align: center;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, .09);
}
.wheel:first-child { box-shadow: none; }
.wheel:nth-child(3n + 1):not(:first-child) { margin-left: 4px; }
.wheel i {
  display: block;
  font-style: normal;
  transform: translateY(calc(var(--d, 0) * -1.25em));
  transition: transform 170ms var(--seat);
}
.wheel b { display: block; height: 1.25em; font-weight: 400; }
.wheel.spin i {
  transition: none;
  filter: blur(.7px);
  animation: spin var(--spin, 420ms) linear infinite;
}
@keyframes spin {
  from { transform: translateY(0); }
  to { transform: translateY(-12.5em); }
}

.keywell {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* ---------- pilot lamp: lights once, on success ---------- */

.pilot {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2b6846, #12301f 70%);
  box-shadow: 0 0 0 2px var(--bezel), 0 0 0 3px var(--bezel-edge);
  transition: background 120ms, box-shadow 120ms;
}
.is-copied .pilot {
  background: radial-gradient(circle at 38% 32%, #f1fff6, #7df0ae 28%, var(--pilot) 62%, #1c8a4c);
  box-shadow: 0 0 0 2px var(--bezel), 0 0 0 3px var(--bezel-edge);
}

/* ---------- the key ---------- */

.key {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  border: 0;
  cursor: pointer;
  min-height: 44px;
  padding: .85em 1.35em .8em;
  border-radius: 7px;
  font-family: var(--engrave-wide);
  font-size: .9rem;
  line-height: 1;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #fff6ee;
  text-shadow: 0 1px 0 rgba(90, 6, 0, .65);
  background:
    linear-gradient(180deg, transparent 58%, rgba(70, 4, 0, .42) 100%),
    radial-gradient(130% 150% at 50% 0%, #f0503c 0%, var(--key) 36%, #98160d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .45),
    0 0 0 3px var(--bezel),
    0 0 0 4px var(--bezel-edge),
    0 7px 14px rgba(0, 0, 0, .6);
  transition: transform 90ms var(--seat), box-shadow 90ms var(--seat), filter 160ms;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.key:hover { filter: brightness(1.13) saturate(1.06); }
.key:active {
  transform: translateY(2px);
  filter: brightness(.93);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, .5),
    0 0 0 3px var(--bezel),
    0 0 0 4px var(--bezel-edge),
    0 2px 5px rgba(0, 0, 0, .6);
}
.key:focus-visible { outline: 2px solid var(--lamp-core); outline-offset: 7px; }
.key--big {
  padding: 1em 2.2em .95em;
  border-radius: 10px;
  font-size: clamp(1.15rem, .95rem + 1vw, 1.6rem);
}

/* ---------- frames ---------- */

.frame {
  position: relative;
  min-height: 100svh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1.75rem;
  padding: 8rem var(--gap) 4rem;
}
.say {
  margin: 0;
  max-width: 17ch;
  font-family: var(--engrave-wide);
  font-weight: 400;
  font-size: clamp(2rem, 1rem + 5vw, 5.25rem);
  line-height: 1.04;
  letter-spacing: .03em;
  text-transform: uppercase;
  text-align: center;
  text-wrap: balance;
  color: var(--lamp);
}
.note {
  margin: 0;
  max-width: 36rem;
  padding: 1.05em 2.2em 1.1em;
  text-wrap: pretty;
}

.closing {
  display: grid;
  justify-items: center;
  gap: 1.15em;
  width: min(40rem, 100%);
  padding: 1.7em 2.4em 1.45em;
  text-align: center;
}
.closing__lead { margin: 0; max-width: 31rem; font-size: 1.125rem; text-wrap: balance; }
.closing__action { position: relative; padding: .35em 0 .2em; }
.closing__action .pilot {
  position: absolute;
  right: calc(100% + 16px);
  top: 50%;
  margin-top: -6px;
}
/* The key needs the script; without it the link to the skill is the action. */
html:not(.js) .keywell,
html:not(.js) .register,
html:not(.js) .closing__action { display: none; }
.closing__status {
  margin: 0;
  min-height: 1.2em;
  font-family: var(--engrave-wide);
  font-size: .8rem;
  line-height: 1.2;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.closing__fine {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .25em 1.3em;
  font-size: .92rem;
  color: var(--ink-2);
}
.closing__fine a { color: var(--ink); }

/* ---------- with the board running, the lamps and one plate carry the copy ---------- */

.lamps { scroll-snap-type: y proximity; }
.lamps .frame {
  height: 100svh;
  min-height: 0;
  padding: 0;
  scroll-snap-align: start;
}
.lamps .say,
.lamps .note {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.lamps .frame--last {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 0 var(--gap) max(calc(var(--gap) * 1.6), env(safe-area-inset-bottom));
}

.caption {
  display: none;
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(var(--gap), env(safe-area-inset-bottom));
  width: min(38rem, calc(100vw - 2 * var(--gap)));
  padding: 1.05em 2.2em 1.1em;
  transform: translateX(-50%);
  transition: opacity 220ms var(--seat), transform 220ms var(--seat);
}
.lamps .caption { display: block; }
.caption p { margin: 0; text-wrap: pretty; }
.caption.swap { animation: seat 420ms var(--seat); }
@keyframes seat {
  from { transform: translate(-50%, 12px); clip-path: inset(0 0 100% 0); }
  to { transform: translate(-50%, 0); clip-path: inset(0 0 0 0); }
}
.at-last .caption { opacity: 0; transform: translate(-50%, 18px); pointer-events: none; }

/* ---------- small boards ---------- */

@media (max-width: 720px) {
  .rail { grid-template-columns: 1fr auto; }
  .register { grid-column: 1 / -1; grid-row: 2; padding: .4em 1.4em .34em; }
  .register__window { font-size: 1rem; }
  .nameplate { font-size: .78rem; padding: .7em 1.9em .62em; letter-spacing: .13em; }
  .key--small { font-size: .78rem; padding: .85em 1.05em .8em; }
  .keywell { gap: 9px; }
  .caption, .note { padding: .95em 1.7em 1em; }
  .closing { padding: 1.5em 1.5em 1.3em; }
  .closing__lead { font-size: 1.0625rem; }
}

@media (prefers-reduced-motion: reduce) {
  .flash.go, .caption.swap, .wheel.spin i { animation: none; }
  .wheel i, .key, .caption, .pilot { transition: none; }
  .lamps { scroll-snap-type: none; }
}
