/**
 * Post feed: cards, reactions and comment threads.
 *
 * The palette stays the monochrome one from style.css — the only colour in a
 * card comes from the avatars and the reaction emoji themselves, so an active
 * reaction reads as "you picked this" through weight and fill rather than by
 * introducing a hue the rest of the product does not use.
 */

.kk-feed-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-anchor: none;
    padding: 20px 20px 60px;
    background: var(--color-section-alt);
}

.kk-feed-col {
    max-width: 680px;
    margin: 0 auto;
}

.kk-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Avatars ────────────────────────────────────────────── */

.kk-avatar {
    flex-shrink: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.02em;
    user-select: none;
}

.kk-avatar-md {
    width: 44px;
    height: 44px;
    font-size: 15px;
}

.kk-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

/* ── Composer ───────────────────────────────────────────── */

.kk-composer {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.kk-composer-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.kk-composer textarea {
    flex: 1;
    min-width: 0;
    border: 1px solid transparent;
    background: var(--color-section-alt);
    border-radius: 22px;
    outline: none;
    resize: none;
    font-family: var(--font-family);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--color-text);
    padding: 11px 16px;
    max-height: 260px;
    transition: border-color 0.15s, background 0.15s, border-radius 0.15s;
}

.kk-composer textarea:focus {
    background: #fff;
    border-color: var(--color-accent);
    border-radius: var(--radius-md);
}

.kk-composer-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

.kk-composer-counter {
    font-size: 11.5px;
    color: var(--color-text-light);
}

.kk-form-error {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-error);
}

/* ── Buttons ────────────────────────────────────────────── */

.kk-btn,
.kk-btn-sm,
.kk-btn-outline,
.kk-btn-ghost {
    font-family: var(--font-family);
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.kk-btn {
    border: none;
    background: var(--color-accent);
    color: #fff;
    font-size: 13.5px;
    padding: 9px 20px;
}

.kk-btn-sm {
    border: none;
    background: var(--color-accent);
    color: #fff;
    font-size: 12.5px;
    padding: 6px 14px;
}

.kk-btn:hover:not(:disabled),
.kk-btn-sm:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.kk-btn:disabled,
.kk-btn-sm:disabled {
    opacity: 0.35;
    cursor: default;
}

.kk-btn-outline {
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
    font-size: 13px;
    padding: 9px 18px;
}

.kk-btn-outline:hover {
    border-color: var(--color-accent);
}

.kk-btn-ghost {
    border: none;
    background: none;
    color: var(--color-text-light);
    font-size: 12.5px;
    padding: 6px 8px;
}

.kk-btn-ghost:hover {
    color: var(--color-text);
}

/* ── Post card ──────────────────────────────────────────── */

.kk-post {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 16px 6px;
}

.kk-post-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.kk-post-ident {
    flex: 1;
    min-width: 0;
    line-height: 1.35;
}

.kk-post-author {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.kk-name {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--color-text);
}

.kk-badge {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-light);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0 4px;
}

