/*
 | Comment threads and the post card (.th-*). Group posts
 | (livewire/group-discussion) and the lesson / course / tip discussions
 | (livewire/discussion) share the comment look: a bubble, one quiet meta
 | line under it (time · Like · Reply · …, the reaction count at the end),
 | replies one level in, under a rail. Behaviour: public/js/thread.js.
 | Loaded with partials/social-assets. Logical properties throughout, so
 | Arabic mirrors without overrides.
 */
.th-post, .th-comments, .th-comment, .th-thread, .discussion {
    --th-ink: #25236b;
    --th-text: #2a2945;
    --th-muted: #6b6a80;
    --th-action: #4a4964;
    --th-accent: #3f3bb0;
    --th-accent-soft: #eeeefb;
    --th-bubble: #f4f4f9;
    --th-line: #e8e7ef;
    --th-hair: #eeedf4;
    --th-hover: #f3f3f8;
    --th-danger: #b42318;
    --th-ok: #1f7a4d;
    --th-ok-soft: #e7f5ee;
    --th-off: #c9c8d8;
}

/* ---------- the post card ---------- */
.th-post { list-style: none; }
.th-post__card {
    position: relative;
    border: 1px solid var(--th-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(27, 26, 58, .04), 0 8px 24px -12px rgba(27, 26, 58, .08);
}
.th-post.is-pinned .th-post__card { border-color: #c9c6f2; }
.th-post.is-announcement .th-post__card { border-color: #f2c94c; }
.th-post.is-hidden .th-post__card { opacity: .75; border-style: dashed; }

.th-post__head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 0; }
.th-post__who { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.th-post__name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; color: var(--th-ink); font-size: 15px; font-weight: 700; line-height: 1.35; }
.th-post__sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--th-muted); font-size: 12.5px; line-height: 1.4; }
.th-post__flags { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }

