/* Charter composer — the new-charter draft form: fields, char limits, required
   errors, reference picker, live review/feedback + structure panels. A future
   post/reply composer is a sibling (post-compose); the shared AI-review
   backdrop already lives in components/fallacies.css. */

.composer {
  display: grid;
  gap: var(--space-5);
  width: 100%;
}

.compose-card {
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft);
}

.compose-card {
  display: grid;
  gap: var(--space-2);
}

.charter {
  gap: var(--space-4);
}

.charter-legend {
  margin-inline: -2px;
  padding-inline: 2px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 820;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Kickoff Post legend with the fallacy summary trailing the label. */
.compose-legend-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: var(--space-3);
}

.compose-fallacy-summary {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

.compose-fallacy-summary.has-fallacies {
  color: var(--color-warning);
}

.compose-fallacy-summary.is-hidden {
  display: none;
}

.compose-references {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.compose-references-heading {
  padding: 0;
}

.field-disclosure {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 720;
  line-height: var(--line-ui);
  cursor: pointer;
}

.field-disclosure .section-chevron {
  font-size: 1rem;
  transform: translate(-1px, -1px);
}

.field-disclosure[aria-expanded="true"] .section-chevron {
  transform: translateY(1px) rotate(90deg);
}

.compose-reference-list {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) 0 var(--space-2);
}

.field .compose-reference-option {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: start;
  gap: var(--space-2);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: var(--line-ui);
}

.compose-reference-number {
  color: var(--clay);
  font-weight: 720;
  text-decoration: none;
}

.compose-reference-number:hover,
.compose-reference-number:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.field .compose-reference-option label {
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.compose-reference-empty {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  line-height: var(--line-ui);
}

.field .compose-reference-option input {
  box-sizing: border-box;
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 2px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background-color: var(--panel);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.field .compose-reference-option input:checked {
  border-color: var(--line);
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3 7.2L5.8 10L11 4' stroke='%23b58900' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.field .compose-reference-option input:hover,
.field .compose-reference-option input:active {
  border-color: var(--line);
  background-color: var(--panel);
}

.field .compose-reference-option input:checked:hover,
.field .compose-reference-option input:checked:active {
  border-color: var(--line);
  background-color: var(--panel);
}

.field {
  display: grid;
  gap: var(--space-2);
}

.field-helper {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: var(--line-ui);
}

.select {
  width: fit-content;
  min-width: 180px;
  max-width: 100%;
  min-height: 48px;
  padding: 0 calc(var(--space-4) + 18px) 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b6b6b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  color: var(--ink);
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.type-menu {
  position: relative;
  width: fit-content;
  max-width: 100%;
}

.type-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
}

.type-menu-list {
  position: absolute;
  z-index: 20;
  top: -1px;
  left: 0;
  display: grid;
  width: 100%;
  min-width: 180px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.type-menu-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: space-between;
  min-height: 48px;
  padding: 0 var(--space-3);
  border: 0;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.type-menu-label {
  min-width: 0;
}

.type-menu-check {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  background: transparent;
}

.type-menu-option.is-selected .type-menu-check {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18' fill='none'%3E%3Cpath d='M4 9.2L7.5 12.5L14 5.5' stroke='%23b58900' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.type-menu-option:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 1px var(--line);
}

@media (hover: hover) and (pointer: fine) {
  .type-menu-option:hover {
    background-color: var(--paper);
  }
}

.field-box-sm {
  min-height: 48px;
  height: auto;
  overflow: hidden;
  resize: none;
}

.field-box-lg {
  min-height: 160px;
  height: auto;
  overflow: hidden;
  resize: none;
}

/* Inline AI evaluation: the backdrop renders the first post (with hover-popover
   anchors on flagged sentences) while a transparent textarea on top handles
   editing and the caret. The wrapper draws the visible field box. */
.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: var(--space-2);
}

.limit-error {
  display: none;
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: var(--line-ui);
  /* The Kickoff Post legend is uppercased; keep its error in normal case so it
     matches the Title error. */
  letter-spacing: normal;
  text-transform: none;
  pointer-events: none;
}

.limit-error.is-visible {
  display: block;
  color: var(--color-warning);
}

.field label,
.field-heading {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 720;
  line-height: var(--line-ui);
}

.label-separator {
  color: var(--muted);
  font-size: 0.88rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  line-height: var(--line-reading);
}

input {
  min-height: 48px;
  padding: 0 var(--space-3);
}

textarea {
  height: 238px;
  padding: var(--space-3);
  overflow: auto;
  font-family: var(--font-reading);
  resize: vertical;
}

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

.feedback {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-1);
  padding: 0;
  border: 0;
  background: transparent;
}

.field-heading {
  margin: 0;
}

.fallacy-summary {
  margin: 0;
  color: var(--clay);
  font-size: 0.9rem;
  font-weight: 720;
}

.eval-chip {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 720;
  line-height: var(--line-ui);
}

.eval-chip.is-hidden {
  display: none;
}

.eval-chip.is-ok .eval-mark {
  color: var(--accent);
}

.eval-chip.is-info .eval-mark {
  color: var(--muted);
}

.eval-list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-4);
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.eval-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3);
  align-items: start;
}

.eval-item strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.94rem;
}

.eval-item span {
  display: block;
  color: var(--muted);
  font-family: var(--font-reading);
  line-height: 1.5;
}

.eval-item .eval-quote {
  margin: var(--space-1) 0;
  color: var(--ink);
  font-style: italic;
}

.eval-item .eval-mark {
  font-weight: 720;
  line-height: 1.4;
}

.eval-item.is-warn .eval-mark {
  color: var(--clay);
}

.eval-item.is-ok .eval-mark {
  color: var(--accent);
}

.feedback-panel {
  padding: var(--space-4);
  border: 1px solid var(--color-highlight-border);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.structure-panel {
  overflow: visible;
  padding: 0;
  background: transparent;
}

.structure-sketch {
  display: block;
  width: min(100%, 460px);
  height: auto;
  margin: 0 auto;
  color: var(--ink);
}

.feedback-panel h3 {
  margin-bottom: var(--space-2);
  font-size: 0.94rem;
}

.feedback-panel p,
.feedback-panel li {
  color: var(--muted);
  font-family: var(--font-reading);
  line-height: 1.5;
}

.feedback-panel p {
  margin-bottom: var(--space-2);
}

.feedback-panel ul {
  margin: 0;
  padding-left: 20px;
}
