/* Custody Roundtable
 *
 * One rule carries the design: gold means a name is attached to it. Named
 * people, signed replies and roundtable attribution are gold. Structure,
 * numbering and status stay grey. The project's editorial rule is that every
 * branch carries a named attribution, so the names are the brightest thing on
 * the page.
 *
 * Monospace is the structural face, for node numbers, pillars, status, keys
 * and timestamps, because this content genuinely is hex, paths and keys. The
 * arguments themselves are set in sans at a readable measure.
 *
 * The spine, a hairline with square markers, carries position in the tree.
 */

:root {
  /* Bitcoin Butlers palette. Gold is the only brand colour. */
  --ink: #0a0a0a;
  --paper: #141414;
  --raised: #1a1a1a;
  --overlay: #1e1e1e;
  --rule: rgb(255 255 255 / 0.08);
  --rule-2: rgb(251 220 123 / 0.15);
  --rule-gold: rgb(251 220 123 / 0.3);

  --cream: #f4eee1;
  --muted: #a1a1a1;
  --dim: #737373;

  --gold: #fbdc7b;
  --gold-hover: #fda24a;
  --ember: #ff9125;
  --on-gold: #0a0a0a;

  --gold-grad: linear-gradient(90deg, #ff9125, #fbdc7b, #fda24a);

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "JetBrains Mono", "Roboto Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --page: 46rem;
  --measure: 36rem;
  --spine: clamp(1.15rem, 5vw, 2rem); /* width of the spine gutter */
  --pad: clamp(1.1rem, 5vw, 2.5rem);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--page);
  margin: 0 auto;
  padding: 2.5rem var(--pad) 5rem;
}

p { margin: 0 0 1rem; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }

a { color: var(--gold); text-decoration: none; border-bottom: 1px solid rgb(251 220 123 / 0.3); }
a:hover { border-bottom-color: var(--gold); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 2px;
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* --- structural type -------------------------------------------------- */

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  max-width: none;
}

h1 {
  font-size: clamp(1.75rem, 6.4vw, 3rem);
  line-height: 1.06;
  letter-spacing: -0.025em;
  font-weight: 650;
  margin: 0 0 1.25rem;
  max-width: 20ch;
  text-wrap: balance;
  color: var(--gold); /* fallback before the gradient paints */
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Section headings sit on a hairline, in the structural face. */
.section {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
  margin: 3rem 0 1.1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
  max-width: none;
}

.lede {
  color: var(--cream);
  font-size: 1.0625rem;
  max-width: var(--measure);
}

/* --- the thread: the page's opening thesis ---------------------------- */

.thread {
  margin: 2.5rem 0 1rem;
  padding-left: var(--spine);
  border-left: 2px solid var(--gold);
}
.thread q {
  display: block;
  quotes: none;
  font-size: clamp(1.25rem, 4.2vw, 1.75rem);
  line-height: 1.32;
  letter-spacing: -0.012em;
  color: var(--cream);
  max-width: 26ch;
}
.thread .attrib {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-top: 1rem;
}

/* --- the tree --------------------------------------------------------- */

.pillar { margin-bottom: 2.25rem; }

.pillar-head {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.5rem;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  max-width: none;
}
.pillar-key { color: var(--ember); }

.tree {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--spine);
  position: relative;
}
/* the spine itself */
.tree::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.85rem;
  bottom: 0.85rem;
  width: 1px;
  background: var(--rule-2);
}

.node-row { position: relative; }
/* branch stub, joining each node to the spine */
.node-row::before {
  content: "";
  position: absolute;
  left: calc(var(--spine) * -1);
  top: 1.35rem;
  width: calc(var(--spine) - 0.45rem);
  height: 1px;
  background: var(--rule-2);
}
/* the node marker */
.node-row::after {
  content: "";
  position: absolute;
  left: calc(var(--spine) * -1 - 2.5px);
  top: 1.35rem;
  margin-top: -2.5px;
  width: 5px;
  height: 5px;
  background: var(--rule-2);
  transform: rotate(45deg);
}
.node-row.is-open::after { background: var(--gold); }
.node-row.is-next::after { background: var(--ember); }

