/* Held in Common: styles for the node and commons pages.
 *
 * Look: the "Common Signal" system from heldincommon.org. Space Grotesk for
 * text, Space Mono for labels and headings, Cormorant for ledes; pink, blue,
 * jade and violet on white; hard ink hairlines; flat, square-cornered blocks.
 *
 * How this file is organised:
 *   1. Design tokens: every colour, font, size and space. Change them here
 *      and the whole site follows.
 *   2. Base: the page, links, focus.
 *   3. Shared patterns: the mono label, buttons, form controls, panels.
 *   4. Site frame: role bar, top bar, footer.
 *   5. Page parts, in the order a visitor meets them.
 *   6. Small screens.
 *
 * Conventions: components read tokens, never raw values; a coloured thing
 * takes its colour from a --tone variable set by a modifier class; shared
 * looks are grouped selectors inside :where(), which adds no specificity, so
 * a component can still override any part of them.
 */

/* 1. Design tokens --------------------------------------------------------- */

:root {
  /* Brand colours */
  --pink: #ff2d9b;
  --blue: #1f5cff;
  --jade: #12b37d;
  --jade-ink: #0a7a54;
  --jade-wash: #effaf5;
  --violet: #8b3fd9;
  --violet-ink: #6a2caf;

  /* Neutrals */
  --ink: #111;
  --gray: #6f6f6f;
  --faint: #a4a29b;
  --white: #fff;
  --cream: #f2efe8;
  --cream-deep: #e3e0d8;
  --line: rgb(17 17 17 / 15%);

  /* What each colour is for */
  --text: var(--ink);
  --text-muted: var(--gray);
  --surface: var(--white);
  --surface-sunk: var(--cream);
  --link: var(--blue);
  --accent: var(--pink);

  /* Fonts */
  --font-text: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-serif: "Cormorant", Georgia, serif;

  /* Type sizes (rem, so they follow the reader's browser setting) */
  --text-2xs: 0.6875rem; /* 11px: badges, chips */
  --text-xs: 0.75rem; /* 12px: labels, buttons */
  --text-sm: 0.875rem; /* 14px: fine print */
  --text-hint: 0.9375rem; /* 15px: helper text */
  --text-md: 1rem; /* 16px */
  --text-base: 1.0625rem; /* 17px: body */
  --text-lg: 1.1875rem; /* 19px: reading text */
  --text-xl: 1.375rem; /* 22px: card names */
  --text-lede: clamp(1.25rem, 2.4vw, 1.75rem);
  --text-display: clamp(2.5rem, 6.5vw, 4.75rem);
  --track: 0.08em; /* letter-spacing for mono labels */
  --track-wide: 0.12em;

  /* Space (a 4px scale) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3.5rem;
  --space-9: 4.5rem;

  /* Lines and widths */
  --rule: 1px solid var(--ink);
  --rule-strong: 1.5px solid var(--ink);
  --rule-soft: 1px solid var(--line);
  --accent-edge: 4px;
  --focus: 2px solid var(--blue);
  --measure: 70ch; /* longest comfortable line of text */
  --panel-width: 640px;
  --page-width: 1180px;

  /* Icons */
  --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23111111' stroke-width='1.8'/%3E%3C/svg%3E");
}

/* 2. Base ------------------------------------------------------------------ */

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

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: var(--text-base) / 1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-underline-offset: 3px;
}

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

code,
.mono {
  font-family: var(--font-mono);
}

/* Element defaults use :where() (no specificity) so any class overrides them. */
:where(button) {
  font: inherit;
  cursor: pointer;
}

/* 3. Shared patterns ------------------------------------------------------- */

/* The mono label: small, bold, upper-case monospace. Used for labels,
   buttons, badges and navigation; each sets only its own size and colour. */
:where(
    .field-label,
    .section-h,
    .topbar-links,
    .primary,
    .secondary,
    .secondary-link,
    .link-btn,
    .vis-badge,
    .signal-chip,
    .gov-license,
    .commons-status,
    .add-commons summary,
    .role-bar
  ) {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-xs);
  letter-spacing: var(--track);
  text-transform: uppercase;
}

