/* ---------------------------------------------------------------------------
   forum-view.css: the large message viewer shared by the Threads forum and the
   Issue Tracker (header, toolbar, messages, reactions, editing, composer).
   Page-specific bits stay in each page's own stylesheet.
   --------------------------------------------------------------------------- */

/* ---- Viewer panel --------------------------------------------------------- */

body.thread-view-open { overflow: hidden; }

.thread-view-overlay { position: fixed; inset: 0; background: rgba(12,10,8,0.68); z-index: 90000; display: flex; align-items: center; justify-content: center; padding: 24px; animation: oreFadeIn 0.18s ease; }
.thread-view { width: min(900px, 100%); height: min(86vh, 920px); display: flex; flex-direction: column; overflow: hidden; background: var(--ore-card-bg); border: 2px solid var(--ore-card-border); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.thread-view-header { display: flex; align-items: flex-start; gap: 14px; padding: 12px 16px; background: var(--ore-card-border); color: #fff; border-bottom: 3px solid var(--cat-color, var(--am-gold-light)); }
.tv-heading { flex: 1; min-width: 0; }
.tv-heading-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.tv-category { font-family: var(--font-body); font-size: 0.58rem; text-transform: uppercase; letter-spacing: 1px; padding: 2px 10px; color: #fff; background: var(--cat-color, var(--mc-accent)); }
.tv-state { font-family: var(--font-body); font-size: 0.58rem; text-transform: uppercase; letter-spacing: 1px; padding: 2px 10px; border: 1px solid rgba(255,255,255,0.45); color: #fff; }
.tv-state.archived { color: #e8d9c3; border-color: #e8d9c3; }
.tv-title { margin: 0; font-family: var(--font-display); font-size: 1.1rem; line-height: 1.35; color: #fff; word-break: break-word; }
.tv-subtitle { margin-top: 4px; font-size: 0.7rem; opacity: 0.7; }
.tv-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.tv-actions .follow-btn { border-color: rgba(255,255,255,0.5); color: #fff; }
.tv-actions .follow-btn:hover, .tv-actions .follow-btn.active { border-color: var(--mc-accent-light); color: var(--mc-accent-light); }
.tv-actions .thread-action-btn { height: 28px; padding: 0 10px; }
.tv-close { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: none; border: none; color: #fff; font-size: 0.95rem; cursor: pointer; opacity: 0.75; transition: opacity 0.2s ease, background 0.2s ease; }
.tv-close:hover { opacity: 1; background: rgba(255,255,255,0.12); }

.thread-view-body { flex: 1; overflow-y: auto; padding: 18px 20px 10px 20px; background: linear-gradient(180deg, rgba(176, 141, 85, 0.06), rgba(176, 141, 85, 0) 140px); scrollbar-width: thin; }
.tv-message { display: flex; gap: 12px; padding: 9px 0; }
.tv-message.grouped { padding-top: 2px; }
.tv-avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--mc-accent); object-fit: cover; flex-shrink: 0; background: var(--ore-card-border); }
.tv-avatar-placeholder { display: flex; align-items: center; justify-content: center; font-family: var(--font-body); font-size: 0.95rem; color: #fff; }
.tv-avatar-spacer { width: 38px; flex-shrink: 0; }
.tv-message-main { flex: 1; min-width: 0; }
.tv-message-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.tv-author { font-family: var(--font-body); font-size: 0.85rem; font-weight: bold; color: var(--text-dark); }
.tv-staff-tag { font-family: var(--font-display); font-size: 0.52rem; text-transform: uppercase; letter-spacing: 1px; padding: 1px 6px; color: #fff; background: var(--ore-copper); }
.tv-starter-tag { font-family: var(--font-display); font-size: 0.52rem; text-transform: uppercase; letter-spacing: 1px; padding: 1px 6px; color: #fff; background: var(--mc-accent); }
.tv-time { font-size: 0.66rem; color: var(--text-dark); opacity: 0.45; }
.tv-message-body { font-size: 0.9rem; line-height: 1.62; color: var(--text-dark); word-break: break-word; }
.tv-message-body p { margin: 0 0 8px 0; }
.tv-message-body p:last-child { margin-bottom: 0; }
.tv-message-body strong, .tv-message-body b { color: var(--mc-accent-light); }
.tv-message-body code { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--ore-card-border); padding: 1px 5px; font-size: 0.88em; }
.tv-message-body pre { background: rgba(0,0,0,0.06); border: 2px solid var(--ore-card-border); padding: 10px 12px; overflow-x: auto; }
.tv-message-body blockquote { margin: 6px 0; padding: 2px 0 2px 12px; border-left: 4px solid var(--am-gold-light); opacity: 0.85; }
/* ---- Message actions, reactions and editing (forum stage 2) ---- */
.tv-message { position: relative; }
.tv-msg-actions { position: absolute; top: 4px; right: 0; display: flex; gap: 2px; padding: 2px; background: var(--mc-card); border: 2px solid var(--mc-black); box-shadow: 0 2px 0 rgba(0,0,0,0.35); opacity: 0; pointer-events: none; transition: opacity 0.12s ease; }
.tv-message:hover > .tv-msg-actions, .tv-message:focus-within > .tv-msg-actions { opacity: 1; pointer-events: auto; }
.tv-msg-actions[hidden] { display: none; }
.tv-msg-action { min-width: 28px; height: 24px; padding: 0 8px; font-family: var(--font-body); font-size: 0.72rem; font-weight: 600; color: var(--mc-muted); background: none; border: none; border-radius: 0; cursor: pointer; }
.tv-msg-action:hover, .tv-msg-action:focus-visible { color: var(--am-gold-bright); background: rgba(176, 141, 85, 0.18); outline: none; }
@media (hover: none) {
    .tv-msg-actions { position: static; opacity: 1; pointer-events: auto; align-self: flex-start; background: none; border: none; box-shadow: none; flex-direction: column; }
}
.tv-edited { font-size: 0.66rem; color: var(--mc-faint); font-style: italic; cursor: help; }
.tv-grouped-meta { margin-top: 2px; }
.tv-reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tv-reactions[hidden] { display: none; }
.tv-react-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; font-family: var(--font-body); font-size: 0.78rem; color: var(--mc-text); background: var(--mc-well); border: 2px solid var(--mc-black); border-radius: 0; cursor: pointer; }
.tv-react-chip:hover:not(:disabled) { border-color: var(--am-gold); }
.tv-react-chip.mine { background: rgba(176, 141, 85, 0.22); border-color: var(--am-gold-light); color: var(--am-gold-bright); }
.tv-react-chip:disabled { cursor: default; opacity: 0.85; }
.tv-react-emoji, .tv-react-option-img, .tv-msg-action-img { image-rendering: pixelated; image-rendering: crisp-edges; display: block; flex-shrink: 0; }
.tv-react-emoji { width: 20px; height: 20px; }
.tv-msg-action { display: inline-flex; align-items: center; gap: 1px; }
.tv-msg-action-img { width: 16px; height: 16px; }
.tv-react-count { font-weight: 700; font-size: 0.72rem; }
.tv-react-picker { display: grid; grid-template-columns: repeat(10, 34px); gap: 2px; width: max-content; max-width: 100%; margin-top: 6px; padding: 3px; background: var(--mc-card); border: 2px solid var(--mc-black); box-shadow: 0 3px 0 rgba(0,0,0,0.35); }
.tv-react-option { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; background: none; border: none; border-radius: 0; cursor: pointer; }
.tv-react-option-img { width: 24px; height: 24px; }
@media (max-width: 480px) { .tv-react-picker { grid-template-columns: repeat(6, 34px); } }
.tv-react-option:hover, .tv-react-option:focus-visible { background: rgba(176, 141, 85, 0.22); outline: none; }
.tv-edit-box { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.tv-edit-title, .tv-edit-input { width: 100%; padding: 8px 10px; font-family: var(--font-body); font-size: 0.88rem; line-height: 1.5; color: var(--mc-text); background: var(--mc-well); border: 2px solid var(--mc-black); border-radius: 0; box-sizing: border-box; }
.tv-edit-input { min-height: 90px; resize: vertical; }
.tv-edit-title:focus, .tv-edit-input:focus { outline: none; border-color: var(--mc-accent); }
.tv-edit-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.tv-edit-actions .ore-btn { height: 30px; padding: 0 14px; margin: 0; }
.tv-edit-hint { margin-right: auto; font-size: 0.68rem; color: var(--mc-faint); }
.tv-message-body img.user-img { max-height: 360px; }

.tv-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px 0; font-family: var(--font-body); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dark); opacity: 0.5; }
.tv-divider::before, .tv-divider::after { content: ""; flex: 1; height: 1px; background: rgba(0,0,0,0.15); }
.tv-empty { text-align: center; padding: 24px 10px; font-family: var(--font-body); font-size: 0.82rem; opacity: 0.5; }
.tv-archived-note { margin: 0 0 12px 0; padding: 10px 12px; font-family: var(--font-body); font-size: 0.72rem; line-height: 1.5; color: var(--text-dark); background: rgba(122,122,122,0.12); border: 2px dashed var(--ore-stone); }

.thread-view-composer { border-top: 2px solid var(--ore-card-border); padding: 10px 16px 12px 16px; background: rgba(0,0,0,0.03); }
.tv-composer-row { display: flex; align-items: flex-end; gap: 10px; }
.tv-composer-row textarea { flex: 1; min-height: 44px; max-height: 150px; padding: 10px 12px; font-family: var(--font-body); font-size: 0.88rem; line-height: 1.5; color: var(--text-dark); background: var(--mc-well); border: 2px solid var(--ore-card-border); resize: vertical; }
.tv-composer-row textarea:focus { outline: none; border-color: var(--mc-accent); }
.tv-composer-row .ore-btn { height: 42px; padding: 0 20px; flex-shrink: 0; }
.tv-composer-row .md-editor { flex: 1; }
.tv-composer-row .md-editor + .ore-btn { align-self: flex-start; height: 34px; margin-top: 0; }
.md-editor-compact .md-tools { justify-content: flex-start; }
.tv-locked { text-align: center; padding: 8px 0; font-family: var(--font-body); font-size: 0.8rem; opacity: 0.65; }
.tv-loading { text-align: center; padding: 40px 10px; font-family: var(--font-body); font-size: 0.85rem; opacity: 0.6; }

.tv-author { padding: 0; background: none; border: none; border-radius: 0; cursor: pointer; text-align: left; }
.tv-author:hover, .tv-author:focus-visible { color: var(--am-gold-bright); text-decoration: underline; outline: none; }
.tv-avatar[data-act="profile"] { cursor: pointer; }
.tv-state.locked { color: var(--am-gold-bright); border-color: var(--am-gold-light); }

.tv-locked-note { margin: 0 0 12px 0; padding: 10px 12px; font-family: var(--font-body); font-size: 0.72rem; line-height: 1.5; color: var(--am-gold-bright); background: rgba(176, 141, 85, 0.12); border: 2px solid var(--am-gold); }
.tv-msg-action-danger:hover, .tv-msg-action-danger:focus-visible { color: #ff8a8a; background: rgba(195, 54, 54, 0.2); }

.tv-message.tv-highlight { animation: tvHighlight 2.6s ease; }
@keyframes tvHighlight { 0%, 40% { background: rgba(176, 141, 85, 0.25); box-shadow: -6px 0 0 var(--am-gold-light); } 100% { background: transparent; box-shadow: none; } }

/* ---- Roomier layout -------------------------------------------------------- */
/* Wider window, the action buttons on their own toolbar row under the title,
   and a tall editor that takes over the composer's space while editing. */
.thread-view-overlay { padding: 16px; }
.thread-view { width: min(1180px, 100%); height: min(94vh, 1100px); }
.thread-view-header { flex-wrap: wrap; row-gap: 10px; padding: 14px 18px 12px; }
.thread-view-header .tv-heading { order: 1; flex: 1 1 0; }
.thread-view-header .tv-close { order: 2; }
.thread-view-header .tv-actions { order: 3; flex: 1 1 100%; justify-content: flex-start; gap: 8px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.thread-view-header .tv-actions:empty { display: none; }
.tv-title { font-size: 1.3rem; }
.tv-subtitle { font-size: 0.78rem; }
.tv-actions .thread-action-btn, .tv-actions .follow-btn { height: 32px; min-width: 72px; padding: 0 14px; font-size: 0.72rem; white-space: nowrap; flex-shrink: 0; }
.tv-actions .ore-btn.btn-red { margin-left: auto; }
.thread-view-body { padding: 20px 28px 12px; }
.tv-message-body { font-size: 0.95rem; }

.tv-edit-box { gap: 10px; margin-top: 6px; }
.tv-edit-box .tv-edit-title { font-size: 1rem; padding: 10px 12px; }
.tv-edit-box .tv-edit-input { min-height: 220px; max-height: none; }
.tv-edit-box.is-op .tv-edit-input { min-height: 320px; }
.tv-edit-actions .ore-btn { height: 34px; padding: 0 18px; }
/* while editing, the reply box steps aside so the editor has the room */
.thread-view:has(.tv-edit-box) .thread-view-composer { display: none; }

@media (max-width: 800px) {
    .thread-view-overlay { padding: 0; }
    .thread-view { height: 100%; }
    .thread-view-header { padding: 12px 14px 10px; }
    .tv-title { font-size: 1.1rem; }
    .tv-actions .thread-action-btn, .tv-actions .follow-btn { min-width: 0; padding: 0 12px; }
    .tv-actions .ore-btn.btn-red { margin-left: 0; }
    .thread-view-body { padding: 14px 14px 8px; }
    .tv-edit-box .tv-edit-input { min-height: 180px; }
    .tv-edit-box.is-op .tv-edit-input { min-height: 240px; }
}

@media (max-width: 800px) {
    .thread-view-overlay { align-items: stretch; }
    .thread-view { width: 100%; max-height: none; border-width: 0; box-shadow: none; }
    .tv-actions { width: 100%; justify-content: flex-start; }
    .thread-view-composer { padding: 10px 12px 14px 12px; }
}

/* ---- Phase 4B: hidden posts, staff edits, slow mode, timeouts (forum + issues) ---- */
.tv-message.is-hidden .tv-message-main { opacity: 0.85; }
.tv-hidden-banner { margin: 0 0 8px 0; padding: 6px 10px; font-family: var(--font-body); font-size: 0.74rem; color: var(--mc-text); background: rgba(170, 60, 50, 0.16); border-left: 4px solid var(--btn-red, #b33a2e); }
.tv-hidden-placeholder { margin: 0; font-family: var(--font-body); font-size: 0.8rem; font-style: italic; color: var(--mc-faint); }
.tv-edited-staff { font-style: normal; color: var(--am-gold-bright); }
.tv-slow-note { margin: 0 0 6px 0; font-family: var(--font-body); font-size: 0.72rem; color: var(--mc-faint); }
.mod-timeout-banner { margin: 12px auto; max-width: 1100px; padding: 10px 14px; font-family: var(--font-body); font-size: 0.85rem; color: var(--mc-text); background: rgba(170, 60, 50, 0.18); border: 2px solid var(--btn-red, #b33a2e); box-sizing: border-box; }
@media (max-width: 1140px) { .mod-timeout-banner { margin: 12px 16px; } }
.fr-tag-hidden { color: #f0a49b; border-color: var(--btn-red, #b33a2e); }

/* ---- Phase 5B: instant replies, live updates, reply context, shortcuts ---- */
.tv-message.is-pending { opacity: 0.6; }
.tv-sending { font-size: 0.66rem; color: var(--mc-faint); font-style: italic; }
.tv-new-replies { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 91000; padding: 6px 14px; font-family: var(--font-display); font-size: 0.72rem; color: #1b1b1b; background: var(--am-gold-light, #c9a227); border: 2px solid var(--mc-black); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4); cursor: pointer; }
.tv-quote-link { cursor: pointer; font-size: 0.74rem; font-weight: 700; color: var(--am-gold-bright); }
.tv-quote-link:hover { text-decoration: underline; }
.tv-message.tv-kbd-focus { outline: 2px solid var(--am-gold-light, #c9a227); outline-offset: -2px; }
@media (max-width: 600px) {
    .tv-composer-row textarea { font-size: 16px; }
    .tv-msg-action { min-height: 32px; }
}

/* ---- Phase 5B part 2: solved threads, tags, edit history, mobile polish ---- */
.tv-state.solved { color: #bfe3a6; border-color: #8fbf6a; }
.tv-tag { font-family: var(--font-body); font-size: 0.58rem; text-transform: uppercase; letter-spacing: 1px; padding: 2px 8px; color: #fff; border: 1px solid var(--tag-color, var(--mc-accent)); background: color-mix(in srgb, var(--tag-color, var(--mc-accent)) 35%, transparent); }
.tv-solved-note { margin: 4px 0 10px 0; padding: 8px 12px; font-family: var(--font-body); font-size: 0.8rem; color: var(--mc-text); background: rgba(110, 160, 80, 0.14); border-left: 4px solid #7aa856; }
.tv-solved-note.tv-solved-hint { background: rgba(176, 141, 85, 0.1); border-left-color: var(--am-gold-light); }
.tv-solved-mark { font-family: var(--font-display); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: #8fbf6a; margin-right: 6px; }
.tv-solved-jump { background: none; border: none; padding: 0; margin-left: 4px; font: inherit; font-weight: 700; color: var(--am-gold-bright); cursor: pointer; }
.tv-solved-jump:hover { text-decoration: underline; }
.tv-message.is-answer { background: rgba(110, 160, 80, 0.09); box-shadow: -4px 0 0 #7aa856; padding-left: 8px; margin-left: -8px; }
.tv-answer-tag { font-family: var(--font-display); font-size: 0.52rem; text-transform: uppercase; letter-spacing: 1px; padding: 1px 6px; color: #fff; background: #5f8f3e; }
.tv-msg-action-answer { color: #8fbf6a; }
button.tv-edited { background: none; border: none; padding: 0; font-family: inherit; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
button.tv-edited:hover { color: var(--am-gold-bright); }
.tv-history { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.tv-history-item { border: 2px solid var(--mc-black); background: var(--mc-well); padding: 0; }
.tv-history-item > summary { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 8px 10px; cursor: pointer; font-family: var(--font-body); font-size: 0.78rem; color: var(--mc-text); }
.tv-history-item > summary span { color: var(--mc-faint); font-size: 0.72rem; }
.tv-history-item > summary .tv-history-reason { color: var(--am-gold-bright); }
.tv-history-title { padding: 0 12px; font-family: var(--font-display); font-size: 0.9rem; color: var(--mc-text); }
.tv-history-body { padding: 6px 12px 10px 12px; }

/* Smoother open and close; on phones the panel slides up from the bottom. */
@keyframes tvPanelIn { from { opacity: 0; transform: translateY(14px) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes tvSheetIn { from { transform: translateY(100%); } to { transform: none; } }
.thread-view-overlay .thread-view { animation: tvPanelIn 0.18s ease-out; }
.thread-view-overlay.is-closing { animation: none; opacity: 0; transition: opacity 0.16s ease; }
.thread-view-overlay.is-closing .thread-view { transform: translateY(14px); transition: transform 0.16s ease; }
@media (max-width: 800px) {
    .thread-view-overlay .thread-view { animation: tvSheetIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); height: 100dvh; }
    .thread-view-overlay.is-closing .thread-view { transform: translateY(100%); transition: transform 0.18s ease-in; }
    /* The composer stays above the keyboard and the phone's home bar. */
    .thread-view-composer { position: sticky; bottom: 0; padding-bottom: max(14px, env(safe-area-inset-bottom)); background: var(--ore-card-bg); }
    .tv-tag { font-size: 0.54rem; }
}
@media (prefers-reduced-motion: reduce) {
    .thread-view-overlay .thread-view { animation: none; }
}
