/* ==========================================================================
   gists.css — listing, viewer and editor for code snippets (pages/gists.php).
   Code block styling itself is shared with rich-content.css via the .rc/.rc-code
   classes, so a gist and a fenced block in a forum post look identical.
   ========================================================================== */

.gist-page {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 18px 64px;
}

/* ---- Header -------------------------------------------------------------- */
.gist-head {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.gist-head-text { flex: 1 1 260px; min-width: 0; }
.gist-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0;
    font-family: var(--font-display, inherit);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary, #f8fafc);
}
.gist-title a { color: var(--accent, #3b82f6); text-decoration: none; }
.gist-title a:hover { text-decoration: underline; }
.gist-title i { color: var(--text-secondary, #94a3b8); }
.gist-name { font-family: var(--font-mono, ui-monospace, monospace); font-size: 19px; }
.gist-sep { color: var(--text-tertiary, #64748b); font-weight: 400; }
.gist-meta { font-size: 12.5px; color: var(--text-tertiary, #64748b); }
.gist-meta a { color: var(--accent, #3b82f6); }
.gist-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gist-actions .is-starred i { color: var(--warning, #f59e0b); }
.gist-description {
    margin: 0 0 16px;
    font-size: 15px;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.6;
}
.gist-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: var(--radius-full, 999px);
}
.gist-badge.secret {
    color: var(--warning, #f59e0b);
    background: var(--warning-soft, rgba(245, 158, 11, 0.14));
    border: 1px solid rgba(245, 158, 11, 0.35);
}

/* ---- Search -------------------------------------------------------------- */
.gist-search { position: relative; margin-bottom: 18px; }
.gist-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary, #64748b);
    pointer-events: none;
}
.gist-search .form-input { padding-left: 38px; width: 100%; }

/* ---- Listing ------------------------------------------------------------- */
.gist-list { display: flex; flex-direction: column; gap: 18px; }
.gist-card {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-md, 16px);
    background: var(--surface-1, rgba(15, 23, 42, 0.65));
    padding: 14px 16px;
    transition: border-color .16s ease, transform .16s ease;
}
.gist-card:hover { border-color: rgba(59, 130, 246, 0.45); transform: translateY(-1px); }
.gist-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.gist-card-title { flex: 1; min-width: 0; }
.gist-card-title a { color: var(--text-primary, #f8fafc); text-decoration: none; }
.gist-card-title a:hover strong { color: var(--accent, #3b82f6); }
.gist-card-title strong { font-family: var(--font-mono, ui-monospace, monospace); font-size: 14.5px; }
.gist-card-author { color: var(--text-secondary, #94a3b8); }
.gist-card-stats { display: flex; gap: 12px; font-size: 12.5px; color: var(--text-tertiary, #64748b); white-space: nowrap; }
.gist-card-desc { margin: 0 0 10px; font-size: 14px; color: var(--text-secondary, #94a3b8); }
/* Card previews are excerpts: cap the height so one long snippet cannot own the page. */
.gist-card .rc-code-pre { max-height: 260px; overflow: auto; }

/* ---- Editor -------------------------------------------------------------- */
.gist-form { display: flex; flex-direction: column; gap: 14px; }
.gist-desc { width: 100%; }
.gist-file {
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: var(--radius-md, 16px);
    overflow: hidden;
    background: var(--surface-1, rgba(15, 23, 42, 0.65));
}
.gist-file:focus-within { border-color: var(--accent, #3b82f6); box-shadow: 0 0 0 3px var(--accent-ring, rgba(59,130,246,.35)); }
.gist-file-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: rgba(148, 163, 184, 0.07);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.gist-filename {
    flex: 1 1 240px;
    min-width: 0;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 13.5px;
    color: var(--text-primary, #f8fafc);
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 7px;
    padding: 6px 10px;
    outline: none;
}
.gist-filename:focus { border-color: var(--accent, #3b82f6); }
.gist-file-hint { font-size: 11.5px; color: var(--text-tertiary, #64748b); }
.gist-code-input {
    display: block;
    width: 100%;
    min-height: 380px;
    padding: 14px 16px;
    font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-primary, #f8fafc);
    background: transparent;
    border: 0;
    outline: none;
    resize: vertical;
    tab-size: 4;
    white-space: pre;
    overflow-x: auto;
}
.gist-form-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.gist-form-actions { display: flex; gap: 8px; }

/* ---- Comments ------------------------------------------------------------ */
.gist-comments { margin-top: 32px; }
.gist-section-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    color: var(--text-primary, #f8fafc);
}
.gist-comment { display: flex; gap: 12px; margin-bottom: 16px; }
.gist-comment-body {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm, 10px);
    background: var(--surface-1, rgba(15, 23, 42, 0.65));
    overflow: hidden;
}
.gist-comment-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 13px;
    font-size: 13px;
    background: rgba(148, 163, 184, 0.07);
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.gist-comment-del {
    margin-left: auto;
    background: none;
    border: 0;
    color: var(--text-tertiary, #64748b);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 5px;
}
.gist-comment-del:hover { color: var(--danger, #f43f5e); background: var(--danger-soft, rgba(244,63,94,.14)); }
.gist-comment-body .rc { padding: 12px 13px; }
.gist-comment-form { margin-top: 18px; }
.gist-comment-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

/* ---- Empty state & pager ------------------------------------------------- */
.gist-empty {
    text-align: center;
    padding: 70px 20px;
    color: var(--text-secondary, #94a3b8);
}
.gist-empty i { font-size: 52px; color: var(--text-quaternary, #475569); margin-bottom: 16px; display: block; }
.gist-empty h2 { margin: 0 0 8px; font-size: 20px; color: var(--text-primary, #f8fafc); }
.gist-empty p { margin: 0 0 18px; }
.gist-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 26px;
}

@media (max-width: 640px) {
    .gist-page { padding: 16px 12px 48px; }
    .gist-title { font-size: 18px; }
    .gist-name { font-size: 16px; }
    .gist-actions { width: 100%; }
    .gist-code-input { min-height: 280px; font-size: 12.5px; }
}

[data-theme="light"] .gist-card,
[data-theme="light"] .gist-file,
[data-theme="light"] .gist-comment-body { background: #fff; border-color: rgba(15, 23, 42, 0.12); }