/* Page headings end in a pink dot. */
.intro h1::after {
  content: ".";
  color: var(--accent);
}

/* Muted helper text under a field or panel. */
.hint {
  margin: var(--space-3) 0 0;
  font-size: var(--text-hint);
  color: var(--text-muted);
}

.section-h {
  margin: 0 0 var(--space-2);
  letter-spacing: var(--track-wide);
  color: var(--text-muted);
}

.field-label {
  display: block;
  margin-bottom: var(--space-3);
}

/* Buttons. .primary is the one main action on a page; .secondary is every
   other button; .link-btn and .linklike look like links. */

.primary,
.secondary {
  display: inline-block;
  border: 0;
  border-radius: 0;
  text-decoration: none;
}

.primary {
  padding: 18px 34px;
  font-size: 0.8125rem;
  background: var(--accent);
  color: var(--white);
}

.primary:hover {
  background: var(--ink);
}

.secondary {
  flex: none;
  padding: 11px 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.secondary:hover {
  background: var(--ink);
  color: var(--white);
}

.secondary-link {
  margin-left: var(--space-4);
  color: var(--ink);
}

.link-btn,
.linklike {
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.link-btn {
  color: var(--link);
  border-bottom: 1px solid currentcolor;
}

.linklike {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}

.linklike:hover {
  color: var(--accent);
}

/* A row of actions at the end of a page or form. */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-5);
  margin-top: var(--space-9);
}

/* Form controls */
input:is([type="text"], [type="password"], [type="url"]),
textarea,
select {
  width: 100%;
  padding: 13px var(--space-4);
  font: var(--text-base) / 1.5 var(--font-text);
  color: var(--text);
  background: var(--surface);
  border: var(--rule-strong);
  border-radius: 0;
}

:is(input, textarea)::placeholder {
  color: var(--faint);
}

:is(input, textarea, select):hover {
  border-color: var(--link);
}

:is(input, textarea, select):focus {
  outline: none;
  border-color: var(--link);
  box-shadow: inset 0 0 0 1px var(--link);
}

textarea {
  min-height: 128px;
  resize: vertical;
}

select {
  appearance: none;
  padding-right: 44px;
  background: var(--surface) var(--icon-chevron) no-repeat right var(--space-4)
    center / 13px;
  cursor: pointer;
}

.mono-input {
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}

fieldset {
  min-width: 0;
  margin: var(--space-6) 0 0;
  padding: 0;
  border: 0;
}

.field {
  display: block;
  margin-top: var(--space-5);
}

.field-row {
  display: grid;
  gap: var(--space-5);
  margin-top: var(--space-6);
}

.field-row .field {
  margin-top: 0;
}

.stack-form {
  max-width: 680px;
  margin-top: var(--space-2);
}

/* Panels: a block set apart with an edge in its --tone colour. */
.caution,
.origin-box,
.notice-bar {
  border-left: var(--accent-edge) solid var(--tone);
}

.caution {
  --tone: var(--accent);

  margin-top: var(--space-5);
  padding: var(--space-5);
  background: var(--surface-sunk);
}

.caution p {
  margin: 0;
  max-width: 90ch;
  line-height: 1.6;
  color: var(--text-muted);
}

.caution strong {
  color: var(--text);
  font-weight: 600;
}

.caution + .actions {
  margin-top: var(--space-7);
}

/* Something to copy or keep (a recovery code, an invite). */
.recovery {
  max-width: var(--panel-width);
  margin: var(--space-4) 0 var(--space-5);
  padding: var(--space-4) var(--space-5);
  border: 2px dashed var(--tone, var(--ink));
}

.recovery-code {
  margin: 0 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
  user-select: all;
}

/* 4. Site frame ------------------------------------------------------------ */

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-8) clamp(20px, 5vw, 72px) var(--space-9);
}

