/* =============================================================================
   The Hacked Edge — Rules comment widget
   Uses the site's existing theme tokens (--color-*, --font-*) from style.css.
   ============================================================================= */

/* --- The toggle beside each section heading --------------------------------- */
.he-comment-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    margin-left: 0.6em;
    padding: 0.15em 0.55em;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1;
    vertical-align: middle;
    color: var(--color-text-muted);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}
.he-comment-toggle:hover {
    color: var(--color-text);
    border-color: var(--color-accent-dim);
    background: var(--color-bg-card-hover);
}
.he-comment-toggle.is-open {
    color: var(--color-text);
    border-color: var(--color-accent);
}
.he-comment-toggle .he-ct-icon { font-size: 0.85em; }
.he-comment-toggle .he-ct-count {
    min-width: 1.1em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.he-comment-toggle.has-comments {
    color: var(--color-text);
    border-color: var(--color-accent-dim);
}

/* --- The thread panel that expands under a heading -------------------------- */
.he-thread {
    margin: 1rem 0 2rem;
    padding: 1.25rem 1.4rem 1.4rem;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent);
    border-radius: 6px;
    font-family: var(--font-body);
    animation: he-thread-in 0.16s ease;
}
@keyframes he-thread-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.he-thread[hidden] { display: none; }

.he-thread-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border-subtle);
}
.he-thread-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-accent);
}
.he-thread-close {
    background: none;
    border: none;
    color: var(--color-text-dim);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem;
}
.he-thread-close:hover { color: var(--color-text); }

/* --- Individual comments ---------------------------------------------------- */
.he-comment-list { display: flex; flex-direction: column; gap: 1rem; }

.he-empty {
    color: var(--color-text-dim);
    font-size: 0.9rem;
    font-style: italic;
    padding: 0.25rem 0 0.5rem;
}

.he-comment { display: flex; gap: 0.75rem; }
.he-comment.is-hidden { opacity: 0.55; }

.he-avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    overflow: hidden;
}
.he-comment-main { flex: 1 1 auto; min-width: 0; }
.he-comment-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}
.he-comment-author { font-weight: 600; color: var(--color-text); font-size: 0.9rem; }
.he-badge {
    font-size: 0.62rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.1em 0.45em;
    border-radius: 3px;
    background: var(--color-accent-dim);
    color: #fff;
    font-weight: 600;
}
.he-badge.hidden-tag { background: var(--color-text-dim); color: var(--color-bg); }
.he-comment-time { font-size: 0.75rem; color: var(--color-text-dim); }
.he-comment-body {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.he-comment-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.35rem;
}
.he-comment-actions button {
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--color-text-dim);
    cursor: pointer;
}
.he-comment-actions button:hover { color: var(--color-accent-hover); }

/* --- The composer ----------------------------------------------------------- */
.he-composer { margin-top: 1.25rem; }
.he-composer textarea {
    width: 100%;
    min-height: 4.5rem;
    resize: vertical;
    padding: 0.7rem 0.85rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg-dark);
    border: 1px solid var(--color-border);
    border-radius: 5px;
}
.he-composer textarea:focus {
    outline: none;
    border-color: var(--color-accent);
}
.he-composer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.6rem;
}
.he-composer-hint { font-size: 0.75rem; color: var(--color-text-dim); }

/* --- Buttons ---------------------------------------------------------------- */
.he-btn {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.he-btn-primary { background: var(--color-accent); color: #fff; }
.he-btn-primary:hover { background: var(--color-accent-hover); }
.he-btn-primary:disabled { opacity: 0.5; cursor: default; }
.he-btn-ghost {
    background: var(--color-bg-card);
    border-color: var(--color-border);
    color: var(--color-text);
}
.he-btn-ghost:hover { border-color: var(--color-accent-dim); background: var(--color-bg-card-hover); }

/* Google sign-in button */
.he-signin {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}
.he-signin svg { width: 18px; height: 18px; flex: 0 0 auto; }

.he-signed-in-as {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--color-text-dim);
}
.he-signed-in-as button {
    background: none; border: none; padding: 0;
    color: var(--color-text-dim); font-size: 0.78rem;
    cursor: pointer; text-decoration: underline;
}
.he-signed-in-as button:hover { color: var(--color-text); }

.he-error {
    color: var(--color-accent-hover);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* --- Replies (nested under a top-level comment) ----------------------------- */
.he-replies {
    margin-top: 0.9rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.he-replies:empty { display: none; }
.he-comment.is-reply .he-avatar { width: 26px; height: 26px; font-size: 0.72rem; }
.he-comment.is-reply .he-comment-author { font-size: 0.85rem; }

/* Reply composer mounted under a comment */
.he-reply-mount:empty { display: none; }
.he-composer-reply {
    margin-top: 0.9rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--color-accent-dim);
}
.he-composer-reply textarea { min-height: 3.5rem; }

.he-composer-btns { display: inline-flex; gap: 0.5rem; }

/* "Email me when someone replies" opt-in */
.he-notify {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}
.he-notify input {
    width: 15px;
    height: 15px;
    accent-color: var(--color-accent);
    cursor: pointer;
}
