/* ===== Comment Type Selector ===== */
.menu-item:hover:before {
    content: '';
    top:0;left:0;
    position:absolute;
    background:transparent;
    width:100%;
    height:100%;
}

#comment-type-selector.menu-force-closed:hover > menu,
#ks-modal-comment-type-selector.menu-force-closed:hover > menu {
    pointer-events: none;
}

#comment-type-selector.menu-force-closed:hover > menu > menuitem,
#ks-modal-comment-type-selector.menu-force-closed:hover > menu > menuitem {
    opacity: 0;
    transform: translateY(150%);
}

nav > menu > menuitem > a + menu:after {
    content: '';
    position: absolute;
    border: 10px solid transparent;
    border-top: 10px solid white;
}

/* ===== Comment section wrapper ===== */
.ks-comments {
    background-color: #ffffff;
}

.ks-comments h2 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.ks-comments p {
    margin-bottom: 0.75rem;
}

/* ===== Comment bubble ===== */
comment-bubble {
    border: 1px solid rgba(0, 0, 0, 0.48);
    border-radius: 48px;
    padding: 12px 48px !important;
    display: flex;
    margin: 0 2.5rem 0 1.3rem;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

comment-bubble:hover {
    background-color: rgba(11, 94, 215, 0.04);
}

/* ===== Form controls ===== */
.ks-comment-form .form-label,
.ks-reply-form .form-label {
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.ks-comment-form .form-control,
.ks-reply-form .form-control {
    border-radius: 0.375rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    font-size: 0.95rem;
}

.ks-comment-form .form-control:focus,
.ks-reply-form .form-control:focus {
    border-color: rgba(0, 123, 255, 0.7);
    outline: 0;
    box-shadow: 0 0 0 0.15rem rgba(0, 123, 255, 0.18);
}

.ks-comment-form textarea.form-control,
.ks-reply-form textarea.form-control {
    border-radius: 1rem !important;
}

.ks-form-control {
    margin-top: 60px !important;
}

.ks-comment-form textarea.form-control {
    resize: vertical;
    min-height: 120px;
    height: auto;
    overflow-y: hidden;
}

.ks-reply-form textarea.form-control {
    resize: vertical;
    min-height: 60px;
    height: auto;
    overflow-y: hidden;
}

.ks-comment-form .form-text {
    font-size: 0.8rem;
}

/* ===== Shared comment action buttons ===== */
.ks-comment-form button.btn:not(.nav-btn),
.ks-reply-form button.btn,
.ks-comment-like,
.ks-reply-like,
.ks-comment-reply-toggle,
.ks-share .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
    line-height: 1;
    border: 0 solid transparent;
    background-color: #F7F7F7;
    color: rgba(0, 0, 0, 0.7);
    cursor: pointer;
    transition:
        background-color 120ms ease,
        color 120ms ease,
        transform 80ms ease;
    outline: none;
    box-shadow: none;
    text-decoration: none;
}

.ks-comment-form button.btn:not(.nav-btn):hover,
.ks-reply-form button.btn:hover,
.ks-comment-like:hover,
.ks-reply-like:hover,
.ks-comment-reply-toggle:hover,
.ks-share .btn:hover {
    background-color: #F3F3F3;
    border-color: transparent;
    color: rgba(0, 0, 0, 0.7);
    outline: none;
    box-shadow: none;
    text-decoration: none;
}

.ks-comment-form button.btn:not(.nav-btn):focus,
.ks-comment-form button.btn:not(.nav-btn):focus-visible,
.ks-comment-form button.btn:not(.nav-btn):active,
.ks-comment-form button.btn:not(.nav-btn).active,
.ks-comment-form button.btn:not(.nav-btn):active:focus,
.ks-comment-form button.btn:not(.nav-btn):not(:disabled):not(.disabled):active,
.ks-reply-form button.btn:focus,
.ks-reply-form button.btn:focus-visible,
.ks-reply-form button.btn:active,
.ks-reply-form button.btn.active,
.ks-reply-form button.btn:active:focus,
.ks-reply-form button.btn:not(:disabled):not(.disabled):active,
.ks-comment-like:focus,
.ks-comment-like:focus-visible,
.ks-comment-like:active,
.ks-comment-like.active,
.ks-comment-like:active:focus,
.ks-comment-like:not(:disabled):not(.disabled):active,
.ks-reply-like:focus,
.ks-reply-like:focus-visible,
.ks-reply-like:active,
.ks-reply-like.active,
.ks-reply-like:active:focus,
.ks-reply-like:not(:disabled):not(.disabled):active,
.ks-comment-reply-toggle:focus,
.ks-comment-reply-toggle:focus-visible,
.ks-comment-reply-toggle:active,
.ks-comment-reply-toggle.active,
.ks-comment-reply-toggle:active:focus,
.ks-comment-reply-toggle:not(:disabled):not(.disabled):active,
.ks-share .btn:focus,
.ks-share .btn:focus-visible,
.ks-share .btn:active,
.ks-share .btn.active,
.ks-share .btn:active:focus,
.ks-share .btn:not(:disabled):not(.disabled):active {
    outline: none;
    box-shadow: none;
    border-color: transparent;
}

.ks-comment-form button.btn:not(.nav-btn):active,
.ks-reply-form button.btn:active,
.ks-comment-like:active,
.ks-reply-like:active,
.ks-comment-reply-toggle:active,
.ks-share .btn:active {
    transform: translateY(1px);
}

/* ===== Share controls ===== */
.ks-share {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.ks-share span.me-2 {
    margin-right: 0.5rem;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.65);
}

/* ===== Comment thread ===== */
.ks-comment-thread {
    margin: 0 2.5rem 0 1.3rem;
}

.ks-comment-item,
.ks-reply-item {
    background: #ffffff;
    border-radius: 16px;
}

.ks-comment-item {
    position: relative;
    padding: 1rem 1rem 0.85rem;
    margin-bottom: 1rem;
}

.ks-reply-item {
    position: relative;
    padding: 0.85rem 0.9rem 0.85rem 1em;
    margin-bottom: 0.85rem;
}

.ks-comment-item:last-child {
    border-bottom: none;
}

.ks-comment-header,
.ks-reply-header {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
}

.ks-comment-header {
    margin-bottom: 0.5rem;
}

.ks-reply-header {
    margin-bottom: 0.35rem;
}

.ks-comment-author {
    font-weight: 400;
    font-size: 0.95rem;
    color: #665665;
}

.ks-comment-meta {
    font-size: 0.8rem;
    color: rgba(0, 0, 0, 0.55);
}

.ks-comment-body {
    line-height: 1.5;
    margin-bottom: 0.45rem;
}

.ks-reply-body {
    line-height: 1.5;
    margin-bottom: 0.35rem;
}

.ks-comment-course a {
    color: #0b5ed7;
    text-decoration: underline;
    word-break: break-all;
}

/* ===== Profile block ===== */
.ks-comment-profile {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    column-gap: 0.75rem;
    align-items: start;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.ks-comment-profile:hover {
    text-decoration: none;
    color: inherit;
}

.ks-modal-avatar {
    width: 58px;
    height: 58px;
    border-radius: 999px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.06);
}

.ks-comment-avatar-wrap {
    position: relative;
    display: block;
    width: 44px;
    height: 44px;
}

.ks-comment-avatar {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.06);
}