.node-row > * {
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  gap: 0 0.75rem;
  align-items: baseline;
  padding: 0.7rem 0.25rem 0.7rem 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  color: var(--cream);
}
.node-row:last-child > * { border-bottom: 0; }

.node-row a:hover { background: var(--paper); }
.node-row a:hover .node-name { color: var(--gold); }

.node-id {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--dim);
  letter-spacing: 0.02em;
}
.node-name {
  font-size: 1rem;
  line-height: 1.35;
  transition: color 0.12s ease;
}
.node-state {
  grid-column: 2;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  margin-top: 0.3rem;
}
.node-state.is-open { color: var(--gold); }
.node-state.is-next { color: var(--ember); }

.node-row.is-pending > * { color: var(--muted); }
.node-row.is-pending .node-name { color: var(--muted); }

/* --- node page -------------------------------------------------------- */

.crumb {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 0;
  display: inline-block;
  margin-bottom: 2rem;
}
.crumb:hover { color: var(--gold); }

.state-tag { color: var(--gold); }
.state-tag.is-next { color: var(--ember); }
.state-tag.is-pending { color: var(--dim); }

/* The question is the reason the page exists, so it gets the most air. */
.question {
  font-size: clamp(1.1rem, 3.4vw, 1.3rem);
  line-height: 1.45;
  color: var(--cream);
  max-width: var(--measure);
  margin: 0 0 1.25rem;
}

.premise,
.framing {
  padding-left: var(--spine);
  border-left: 2px solid var(--rule-gold);
  color: var(--cream);
  max-width: none;
}
.premise p,
.framing p { max-width: var(--measure); }

.empty {
  color: var(--dim);
  font-size: 0.95rem;
}

/* --- video ------------------------------------------------------------ */

.video-slot {
  background: var(--paper);
  border: 1px dashed var(--rule-2);
  border-radius: 4px;
  padding: 1.25rem;
  color: var(--dim);
  font-size: 0.95rem;
}
.video-slot.filled { border-style: solid; border-color: var(--rule-2); color: var(--cream); }
.video-slot video { width: 100%; border-radius: 3px; margin-bottom: 0.75rem; }
.video-slot .transcript { font-size: 1rem; }
.video-slot .attribution {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--gold);
  margin-bottom: 0.6rem;
}

/* --- comments --------------------------------------------------------- */

.mic-note {
  color: var(--cream);
  font-size: 0.95rem;
  max-width: var(--measure);
  margin-bottom: 1.5rem;
}

.comment-filter {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 0.9rem;
  flex-wrap: wrap;
}
.filter-btn {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.5rem 0.85rem;
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  border: 1px solid var(--rule-2);
  transition: color 0.12s ease, border-color 0.12s ease;
}
.filter-btn:hover { color: var(--cream); border-color: var(--rule-gold); }
.filter-btn[aria-pressed="true"] {
  color: var(--on-gold);
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 600;
}

.comment-status {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--dim);
  margin: 0 0 1.25rem;
  max-width: var(--measure);
}

.comment-list { display: flex; flex-direction: column; }

.comment {
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.comment-body { color: var(--cream); }
.comment-head {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
/* Only whitelisted keys carry a face, and it is served from this site. */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--raised);
  align-self: center;
  flex: none;
}

/* Gold here is the whole point: a name is attached to this. */
.comment-author {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
}
.comment-author.is-anon {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
}
.roundtable-badge {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
  color: var(--ember);
  border: 1px solid rgb(255 145 37 / 0.4);
}
.comment-time {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--dim);
  margin-left: auto;
}
.comment-body {
  font-size: 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: var(--measure);
}

/* --- composer --------------------------------------------------------- */

