/* article-issue.css — styles for the "open an issue" button, the
 * modal dialog, and the issue list block. Imported from
 * `RootLayout.astro` on article and project page types
 * (article-graph.css / architecture.css are loaded by SeoHead
 *  — this file is appended via the article-issue layout slot).
 *
 * Reuses the typography tokens from prose.css; new color tokens
 * are introduced for severity badges (warning + danger with safe
 * fallbacks to existing tokens).
 */

.open-issue-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border-radius: 999px;
  border: 1px solid var(--accent, #4dd0e1);
  background: transparent;
  color: var(--accent, #4dd0e1);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.open-issue-btn:hover,
.open-issue-btn:focus-visible {
  background: var(--accent, #4dd0e1);
  color: var(--bg, #0c0f17);
}

.open-issue-btn[hidden] {
  display: none;
}

/* ---------- modal ---------- */

.article-issue-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 11, 18, 0.72);
  padding: 1.5rem;
}

.article-issue-modal[hidden] {
  display: none;
}

.article-issue-modal__panel {
  width: min(640px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--bg, #0c0f17);
  border: 1px solid var(--muted, #2a2f3a);
  border-radius: 14px;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.article-issue-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.article-issue-modal__title {
  margin: 0;
  font-size: 1.125rem;
}

.article-issue-modal__close {
  background: transparent;
  border: 1px solid var(--muted, #2a2f3a);
  border-radius: 8px;
  width: 2rem;
  height: 2rem;
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  color: inherit;
}

.article-issue-modal__article {
  font-size: 0.875rem;
  color: var(--muted, #99a);
  margin: 0 0 1.25rem;
}

.article-issue-modal__article code {
  margin-left: 0.5rem;
  padding: 0.125rem 0.375rem;
  border-radius: 6px;
  background: var(--code-bg, #1a1f29);
  font-size: 0.75rem;
}

.article-issue-modal__form {
  display: grid;
  gap: 1rem;
}

.article-issue-modal__field {
  display: grid;
  gap: 0.4rem;
  border: 0;
  margin: 0;
  padding: 0;
}

.article-issue-modal__field > span,
.article-issue-modal__field > legend {
  font-weight: 600;
  font-size: 0.9rem;
}

.article-issue-modal__field input[type="text"],
.article-issue-modal__field textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--muted, #2a2f3a);
  background: var(--code-bg, #1a1f29);
  color: inherit;
  font: inherit;
}

.article-issue-modal__field textarea {
  min-height: 7rem;
  resize: vertical;
}

.article-issue-modal__severity {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.article-issue-modal__severity label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
}

.article-issue-modal__captcha {
  display: grid;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  border: 1px dashed var(--muted, #2a2f3a);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.article-issue-modal__snippet {
  margin: 0;
  padding: 0.625rem 0.75rem;
  background: var(--code-bg, #1a1f29);
  border-radius: 6px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.85rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

.article-issue-modal__answer input {
  width: 8rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--muted, #2a2f3a);
  background: var(--code-bg, #1a1f29);
  color: inherit;
  font: inherit;
}

.article-issue-modal__retry {
  justify-self: start;
  background: transparent;
  border: 1px solid var(--muted, #2a2f3a);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.article-issue-modal__error {
  color: var(--danger, #dc2626);
  font-size: 0.875rem;
}

.article-issue-modal__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.article-issue-modal__submit,
.article-issue-modal__cancel {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--muted, #2a2f3a);
  background: var(--accent, #4dd0e1);
  color: var(--bg, #0c0f17);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.article-issue-modal__cancel {
  background: transparent;
  color: inherit;
}

.article-issue-modal__article-url {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted, #99a);
  word-break: break-all;
}

.article-issue-modal__thanks-link {
  color: var(--accent, #4dd0e1);
  text-decoration: underline;
}

/* ---------- issue list ---------- */

.issue-list {
  margin-top: 2rem;
  display: grid;
  gap: 1rem;
}

.issue-list__section_title {
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted, #99a);
}

.issue-list__group_title {
  display: block;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--muted, #99a);
}

.issue-list__empty,
.issue-list__error {
  padding: 0.75rem 1rem;
  border: 1px dashed var(--muted, #2a2f3a);
  border-radius: 10px;
  color: var(--muted, #99a);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* The hydration script toggles the `hidden` attribute on the
 * empty-state <p> based on the comment count. The class rule above
 * sets `display: flex`, which would override the browser default
 * `[hidden] { display: none }` and leave the dashed-bordered box
 * visible alongside the rendered comment. Re-assert the hidden
 * state explicitly so the attribute is honoured here. */
.issue-list__empty[hidden],
.issue-list__error[hidden] {
  display: none;
}

.issue-list__error button {
  background: transparent;
  border: 1px solid var(--muted, #2a2f3a);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.issue-item {
  padding: 1rem;
  border: 1px solid var(--muted, #2a2f3a);
  border-radius: 10px;
  display: grid;
  gap: 0.5rem;
}

.issue-item__badges {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.issue-status {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid currentColor;
}

.issue-status--open {
  color: var(--accent, #4dd0e1);
}

.issue-status--closed {
  color: var(--muted, #99a);
}

.issue-severity {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: lowercase;
  border: 1px solid currentColor;
}

.issue-severity--question { color: var(--muted, #99a); }
.issue-severity--minor    { color: var(--accent, #4dd0e1); }
.issue-severity--major    { color: var(--warning, #d97706); }
.issue-severity--critical { color: var(--danger, #dc2626); }

.issue-item__title a {
  color: inherit;
  text-decoration: underline;
}

.issue-item__excerpt {
  color: var(--muted, #99a);
  font-size: 0.875rem;
}

.issue-item__open-on-github {
  font-size: 0.85rem;
  color: var(--accent, #4dd0e1);
}

/* ---------- comment card ----------
 *
 * Rendered by `src/scripts/article-issue-list.ts` in place of the
 * `.issue-item` block above. The comment block lives outside the
 * `.prose` wrapper so the prose typography rules do not apply; the
 * rules below give the `.comment-item__*` markup a card layout
 * (header row with author + relative time, body line) that matches
 * the rest of the discussion block.
 */
.comment-item {
  padding: 0.875rem 1rem;
  border: 1px solid var(--muted, #2a2f3a);
  border-radius: 10px;
  display: grid;
  gap: 0.5rem;
  background: var(--code-bg, #1a1f29);
}

.comment-item__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted, #99a);
}

.comment-item__author {
  color: var(--bright, #fff);
  font-weight: 600;
}

.comment-item__time {
  color: var(--muted, #99a);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.comment-item__body {
  margin: 0;
  color: var(--fg, #D4D4D4);
  font-size: 0.9rem;
  line-height: 1.6;
  /* Preserve user-entered whitespace (line breaks, indentation) but
   * never overflow the card's horizontal padding. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
