/* Spaces v2 community chrome: official badge, member stats, Join, About.
   Scoped under the space view and prefixed per AGENTS.md §12.9. Loaded only
   on the Space route so nothing leaks into other pages. */

.spaces-official-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--color-accent-soft, #e6f7f1);
  color: var(--color-accent-strong, #0a7f5c);
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}

.spaces-hero-community {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 10px;
}

.spaces-hero-stats {
  margin: 0;
  color: var(--color-text-muted, #5b6672);
  font-size: 14px;
}

.spaces-stat-sep {
  margin: 0 6px;
}

.spaces-lifecycle-note {
  color: var(--color-text-subtle, #8a939d);
}

.spaces-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spaces-join-btn,
.spaces-about-btn {
  padding: 8px 18px;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
}

.spaces-join-btn {
  border: 0;
  background: var(--color-primary, #0ba8d2);
  color: #fff;
}

/* Joined is a state, not a different control: same shape, quieter styling, so
   the button does not jump when it toggles. */
.spaces-join-btn[data-joined="true"] {
  background: transparent;
  border: 1px solid var(--color-border, #e3e7ec);
  color: var(--color-text-muted, #5b6672);
}

.spaces-join-btn[disabled] {
  opacity: 0.6;
  cursor: default;
}

.spaces-about-btn {
  border: 1px solid var(--color-border, #e3e7ec);
  background: transparent;
  color: inherit;
}

.spaces-join-status {
  flex-basis: 100%;
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted, #5b6672);
}

.spaces-join-status.is-error {
  color: var(--color-danger, #c0392b);
}

.spaces-about {
  margin: 12px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--color-border, #e3e7ec);
  border-radius: 12px;
}

.spaces-about-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted, #5b6672);
}

.spaces-about-body p {
  margin: 0 0 8px;
  line-height: 1.55;
}

.spaces-about-owner {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--color-text-muted, #5b6672);
}

/* Named -feed-empty, not -empty: `.spaces-empty` already belongs to the
   Discovery Spaces sidebar widget in style.css. Two owners for one class is
   exactly the collision §12.9 exists to prevent. */
.spaces-feed-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--color-text-muted, #5b6672);
}

.spaces-feed-empty-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: inherit;
}

.spaces-feed-empty-body {
  margin: 0 auto 14px;
  max-width: 44ch;
  line-height: 1.55;
}

/* Space pages use the right rail for context, not duplicate navigation. */
.spaces-context-card {
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid var(--color-border, #e3e7ec);
  border-radius: 16px;
  background: #fbfcfe;
}

.spaces-context-title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
}

.spaces-context-description {
  margin: 0 0 16px;
  color: var(--color-text-muted, #5b6672);
  font-size: 13px;
  line-height: 1.5;
}

.spaces-context-list {
  margin: 0;
}

.spaces-context-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--color-border, #e3e7ec);
}

.spaces-context-row dt,
.spaces-context-row dd {
  margin: 0;
  font-size: 13px;
}

.spaces-context-row dt {
  color: var(--color-text-muted, #5b6672);
  font-weight: 600;
}

.spaces-context-row dd {
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 600;
}

.spaces-state-label {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--color-surface-muted, #f1f4f7);
  color: var(--color-text-muted, #5b6672);
  font-size: 11px;
  font-weight: 600;
}

@media (max-width: 640px) {
  .spaces-hero-community {
    gap: 8px 12px;
  }

  .spaces-hero-actions {
    width: 100%;
  }

  .spaces-join-btn,
  .spaces-about-btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

/* Focus. Every interactive element added here must show where the keyboard is
   — :focus-visible so a mouse click does not leave a ring behind. */
.spaces-join-btn:focus-visible,
.spaces-about-btn:focus-visible,
.spaces-item:focus-visible {
  outline: 2px solid var(--color-primary, #0ba8d2);
  outline-offset: 2px;
  border-radius: 8px;
}

.spaces-join-btn:focus-visible,
.spaces-about-btn:focus-visible {
  border-radius: 999px;
}

/* The sidebar rows are links now, so cancel the default underline/colour. */
.spaces-item {
  color: inherit;
  text-decoration: none;
}

/* Owner / moderator control panel. */
.spaces-manage {
  margin: 12px 0 0;
  padding: 16px 18px;
  border: 1px solid var(--color-border, #e3e7ec);
  border-radius: 12px;
}

.spaces-manage-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}

.spaces-manage-note,
.spaces-manage-hint {
  margin: 0 0 12px;
  max-width: 62ch;
  color: var(--color-text-muted, #5b6672);
  font-size: 13px;
  line-height: 1.55;
}

.spaces-manage-group {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.spaces-manage-legend {
  padding: 0;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted, #5b6672);
}

.spaces-manage-label {
  display: block;
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.spaces-manage-input {
  display: block;
  width: 100%;
  max-width: 520px;
  padding: 9px 12px;
  border: 1px solid var(--color-border, #e3e7ec);
  border-radius: 8px;
  font: inherit;
  box-sizing: border-box;
}

.spaces-manage-checkbox {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
  font-size: 14px;
  cursor: pointer;
}

.spaces-manage-field {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--color-border-subtle, #eef1f4);
  border-radius: 10px;
}

.spaces-manage-field-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.spaces-manage-field-label {
  flex: 1 1 220px;
  max-width: 340px;
}

.spaces-manage-field-type {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-surface-muted, #f1f4f7);
  color: var(--color-text-muted, #5b6672);
  font-size: 11px;
  font-weight: 600;
}

.spaces-manage-field-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.spaces-manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.spaces-manage-status {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted, #5b6672);
}

.spaces-manage-status.is-error {
  color: var(--color-danger, #c0392b);
}

.spaces-manage-input:focus-visible {
  outline: 2px solid var(--color-primary, #0ba8d2);
  outline-offset: 1px;
}

/* Dedicated owner/moderator settings surface. The public Space feed stays a
   reading page; management gets a quiet, conventional settings layout. */
.layout-wrapper:has(.spaces-manage-page) {
  display: block;
  max-width: 960px;
}

.spaces-manage-page {
  width: 100%;
  padding: 12px 0 64px;
}

.spaces-manage-page-header {
  padding: 4px 0 24px;
  border-bottom: 1px solid var(--border);
}

.spaces-manage-back {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.spaces-manage-back:hover {
  color: var(--text);
}

.spaces-manage-page-title {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.2;
}

.spaces-manage-page .spaces-manage-note {
  margin: 0;
}

.spaces-manage-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  min-height: 520px;
}

.spaces-manage-nav {
  padding: 24px 24px 0 0;
}

.spaces-manage-nav-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.spaces-manage-nav-item:hover {
  background: var(--primary-light);
  color: var(--text);
}

.spaces-manage-nav-item.is-active {
  background: var(--primary-light);
  color: var(--text);
}

.spaces-manage-content {
  min-width: 0;
  padding: 24px 0 0 32px;
  border-left: 1px solid var(--border);
}

.spaces-manage-page .spaces-manage {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

.spaces-manage-page .spaces-manage-input {
  max-width: 560px;
}

@media (max-width: 700px) {
  .spaces-manage-page {
    padding-top: 0;
  }

  .spaces-manage-page-header {
    padding-bottom: 18px;
  }

  .spaces-manage-page-title {
    font-size: 22px;
  }

  .spaces-manage-layout {
    display: block;
  }

  .spaces-manage-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .spaces-manage-nav-item {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .spaces-manage-content {
    padding: 20px 0 0;
    border-left: 0;
  }
}