/* The coloured bar on every page: your node (jade) or a shared commons
   (violet), so nobody confuses the two. */
.role-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 20px;
  font-size: var(--text-2xs);
  line-height: 1;
  color: var(--white);
  background: var(--tone);
}

.role-node {
  --tone: var(--jade-ink);
}

.role-commons {
  --tone: var(--violet);
}

.role-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentcolor;
}

.role-instance,
.role-address {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.role-instance {
  opacity: 0.85;
}

.role-address,
.role-link {
  margin-left: auto;
}

.role-address code {
  padding: 3px 6px;
  font-size: var(--text-xs);
  font-weight: 700;
  background: rgb(255 255 255 / 18%);
  user-select: all;
}

.role-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgb(255 255 255 / 70%);
}

.role-link:hover {
  border-bottom-color: currentcolor;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: var(--space-2);
  padding-bottom: 28px;
  border-bottom: var(--rule);
}

.wordmark {
  font: 700 1.25rem var(--font-mono);
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}

.dot {
  color: var(--accent);
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.topbar-links a {
  color: var(--ink);
  text-decoration: none;
}

.topbar-links a:hover {
  color: var(--accent);
}

.inline-form {
  display: inline;
  margin: 0;
}

/* News for the member, e.g. "now listed on …". */
.notice-bar {
  --tone: var(--jade-ink);

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: var(--space-4) 0 var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--jade-wash);
}

.notice-bar p {
  margin: 2px 0;
  font-size: var(--text-md);
}

.notice-bar form {
  margin: 0;
}

.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-9);
  padding-top: var(--space-5);
  border-top: var(--rule-soft);
  font: var(--text-sm) var(--font-mono);
  color: var(--text-muted);
}

/* 5. Page parts ------------------------------------------------------------ */

/* Page heading and lede */
.intro h1 {
  margin: var(--space-7) 0 var(--space-4);
  font: 700 var(--text-display) / 1 var(--font-mono);
  letter-spacing: -0.03em;
  word-spacing: -0.12em;
}

.lede {
  max-width: 42ch;
  margin: 0;
  font: italic 500 var(--text-lede) / 1.35 var(--font-serif);
}

.empty-note {
  font: italic 500 var(--text-xl) var(--font-serif);
  color: var(--text-muted);
}

.prose {
  max-width: var(--measure);
  margin-top: var(--space-4);
}

.prose h2 {
  margin-top: var(--space-6);
}

.prose p {
  font-size: var(--text-lg);
  line-height: 1.65;
}

/* Reach: who can see a profile. Each reach has a --tone. */
.vis-public {
  --tone: var(--pink);
}

.vis-commons {
  --tone: var(--blue);
}

.vis-members {
  --tone: var(--ink);
}

.vis-federated {
  --tone: var(--violet);
}

.vis-badge {
  align-self: flex-start;
  margin-top: var(--space-2);
  padding: 3px var(--space-3);
  font-size: var(--text-2xs);
  color: var(--white);
  background: var(--tone);
}

/* Directory */
.dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-7);
}

.dir-card {
  display: flex;
  flex-direction: column;
  border: var(--rule);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.dir-card:hover {
  box-shadow: inset 0 0 0 1px var(--ink);
}

.dir-bar {
  height: var(--space-2);
  background: var(--tone, var(--gray));
}

.dir-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-5);
}

.dir-avatar {
  display: block;
  width: 46px;
  height: 46px;
  margin-bottom: var(--space-3);
  object-fit: cover;
  border: var(--rule);
}

.dir-name {
  font: 700 var(--text-xl) / 1.2 var(--font-text);
  letter-spacing: -0.01em;
}

.dir-handle {
  font: var(--text-sm) var(--font-mono);
  color: var(--text-muted);
}

.dir-role {
  margin-top: var(--space-1);
  font-size: var(--text-md);
}

.dir-role.locked {
  font: italic 500 var(--text-base) var(--font-serif);
  color: var(--text-muted);
}

