/* ── Design tokens ───────────────────────────────────────────── */
:root {
    --c-primary:        #f52f6e;
    --c-primary-light:  rgba(245, 47, 110, 0.08);
    --c-primary-hover:  rgba(245, 47, 110, 0.15);
    --c-text:           #2b2b2b;
    --c-text-muted:     #7a7a7a;
    --c-bg:             #f6f7f9;
    --c-bg-reply:       #f2f3f5;
    --c-white:          #ffffff;
    --c-border:         #e4e6ea;
    --radius-sm:        8px;
    --radius-md:        12px;
    --radius-lg:        18px;
    --shadow-card:      0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-hover:     0 4px 16px rgba(0, 0, 0, 0.10);
    --transition:       0.2s ease;
}

/* ── Comment textarea ─────────────────────────────────────────── */
#comment {
    padding: 12px 14px;
    background-color: var(--c-bg);
    color: var(--c-text);
    height: 46px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--c-border);
    transition: border-color var(--transition), box-shadow var(--transition);
    resize: none;
    font-size: 14px;
    line-height: 1.5;
}
#comment:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-light);
    outline: none;
    background: var(--c-white);
}

/* ── Post button ──────────────────────────────────────────────── */
.justify-last {
    width: 100%;
    justify-content: flex-end !important;
}
.justify-last .btn-danger-custom,
.justify-last.comment-btn-wrap .btn-danger-custom {
    width: auto;
    margin-top: 10px;
    padding: 8px 20px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    background: var(--c-primary);
    color: var(--c-white);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 3px 10px rgba(245, 47, 110, 0.3);
}
.justify-last .btn-danger-custom:hover {
    background: #d4265e;
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(245, 47, 110, 0.4);
}
.justify-last.comment-btn-wrap {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin-top: 8px;
}
.justify-last.comment-btn-wrap .btn-danger-custom {
    margin-top: 0;
}

/* ── Comment form loading overlay ──────────────────────────────── */
form.comment-post {
    position: relative;
}
form.comment-post.loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-md);
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: center;
}
form.comment-post.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    z-index: 6;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Comments block ───────────────────────────────────────────── */
div.comments-block {
    width: 100%;
    margin-top: 20px;
}

/* ── Avatar ───────────────────────────────────────────────────── */
.comment-user {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-bg);
}
.comment-user.justify-center {
    background: var(--c-primary-light);
    border: 2px solid var(--c-primary);
}
.comment-user.justify-center span.user-initial {
    font-size: 18px;
    font-weight: 700;
    color: var(--c-primary);
    line-height: 1;
}
.comment-user img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Comment card ─────────────────────────────────────────────── */
/*
 * IMPORTANT: flex-wrap MUST be wrap.
 * The JS appends reply .comment-item.reply nodes directly inside the parent
 * .comment-item, making them a 3rd flex child. With wrap they go on their
 * own row (width:100%); without wrap they squeeze the text to single chars.
 */
.comment-item {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    background: var(--c-white);
    border: 1px solid var(--c-border);
    box-shadow: var(--shadow-card);
    align-items: flex-start;
    transition: box-shadow var(--transition);
}
.comment-item:hover {
    box-shadow: var(--shadow-hover);
}
.comment-area {
    flex: 1;
    min-width: 0;
    /* explicit fallback so the area never collapses when nested */
    width: calc(100% - 56px);
}

/* ── Comment content ──────────────────────────────────────────── */
h4.user-title {
    font-weight: 700;
    font-size: 15px;
    margin: 0 0 4px;
    color: var(--c-text);
}
p.comment-text {
    font-size: 14px;
    line-height: 1.6;
    color: #4a4a4a;
    margin: 0;
    word-break: break-word;
}

/* ── Reply actions row ────────────────────────────────────────── */
.comment-reply {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 10px;
}
.comment-reply.has-no-reply {
    justify-content: flex-end;
}
.comment-reply i {
    margin-right: 4px;
    font-size: 12px;
}

/* Reply link (post a reply) */
.comment-reply > a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text-muted);
    padding: 4px 12px;
    border-radius: 50px;
    border: 1.5px solid var(--c-border);
    background: transparent;
    text-decoration: none;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.comment-reply > a:hover {
    color: var(--c-primary);
    border-color: var(--c-primary);
    background: var(--c-primary-light);
}

/* ── Reply count badge / toggle ───────────────────────────────── */
.reply-heading {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text-muted);
    background: var(--c-bg);
    border: 1.5px solid var(--c-border);
    border-radius: 50px;
    padding: 4px 12px;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
    user-select: none;
}
.reply-heading::before {
    content: "\f086";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 11px;
    color: var(--c-primary);
}
.reply-heading:hover {
    color: var(--c-primary);
    border-color: var(--c-primary);
    background: var(--c-primary-light);
}
.reply-heading.active {
    color: var(--c-primary);
    border-color: var(--c-primary);
    background: var(--c-primary-light);
}

/* ── Nested reply items ───────────────────────────────────────── */
/*
 * Replies are appended by JS directly inside the parent .comment-item flex
 * container. width:100% pushes them onto their own flex row.
 * No horizontal margin — that would overflow the parent's inner width.
 * The left border provides the visual thread/indent cue instead.
 */