.th-kind { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--th-accent-soft); color: var(--th-accent); font-size: 12px; font-weight: 600; line-height: 1.4; }
.th-kind i { font-size: 13px; line-height: 1; }
.th-kind--announcement { background: #fff4db; color: #8a5a00; }
.th-kind--question { background: #e6f2fb; color: #1d5f8f; }
.th-kind--share { background: var(--th-ok-soft); color: var(--th-ok); }

.th-badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; background: #e6e6fa; color: var(--th-accent); font-size: 11px; font-weight: 600; line-height: 1.5; }
.th-badge i { font-size: 12px; line-height: 1; }
.th-badge--mentor { background: #f2c94c; color: #1c1c6e; }
.th-badge--ok { background: var(--th-ok-soft); color: var(--th-ok); }

.th-follow {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    min-height: 36px; padding: 6px 14px;
    border: 1px solid #d9d8e6; border-radius: 999px; background: #fff;
    color: var(--th-ink); font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer;
}
.th-follow i { font-size: 14px; line-height: 1; }
.th-follow:hover { background: var(--th-hover); }
.th-follow.is-on { border-color: transparent; background: var(--th-accent-soft); color: var(--th-accent); }

.th-post__content { padding: 12px 16px 0; }
.th-post__title { margin: 0 0 8px; color: var(--th-ink); font-size: 18px; font-weight: 700; line-height: 1.4; }
.th-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.th-tag { padding: 3px 9px; border-radius: 6px; background: var(--th-accent-soft); color: var(--th-accent); font-size: 12px; font-weight: 500; }
.th-post__body-wrap { position: relative; }
.th-post__body { max-height: 240px; overflow: hidden; color: var(--th-text); font-size: 15px; line-height: 1.8; overflow-wrap: anywhere; }
.th-post__body.is-open { max-height: none; }
.th-post__body > :first-child { margin-top: 0; }
.th-post__body > :last-child { margin-bottom: 0; }
.th-post__body ul, .th-post__body ol { margin: 8px 0; padding-inline-start: 22px; }
.th-post__body ul { list-style: disc; }
.th-post__body ol { list-style: decimal; }
.th-post__body-wrap.is-clamped::after {
    content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 72px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff);
    pointer-events: none;
}
.th-more { margin-top: 6px; padding: 4px 0; border: 0; background: none; color: var(--th-accent); font-size: 14px; font-weight: 600; cursor: pointer; }
.th-more:hover { color: var(--th-ink); text-decoration: underline; }
.th-post__error { margin: 6px 16px 0; color: var(--th-danger); font-size: 13px; }

/* Reactions in the post: the summary row, then the action bar. */
.mgr--post { display: block; }
.mgr__stats { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 8px 16px 4px; color: var(--th-muted); font-size: 13px; }
.mgr__stats .mgr__sum { margin-inline-start: -4px; }
.th-stats__comments { margin-inline-start: auto; padding: 4px 0; border: 0; background: none; color: var(--th-muted); font-size: 13px; cursor: pointer; }
.th-stats__comments:hover { color: var(--th-ink); text-decoration: underline; }
.mgr__actions {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
    margin: 0 12px; padding: 4px 0;
    border-block: 1px solid var(--th-hair);
}
.mgr__cell { display: flex; position: relative; }
.mgr__cell .mgr__anchor { display: flex; flex: 1; }
.mgr--post .mgr__btn, .th-action {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent;
    color: var(--th-action); font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer;
}
.mgr--post .mgr__btn i, .th-action i { font-size: 19px; line-height: 1; }
.mgr--post .mgr__btn-icon { font-size: 17px; line-height: 1; }
.mgr--post .mgr__btn:hover, .th-action:hover, .th-action.is-open { background: var(--th-hover); }
.th-action.is-on { color: var(--th-accent); }
.th-action.is-off { color: var(--th-muted); cursor: default; font-weight: 500; }
.th-action.is-off:hover { background: none; }
.th-action:focus-visible, .mgr--post .mgr__btn:focus-visible { outline: 2px solid var(--th-accent); outline-offset: -2px; }
.mgr--post .mgr__bar { inset-inline-start: 0; }
.mgr--post > .mgr__error { display: block; margin: 4px 16px 0; }

/* Share popover */
.th-share { position: relative; display: flex; }
.th-share__pop {
    position: absolute; bottom: calc(100% + 8px); inset-inline-end: -40px; z-index: 40;
    display: flex; flex-direction: column; gap: 12px;
    width: min(340px, calc(100vw - 32px)); padding: 16px;
    border: 1px solid var(--th-line); border-radius: 16px; background: #fff;
    box-shadow: 0 20px 48px -12px rgba(27, 26, 58, .3);
}
.th-share__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--th-ink); font-size: 15px; }
.th-share__note { margin: -4px 0 0; color: var(--th-muted); font-size: 12.5px; line-height: 1.5; }
.th-share__link { display: flex; align-items: center; gap: 8px; padding: 4px; border: 1px solid var(--th-line); border-radius: 10px; background: #fafafc; }
.th-share__link input { flex: 1; min-width: 0; padding: 6px 8px; border: 0; background: none; color: var(--th-action); font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; outline: none; }
.th-share__error { margin: -4px 0 0; color: var(--th-danger); font-size: 12.5px; }
@media (max-width: 480px) {
    .th-share__pop { position: fixed; inset: auto 16px 16px; width: auto; z-index: 1100; }
}

/* Small shared controls */
.th-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
    min-height: 36px; padding: 0 14px; border: 0; border-radius: 8px;
    background: var(--th-ink); color: #fff; font-size: 13px; font-weight: 600; line-height: 1; cursor: pointer;
}
.th-btn:hover { background: #1b1a50; }
.th-btn:disabled { background: var(--th-off); cursor: not-allowed; }
.th-link { display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; border: 0; background: none; color: var(--th-accent); font-size: 13px; font-weight: 600; line-height: 1.3; cursor: pointer; }
.th-link i { font-size: 15px; line-height: 1; }
.th-link:hover { color: var(--th-ink); text-decoration: underline; }
.th-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--th-muted); cursor: pointer; }
.th-icon-btn i { font-size: 16px; line-height: 1; }
.th-icon-btn:hover { background: var(--th-hover); color: var(--th-ink); }

