/*
 * read.gonglogic.com — the feedback box and the forum.
 *
 * A file of its own so library.css stays one system owned in one place; everything
 * here is drawn from that file's TOKENS (--paper, --surface, --ink, --rule, --accent
 * …), so dark mode is already done: the tokens change under
 * `prefers-color-scheme: dark` and nothing here has to.
 *
 * ── THE FORMS
 *
 * The theme styles a bare <form> as a white, bordered, 34rem card with grey inputs —
 * built for gonglogic.com's contact page, with no dark mode, so on a dark library
 * page it would be a white slab. These forms are drawn on the library's surface with
 * its tokens instead. The theme's rules are (0,2,3) at their strongest
 * (`form fieldset .field input[type=text]`); every rule below starts
 * `[data-area="library"] .cm-form` and so outranks them without !important.
 */

/* ═══ LAYOUT ═══════════════════════════════════════════════════════════════════ */

.cm-split {
  display: grid;
  gap: 2rem;
}
@media (min-width: 60rem) {
  .cm-split { grid-template-columns: minmax(0, 38rem) minmax(0, 1fr); gap: 3.5rem; align-items: start; }
}
.cm-aside .section-head__title { margin-bottom: 0.9rem; font-size: 1.25rem; }
.cm-aside .ticks { margin-bottom: 1rem; }
.cm-status code { font-size: 0.9em; overflow-wrap: anywhere; }
.cm-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 1rem; }
.cm-status { margin: 1.25rem 0 0; }
.cm-staff { margin-bottom: 1.5rem; }

.cm-crumb,
.cm-crumb:hover { color: inherit; text-decoration: none; }
.cm-crumb:hover { text-decoration: underline; text-underline-offset: 0.2em; }

.cm-tag--warn { background: var(--bad-wash); color: var(--bad); }

/* ═══ FORMS ════════════════════════════════════════════════════════════════════ */

[data-area="library"] .cm-form form {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--ink);
}
@media (min-width: 48rem) {
  [data-area="library"] .cm-form form { padding: 2rem; }
}
[data-area="library"] .cm-form form fieldset .field { margin-bottom: 1.35rem; }
/* Under a topic or a post, the form takes the column's width rather than a form's. */
.cm-form--wide { max-width: 46rem; }
[data-area="library"] .cm-form form fieldset .field label.left,
[data-area="library"] .cm-form form fieldset .field > label,
[data-area="library"] .cm-form form fieldset .optionset legend,
[data-area="library"] .cm-form form fieldset .field.optionset > label {
  display: block;
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}
[data-area="library"] .cm-form form fieldset .field input[type=text],
[data-area="library"] .cm-form form fieldset .field input[type=email],
[data-area="library"] .cm-form form fieldset .field textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-s);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
}
[data-area="library"] .cm-form form fieldset .field input[type=text]:hover,
[data-area="library"] .cm-form form fieldset .field input[type=email]:hover,
[data-area="library"] .cm-form form fieldset .field textarea:hover { border-color: var(--ink-3); }
[data-area="library"] .cm-form form fieldset .field input[type=text]:focus,
[data-area="library"] .cm-form form fieldset .field input[type=email]:focus,
[data-area="library"] .cm-form form fieldset .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
  outline: none;
}
[data-area="library"] .cm-form form fieldset .field textarea { min-height: 8rem; resize: vertical; }
[data-area="library"] .cm-form form fieldset .field .description {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink-3);
}

/* The kinds of report, as a column of tappable rows rather than four bare radios. */
[data-area="library"] .cm-form .optionset ul { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
[data-area="library"] .cm-form .optionset li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-s);
  background: var(--paper);
}
[data-area="library"] .cm-form .optionset li:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
[data-area="library"] .cm-form .optionset li label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
[data-area="library"] .cm-form .optionset input[type=radio] { flex: none; width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent-strong); }

[data-area="library"] .cm-form form .message {
  margin: 0 0 1.25rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-s);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.95rem;
}
[data-area="library"] .cm-form form .message.bad,
[data-area="library"] .cm-form form .message.error,
[data-area="library"] .cm-form form .message.required,
[data-area="library"] .cm-form form .message.validation {
  border-color: var(--bad);
  background: var(--bad-wash);
  color: var(--ink);
}
[data-area="library"] .cm-form form .message.good { border-color: var(--ok); background: var(--ok-wash); }