.comment-item.reply {
    width: 100%;             /* own row inside parent flex */
    flex-wrap: wrap;
    background: var(--c-bg-reply);
    border: none;
    border-left: 3px solid var(--c-primary);
    box-shadow: none;
    margin-top: 8px;
    padding: 10px 12px 10px 14px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    position: relative;
}
.comment-item.reply:hover {
    background: #edeef1;
    box-shadow: none;
}
.comment-item.reply .comment-user {
    width: 34px;
    height: 34px;
}
.comment-item.reply .comment-user.justify-center span.user-initial {
    font-size: 14px;
}
.comment-item.reply .comment-area {
    flex: 1;
    min-width: 0;
    width: calc(100% - 46px);
}
.comment-item.reply h4.user-title {
    font-size: 13px;
}
.comment-item.reply p.comment-text {
    font-size: 13px;
}
/* Remove the old small horizontal connector line */
.comment-item.reply::after {
    display: none;
}

/* ── Main comment block (pinned bottom in gallery) ────────────── */
.comment-block.main-comment-block {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: calc(100% - 50px);
    z-index: 55;
    transform: translateX(-50%);
}

/* ── Inline reply form ────────────────────────────────────────── */
.comment-reply-wrapper {
    margin-top: 12px;
    width: 100%;
    position: relative;
    background: var(--c-white);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    box-shadow: var(--shadow-card);
}
.input-wrapper.reply-input-wrapper {
    margin-top: 0;
}
.form-group.justify-last.reply-submit {
    display: inline-flex;
    position: absolute;
    right: 8px;
    top: 10px;
    width: auto;
}
#comment-reply-wrapper .form-group {
    margin-bottom: 0;
}
#comment-reply-wrapper .form-group i,
#comment-reply-wrapper .form-group button {
    margin: 0;
}

/* Reply form close button */
.reply-close {
    position: absolute;
    background: transparent;
    height: 20px;
    width: 20px;
    z-index: 5;
    right: 8px;
    top: 8px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition);
}
.reply-close:hover {
    opacity: 1;
}
.reply-close::before,
.reply-close::after {
    content: '';
    display: inline-block;
    height: 100%;
    width: 2px;
    background: var(--c-primary);
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 2px;
}
.reply-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.reply-close::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/* Reply form loading state */
div#comment-reply-wrapper.loading {
    position: relative;
}
div#comment-reply-wrapper.loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-md);
    z-index: 5;
}
div#comment-reply-wrapper.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    z-index: 6;
}

/* ── Gallery comments block loading state ──────────────────────── */
.gallery-comments-block.loading {
    position: relative;
    min-height: 60px;
}
.gallery-comments-block.loading::after {
    content: "";
    position: absolute;
    top: 20px;
    left: 50%;
    width: 28px;
    height: 28px;
    margin-left: -14px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ── Info / login popup ────────────────────────────────────────── */
.info-pop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 55555;
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.info-content {
    width: 420px;
    max-width: calc(100vw - 32px);
    background: var(--c-white);
    color: var(--c-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 36px 32px 28px;
    position: relative;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
p.info-message {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--c-text);
    margin: 0 0 8px;
}
a.info-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 40px;
    background: var(--c-primary);
    color: var(--c-white);
    border-radius: 50px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    transition: background var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 14px rgba(245, 47, 110, 0.35);
}
a.info-btn:hover {
    background: #d4265e;
    box-shadow: 0 6px 18px rgba(245, 47, 110, 0.45);
}
.close-info {
    position: absolute;
    height: 28px;
    width: 28px;
    top: 14px;
    right: 14px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity var(--transition);
}
.close-info:hover { opacity: 1; }
.close-info::before,
.close-info::after {
    content: '';
    display: inline-block;
    height: 100%;
    width: 2px;
    background: var(--c-text);
    position: absolute;
    top: 50%;
    left: 50%;
}
.close-info::before { transform: translate(-50%, -50%) rotate(45deg); }
.close-info::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/* ── Section headings ─────────────────────────────────────────── */
h2.primary-heading.blog {
    text-align: left;
}
/* ── Gallery panel overrides ──────────────────────────────────── */
.gallery-comment h2.primary-heading {
    margin-bottom: 8px;
    font-size: 18px;
}
.gallery-comment .comment-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    gap: 8px;
}
.gallery-comment .comment-user {
    width: 32px;
    height: 32px;
    margin-top: 2px;
}
.gallery-comment .comment-user.justify-center span.user-initial {
    font-size: 13px;
}
.gallery-comment .comment-area {
    width: calc(100% - 40px);
}
.gallery-comment h4.user-title {
    font-size: 13px;
    margin-bottom: 3px;
}
.gallery-comment p.comment-text {
    font-size: 13px;
}
.gallery-comment .comment-reply {
    margin-top: 6px;
}
.gallery-comment .reply-heading {
    font-size: 11px;
    padding: 3px 10px;
}
.gallery-comment .reply-heading.active {
    color: var(--c-primary);
}
.gallery-comment .comment-item.reply {
    margin-left: 0;       /* no horizontal margin — left border is the indent */
    padding: 8px 10px 8px 12px;
}
.gallery-comment .comment-item.reply .comment-user {
    width: 26px;
    height: 26px;
}
.gallery-comment .comment-item.reply .comment-area {
    flex: 1;
    min-width: 0;
    width: calc(100% - 38px);
}
.gallery-comment .comments-block {
    overflow-y: auto;
    max-height: calc(100% - 65px);
    margin-bottom: 110px;
    padding-right: 4px;
}
/* Custom scrollbar for gallery panel */
.gallery-comment .comments-block::-webkit-scrollbar {
    width: 4px;
}
.gallery-comment .comments-block::-webkit-scrollbar-track {
    background: transparent;
}
.gallery-comment .comments-block::-webkit-scrollbar-thumb {
    background: var(--c-border);
    border-radius: 4px;
}
.gallery-comment .comments-block::-webkit-scrollbar-thumb:hover {
    background: var(--c-primary);
}
