/* Block markdown, spoilers and dynamic timestamps (client/js/markdown.js, spoilers.js,
   timestamps.js), the Leaving Parley dialog (maskedLinks.js) and attachment details
   (attachmentEdit.js). Uses the theme tokens from styles.css. */

/* ---- blocks: headers, subtext, quotes, lists, code blocks ---- */
.content h1, .content h2, .content h3 { margin: 8px 0 0; color: var(--text-strong); font-weight: 700; line-height: 1.375; white-space: pre-wrap; }
.content h1 { font-size: 1.5rem; }
.content h2 { font-size: 1.25rem; }
.content h3 { font-size: 1rem; }
.content > :is(h1, h2, h3):first-child { margin-top: 4px; }
.content small.subtext { display: block; font-size: 0.8125rem; line-height: 1.11rem; color: var(--text-muted); }
.content blockquote { margin: 2px 0; padding: 0 8px 0 12px; border-left: 4px solid var(--bg-active); border-radius: 4px 0 0 4px; max-width: 90%; }
.content ul, .content ol { margin: 4px 0 0 16px; padding: 0 0 0 8px; white-space: normal; }
.content li { margin-bottom: 2px; white-space: pre-wrap; }
.content ul { list-style: disc; }
.content ul ul { list-style: circle; }
.content ul ul ul { list-style: square; }
.content li > ul, .content li > ol { margin-top: 2px; }
/* AI agents' posts only (renderMarkdown's ctx.rich): pipe tables, scrolling sideways when wide, and --- rules. */
.content .md-table-box { max-width: 100%; overflow-x: auto; margin: 6px 0 4px; white-space: normal; }
.content table.md-table { border-collapse: collapse; font-size: 0.875rem; line-height: 1.3; }
.content .md-table th, .content .md-table td { padding: 5px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; min-width: 60px; max-width: 420px; overflow-wrap: anywhere; }
.content .md-table th { background: var(--bg-panel); color: var(--text-strong); font-weight: 600; }
.content hr { margin: 10px 0; border: 0; border-top: 1px solid var(--border); }
.content pre.code-block { position: relative; }
.content pre.code-block .code-lang { position: absolute; top: 4px; right: 8px; font-size: 11px; font-family: inherit; text-transform: lowercase; color: var(--text-muted); user-select: none; pointer-events: none; }

/* ---- masked links and timestamps ---- */
.content a.masked-link { text-decoration: none; }
.content a.masked-link:hover { text-decoration: underline; }
.content time.timestamp-dynamic { background: var(--overlay-subtle); border-radius: 3px; padding: 0 2px; }

/* ---- ||spoiler|| text ---- */
.spoiler-text { border-radius: 3px; background: var(--overlay-subtle); padding: 0 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.spoiler-text.hidden { background: var(--spoiler-hidden); cursor: pointer; }
.spoiler-text.hidden:hover { background: var(--spoiler-hidden-hover); }
.spoiler-text.hidden:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.spoiler-text.hidden > .spoiler-content { opacity: 0; }

/* ---- spoilered attachments and link previews ---- */
.spoiler-media { position: relative; display: block; width: fit-content; max-width: 100%; border-radius: 6px; overflow: hidden; }
.spoiler-media.hidden { cursor: pointer; }
.spoiler-media.hidden > :not(.spoiler-label) { filter: blur(40px) brightness(0.7); }
.spoiler-media.hidden:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spoiler-label { position: absolute; inset: 0; margin: auto; width: fit-content; height: fit-content; padding: 8px 12px; border-radius: 20px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 14px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; pointer-events: none; }
.spoiler-media.hidden:hover .spoiler-label { background: rgba(0, 0, 0, 0.85); }
.spoiler-placeholder { width: 400px; max-width: 100%; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #2b2d33, #121316); }
.spoiler-media:has(> .embed) { margin-top: 6px; }
.spoiler-media > .embed { margin-top: 0; }
.spoiler-media > .file-card { margin: 0; }

/* ---- pending uploads: Spoiler / Modify / Remove ---- */
.pending .preview { position: relative; }
.pending.spoiler .preview > :not(.spoiler-label) { filter: blur(14px); }
.pending.spoiler .preview .spoiler-label { padding: 4px 8px; font-size: 11px; }
.pending-tools { position: absolute; top: -10px; right: -8px; display: flex; background: var(--bg-sidebar); border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); overflow: hidden; }
.pending-tool { display: grid; place-items: center; width: 30px; height: 28px; padding: 0; border: 0; border-radius: 0; background: none; color: var(--text-muted); }
.pending-tool:hover { background: var(--bg-hover); color: var(--text-strong); }
.pending-tool.spoiler-toggle.on { color: var(--accent); }
.pending-tool.danger:hover { color: var(--danger); }
.pending .alt-note { position: absolute; left: 12px; top: 84px; padding: 1px 4px; border-radius: 3px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 10px; font-weight: 700; }

/* ---- dialogs: Modify Attachment, remove confirmation, Leaving Parley ---- */
.attachment-modal .settings-field { margin-top: 12px; }
.attachment-modal input:not([type='checkbox']), .attachment-modal textarea { width: 100%; box-sizing: border-box; }
.attachment-modal textarea { resize: vertical; font: inherit; }
.modify-preview { display: grid; place-items: center; background: var(--bg-rail); border-radius: 6px; padding: 8px; color: var(--text-muted); }
.modify-preview img, .modify-preview video { max-width: 100%; max-height: 200px; border-radius: 4px; display: block; }
.modify-spoiler-row, .leaving-trust { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; cursor: pointer; }
.attachment-modal h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-modal .modal-actions button.danger-button { background: var(--danger); color: #fff; border: 0; border-radius: 4px; padding: 10px 16px; font-weight: 600; }
.leaving-url { background: var(--bg-rail); border-radius: 4px; padding: 10px 12px; color: var(--text-strong); font-weight: 600; overflow-wrap: anywhere; }

/* ---- Edit Message: Remove Attachment ---- */
.attachment-edit { position: relative; max-width: 100%; }
.attachment-edit > .remove-attachment { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 6px; background: var(--bg-sidebar); color: var(--text-muted); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
.attachment-edit > .remove-attachment:hover { color: var(--danger); background: var(--bg-hover); }

/* Checkboxes keep their size in dialogs (.modal input is full width). */
.modal input.leaving-trust-box, .modal input.modify-spoiler { width: auto; flex: none; margin: 0; }

/* Spoiler thumbnails in Pinned Messages and search results. */
:is(.pin-attachments, .search-attachments) > .spoiler-media { border-radius: 4px; }
:is(.pin-attachments, .search-attachments) > .spoiler-media > img { display: block; }
:is(.pin-attachments, .search-attachments) .spoiler-label { padding: 3px 8px; font-size: 11px; }