.kk-post-title,
.kk-post-when {
    font-size: 12.5px;
    color: var(--color-text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kk-time {
    font-size: 12.5px;
    color: var(--color-text-light);
}

.kk-post-del {
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--color-text-light);
    padding: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s, color 0.15s, background 0.15s;
}

.kk-post:hover .kk-post-del,
.kk-post-del:focus-visible {
    opacity: 1;
}

.kk-post-del:hover {
    color: var(--color-error);
    background: var(--color-error-bg);
}

/* Line breaks arrive as <br> from kk_message_html(), so pre-wrap would render
   every newline twice and open a paragraph gap into a chasm. */
.kk-post-body {
    font-size: 14.5px;
    line-height: 1.62;
    margin-top: 12px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.kk-post-body a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ── Tally row ──────────────────────────────────────────── */

.kk-post-tally {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 20px;
    margin-top: 12px;
}

.kk-tally {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.kk-tally[hidden] {
    display: none;
}

.kk-chips {
    display: inline-flex;
    align-items: center;
}

/* Overlapped discs, as on LinkedIn, so a busy post stays one compact cluster. */
.kk-chip {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    line-height: 1;
}

.kk-chip + .kk-chip {
    margin-left: -5px;
}

.kk-tally-count {
    font-size: 12.5px;
    color: var(--color-text-light);
    margin-left: 2px;
}

.kk-count-link {
    border: none;
    background: none;
    font-family: var(--font-family);
    font-size: 12.5px;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 2px 0;
}

.kk-count-link:hover {
    color: var(--color-text);
    text-decoration: underline;
}

.kk-count-link[hidden] {
    display: none;
}

/* ── Action row ─────────────────────────────────────────── */

.kk-post-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px solid var(--color-border);
}

.kk-act,
.kk-act-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: none;
    background: none;
    font-family: var(--font-family);
    color: var(--color-text-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.12s, color 0.12s;
}

.kk-act {
    flex: 1;
    font-size: 13.5px;
    font-weight: 600;
    padding: 9px 10px;
}

.kk-act-sm {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 6px;
}

.kk-act:hover,
.kk-act-sm:hover {
    background: rgba(17, 17, 17, 0.06);
    color: var(--color-text);
}

/* Your own reaction is marked with weight and ink, not a new accent colour. */
.kk-act.is-on,
.kk-act-sm.is-on {
    color: var(--color-text);
    font-weight: 700;
}

.kk-act-danger:hover {
    color: var(--color-error);
    background: var(--color-error-bg);
}

.kk-react-face {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

/* ── Reaction picker ────────────────────────────────────── */

.kk-react {
    position: relative;
    display: inline-flex;
    flex: 1;
}

.kk-comment-tools .kk-react {
    flex: 0 0 auto;
}

.kk-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px 7px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 26px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.13s, transform 0.13s, visibility 0.13s;
}

.kk-react:hover .kk-picker,
.kk-react:focus-within .kk-picker,
.kk-react.is-open .kk-picker {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.kk-picker-opt {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 3px;
    border-radius: 50%;
    transition: transform 0.12s, background 0.12s;
}

.kk-picker-opt:hover,
.kk-picker-opt:focus-visible {
    transform: scale(1.28);
    background: var(--color-section-alt);
}

.kk-picker-opt.is-on {
    background: var(--color-section-alt);
    box-shadow: inset 0 0 0 1px var(--color-border);
}

/* ── Comments ───────────────────────────────────────────── */

.kk-post-comments {
    border-top: 1px solid var(--color-border);
    margin-top: 2px;
    padding: 12px 0 10px;
}

.kk-post-comments[hidden] {
    display: none;
}

.kk-comment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.kk-comment-list:empty {
    display: none;
}

.kk-comment-slot.is-folded {
    display: none;
}

.kk-more-comments {
    border: none;
    background: none;
    font-family: var(--font-family);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 0 0 10px;
}

.kk-more-comments:hover {
    color: var(--color-text);
    text-decoration: underline;
}

.kk-comment {
    display: flex;
    gap: 9px;
}

.kk-comment-main {
    flex: 1;
    min-width: 0;
}

.kk-bubble {
    background: var(--color-section-alt);
    border-radius: var(--radius-md);
    padding: 9px 13px 10px;
}

.kk-bubble-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 7px;
    line-height: 1.3;
}

.kk-bubble-head .kk-name {
    font-size: 13.5px;
}

.kk-role {
    font-size: 11.5px;
    color: var(--color-text-light);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kk-bubble-head .kk-time {
    font-size: 11.5px;
    margin-left: auto;
    flex-shrink: 0;
}

.kk-bubble-body {
    font-size: 14px;
    line-height: 1.55;
    margin-top: 3px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.kk-bubble-body a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.kk-comment-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 3px 0 0 4px;
}

.kk-comment-tools .kk-tally {
    margin-left: 2px;
}

.kk-comment-tools .kk-chip {
    width: 17px;
    height: 17px;
    font-size: 9.5px;
}

.kk-comment-tools .kk-tally-count {
    font-size: 11.5px;
}

.kk-replies {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.kk-replies:empty {
    display: none;
}

.kk-comment-reply .kk-bubble {
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--color-border);
}

/* ── Comment composer ───────────────────────────────────── */

.kk-comment-form {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-top: 12px;
}

.kk-comment-form-reply {
    margin-top: 10px;
}

.kk-comment-field {
    flex: 1;
    min-width: 0;
}

.kk-comment-form textarea {
    width: 100%;
    border: 1px solid var(--color-border);
    background: #fff;
    border-radius: 18px;
    outline: none;
    resize: none;
    font-family: var(--font-family);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--color-text);
    padding: 8px 14px;
    max-height: 180px;
    transition: border-color 0.15s, border-radius 0.15s;
}

.kk-comment-form textarea:focus {
    border-color: var(--color-accent);
    border-radius: var(--radius-md);
}

.kk-comment-send {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

/* The send row only earns its space once there is something to send. */
.kk-comment-send {
    display: none;
}

.kk-comment-form.is-active .kk-comment-send {
    display: flex;
}

/* ── New posts pill and pagination ──────────────────────── */

.kk-new-posts {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #fff;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    cursor: pointer;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.kk-new-posts:hover {
    border-color: var(--color-accent);
}

.kk-new-posts[hidden] {
    display: none;
}

.kk-feed-more {
    display: flex;
    justify-content: center;
    padding: 16px 0 4px;
}

.kk-feed-more button[hidden] {
    display: none;
}

/* ── Empty and read-only states ─────────────────────────── */

.kk-empty {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-light);
}

.kk-empty h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
}

.kk-empty p {
    font-size: 14px;
}

.kk-readonly {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 13px 16px;
    margin-bottom: 12px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    background: #fff;
    font-size: 13.5px;
    color: var(--color-text-light);
}

.kk-readonly strong {
    color: var(--color-text);
    font-weight: 600;
}

/* ── Attached images ────────────────────────────────────── */

/**
 * The grid follows the count. A single image keeps its own proportions through
 * the aspect-ratio the renderer measured; two or more are cropped to uniform
 * tiles, because a row of mismatched heights reads as broken rather than as
 * faithful to the originals.
 */
.kk-shots {
    display: grid;
    gap: 3px;
    margin-top: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-section-alt);
}

