/* Registration page. Shares the brand tokens from styles.css; everything here
   is page-specific. The one deliberate contrast: the entry "buffer", a dark
   editor pane where the registry entry writes itself, on an otherwise light
   page. Class prefixes: .reg- (layout), .station (form), .buffer/.gate/.handoff
   (rail). */

/* Buffer tokens keep >=4.5:1 on --buffer-bg; --pass-ink is the AA-safe green
   for TEXT on white (the brand --pass is a fill color, 3.4:1 as text). */
:root {
  --buffer-bg: #1c2333;
  --buffer-line: #232b40;
  --tok-key: #a9bff2;
  --tok-str: #eed45b;
  --tok-val: #eef1f8;
  --tok-comment: #8e99b3;
  --tok-punct: #8b96b0;
  --pass-ink: #1a7f37;
  --muted-on-gold: #5c636e;
}

.crumb {
  margin: 0 0 6px;
  font-size: 13px;
}
.crumb a {
  color: var(--muted);
  text-decoration: none;
}
.crumb a:hover {
  color: var(--link);
}

.reg-wrap {
  grid-template-columns: minmax(0, 1fr) 440px;
}

/* --- Stations ------------------------------------------------------------ */

.station {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(27, 35, 51, 0.08);
}
.station h2 {
  margin: 0;
  font-size: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}
/* The station marker reads as a YAML comment: this section IS the block of
   the entry it produces. */
.station-no {
  color: var(--secondary-ink);
  background: var(--secondary-soft);
  border: 1px solid var(--secondary);
  border-radius: 6px;
  padding: 1px 8px;
  margin-right: 6px;
  font-weight: 400;
}
.station-lead {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 62ch;
}
.station-lead code,
.hint code,
.handoff code,
.gates-lead code {
  background: #f2f4f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

.field {
  margin: 0 0 16px;
  border: 0;
  padding: 0;
}
.field:last-child {
  margin-bottom: 0;
}
.field > label,
.field > legend,
.field > .field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 5px;
}
.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field select,
.field textarea {
  width: 100%;
  background: #fff;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  /* Ubuntu Mono (the usual Linux `monospace` fallback) draws underscores on
     the clipped bottom row of a single-line editor at line-height: normal,
     so package_name underscores become invisible. A taller line box keeps
     the glyph inside the visible area. */
  line-height: 1.6;
}
.field select {
  width: auto;
  min-width: 160px;
}
#ref-select {
  width: 100%;
}
.ref-toggle {
  margin-top: 6px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--link);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.ref-toggle:hover {
  text-decoration: underline;
}
.ref-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.field textarea {
  resize: vertical;
  min-height: 56px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}
.field input.mono,
.mono {
  /* DejaVu Sans Mono before the generic fallback: its underscore sits above
     the editor clip line, unlike Ubuntu Mono's. */
  font-family: ui-monospace, SFMono-Regular, Menlo, "DejaVu Sans Mono", monospace;
}
.field input[aria-invalid="true"] {
  border-color: var(--fail);
}

.hint {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 62ch;
}
.status {
  margin: 5px 0 0;
  font-size: 12.5px;
  min-height: 16px;
  color: var(--muted);
}
.status[data-tone="ok"] {
  color: var(--pass-ink);
}
.status[data-tone="bad"] {
  color: var(--fail);
}
.status[data-tone="warn"] {
  color: var(--secondary-ink);
}

/* Radio choice cards (governance, ref kind). */
.choice-set {
  display: grid;
  gap: 8px;
}
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.choice:hover {
  border-color: var(--secondary);
}
.choice:has(input:checked) {
  border-color: var(--secondary);
  background: var(--secondary-soft);
  box-shadow: 0 1px 6px rgba(238, 212, 91, 0.35);
}
.choice:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.choice input {
  margin-top: 3px;
  accent-color: var(--secondary-ink);
}
.choice-title {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13.5px;
  font-weight: 600;
}
.choice-desc {
  display: block;
  font-size: 12.5px;
  /* Dark enough for the gold-soft background of the selected card. */
  color: var(--muted-on-gold);
}