.ks-comment-profile-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.ks-comment-role {
    font-size: 0.82rem;
    color: rgba(0, 0, 0, 0.62);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ks-comment-knoc-link {
    font-size: 0.8rem;
    color: #000000;
    font-weight: 500;
}

/* comment content aligns under the text column, not under the image */
.ks-comment-body,
.ks-comment-web,
.ks-comment-item > .d-flex,
.ks-replies {
    margin-left: calc(44px + 0.75rem);
}

/* ===== Website link under comment ===== */
.ks-comment-web {
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
    color: rgba(0, 0, 0, 0.72);
    word-break: break-word;
}

.ks-comment-web a {
    color: #000000;
    font-weight: 400;
    text-decoration: underline;
}

/* ===== Reply / Like visuals ===== */
.ks-comment-reply-toggle[aria-expanded="true"] {
    background-color: rgba(11, 94, 215, 0.08);
    border-color: transparent;
    color: #0b5ed7;
}

.ks-comment-reply-icon {
    font-size: 0.9rem;
}

.ks-comment-like-icon {
    font-size: 0.9rem;
}

.ks-comment-like-count {
    font-variant-numeric: tabular-nums;
}

.ks-comment-like[data-liked="true"],
.ks-reply-like[data-liked="true"] {
    border-color: transparent;
}

.ks-comment-like[data-liked="true"] .thumb-icon,
.ks-reply-like[data-liked="true"] .thumb-icon {
    fill: #2563eb;
    stroke: #2563eb;
    color: #2563eb;
}

.ks-comment-reply-icon,
.ks-comment-like-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ks-comment-reply-icon .reply-icon,
.ks-comment-like-icon .thumb-icon {
    width: 18px;
    height: 18px;
    fill: transparent;
    stroke: #070707;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: fill 0.2s ease, stroke 0.2s ease, transform 0.15s ease;
}

.ks-comment-reply-icon:hover .reply-icon,
.ks-comment-like-icon:hover .thumb-icon {
    transform: scale(1.06);
}

.ks-comment-like-icon[data-liked="true"] .thumb-icon {
    fill: #2563eb;
    stroke: #2563eb;
}

/* ===== Replies ===== */
.ks-replies {
    /* line width */
    --ks-thread-stroke: 1px;
    --ks-thread-color: #d9d9d9;
    --ks-thread-radius: 10px;
    --ks-reply-indent: 1em;
    --ks-reply-avatar-size: 32px;
    --ks-parent-avatar-size: 44px;
    --ks-stem-left: calc(
        (var(--ks-parent-avatar-size) / 2)
        - var(--ks-parent-avatar-size)
        - 0.75rem
    );
    position: relative;
    margin-top: 0.75rem;
    /* Allow the stem / elbows to paint outside the box to the left */
    overflow: visible;
}

/* Ensure reply header content can wrap, so date doesn't sit on top of avatar */
.ks-reply-header .d-flex.align-items-start {
    flex-wrap: wrap;
}

/* In replies, place the date on its own line, aligned with reply text,
   instead of overlapping the avatar */
.ks-reply-header .ks-comment-meta {
    margin-left: 0.75rem;   /* push date to the right of the profile block */
    white-space: nowrap;    /* keep "x minutes ago" on one line */
}

/* ... existing code ... */

/*
 * ── Thread connector: vertical stem ──
 * Positioned inside .ks-replies with a negative left so it aligns
 * with the centre of the PARENT comment's avatar.
 * Height is set by JS via --ks-stem-height.
 */
.ks-thread-stem {
    position: absolute;
    top: 0;
    left: var(--ks-stem-left);
    width: var(--ks-thread-stroke);
    height: var(--ks-stem-height, 100%);
    background: var(--ks-thread-color);
    border-radius: 999px;
    pointer-events: none;
    z-index: 0;
}

/*
 * ── Thread connector: elbow arc per reply ──
 * Draws from the vertical stem (negative left, relative to .ks-reply-item)
 * arcing into the horizontal centre of the reply avatar.
 *
 * Horizontal geometry (from .ks-reply-item left edge):
 *   • Stem is at  --ks-stem-left  (negative, relative to .ks-replies)
 *     but .ks-reply-item sits directly inside .ks-replies-list inside
 *     .ks-replies, so same coordinate space.
 *   • Reply avatar centre is at:
 *       reply padding-left (1em)          ← .ks-reply-item padding
 *     + reply profile margin-left (1em)   ← .ks-reply-item .ks-comment-profile margin-left
 *     + reply-avatar-size / 2
 *   • Elbow width = avatar-centre-x − stem-left
 *
 * Vertical geometry (from .ks-reply-item top edge):
 *   • Reply avatar vertical centre is at:
 *       reply padding-top (0.85rem) + reply-avatar-size / 2
 *   • The arc box top = avatar-centre-y − radius
 */
.ks-reply-item::before {
    content: "";
    position: absolute;
    top: calc(
        0.85rem
        + (var(--ks-reply-avatar-size) / 2)
        - var(--ks-thread-radius)
    );
    left: var(--ks-stem-left);
    width: calc(
        var(--ks-reply-indent)
        + var(--ks-reply-indent)
        + (var(--ks-reply-avatar-size) / 2)
        - var(--ks-stem-left)
    );
    height: var(--ks-thread-radius);

    border-left: var(--ks-thread-stroke) solid var(--ks-thread-color);
    border-bottom: var(--ks-thread-stroke) solid var(--ks-thread-color);
    border-bottom-left-radius: var(--ks-thread-radius);
    border-right: none;
    border-top: none;
    background: transparent;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 0;
}

/* The JS-driven stem height handles stopping the line — no masking needed */
.ks-replies-list .ks-reply-item:last-child::after {
    content: none;
}

.ks-comment-item > .ks-comment-header .ks-comment-avatar-wrap::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    width: var(--ks-thread-stroke, 1px);
    height: calc(100% + 0.75rem);
    background: var(--ks-thread-color, #d9d9d9);
    transform: translateX(-50%);
    border-radius: 999px;
    pointer-events: none;
    z-index: 0;
}

.ks-comment-item .ks-replies:not(:has(.ks-replies-list .ks-reply-item)) + *,
.ks-comment-item .ks-comment-header .ks-comment-avatar-wrap:has(+ .ks-comment-profile-text)::before {
    /* intentionally left for selector grouping compatibility */
}

.ks-comment-item:not(:has(.ks-replies-list .ks-reply-item)) .ks-comment-header .ks-comment-avatar-wrap::before {
    content: none;
}


/* smaller REPLY avatar */
.ks-reply-item .ks-comment-profile {
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 0.65rem;
    margin-left: 1em;
}

.ks-reply-item .ks-comment-avatar-wrap {
    width: 32px;
    height: 32px;
}

.ks-reply-item .ks-comment-avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
}

