/* ============================================================
     WAITLIST — the register, as a real object: a printed paper
     logbook hanging from a bolt on the wall by a piece of cord.
     Paper stays paper in both themes.
     ============================================================ */
[data-theme="light"] {
  --paper: #f8f2e2;
  --p-edge: rgba(46, 42, 33, 0.28);
  --p-ink: #2e2a21;
  --p-ink-soft: rgba(46, 42, 33, 0.66);
  --p-ink-faint: rgba(46, 42, 33, 0.4);
  --p-rule: rgba(78, 100, 150, 0.28);
  --p-rule-strong: rgba(78, 100, 150, 0.45);
  --p-margin: rgba(189, 76, 60, 0.5);
  --p-stamp: #4a5fa5;
  --cord: #a98a5b;
}
[data-theme="dark"] {
  --paper: rgb(52, 53, 61);
  --p-edge: rgba(8, 8, 12, 0.7);
  --p-ink: rgb(240, 236, 224);
  --p-ink-soft: rgba(240, 236, 224, 0.64);
  --p-ink-faint: rgba(240, 236, 224, 0.38);
  --p-rule: rgba(152, 172, 226, 0.3);
  --p-rule-strong: rgba(152, 172, 226, 0.52);
  --p-margin: rgba(224, 110, 95, 0.55);
  --p-stamp: #93a7e6;
  --cord: #a98a5b;
}

body:has(.join-wall) {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
body:has(.join-wall) #top {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.join-wall {
  position: relative;
  flex: 1 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: calc(var(--module) * 0.8) var(--half-module) calc(var(--module) * 1.4);
}

/* ---------- the hang: bolt, cord, swing ---------- */
.hang {
  position: relative;
  z-index: 3;
  width: min(100%, 560px);
}
.hang-bolt {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% -50%;
  width: 22px;
  height: 22px;
  border: none;
  padding: 0;
  background: transparent;
  z-index: 4;
  /* shadow lives here; the face rotates separately so the
       shadow offset never spins with the screw */
  filter: drop-shadow(2px 3px 0 var(--hard-ink));
  cursor: pointer;
}
.bolt-face {
  position: absolute;
  inset: 0;
  background-image: var(--torx-uri);
  background-size: contain;
  background-repeat: no-repeat;
}
.hang-bolt:hover .bolt-face {
  scale: 1.15;
}
.hang-swing {
  transform-origin: 50% 0;
  visibility: hidden;
}
.join-wall.register-ready .hang-swing {
  visibility: visible;
}
@media (prefers-reduced-motion: no-preference) {
  /* the bolt gives way — face spins, shadow stays put */
  .join-wall.dropped .bolt-face {
    animation: bolt-out 0.5s ease-in forwards;
  }
  @keyframes bolt-out {
    55% {
      rotate: -290deg;
      scale: 1;
      opacity: 1;
    }
    100% {
      rotate: -360deg;
      scale: 0.3;
      opacity: 0;
    }
  }
  /* the fall itself is animated from JS — random tilt every time */
}
@media (prefers-reduced-motion: reduce) {
  .join-wall.dropped .hang {
    visibility: hidden;
  }
}
/* while dropped, the (invisible) container must not eat clicks
     meant for the rehang button or the wall */
.join-wall.dropped .hang {
  pointer-events: none;
}

