/* Comment section styles — toggle, form, list, and tween animations. */

/* ── Toggle header ───────────────────────────────────────────── */
.comment-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 18px 0;
    margin-top: 56px;
    background: none;
    border: none;
    border-top: 1px solid var(--color-rule);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    letter-spacing: 0.03em;
    text-align: left;
    transition: color 0.2s ease;
}

.comment-toggle:hover {
    color: var(--color-text);
}

.comment-toggle-chevron {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.comment-toggle.is-open .comment-toggle-chevron {
    transform: rotate(45deg);
}

/* ── Collapsible container ───────────────────────────────────── */
.comment-section {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition:
        max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.comment-section.is-open {
    opacity: 1;
    /* max-height is set dynamically via JS for a clean tween */
}

/* ── Form ────────────────────────────────────────────────────── */
.comment-form {
    padding: 24px 0 32px;
}

.comment-form-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.comment-input-group {
    position: relative;
}

.comment-input {
    display: block;
    width: 100%;
    padding: 10px 0;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 400;
    color: var(--color-text);
    background: transparent;
    border: none;
    border-bottom: 1.5px solid var(--color-input-border);
    outline: none;
    transition: border-color 0.25s ease;
    line-height: 1.5;
}

.comment-input:focus {
    border-bottom-color: var(--color-text);
}

.comment-input::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.7;
    font-weight: 400;
}

.comment-textarea {
    resize: vertical;
    min-height: 72px;
    max-height: 240px;
    font-family: var(--font-ui);
}

.comment-submit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--color-button-text);
    background: var(--color-button-bg);
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.comment-submit:hover {
    background: var(--color-button-hover);
}

.comment-submit:active {
    transform: scale(0.97);
}

.comment-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Pending notice ──────────────────────────────────────────── */
.comment-pending-notice {
    padding: 12px 16px;
    margin-bottom: 20px;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    background: var(--color-input-bg);
    border: 1px solid var(--color-rule);
    animation: comment-fade-in 0.4s ease;
}

/* ── Comment list ────────────────────────────────────────────── */
.comment-list {
    list-style: none;
    border-top: 1px solid var(--color-rule);
    margin-top: 8px;
}

.comment-item {
    padding: 20px 0;
    border-bottom: 1px solid var(--color-rule);
    animation: comment-fade-in 0.4s ease;
}

.comment-item-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
}

.comment-author {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: 0.01em;
}

.comment-time {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--color-text-secondary);
    letter-spacing: 0.02em;
}

.comment-body {
    font-family: var(--font-post);
    font-size: 1rem;
    font-weight: 300;
    line-height: 1.65;
    color: var(--color-text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.comment-empty {
    padding: 28px 0;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    text-align: center;
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes comment-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 720px) {
    .comment-toggle {
        margin-top: 40px;
        font-size: 0.78rem;
    }

    .comment-form {
        padding: 18px 0 24px;
    }

    .comment-input {
        font-size: 0.88rem;
    }
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .comment-section {
        transition: none;
    }

    .comment-toggle-chevron {
        transition: none;
    }

    .comment-item,
    .comment-pending-notice {
        animation: none;
    }
}