.btn-secondary {
  display: inline-block;
  font-size: 13px;
  font-family: inherit;
  color: var(--fg);
  background: var(--secondary-soft);
  border: 1px solid var(--secondary);
  border-radius: 7px;
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow 0.15s ease;
}
.btn-secondary:hover {
  box-shadow: 0 2px 9px rgba(238, 212, 91, 0.5);
}
.btn-secondary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Discovered packages / maintainer suggestions. */
.scan-zone {
  margin-bottom: 14px;
}
.found-list {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
}
.found {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border: 1px dashed var(--secondary);
  background: var(--secondary-soft);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
}
.found > div {
  min-width: 0;
}
.found-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.found-desc {
  color: var(--muted-on-gold);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.found-add {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--fg);
  background: #fff;
  border: 1px solid var(--secondary);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
}
.found-add:hover {
  box-shadow: 0 1px 6px rgba(238, 212, 91, 0.5);
}
.found-add:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

/* Package editor cards. */
.pkg {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.pkg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.pkg-head input {
  flex: 1;
  min-width: 0;
  background: #fff;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 14px;
  line-height: 1.6;
}
.pkg-head input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}
.pkg-remove {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--fail);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
}
.pkg-remove:hover {
  border-color: var(--fail);
}
.pkg .field {
  margin-bottom: 12px;
}

/* Tag picker: the vocabulary as toggle chips, grouped. Selected chips use the
   browse page's .tag look. */
.tagpick-group {
  margin: 6px 0 8px;
}
.tagpick-group-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 4px;
}
.tagpick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tagchip {
  font-size: 12px;
  font-family: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 9px;
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.tagchip:hover {
  border-color: var(--secondary);
  color: var(--fg);
}
.tagchip[aria-pressed="true"] {
  background: var(--secondary-soft);
  border-color: var(--secondary);
  color: var(--secondary-ink);
  font-weight: 600;
}
.tagchip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.tagchip:disabled {
  opacity: 0.45;
  cursor: default;
}
.tagpick-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin: 6px 0 0;
  min-height: 16px;
}
.tagpick-meta b {
  color: var(--fg);
}

.pkg-advanced summary {
  font-size: 12.5px;
}
.pkg-advanced .maint-row {
  margin-top: 8px;
}

/* Maintainer rows. */
.maint-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.maint-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #f2f4f9;
  object-fit: cover;
}
/* Both the avatar and its dashed placeholder toggle via the hidden attribute;
   an explicit display would otherwise override it. */
.maint-avatar[hidden],
.maint-avatar-slot[hidden] {
  display: none;
}
.maint-avatar-slot {
  display: inline-block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px dashed var(--border);
}
.maint-row > span:first-child {
  display: inline-flex;
  align-items: center;
}
.maint-row input {
  width: 100%;
  background: #fff;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 13.5px;
  line-height: 1.6;
  min-width: 0;
}
.maint-row input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}
.maint-row input[aria-invalid="true"] {
  border-color: var(--fail);
}
.maint-remove {
  font-size: 12px;
  color: var(--fail);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
}
.maint-remove:hover {
  border-color: var(--fail);
}
.maint-errors {
  grid-column: 2 / -1;
  font-size: 12.5px;
  color: var(--fail);
  margin: -2px 0 0;
}

/* --- Rail: buffer + gates + handoff --------------------------------------- */

.reg-rail {
  position: sticky;
  top: 20px;
  align-self: start;
  display: grid;
  gap: 14px;
}