.comment-form {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.signer-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.signer-who {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.signer-btn {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 0.55rem 0.9rem;
  border-radius: 4px;
  background: var(--raised);
  color: var(--gold);
  border: 1px solid var(--rule-2);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.signer-btn:hover { border-color: var(--rule-gold); background: var(--overlay); }
.signer-link {
  font-family: var(--mono);
  font-size: 0.72rem;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
}
.signer-link:hover { color: var(--gold); }
.help-link {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom-color: rgb(139 139 148 / 0.4);
  margin-left: auto;
}
.help-link:hover { color: var(--gold); }

.signer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--muted);
  border-color: var(--rule);
}
.signer-hint {
  flex-basis: 100%;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0.15rem 0 0;
  max-width: var(--measure);
}

.deep-link-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.bunker-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
/* iOS Safari zooms the page when a focused field is under 16px, which drags
 * the whole layout off-screen. Every field here stays at 1rem or more. */
.bunker-input,
.comment-input {
  font-family: var(--mono);
  font-size: 1rem;
  width: 100%;
  min-width: 0;
  background: var(--overlay);
  color: var(--cream);
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  padding: 0.8rem 0.85rem;
}
.bunker-input:focus, .comment-input:focus { border-color: var(--rule-gold); }
/* The Connect button drops below the field rather than squeezing beside it. */
.bunker-input { flex: 1 1 100%; }
.comment-input {
  font-family: var(--sans);
  resize: vertical;
  line-height: 1.55;
}
.comment-input::placeholder, .bunker-input::placeholder { color: var(--dim); }
.bunker-row .comment-note { flex-basis: 100%; }

.comment-send {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  padding: 0.7rem 1.3rem;
  border-radius: 4px;
  background: var(--gold);
  color: var(--on-gold);
  border: 1px solid var(--gold);
  transition: background 0.12s ease;
}
.comment-send:hover { background: var(--gold-hover); }
.comment-send:disabled {
  background: var(--paper);
  color: var(--dim);
  border-color: var(--rule);
  cursor: not-allowed;
}
.comment-note {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
  max-width: var(--measure);
}

.deep-link {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}
.deep-link::after { content: " \2192"; }

/* --- how to comment --------------------------------------------------- */

.howto { max-width: none; }
.howto h3 {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
  margin: 2.25rem 0 0.75rem;
}
.howto h3:first-of-type { margin-top: 0.5rem; }
.howto p,
.howto li { font-size: 1rem; max-width: var(--measure); color: var(--cream); }
.howto ul,
.howto ol {
  padding-left: 1.1rem;
  margin: 0 0 1rem;
  color: var(--cream);
}
.howto li { margin-bottom: 0.45rem; }
.howto li::marker { color: var(--dim); }
.howto strong { font-weight: 600; }

/* --- footer ----------------------------------------------------------- */

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}
.page-nav a,
.colophon a {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.colophon {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

:target { scroll-margin-top: 1.5rem; }

/* --- narrow screens --------------------------------------------------- */

@media (max-width: 30rem) {
  /* Let the help link take its own line instead of crowding the edge. */
  /* underline the words, not the whole flex line */
  .help-link { margin-left: 0; flex-basis: 100%; border-bottom: 0; text-decoration: underline; text-underline-offset: 3px; }
  .comment-head { gap: 0.35rem 0.5rem; }
  .signer-bar { gap: 0.6rem 0.5rem; }
  .wrap { padding-top: 1.75rem; }
  .section { margin-top: 2.5rem; }
  .node-row > * { grid-template-columns: 1.9rem 1fr; }
  .thread { margin-top: 2rem; }
}

/* --- motion ----------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .tree .node-row {
    animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
  }
  .tree .node-row:nth-child(1) { animation-delay: 0.02s; }
  .tree .node-row:nth-child(2) { animation-delay: 0.05s; }
  .tree .node-row:nth-child(3) { animation-delay: 0.08s; }
  .tree .node-row:nth-child(4) { animation-delay: 0.11s; }
  .tree .node-row:nth-child(5) { animation-delay: 0.14s; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(0.4rem); }
    to { opacity: 1; transform: none; }
  }
}