/* Where a shared-in card came from: as prominent as the name, so two cards
   with the same display name still differ by origin and signing key. */
.dir-origin {
  margin-top: var(--space-3);
  font: 700 0.8125rem var(--font-mono);
  color: var(--violet-ink);
  overflow-wrap: anywhere;
}

.dir-key {
  margin-top: 2px;
  font: var(--text-2xs) var(--font-mono);
  color: var(--text-muted);
}

/* People waiting for a vouch, and the steward's tools */
.pending {
  margin-top: var(--space-7);
}

.pending-list {
  padding-left: var(--space-4);
}

.pending-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-1) 0;
  padding: 6px 0;
  border-bottom: var(--rule-soft);
}

.steward {
  --tone: var(--violet);
}

.steward-hint {
  margin: 0 0 var(--space-4);
}

/* The commons' "run a node to join" page */
.gate {
  max-width: var(--panel-width);
  margin-top: var(--space-7);
  padding: var(--space-6);
  border: var(--rule);
}

.gate h2 {
  margin: 0 0 20px;
  font: 600 0.9375rem var(--font-mono);
  letter-spacing: var(--track);
  text-transform: uppercase;
}

.gate-steps {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding-left: 1.3em;
  font-size: var(--text-lg);
}

.gate-steps strong {
  font-weight: 600;
}

.gate .actions {
  margin-top: var(--space-6);
}

/* Sign-up: the @ in front of the handle box */
.handle-input {
  display: flex;
  align-items: center;
  border: var(--rule-strong);
}

.handle-input .at {
  padding: 0 var(--space-3);
  font: 700 var(--text-lg) var(--font-mono);
  color: var(--text-muted);
}

.handle-input input,
.handle-input input:focus {
  border: 0;
  box-shadow: none;
}

/* The show/hide button inside passphrase boxes (static/password.js) */
.pw-wrap {
  position: relative;
  display: block;
}

.pw-wrap input {
  padding-right: 48px;
}

.pw-toggle {
  position: absolute;
  top: 50%;
  right: var(--space-2);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  transform: translateY(-50%);
}

.pw-toggle:hover,
.pw-toggle[aria-pressed="true"] {
  color: var(--text);
}

/* Publish form */
.name-row {
  grid-template-columns: 2fr 1fr;
}

.city-input {
  margin-top: var(--space-3);
}

.photo-field {
  display: flex;
  align-items: flex-start;
  gap: var(--space-6);
}

.photo-pick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
}

.photo-pick input[type="file"] {
  font: var(--text-sm) var(--font-mono);
}

.avatar-preview {
  display: block;
  flex: none;
  width: 104px;
  height: 104px;
  object-fit: cover;
  border: var(--rule-strong);
  background: var(--surface);
}

.avatar-preview.empty {
  border-style: dashed;
  background: repeating-linear-gradient(
    45deg,
    var(--cream) 0 7px,
    var(--cream-deep) 7px 14px
  );
}

/* Choice cards: who can see it (radio) and signals (checkbox) */
.reach-options {
  display: grid;
  gap: var(--space-4);
}

.reach,
.signal {
  display: flex;
  align-items: flex-start;
  border: var(--rule-soft);
  background: var(--surface);
  cursor: pointer;
}

.reach:hover,
.signal:hover {
  border-color: var(--ink);
}

.reach {
  gap: 20px;
  padding: var(--space-5);
}

.reach input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 2px 0 0;
  appearance: none;
  border: var(--rule-strong);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
}

.reach input:checked {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 6px, var(--surface) 7px);
}