.buffer {
  background: var(--buffer-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(27, 35, 51, 0.25);
}
.buffer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--buffer-line);
  border-bottom: 1px solid #2c3550;
}
.buffer-file {
  color: var(--tok-str);
  font-size: 12.5px;
}
.buffer-note {
  color: var(--tok-comment);
  font-size: 11.5px;
  flex: 1;
}
.buffer-note code {
  color: var(--tok-key);
  font-size: 11.5px;
}
.buffer-copy {
  font-size: 12px;
  font-family: inherit;
  color: var(--tok-val);
  background: transparent;
  border: 1px solid #3a4463;
  border-radius: 6px;
  padding: 2px 10px;
  cursor: pointer;
}
.buffer-copy:hover {
  border-color: var(--tok-str);
  color: var(--tok-str);
}
.buffer-copy:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.handoff .buffer-copy {
  color: var(--fg);
  border-color: var(--border);
}
.handoff .buffer-copy:hover {
  border-color: var(--secondary-ink);
  color: var(--secondary-ink);
}
.buffer-out {
  margin: 0;
  padding: 14px 16px 16px;
  overflow: auto;
  max-height: 46vh;
  font-size: 12.5px;
  line-height: 1.55;
}
.buffer-out code {
  font-family: ui-monospace, SFMono-Regular, Menlo, "DejaVu Sans Mono", monospace;
  font-size: 12.5px;
  color: var(--tok-val);
  white-space: pre;
  display: block;
}
.tok-line {
  display: block;
  min-height: 1.55em;
}
.tok-key {
  color: var(--tok-key);
}
.tok-str {
  color: var(--tok-str);
}
.tok-comment {
  color: var(--tok-comment);
  font-style: italic;
}
.tok-punct {
  color: var(--tok-punct);
}
.tok-caret {
  display: inline-block;
  width: 7px;
  height: 1.1em;
  vertical-align: text-bottom;
  background: var(--tok-str);
  animation: caret-blink 1.1s steps(1) infinite;
}
@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}
.tok-line--flash {
  animation: line-flash 0.9s ease-out 1;
}
@keyframes line-flash {
  0% {
    background: rgba(238, 212, 91, 0.28);
  }
  100% {
    background: transparent;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tok-caret {
    animation: none;
  }
  .tok-line--flash {
    animation: none;
  }
}

/* Pre-flight gate list. */
.gates,
.handoff {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(27, 35, 51, 0.08);
}
.gates h2,
.handoff h2 {
  margin: 0;
  font-size: 15px;
}
.gates-lead {
  margin: 4px 0 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.gate-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.gate {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.gate:first-child {
  border-top: 0;
}
.gate-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.gate[data-status="ok"] .gate-icon {
  background: var(--pass);
}
.gate[data-status="fail"] .gate-icon {
  background: var(--fail);
}
.gate[data-status="warn"] .gate-icon {
  background: var(--secondary);
  color: var(--secondary-ink);
}
.gate[data-status="pending"] .gate-icon {
  background: transparent;
  border: 2px dashed var(--unknown);
}
.gate[data-status="info"] .gate-icon {
  background: var(--unknown);
}
.gate-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}
.gate-msg {
  color: var(--muted);
  font-size: 12.5px;
  margin: 1px 0 0;
}
.gate[data-status="fail"] .gate-msg {
  color: var(--fail);
}
.gate[data-status="warn"] .gate-msg {
  color: var(--secondary-ink);
}

/* Handoff. */
.handoff[data-ready="false"] .handoff-body {
  opacity: 0.45;
  pointer-events: none;
}
.handoff-lead {
  margin: 8px 0 10px;
  font-size: 13px;
}
.handoff-body > .btn-secondary {
  display: inline-block;
}
.handoff-manual {
  margin-top: 12px;
}
.handoff-manual summary {
  font-size: 12.5px;
}
.handoff[data-ready="true"] {
  border-color: var(--secondary);
  box-shadow: 0 2px 14px rgba(238, 212, 91, 0.45);
}
.handoff-blocked {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.handoff-steps {
  margin: 10px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
  font-size: 13px;
}
.handoff-steps .hint {
  margin-top: 3px;
}
.handoff-how {
  margin: 0;
}
.pr-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
}
.pr-title {
  background: #f2f4f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.handoff-after {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.handoff-after a {
  color: var(--link);
}

@media (max-width: 1080px) {
  .reg-wrap {
    grid-template-columns: 1fr;
  }
  .reg-rail {
    position: static;
  }
}

@media (max-width: 700px) {
  /* Stack the three maintainer inputs; the avatar and Remove stay on the
     first row next to the name. */
  .maint-row {
    grid-template-columns: 36px 1fr auto;
  }
  .maint-row input[aria-label="Maintainer email"],
  .maint-row input[aria-label="Maintainer GitHub handle"] {
    grid-column: 2 / -1;
  }
  .maint-errors {
    grid-column: 1 / -1;
  }
}
