/* Kommentare (docs/kommentare.md): der Abschnitt unter Meldung und Wiki-Artikel und die Liste der
   eigenen Kommentare (comments/_list). Aufnahme-Knopf und Zeitanzeige kommen aus dem Diktat
   (.runner-button--microphone, .runner-dictation). */

.comments {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

.comments [hidden] {
  display: none !important;
}

.comments__intro {
  display: grid;
  justify-items: start;
  gap: var(--space-3);
}

.comments__open {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.comments__hint {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.comments__plain-form {
  display: grid;
  gap: var(--space-3);
}

/* --- Pop-up ---------------------------------------------------------------------------------
   Hidden whenever it is not open, laid out as an overlay when it is -- with showModal() and
   without (Safari before 15.4 sets only the `open` attribute). */

.comments__dialog {
  display: none;
}

.comments__dialog[open] {
  display: block;
  position: fixed;
  inset: 0;
  height: fit-content;
  z-index: 100;
  box-sizing: border-box;
  width: min(100% - 2rem, 34rem);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  /* Anchored to the top, not centred: with the on-screen keyboard up the send button must stay in
     view, and the card does not jump when its content changes. */
  margin: 1rem auto auto;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-2, 0 12px 32px rgba(0, 0, 0, 0.18));
}

/* The page behind the open pop-up stays put. */
html:has(.comments__dialog[open]) {
  overflow: hidden;
}

.comments__dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

/* Without showModal() there is no ::backdrop: dim the page with a huge shadow instead. */
.comments__dialog--plain[open] {
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
}

.comments__card {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5) var(--space-5);
}

.comments__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.comments__head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.comments__close {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-muted);
  background: var(--surface);
  cursor: pointer;
}

.comments__close:hover {
  color: var(--ink);
}

.comments__close:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.comments__form {
  display: grid;
  gap: var(--space-3);
}

.comments__notice {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

/* Short field: the buttons stay reachable above the on-screen keyboard. */
.comments__text textarea {
  min-height: 4.5rem;
  max-height: 8rem;
}

.comments__preview {
  display: grid;
  gap: var(--space-3);
}

.comments__preview audio {
  width: 100%;
}

.comments__preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
}

.comments__list {
  display: grid;
  gap: var(--space-3);
}

.comments__list-heading {
  margin: 0;
  font-size: 1.05rem;
}

.comments__delivered {
  display: grid;
}

.comment-list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.comments__waiting:empty {
  display: none;
}

.comment {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-raised);
}

.comment-date {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.comment-text {
  margin: 0;
  overflow-wrap: anywhere;
}

.comment audio {
  width: 100%;
}

.comment--waiting {
  border-style: dashed;
}

.comment-badge {
  justify-self: start;
  margin: 0;
  padding: 0 var(--space-2);
  border-radius: 999px;
  color: var(--warn);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--warn);
}