.reach-text {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.reach-title {
  font: 600 1.3125rem / 1.3 var(--font-text);
}

.reach-body {
  font-size: var(--text-lg);
}

.license-select {
  max-width: 360px;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
  margin-top: 6px;
}

.signal {
  gap: var(--space-3);
  padding: var(--space-4);
}

.signal input {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.signal-name {
  display: block;
  font: 600 var(--text-md) var(--font-text);
}

.signal-desc {
  display: block;
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* A profile */
.profile-head {
  margin-top: 20px;
}

.profile-head .vis-badge {
  margin-bottom: var(--space-3);
}

.profile-avatar {
  display: block;
  width: 128px;
  height: 128px;
  margin: 0 0 var(--space-5);
  object-fit: cover;
  border: var(--rule-strong);
}

.pronouns {
  margin: var(--space-1) 0 0;
  font: var(--text-md) var(--font-mono);
  color: var(--text-muted);
}

.profile-bio {
  max-width: var(--measure);
  margin-top: var(--space-6);
}

.profile-bio p {
  font-size: var(--text-lg);
  line-height: 1.7;
  white-space: pre-line;
}

.profile-places {
  margin-top: var(--space-6);
}

.profile-places ul {
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.profile-places li {
  padding: 6px 0;
  border-bottom: var(--rule-soft);
}

.place-city {
  color: var(--text-muted);
}

.profile-meta {
  margin-top: var(--space-7);
  padding-top: 20px;
  border-top: var(--rule);
}

.cid {
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.cid .mono,
.origin-key .mono {
  color: var(--text);
}

/* Licence and signals */
.gov {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-1) 0 0;
}

.gov-license {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
}

.gov-license:hover {
  color: var(--accent);
}

.signal-chip {
  padding: 3px var(--space-3);
  font-size: var(--text-2xs);
  color: var(--jade-ink);
  box-shadow: inset 0 0 0 1.5px var(--jade);
}

/* A profile shared in from another node: where it came from */
.origin-box {
  --tone: var(--violet);

  margin: 0 0 var(--space-3);
  padding: var(--space-3) 0 var(--space-3) var(--space-4);
}

.origin-line {
  margin: 0;
  overflow-wrap: anywhere;
}

.origin-line a {
  font-weight: 700;
}

.origin-label {
  color: var(--text-muted);
}

.origin-key {
  margin: 6px 0 0;
  font-size: var(--text-sm);
}

.origin-note {
  max-width: 60ch;
  margin: var(--space-2) 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* A member's own tools under their profile */
.owner-panel {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px dashed var(--line);
}

.share-panel,
.share-form {
  max-width: var(--panel-width);
  margin-top: var(--space-6);
}

.share-row {
  display: flex;
  align-items: stretch;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.share-row > input,
.share-row > .pw-wrap {
  flex: 1;
}

.add-commons {
  margin-top: var(--space-4);
}

.add-commons summary {
  color: var(--text-muted);
  cursor: pointer;
}

.add-commons summary:hover {
  color: var(--text);
}

.add-commons .share-form {
  margin-top: var(--space-3);
}

/* Lists of commons: one row each, its name then its buttons */
.commons-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.commons-share,
.commons-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.commons-share {
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--line);
}

.commons-row {
  flex-wrap: wrap;
  justify-content: space-between;
}

.commons-meta {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: var(--space-3);
  min-width: 0;
}

.commons-name {
  overflow: hidden;
  font: var(--text-sm) var(--font-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commons-status {
  flex: none;
  font-size: var(--text-2xs);
  color: var(--jade-ink);
}

.commons-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.commons-actions form {
  margin: 0;
}

/* Vouch form: labelled fields that sit side by side, each wide enough */
.vouch-form .field {
  margin-top: var(--space-3);
}

.vouch-row {
  grid-template-columns: 1fr 1fr;
  margin-top: var(--space-3);
}

.vouch-form .actions {
  margin-top: var(--space-4);
}

/* 6. Small screens --------------------------------------------------------- */

@media (max-width: 640px) {
  .name-row,
  .vouch-row {
    grid-template-columns: 1fr;
  }

  .photo-field {
    flex-direction: column;
    gap: var(--space-4);
  }

  .reach {
    gap: var(--space-3);
    padding: 20px var(--space-4);
  }
}
