/* Thread feeds (templates/includes/thread_feed.html): the quick posts page (/posts/) and a profile's
   publications. One column, the author's avatar beside each post, photos in a row that scrolls sideways. */

.thread-feed,
.threads-page {
    --thread-ink: #0f172a;
    --thread-text: #1e293b;
    --thread-muted: #64748b;
    --thread-faint: #94a3b8;
    --thread-line: rgba(15, 23, 42, .08);
    --thread-surface: #fff;
    --thread-raised: #f8fafc;
    --thread-hover: rgba(15, 23, 42, .05);
    --thread-accent: #f97316;
    --thread-like: #ef4444;
    --thread-menu-shadow: 0 18px 44px rgba(15, 23, 42, .16);
}

html[data-theme="dark"] .thread-feed,
html[data-theme="dark"] .threads-page {
    --thread-ink: #edf3fb;
    --thread-text: #dbe4ef;
    --thread-muted: #9fb0c6;
    --thread-faint: #7d8ea6;
    --thread-line: rgba(148, 163, 184, .16);
    --thread-surface: #101928;
    --thread-raised: #172337;
    --thread-hover: rgba(148, 163, 184, .1);
    --thread-accent: #ff9a5c;
    --thread-like: #f87171;
    --thread-menu-shadow: 0 18px 44px rgba(0, 0, 0, .45);
}

/* ---------------------------------------------------------------- the quick posts page */
/* The top padding matches the journal's articles page, so the feed switch above stays in place between the two. */
.threads-page {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: 18px 0 32px;
    box-sizing: border-box;
}

.threads-page > .journal-feeds {
    margin-bottom: 14px;
}

.threads-page__column {
    background: var(--thread-surface);
    min-height: 60vh;
}

.threads-page__head {
    padding: 20px 16px 6px;
}

.threads-page__head h1 {
    margin: 0;
    color: var(--thread-ink);
    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -.01em;
}

.threads-page__head p {
    margin: 6px 0 0;
    color: var(--thread-muted);
    font-size: 14px;
    line-height: 1.4;
}

.threads-page__tabs {
    display: flex;
    margin-top: 10px;
    border-bottom: 1px solid var(--thread-line);
}

.threads-page__tabs a {
    position: relative;
    flex: 1 1 0;
    padding: 14px 8px 13px;
    color: var(--thread-faint);
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    transition: color .18s ease;
}

.threads-page__tabs a:hover,
.threads-page__tabs a.is-active {
    color: var(--thread-ink);
}

.threads-page__tabs a.is-active::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: var(--thread-ink);
}

.threads-composer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--thread-line);
    color: var(--thread-faint);
}

.threads-composer img {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 999px;
    object-fit: cover;
    background: var(--thread-raised);
}

.threads-composer__prompt {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.threads-composer__button {
    flex: none;
    padding: 8px 16px;
    border: 1px solid var(--thread-line);
    border-radius: 12px;
    color: var(--thread-ink);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    transition: background-color .18s ease;
}

.threads-composer:hover .threads-composer__button {
    background: var(--thread-hover);
}

.threads-page__empty {
    padding: 48px 24px 56px;
    color: var(--thread-muted);
    font-size: 15px;
    line-height: 1.5;
    text-align: center;
}

.threads-page__empty p {
    margin: 0 0 14px;
}

.threads-page__empty a {
    display: inline-flex;
    padding: 10px 18px;
    border-radius: 12px;
    background: var(--thread-ink);
    color: var(--thread-surface);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .threads-page {
        padding: 18px 16px 48px;
    }

    .threads-page__column {
        overflow: visible;
        border: 1px solid var(--thread-line);
        border-radius: 28px;
        box-shadow: 0 10px 30px rgba(15, 23, 42, .05);
    }

    .threads-page__head {
        padding: 26px 24px 6px;
    }

    .threads-composer {
        padding: 16px 24px;
    }
}

/* ---------------------------------------------------------------- the feed */
.thread-feed {
    background: var(--thread-surface);
}

/* In a profile the feed is a card of its own, the same on a phone as on a computer. */
#posts-list .thread-feed {
    border: 1px solid var(--thread-line);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .05);
}

@media (min-width: 768px) {
    #posts-list .thread-feed {
        border-radius: 28px;
    }
}

.thread-post {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--thread-line);
    transition: opacity .2s ease, transform .2s ease;
}