.kk-shots-1 { grid-template-columns: 1fr; }
.kk-shots-2 { grid-template-columns: 1fr 1fr; }
.kk-shots-4 { grid-template-columns: 1fr 1fr; }

/* Three images: a tall one on the left, two stacked beside it. */
.kk-shots-3 {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.kk-shots-3 .kk-shot:first-child {
    grid-row: span 2;
}

.kk-shot {
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: var(--color-section-alt);
    cursor: zoom-in;
    overflow: hidden;
    line-height: 0;
}

.kk-shot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.15s;
}

/* A lone image is shown whole rather than cropped — it is the subject of the
   post, not a tile in a contact sheet. */
.kk-shots-1 .kk-shot img {
    object-fit: contain;
    max-height: 560px;
}

.kk-shots-2 .kk-shot,
.kk-shots-3 .kk-shot,
.kk-shots-4 .kk-shot {
    aspect-ratio: 1;
}

.kk-shots-2 .kk-shot { aspect-ratio: 4 / 5; }
.kk-shots-3 .kk-shot:first-child { aspect-ratio: auto; }

.kk-shot:hover img {
    opacity: 0.93;
}

.kk-shot:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.kk-shot-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 17, 17, 0.55);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

/* Under a comment the pictures are an aside, not the point, so they stay small
   and left-aligned instead of running the bubble's full width. */
.kk-shots-sm {
    margin-top: 8px;
    max-width: 320px;
}

.kk-shots-sm.kk-shots-1 .kk-shot img {
    max-height: 260px;
}

/* ── Attach button and pending tray ─────────────────────── */