[data-area="library"] .cm-form form .btn-toolbar { display: flex; margin-top: 1.5rem; }
[data-area="library"] .cm-form form .btn-toolbar input[type=submit].button,
[data-area="library"] .cm-form form .btn-toolbar button[type=submit].button {
  width: auto;
  height: auto;
  min-height: 2.75rem;
  padding: 0.6rem 1.6rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
}
@media (max-width: 30rem) {
  [data-area="library"] .cm-form form .btn-toolbar input[type=submit].button,
  [data-area="library"] .cm-form form .btn-toolbar button[type=submit].button { width: 100%; }
}

/* ═══ THE FORUM'S FRONT PAGE ═══════════════════════════════════════════════════ */

.cm-sections {
  display: grid;
  gap: 0.9rem;
}
@media (min-width: 48rem) {
  .cm-sections { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
}
/* A grid item holds its card at full height and never lets a long word widen it. */
.cm-section { display: flex; min-width: 0; }
.cm-section > .cm-section__link { flex: 1; min-width: 0; }
.cm-section__link,
.cm-section__link:hover {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  height: 100%;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cm-section__link:hover { border-color: var(--accent); box-shadow: var(--shadow-2); }
.cm-section__title { font-family: var(--serif); font-size: 1.3rem; font-weight: 500; line-height: 1.25; }
.cm-section__title .tag { margin-left: 0.3rem; vertical-align: 0.2em; font-family: var(--sans); }
.cm-section__about { font-size: 0.93rem; line-height: 1.5; color: var(--ink-2); }
.cm-section__counts { margin-top: auto; padding-top: 0.4rem; font-size: 0.8rem; color: var(--ink-3); }
.cm-section__latest {
  overflow: hidden;
  font-size: 0.86rem;
  color: var(--ink-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══ TOPIC LISTS ══════════════════════════════════════════════════════════════ */

.cm-topics {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--surface);
  overflow: hidden;
}
.cm-topic + .cm-topic { border-top: 1px solid var(--rule); }
.cm-topic__link,
.cm-topic__link:hover {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1.1rem;
  color: var(--ink);
  text-decoration: none;
}
.cm-topic__link:hover { background: var(--surface-2); }
.cm-topic__title { font-size: 1.02rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.cm-topic__title .tag { vertical-align: 0.1em; }
.cm-topic__meta { font-size: 0.82rem; color: var(--ink-3); }
.cm-topic--hidden .cm-topic__title { color: var(--ink-3); }

.cm-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.cm-pager__where { font-size: 0.88rem; font-variant-numeric: tabular-nums; color: var(--ink-3); }

/* ═══ A TOPIC ══════════════════════════════════════════════════════════════════ */

.cm-topic-title { overflow-wrap: anywhere; }
.cm-posts { display: grid; gap: 1rem; }
.cm-post {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--surface);
  scroll-margin-top: 5rem;
}
.cm-post:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.cm-post--hidden { border-style: dashed; background: var(--surface-2); }
.cm-post__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.6rem;
}
.cm-post__who { font-weight: 600; font-size: 0.95rem; }
.cm-post__who .tag { margin-left: 0.25rem; vertical-align: 0.1em; }
.cm-post__when,
.cm-post__when:hover { font-size: 0.8rem; color: var(--ink-3); text-decoration: none; }
.cm-post__flag { margin: 0 0 0.5rem; font-size: 0.8rem; font-weight: 600; color: var(--bad); }
.cm-post__body { font-size: 1rem; line-height: 1.65; overflow-wrap: anywhere; }
[data-area="library"] .cm-post__body p { margin: 0 0 0.8em; }
[data-area="library"] .cm-post__body p:last-child { margin-bottom: 0; }
.cm-post__body a,
.cm-post__body a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 0.18em; }
.cm-post__foot { display: flex; justify-content: flex-end; margin-top: 0.7rem; }
.cm-post__report,
.cm-post__report:hover { font-size: 0.8rem; color: var(--ink-3); text-decoration: none; }
.cm-post__report:hover { color: var(--bad); text-decoration: underline; }

.cm-reply { margin-top: 2.25rem; }
.cm-reply .section-head__title { margin-bottom: 1rem; }

.cm-quote {
  margin: 0 0 1.5rem;
  padding: 1rem 1.15rem;
  border-left: 3px solid var(--rule-2);
  border-radius: 0 var(--r-s) var(--r-s) 0;
  background: var(--surface-2);
}
.cm-quote .cm-post__who { margin-bottom: 0.4rem; }