/* what's left after gravity wins */
.rehang {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: 2;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.join-wall.dropped .rehang {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 1.05s;
}
.rehang p {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.rehang button {
  background: none;
  border: none;
  padding: 0;
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.rehang button:hover {
  color: var(--accent-deep);
}
.hang-cord {
  display: block;
  width: 100%;
  height: 106px;
  margin-bottom: -22px; /* overlap the paper so the cord reaches the grommets */
  position: relative;
  z-index: 2;
  pointer-events: none;
}
.hang-cord path {
  fill: none;
  stroke: var(--cord);
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* ---------- the book ---------- */
.book {
  position: relative;
  background-color: var(--paper);
  background-image: var(--grain-uri);
  background-size: 160px 160px;
  border: 1px solid var(--p-edge);
  border-radius: 3px;
  box-shadow: var(--shadow-hard);
  color: var(--p-ink);
  padding: 30px 38px 28px;
}
/* punched corner holes the cord runs through */
.book .grommet {
  position: absolute;
  top: 14px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 0 0 3px #cdbf9e,
    0 1px 1px rgba(255, 255, 255, 0.6);
}
.book .grommet.gl {
  left: 22px;
}
.book .grommet.gr {
  right: 22px;
}

/* printed form head */
.bk-head {
  text-align: center;
  padding: 14px 0 12px;
  border-bottom: 2px solid var(--p-ink);
}
.bk-head .bk-org {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--p-ink-soft);
}
.bk-head h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(28px, 3.4vw, 38px);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.1;
  margin: 6px 0 4px;
}
.bk-head .bk-rule {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--p-ink-soft);
}

/* the stamp: how many are on */
.bk-stamp {
  position: absolute;
  top: 38px;
  right: 30px;
  rotate: 4deg;
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  color: var(--p-stamp);
  border: 2px solid var(--p-stamp);
  border-radius: 6px;
  padding: 5px 9px;
  opacity: 0.75;
  mix-blend-mode: multiply;
  pointer-events: none;
}
[data-theme="dark"] .bk-stamp {
  mix-blend-mode: screen;
}
.bk-stamp strong {
  display: block;
  font-size: 14px;
  letter-spacing: 0.06em;
}

/* ---------- the ledger ---------- */
.register {
  position: relative;
  margin-top: 6px;
}
/* red margin line, like a printed form */
.register::before {
  content: "";
  position: absolute;
  left: 44px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--p-margin);
}
.reg-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1.35fr) minmax(108px, 0.8fr);
  gap: 14px;
  align-items: center;
  padding: 9px 2px;
  border-bottom: 1px solid var(--p-rule);
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--p-ink);
}
.reg-row.head {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--p-ink-faint);
  border-bottom: 1px solid var(--p-rule-strong);
  padding-bottom: 6px;
}
.reg-row .no {
  color: var(--p-ink-faint);
}
.reg-row .when {
  color: var(--p-ink-soft);
  font-size: 11px;
}
.reg-row .entry {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reg-row .city {
  color: var(--p-ink-soft);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reg-row .city.muted {
  color: var(--p-ink-faint);
}
.reg-history {
  display: contents;
}
.reg-row.history .no {
  color: var(--p-ink-faint);
}

/* prior signups, drawn as illegible handwriting — never the real address */
.scrawl-cell {
  display: flex;
  align-items: center;
  min-height: 20px;
}
.reg-row .city.scrawl-cell {
  min-height: 16px;
}
.scrawl {
  display: block;
  height: 19px;
  max-width: 100%;
  overflow: visible;
}
.reg-row .city .scrawl {
  height: 14px;
}
.scrawl path {
  fill: none;
  stroke: var(--p-ink-soft);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.78;
}
.reg-row.yours.committed .scrawl path {
  stroke: var(--p-ink);
  opacity: 0.92;
}

/* your line */
.reg-row.yours {
  border-bottom: 2px solid var(--p-ink-soft);
  transition: border-color 0.25s;
}
.reg-row.yours:focus-within {
  border-bottom-color: var(--accent);
}
.reg-row.yours.committed {
  border-bottom-color: var(--accent);
}
.reg-row.yours .no {
  color: var(--accent-deep);
  font-weight: 600;
}
.reg-entry-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: text;
  position: relative;
}
.reg-entry-cell.hinting {
  animation: regShake 0.32s ease;
}
.reg-entry-cell.hinting::after {
  content: attr(data-hint);
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgb(200, 84, 66);
  white-space: nowrap;
  pointer-events: none;
}
@keyframes regShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}
/* contenteditable fields, not <input>: password managers and browser
   autofill never attach to the ledger line */
.reg-input {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 2;
  outline: none;
  color: var(--p-ink);
  caret-color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
}
.reg-input:empty::before {
  content: attr(data-placeholder);
  color: var(--p-ink-faint);
  font-style: italic;
  pointer-events: none;
}
.city-input {
  font-size: 12px;
}
/* the submit lives on the footer line, right-aligned — never mid-ledger */
.reg-commit {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--on-accent);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
  opacity: 0.4;
  transition:
    opacity 0.2s,
    background 0.2s;
}
.book.has-input .reg-commit {
  opacity: 1;
}
.reg-commit:hover {
  background: var(--accent-deep);
  opacity: 1;
}
.reg-commit:disabled {
  cursor: wait;
  opacity: 0.58;
}
.book[data-state="joined"] .reg-commit {
  display: none;
}

.reg-status {
  margin: 8px 0 0;
  min-height: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  color: var(--p-ink-soft);
}
.reg-status[data-tone="error"] {
  color: color-mix(in oklab, var(--accent-deep) 76%, var(--p-ink));
}

/* confirmation, small print */
.reg-after {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.4s cubic-bezier(0.25, 0.9, 0.3, 1);
}
.reg-after > div {
  min-height: 0;
}
.book[data-state="joined"] .reg-after {
  grid-template-rows: 1fr;
}
.reg-after p {
  padding-top: 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--p-ink-soft);
}
.reg-after p strong {
  color: var(--p-ink);
}

.bk-foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--p-rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--p-ink-faint);
}
.book[data-state="joined"] .bk-foot {
  justify-content: flex-start;
}

@media (max-width: 640px) {
  .book {
    padding: 26px 22px 24px;
  }
  .reg-row {
    grid-template-columns: 32px minmax(0, 1fr) minmax(76px, 0.7fr);
  }
  .reg-row .when {
    display: none;
  }
  .register::before {
    left: 32px;
  }
  .bk-stamp {
    display: none;
  }
  .bk-foot {
    gap: 10px;
  }
}
@media (max-width: 600px) {
  .join-wall {
    align-items: start;
    padding-top: 18px;
    padding-bottom: 12px;
  }
  .hang {
    margin-top: 40px;
  }
  .book {
    padding: 22px 16px 20px;
  }
  .bk-head h1 {
    font-size: 26px;
  }
  .reg-row {
    font-size: 12.5px;
    gap: 9px;
  }
  .reg-input {
    font-size: 13px;
    line-height: 1.25;
  }
  .city-input {
    font-size: 12px;
  }
  .book .grommet {
    width: 14px;
    height: 14px;
    top: 12px;
  }
  .book .grommet.gl {
    left: 16px;
  }
  .book .grommet.gr {
    right: 16px;
  }
}