.kk-attach {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.kk-attach:hover {
    background: rgba(17, 17, 17, 0.06);
    color: var(--color-text);
}

.kk-attach:focus-within {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

.kk-attach input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.kk-attach-sm {
    padding: 5px;
    flex-shrink: 0;
    align-self: flex-end;
}

/* Beside a comment box there is no room for a word, only the icon. */
.kk-attach-sm .kk-attach-label {
    display: none;
}

.kk-composer-foot .kk-attach {
    margin-right: auto;
}

.kk-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.kk-tray[hidden] {
    display: none;
}

.kk-tile {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-section-alt);
    border: 1px solid var(--color-border);
}

.kk-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* While the bytes are still going up the thumbnail is dimmed, so a slow upload
   looks like progress rather than a picture that failed to appear. */
.kk-tile.is-loading img {
    opacity: 0.4;
}

.kk-tile-spin {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
}

.kk-tile.is-loading .kk-tile-spin {
    display: flex;
}

.kk-tile-spin::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid rgba(17, 17, 17, 0.2);
    border-top-color: var(--color-text);
    border-radius: 50%;
    animation: kk-spin 0.7s linear infinite;
}

@keyframes kk-spin {
    to { transform: rotate(360deg); }
}

.kk-tile-drop {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(17, 17, 17, 0.65);
    color: #fff;
    cursor: pointer;
    padding: 0;
}

.kk-tile-drop:hover {
    background: rgba(17, 17, 17, 0.85);
}

.kk-tile.is-failed {
    border-color: var(--color-error);
    background: var(--color-error-bg);
}

.kk-tile-failed {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    text-align: center;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--color-error);
}

/* The whole composer lights up while a file is dragged over it. */
.kk-composer.is-dropping,
.kk-comment-form.is-dropping .kk-comment-field {
    outline: 2px dashed var(--color-accent);
    outline-offset: 3px;
    border-radius: var(--radius-md);
}

.kk-comment-input-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.kk-comment-input-row textarea {
    flex: 1;
    min-width: 0;
}

/* ── Lightbox ───────────────────────────────────────────── */

.kk-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, 0.92);
    padding: 40px 64px;
    cursor: zoom-out;
}

.kk-lightbox[hidden] {
    display: none;
}

.kk-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: default;
    border-radius: 2px;
}

.kk-lightbox-close,
.kk-lightbox-nav {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.15s;
}

.kk-lightbox-close:hover,
.kk-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.24);
}

.kk-lightbox-close {
    top: 16px;
    right: 20px;
    width: 42px;
    height: 42px;
}

.kk-lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
}

.kk-lightbox-prev { left: 14px; }
.kk-lightbox-next { right: 14px; }

.kk-lightbox-nav[hidden] {
    display: none;
}

.kk-lightbox-count {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.75);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Small screens ──────────────────────────────────────── */

@media (max-width: 768px) {
    .kk-feed-scroll {
        padding: 12px 10px 40px;
    }

    .kk-post {
        padding: 14px 13px 6px;
    }

    .kk-avatar-md {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .kk-act {
        font-size: 12.5px;
        padding: 9px 4px;
    }

    /* Hover cannot open the picker on touch, so it is tap-to-open there. */
    .kk-react:hover .kk-picker {
        opacity: 0;
        visibility: hidden;
    }

    .kk-react.is-open .kk-picker {
        opacity: 1;
        visibility: visible;
    }

    .kk-shots-1 .kk-shot img {
        max-height: 420px;
    }

    .kk-tile {
        width: 72px;
        height: 72px;
    }

    /* Thumb reach beats a big picture: the arrows move off the edges and the
       image gets the full width. */
    .kk-lightbox {
        padding: 56px 8px 64px;
    }

    .kk-lightbox-nav {
        top: auto;
        bottom: 12px;
        transform: none;
        width: 42px;
        height: 42px;
    }

    .kk-lightbox-prev { left: 24px; }
    .kk-lightbox-next { right: 24px; }

    .kk-lightbox-count {
        bottom: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kk-picker,
    .kk-picker-opt {
        transition: none;
    }
}