.thread-feed__items > .thread-post:last-child {
    border-bottom: 0;
}

.thread-post.is-removing {
    opacity: 0;
    transform: scale(.98);
}

@media (min-width: 768px) {
    .thread-post {
        padding: 16px 24px 12px;
    }
}

.thread-post__avatar img {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    object-fit: cover;
    background: var(--thread-raised);
}

.thread-post__body {
    min-width: 0;
}

.thread-post__head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
    min-width: 0;
}

.thread-post__author {
    min-width: 0;
    overflow: hidden;
    color: var(--thread-ink);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-post__author:hover {
    text-decoration: underline;
}

.thread-post__time {
    flex: none;
    color: var(--thread-faint);
    font-size: 14px;
    white-space: nowrap;
}

.thread-post__time:hover {
    color: var(--thread-muted);
}

.thread-post__kind {
    flex: none;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--thread-raised);
    color: var(--thread-muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.thread-post__menu {
    position: relative;
    flex: none;
    margin: -6px -8px -6px auto;
}

.thread-post__menu-toggle {
    display: flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--thread-faint);
    transition: background-color .18s ease, color .18s ease;
}

.thread-post__menu-toggle:hover {
    background: var(--thread-hover);
    color: var(--thread-ink);
}

.thread-post__menu-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.thread-post__menu-list {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    right: 0;
    width: 220px;
    padding: 6px;
    border: 1px solid var(--thread-line);
    border-radius: 16px;
    background: var(--thread-surface);
    box-shadow: var(--thread-menu-shadow);
}

.thread-post__menu-list[hidden] {
    display: none;
}

.thread-post__menu-list > a,
.thread-post__menu-list > button,
.thread-post__confirm button {
    display: flex;
    width: 100%;
    min-height: 40px;
    align-items: center;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--thread-ink);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.thread-post__menu-list > a:hover,
.thread-post__menu-list > button:hover,
.thread-post__confirm button:hover {
    background: var(--thread-hover);
}

.thread-post__menu-list .is-danger {
    color: #dc2626;
}

html[data-theme="dark"] .thread-post__menu-list .is-danger {
    color: #fda29b;
}

.thread-post__confirm {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--thread-line);
}

.thread-post__confirm[hidden] {
    display: none;
}

.thread-post__confirm p {
    margin: 0 12px 4px;
    color: var(--thread-muted);
    font-size: 13px;
    font-weight: 600;
}

.thread-post__place {
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    color: var(--thread-muted);
    font-size: 13px;
    line-height: 1.35;
}

.thread-post__place svg {
    width: 14px;
    height: 14px;
    flex: none;
    fill: none;
    stroke: var(--thread-accent);
    stroke-width: 2;
}

.thread-post__place span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-post__text {
    display: -webkit-box;
    margin-top: 4px;
    overflow: hidden;
    color: var(--thread-text);
    font-size: 15px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 9;
}

.thread-post__text.is-expanded {
    display: block;
    -webkit-line-clamp: unset;
}

.thread-post__text a {
    color: var(--thread-accent);
}

.thread-post__more {
    margin-top: 2px;
    color: var(--thread-faint);
    font-size: 15px;
    font-weight: 600;
}

.thread-post__more:hover {
    color: var(--thread-ink);
}

/* Photos in a row at one height, each at its own proportions; the row scrolls sideways to the edge. */
.thread-post__media {
    display: flex;
    height: 240px;
    gap: 6px;
    margin: 10px -16px 0 0;
    padding-right: 16px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

.thread-post__media::-webkit-scrollbar {
    display: none;
}

@media (min-width: 768px) {
    .thread-post__media {
        height: 300px;
        margin-right: -24px;
        padding-right: 24px;
    }
}

.thread-post__shot {
    position: relative;
    display: block;
    flex: none;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--thread-line);
    border-radius: 12px;
    background: var(--thread-raised);
    scroll-snap-align: start;
}

.thread-post__shot img {
    display: block;
    width: auto;
    min-width: 120px;
    max-width: none;
    height: 100%;
    object-fit: cover;
}

.thread-post__shot--video {
    width: auto;
    max-width: 100%;
    background: #000;
}

.thread-post__shot--embed {
    aspect-ratio: 16 / 9;
    background: #0f172a;
}

.thread-post__shot--embed img {
    width: 100%;
    min-width: 0;
}