.ks-like-avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    display: block;
    border-radius: 999px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.06);
}

.ks-reply-body,
.ks-reply-item {
    margin-left: 0;
}

.ks-comment-like {
    margin-left: calc(16px + 0.65rem);
}

.ks-reply-item-new {
    background-color: #e7f1ff;
    opacity: 0;
    transition: opacity 500ms ease;
}

.ks-reply-item-new.ks-reply-item-visible {
    opacity: 1;
}

.ks-reply-like {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
}

.ks-reply-form {
    margin-top: 0.85rem;
    margin-left: calc(44px + 0.75rem);
}

.ks-reply-form-wrap {
    margin-top: 0.75rem;
}

.ks-reply-form .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.ks-reply-form .form-control {
    font-size: 0.85rem;
    border-radius: 12px;
}

.ks-like-row {
    margin-left: 40px;
}

/* ===== Pagination ===== */
.ks-comment-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
}

.ks-comment-pagination-list {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ks-comment-page-btn {
    min-width: 2.5rem;
    border-radius: 999px;
    padding: 0.42rem 0.85rem;
    font-size: 0.88rem;
    line-height: 1.1;
    transition:
            background-color 120ms ease,
            border-color 120ms ease,
            color 120ms ease,
            box-shadow 120ms ease;
}

.ks-comment-page-btn:hover:not(:disabled) {

    color: #F5F5F5;
    box-shadow: 0 0 0 0.15rem rgba(11, 94, 215, 0.08);
}

.ks-comment-page-btn.active,
.ks-comment-page-btn[aria-current="page"] {
    background-color: #F7F7F7;
    color: #070707;
}

.ks-comment-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* comment delete buttons */
.ks-btn-anonymize {
    border-radius: 34px !important;
    width: 120px !important;
    height: 34px !important;
    background: #F7F7F7 !important;

    border-color: greenyellow !important;
    border-width: 2px !important;
}

.ks-btn-anonymize:hover {
    background-color: #e0a80064 !important;
}

.ks-btn-delete {
    border-radius: 34px !important;
    width: 120px !important;
    height: 34px !important;
    background: #F7F7F7 !important;

    border-color: crimson !important;
    border-width: 2px !important;
}

.ks-btn-delete:hover {
    color: crimson !important;
    background-color: #c8233364 !important;
}

.modal-header {
    border-bottom: 0 transparent !important;
}

/* ===== Mobile ===== */
@media (max-width: 767.98px) {
    .ks-comments {
        padding: 2.25rem 0;
    }

    .ks-comments h2 {
        font-size: 1.35rem;
    }

    .ks-share {
        margin-top: 0.75rem;
    }

    .ks-comment-thread {
        margin: 0;
    }

    .ks-comment-item,
    .ks-reply-item {
        border-radius: 14px;
    }

    .ks-comment-item {
        padding: 0.9rem;
    }

    .ks-reply-item {
        padding: 0.8rem 0.8rem 0.8rem 0;
    }

    .ks-comment-body {
        font-size: 1rem;
    }

    .ks-comment-profile {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .ks-comment-avatar-wrap {
        width: 44px;
        height: 44px;
    }

    .ks-comment-avatar {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    .ks-comment-body,
    .ks-comment-web,
    .ks-comment-item > .d-flex,
    .ks-replies {
        margin-left: calc(40px + 0.75rem);
    }

    .ks-replies {
        --ks-thread-radius: 8px;
        --ks-parent-avatar-size: 40px;
        --ks-reply-avatar-size: 28px;
        --ks-stem-left: calc(
            (var(--ks-parent-avatar-size) / 2)
            - var(--ks-parent-avatar-size)
            - 0.75rem
        );
    }

    .ks-reply-item::before {
        top: calc(
            0.8rem
            + (var(--ks-reply-avatar-size) / 2)
            - var(--ks-thread-radius)
        );
        left: var(--ks-stem-left);
        width: calc(
            var(--ks-reply-indent)
            + var(--ks-reply-indent)
            + (var(--ks-reply-avatar-size) / 2)
            - var(--ks-stem-left)
        );
    }

    .ks-comment-item .ks-comment-header .ks-comment-avatar-wrap::before {
        height: calc(100% + 0.75rem);
    }

    .ks-comment-item:not(:has(.ks-replies-list .ks-reply-item)) .ks-comment-header .ks-comment-avatar-wrap::before {
        content: none;
    }

    .ks-reply-item .ks-comment-profile {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .ks-reply-item .ks-comment-avatar-wrap {
        width: 36px;
        height: 36px;
    }

    .ks-reply-item .ks-comment-avatar {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .ks-reply-body,
    .ks-reply-item > .ks-comment-like {
        margin-left: calc(1em + 28px + 0.65rem);
    }

    .ks-comment-pagination-list {
        gap: 0.4rem;
    }

    .ks-comment-page-btn {
        min-width: 2.2rem;
        padding: 0.4rem 0.7rem;
        font-size: 0.82rem;
    }

    comment-bubble {
        margin: 0;
        padding: 12px 20px;
    }
}