/* ---------- comments ---------- */
.th-comments { display: flex; flex-direction: column; gap: 14px; padding: 14px 16px 18px; }
.th-comments__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.th-comments__title { color: var(--th-ink); font-size: 14px; font-weight: 700; }
.th-comments__empty { margin: 0; padding: 4px 0; color: var(--th-muted); font-size: 13.5px; text-align: center; }
.th-sort { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--th-hover); }
.th-sort__opt { min-height: 30px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--th-muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.th-sort__opt.is-on { background: #fff; color: var(--th-ink); box-shadow: 0 1px 2px rgba(27, 26, 58, .08); }
.th-threads { display: flex; flex-direction: column; gap: 14px; }
.th-threads__more { align-self: flex-start; }
.th-thread { display: flex; flex-direction: column; gap: 10px; }

.th-comment { display: flex; align-items: flex-start; gap: 10px; }
.th-comment__main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
/* Group comments: one column as wide as the bubble row, so the meta line (and the
   reaction count at its end) stops at the bubble's edge, not the thread's. Editing
   takes the full width again. */
.th-comment__main:has(> .th-comment__row) { display: grid; grid-template-columns: minmax(0, max-content); align-content: start; }
.th-comment__main:has(> .th-edit:not([style*="none"]):not([x-cloak])) { grid-template-columns: minmax(0, 1fr); }
.th-bubble {
    align-self: flex-start; max-width: 100%;
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 14px 10px; border-radius: 14px; border-start-start-radius: 4px;
    background: var(--th-bubble);
}
.th-comment.is-answer .th-bubble { background: var(--th-ok-soft); box-shadow: inset 0 0 0 1px #b8e0c8; }
.th-bubble__who { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.th-bubble__name { color: var(--th-ink); font-size: 13.5px; font-weight: 700; line-height: 1.5; }
.th-bubble__text { margin: 0; color: var(--th-text); font-size: 14.5px; line-height: 1.65; white-space: pre-line; unicode-bidi: plaintext; overflow-wrap: anywhere; }
.th-edit { display: flex; flex-direction: column; gap: 6px; inline-size: 100%; margin: 0; }
.th-edit__hint { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 0; padding: 0 12px; color: var(--th-muted); font-size: 12px; }
.th-edit__hint .th-link { font-size: 12px; }

/* The meta line: time · Like · Reply · Edit · Delete … count chip at the end. */
.mgr--meta.th-meta, .th-meta {
    display: flex; align-items: center; flex-wrap: wrap; gap: 2px 14px;
    padding: 0 6px; color: var(--th-muted); font-size: 12.5px; line-height: 1.4;
}
.th-meta__time { white-space: nowrap; }
.th-meta__act { padding: 2px 0; border: 0; background: none; color: var(--th-action); font-size: 12.5px; font-weight: 600; line-height: 1.4; white-space: nowrap; cursor: pointer; }
.th-meta__act:hover { color: var(--th-ink); text-decoration: underline; }
.th-meta__act--danger:hover { color: var(--th-danger); }
.th-meta__note { color: var(--th-muted); }
.mgr--meta .mgr__anchor { display: inline-flex; }
.mgr--meta .mgr__btn { min-height: 0; padding: 2px 0; border-radius: 4px; color: var(--th-action); font-size: 12.5px; gap: 4px; }
.mgr--meta .mgr__btn:hover { background: none; color: var(--th-ink); text-decoration: underline; }
.mgr--meta .mgr__btn-icon { display: none; }
.mgr--meta .mgr__btn.is-on .mgr__btn-icon { display: inline-flex; font-size: 13px; }
.mgr--meta .mgr__sum {
    margin-inline-start: auto; min-height: 0; padding: 1px 8px 1px 4px;
    border: 1px solid var(--th-line); background: #fff; font-size: 12px; color: var(--th-action);
}
.mgr--meta .mgr__face { width: 18px; height: 18px; font-size: 11px; border-width: 1.5px; }
.mgr--meta .mgr__bar { bottom: calc(100% + 4px); }

/* Replies: one level in, under a rail centred on the 36px avatar above
   (17px + the 2px line + 27px, as in the design). */
.th-comment > .d-avatar, .discussion .d-comment > .d-avatar { width: 36px; height: 36px; font-size: 13px; flex: none; }
.th-replies {
    display: flex; flex-direction: column; gap: 12px;
    margin-inline-start: 17px; padding-inline-start: 27px;
    border-inline-start: 2px solid var(--th-hair);
}
.th-comment--reply > .d-avatar, .discussion .d-replies .d-comment > .d-avatar { width: 30px; height: 30px; font-size: 11.5px; }

/* The bubble and its ⋯ (Edit, Delete…). On a mouse the ⋯ shows on hover or
   focus, like Facebook; on touch it is always there. */
.th-comment__row { display: flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; }
.th-comment__row > .th-bubble { min-width: 0; }
.th-cmenu { position: relative; flex: none; }
.th-cmenu__btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    color: var(--th-muted); list-style: none; cursor: pointer;
}
.th-cmenu__btn::-webkit-details-marker { display: none; }
.th-cmenu__btn i { font-size: 18px; line-height: 1; }
.th-cmenu__btn:hover, .th-cmenu[open] .th-cmenu__btn { background: var(--th-hover); color: var(--th-ink); }
.th-cmenu__btn:focus-visible { outline: 2px solid var(--th-accent); outline-offset: 1px; }
@media (hover: hover) {
    .th-cmenu:not([open]) { opacity: 0; transition: opacity .12s ease; }
    .th-comment:hover .th-cmenu, .d-comment:hover .th-cmenu, .th-cmenu:focus-within { opacity: 1; }
}
.th-cmenu__list {
    position: absolute; top: calc(100% + 4px); inset-inline-end: 0; z-index: 30;
    display: flex; flex-direction: column; min-width: 172px; padding: 6px;
    border: 1px solid var(--th-line); border-radius: 12px; background: #fff;
    box-shadow: 0 16px 36px -12px rgba(27, 26, 58, .28);
}
.th-cmenu__item {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px;
    border: 0; border-radius: 8px; background: none;
    color: var(--th-ink); font-size: 13.5px; font-weight: 600; text-align: start; white-space: nowrap; cursor: pointer;
}
.th-cmenu__item i { font-size: 17px; line-height: 1; }
.th-cmenu__item:hover, .th-cmenu__item:focus-visible { background: var(--th-hover); outline: none; }
.th-cmenu__item.is-danger { color: var(--th-danger); }
.th-cmenu__item.is-danger:hover { background: #fdecea; }

/* ---------- the round composers ---------- */
.th-compose { display: flex; align-items: flex-start; gap: 10px; margin: 0; }
.th-compose__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.th-pill {
    display: flex; align-items: flex-end; gap: 6px;
    padding: 4px; padding-inline-start: 6px;
    border: 1px solid #d9d8e6; border-radius: 22px; background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.th-pill:focus-within, .th-pill.is-focus { border-color: #bdbbe8; box-shadow: 0 0 0 3px var(--th-accent-soft); }
.th-field {
    flex: 1; min-width: 0; display: block;
    padding: 7px 8px; border: 0; background: transparent; outline: none; resize: none;
    color: #1b1a3a; font: inherit; font-size: 14px; line-height: 1.55;
    unicode-bidi: plaintext;
}
.th-field::placeholder { color: #9a99ae; }
.th-send {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 36px; height: 36px; border: 0; border-radius: 50%;
    background: var(--th-ink); color: #fff; cursor: pointer;
    transition: background-color .15s ease, transform .1s ease;
}
.th-send i { font-size: 16px; line-height: 1; }
.th-send:hover { background: #1b1a50; }
.th-send:active { transform: scale(.94); }
.th-send:disabled { background: var(--th-off); cursor: not-allowed; transform: none; }
.th-send--sm { width: 32px; height: 32px; }
.th-send--sm i { font-size: 14px; }
.th-reply { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.th-reply__to { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; color: var(--th-muted); font-size: 12px; }
.th-reply__name { color: var(--th-accent); font-weight: 600; }
.th-reply__to .th-link { font-size: 12px; font-weight: 500; color: var(--th-muted); }

@media (min-width: 640px) {
    .th-post__head { padding: 20px 24px 0; }
    .th-post__flags { padding-inline: 24px; }
    .th-post__content { padding: 14px 24px 0; }
    .th-post__title { font-size: 20px; }
    .mgr__stats { padding-inline: 24px; }
    .mgr__actions { margin-inline: 16px; }
    .th-comments { padding: 16px 24px 20px; }
}
@media (max-width: 480px) {
    .mgr--meta.th-meta, .th-meta { gap: 2px 12px; padding: 0 4px; }
    .th-comment { gap: 8px; }
}
@media (max-width: 420px) {
    .mgr--post .mgr__btn span.mgr__btn-label, .th-action span { font-size: 13px; }
    .mgr--post .mgr__btn, .th-action { gap: 6px; padding: 0 4px; }
}
@media (prefers-reduced-motion: reduce) {
    .th-pill, .th-send { transition: none; }
}

/* ---------- lesson / course / tip discussions (livewire/discussion) ---------- */
.d-sortbar { margin-top: 20px; }
.d-sortbar .th-comments__title { color: var(--th-muted); font-weight: 600; font-size: 13px; }
.d-comment__bubble { gap: 4px; }
.d-comment__bubble .d-comment__meta { gap: 4px 6px; }
.d-comment__bubble .d-comment__author { font-size: 14px; }
.d-comment__bubble .d-comment__body { margin-top: 0; font-size: 14.5px; line-height: 1.65; }
.d-comment__bubble .d-comment__to { margin: 0; font-size: 12.5px; }
.d-comment--instructor .d-comment__bubble { background: #f0f0ff; box-shadow: inset 0 0 0 1px #dcdcfb; }
.d-comment--instructor .d-comment__bubble .d-comment__body { padding: 0; border: 0; border-radius: 0; background: none; }
.d-comment__actions.th-meta { margin-top: 4px; }
.d-comment__actions .d-comment__time, .d-comment__actions .d-comment__edited { font-size: 12.5px; }
.discussion .d-comment__main { display: flex; flex-direction: column; align-items: flex-start; }
.discussion .d-comment__main > .d-composer--edit { align-self: stretch; }
.discussion .d-thread { padding: 14px 0; }
.discussion .d-thread + .d-thread { border-top: 0; }
.discussion .d-replies { margin-inline-start: 17px; padding-inline-start: 27px; border-inline-start-color: var(--th-hair); }
.discussion .d-comment { gap: 10px; }

/* ---------- a shared group post's public page (mentorship/groups/post-shared) ---------- */
.gps { padding: 32px 16px 64px; background: #f4f4f8; }
.gps__inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.gps__eyebrow { display: flex; align-items: center; gap: 8px; margin: 0; color: #6b6a80; font-size: 14px; font-weight: 600; }
.gps__eyebrow i { font-size: 18px; line-height: 1; color: #3f3bb0; }
.gps__card {
    inline-size: 100%; aspect-ratio: 1200 / 630; overflow: hidden;
    border-radius: 16px; background: #16143a; container-type: inline-size;
    box-shadow: 0 1px 2px rgba(27, 26, 58, .06), 0 8px 24px rgba(27, 26, 58, .1);
}
.gps__card-scale { inline-size: 1200px; block-size: 630px; transform-origin: top left; transform: scale(.6); transform: scale(calc(100cqi / 1200px)); }
.gps__body { display: flex; flex-direction: column; gap: 14px; padding: 24px; border: 1px solid #e8e7ef; border-radius: 16px; background: #fff; }
.gps__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gps__lede { margin: 0; padding: 12px 14px; border-radius: 12px; background: #eeeefb; color: #2a2945; font-size: 14px; line-height: 1.6; }
.gps__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.gps__btn {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
    border: 1px solid #d9d8e6; border-radius: 10px; background: #fff; color: #25236b; font-size: 14px; font-weight: 600;
}
.gps__btn:hover { background: #f3f3f8; color: #25236b; text-decoration: none; }
.gps__btn--primary { border-color: #25236b; background: #25236b; color: #fff; }
.gps__btn--primary:hover { background: #1b1a50; color: #fff; }

/* Phones: a post header never collides. The badges wrap under the name, the
   mentor's role line truncates, Follow shrinks to its icon (label kept for
   screen readers and as a tooltip). */
@media (max-width: 575.98px) {
    .th-post__head { align-items: flex-start; gap: 10px; padding: 14px 14px 0; }
    .th-post__sub { flex-wrap: nowrap; min-width: 0; }
    .th-post__sub > span[dir='auto'] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .th-post__sub > time { flex: none; }
    .th-follow { width: 36px; padding: 0; justify-content: center; }
    .th-follow > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .th-post__content { padding: 10px 14px 0; }
    .th-post__title { font-size: 17px; }
}