.thread-post__play {
    position: absolute;
    inset: 0;
    display: flex;
    width: 52px;
    height: 52px;
    margin: auto;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 999px;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    backdrop-filter: blur(12px);
}

.thread-post__play svg {
    width: 22px;
    height: 22px;
    margin-left: 3px;
    fill: currentColor;
}

/* One photo or video: shown whole, as large as the column allows. */
.thread-post__media--single {
    height: auto;
    margin-right: 0;
    padding-right: 0;
    overflow: visible;
}

.thread-post__media--single .thread-post__shot {
    height: auto;
    max-width: 100%;
}

.thread-post__media--single .thread-post__shot img,
.thread-post__media--single .thread-post__shot--video {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 460px;
    min-width: 0;
}

.thread-post__media--single .thread-post__shot--embed {
    width: 100%;
}

/* An article in the feed: its card. */
.thread-post__article {
    display: block;
    margin-top: 8px;
    overflow: hidden;
    border: 1px solid var(--thread-line);
    border-radius: 16px;
    background: var(--thread-surface);
    transition: border-color .18s ease;
}

.thread-post__article:hover {
    border-color: rgba(249, 115, 22, .45);
}

.thread-post__article-cover {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    background: var(--thread-raised);
}

.thread-post__article-copy {
    display: block;
    padding: 12px 14px 14px;
}

.thread-post__article-copy strong {
    display: block;
    color: var(--thread-ink);
    font-size: 16px;
    font-weight: 800;
    line-height: 1.3;
}

.thread-post__article-copy span {
    display: -webkit-box;
    margin-top: 4px;
    overflow: hidden;
    color: var(--thread-muted);
    font-size: 14px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

/* The post's route. */
.thread-post__route {
    display: flex;
    max-width: 100%;
    width: fit-content;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 6px 14px 6px 6px;
    border: 1px solid var(--thread-line);
    border-radius: 14px;
    transition: border-color .18s ease, background-color .18s ease;
}

.thread-post__route:hover {
    border-color: rgba(249, 115, 22, .45);
    background: var(--thread-hover);
}

.thread-post__route img,
.thread-post__route-icon {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 10px;
    object-fit: cover;
    background: var(--thread-raised);
}

.thread-post__route-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--thread-accent);
}

.thread-post__route-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.thread-post__route-copy {
    min-width: 0;
}

.thread-post__route-copy strong,
.thread-post__route-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-post__route-copy strong {
    color: var(--thread-ink);
    font-size: 14px;
    font-weight: 700;
}

.thread-post__route-copy span {
    margin-top: 2px;
    color: var(--thread-muted);
    font-size: 12px;
}

/* Like, comments, save, share. */
.thread-post__actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 6px 0 0 -8px;
}

.thread-action {
    display: inline-flex;
    min-width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 9px;
    border-radius: 999px;
    color: var(--thread-muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.thread-action:hover {
    background: var(--thread-hover);
    color: var(--thread-ink);
}

/* As in Threads, a count shows once there is something to count (an empty one is read as 0 by base.js). */
.thread-action span:empty {
    display: none;
}

.thread-action:active {
    transform: scale(.94);
}

.thread-action svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.thread-action.is-liked,
.thread-action.is-liked:hover {
    color: var(--thread-like);
}

.thread-action.is-liked svg {
    fill: currentColor;
}

.thread-action.is-saved,
.thread-action.is-saved:hover {
    color: var(--thread-accent);
}

.thread-action.is-saved svg {
    fill: currentColor;
}

/* The next page. */
.thread-feed__more {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px 20px;
    border-top: 1px solid var(--thread-line);
}

.thread-feed__more-button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    padding: 0 18px;
    border: 1px solid var(--thread-line);
    border-radius: 12px;
    color: var(--thread-ink);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.thread-feed__more-button:hover {
    background: var(--thread-hover);
}

.thread-feed__spinner {
    display: none;
    width: 26px;
    height: 26px;
    border: 2.5px solid var(--thread-line);
    border-top-color: var(--thread-muted);
    border-radius: 999px;
    animation: thread-feed-spin .8s linear infinite;
}

.thread-feed__more.is-loading .thread-feed__more-button {
    display: none;
}

.thread-feed__more.is-loading .thread-feed__spinner {
    display: block;
}

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

@media (prefers-reduced-motion: reduce) {
    .thread-post,
    .thread-action { transition: none; }
    .thread-feed__spinner { animation-duration: 2s; }
}
