/**
 * TecXtagram — the Instagram-like social area (feed cards, photo composer, stories row,
 * explore grid, post detail, comments thread).
 *
 * Tokens only (theme-aware: the tokens already flip for light/dark via data-theme, so
 * these rules follow the viewer's theme automatically). Scoped to .gtx-tx-* so nothing
 * here leaks into the rest of the app. The heart-fill + heart-burst are pure CSS.
 */

/* ---- Feed column: a narrow, centred Instagram-style column ------------------------- */
.gtx-tx-feed {
    max-width: 42rem;
    margin-inline: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--gtx-s4);
}

/* ---- Stories row ------------------------------------------------------------------- */
.gtx-tx-stories {
    padding: var(--gtx-s3);
    overflow: hidden;
}

.gtx-tx-stories__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: var(--gtx-s3);
    overflow-x: auto;
    scrollbar-width: thin;
}

.gtx-tx-stories__item {
    flex: 0 0 auto;
}

.gtx-tx-stories__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gtx-s1);
    width: 4.75rem;
    text-decoration: none;
    color: var(--gtx-text);
}

/* The gradient "story ring" around a friend's avatar. */
.gtx-tx-stories__ring {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--gtx-r-full);
    background: var(--gtx-ember-grad, linear-gradient(45deg, var(--gtx-ember), var(--gtx-accent)));
}

.gtx-tx-stories__ring .gtx-avatar {
    border: 2px solid var(--gtx-surface);
}

.gtx-tx-stories__name {
    max-width: 100%;
    font-size: var(--gtx-fs-meta);
    color: var(--gtx-text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Photo composer (native <details>) --------------------------------------------- */
.gtx-tx-composer {
    padding: 0;
}

.gtx-tx-composer__trigger {
    display: flex;
    align-items: center;
    gap: var(--gtx-s3);
    padding: var(--gtx-s3);
    cursor: pointer;
    list-style: none;
    color: var(--gtx-text);
}

.gtx-tx-composer__trigger::-webkit-details-marker {
    display: none;
}

.gtx-tx-composer__hint {
    flex: 1;
    color: var(--gtx-text-dim);
}

.gtx-tx-composer__plus {
    color: var(--gtx-accent);
    transition: transform var(--gtx-t-fast) var(--gtx-ease);
}

.gtx-tx-composer[open] .gtx-tx-composer__plus {
    transform: rotate(45deg);
}

.gtx-tx-composer__form {
    display: flex;
    flex-direction: column;
    gap: var(--gtx-s3);
    padding: 0 var(--gtx-s3) var(--gtx-s3);
    border-top: 1px solid var(--gtx-line);
    padding-top: var(--gtx-s3);
}

.gtx-tx-composer__field {
    display: flex;
    flex-direction: column;
    gap: var(--gtx-s1);
}

.gtx-tx-composer__label {
    font-size: var(--gtx-fs-ui);
    font-weight: 600;
}

.gtx-tx-composer__caption {
    width: 100%;
    resize: vertical;
    min-height: 4rem;
    padding: var(--gtx-s2);
    border-radius: var(--gtx-r-s);
    border: 1px solid var(--gtx-line);
    background: var(--gtx-surface-2);
    color: var(--gtx-text);
    font: inherit;
}

.gtx-tx-composer__foot {
    display: flex;
    justify-content: flex-end;
}

/* ---- Feed card --------------------------------------------------------------------- */
.gtx-tx-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gtx-tx-card__head {
    display: flex;
    align-items: center;
    gap: var(--gtx-s2);
    padding: var(--gtx-s3);
}

.gtx-tx-card__author {
    display: inline-flex;
    align-items: center;
    gap: var(--gtx-s2);
    text-decoration: none;
    color: var(--gtx-text);
    font-weight: 600;
}

.gtx-tx-card__author:hover .gtx-tx-card__author-name {
    text-decoration: underline;
}

.gtx-tx-card__time {
    margin-left: auto;
    font-size: var(--gtx-fs-meta);
    color: var(--gtx-text-dim);
}

/* The square-ish media well; double-tap likes it. */
.gtx-tx-card__media {
    position: relative;
    background: #000;
    display: flex;
    justify-content: center;
    max-height: 40rem;
    overflow: hidden;
    user-select: none;
}

.gtx-tx-card__media-link {
    display: block;
    width: 100%;
}

.gtx-tx-card__img {
    display: block;
    width: 100%;
    max-height: 40rem;
    object-fit: contain;
}

/* Heart-burst on double-tap. */
.gtx-tx-card__heart-burst {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    color: #fff;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
}

.gtx-tx-card__heart-burst svg {
    fill: #fff;
    stroke: #fff;
}

.gtx-tx-card__heart-burst.is-active {
    animation: gtx-tx-burst 900ms var(--gtx-ease);
}

@keyframes gtx-tx-burst {
    0% { opacity: 0; transform: scale(0.3); }
    15% { opacity: 0.95; transform: scale(1.15); }
    30% { transform: scale(0.95); }
    45% { transform: scale(1); }
    80% { opacity: 0.95; }
    100% { opacity: 0; transform: scale(1); }
}

.gtx-tx-card__actions {
    display: flex;
    align-items: center;
    gap: var(--gtx-s1);
    padding: var(--gtx-s2) var(--gtx-s3) 0;
}

/* Icon button (heart / comment). */
.gtx-tx-iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--gtx-s1);
    border: none;
    background: none;
    color: var(--gtx-text);
    cursor: pointer;
    border-radius: var(--gtx-r-s);
    transition: transform var(--gtx-t-fast) var(--gtx-ease), color var(--gtx-t-fast) var(--gtx-ease);
}

.gtx-tx-iconbtn:hover {
    color: var(--gtx-accent);
}

.gtx-tx-iconbtn:active {
    transform: scale(0.85);
}

.gtx-tx-iconbtn--sm {
    padding: 2px;
}

.gtx-tx-like {
    display: inline-flex;
    margin: 0;
}

/* Liked state: a filled ember/red heart with a little pop. */
.gtx-tx-like.is-liked .gtx-tx-iconbtn,
.gtx-btn.is-liked svg {
    color: var(--gtx-danger);
}

.gtx-tx-like.is-liked .gtx-tx-iconbtn svg {
    fill: var(--gtx-danger);
    stroke: var(--gtx-danger);
    animation: gtx-tx-pop 300ms var(--gtx-ease);
}

@keyframes gtx-tx-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.gtx-tx-card__likes {
    padding: var(--gtx-s1) var(--gtx-s3) 0;
    font-weight: 600;
    font-size: var(--gtx-fs-ui);
}

.gtx-tx-card__caption {
    padding: var(--gtx-s1) var(--gtx-s3) 0;
    margin: 0;
    line-height: 1.4;
}

.gtx-tx-card__caption-author,
.gtx-tx-comment__author,
.gtx-tx-thread__author {
    font-weight: 600;
    color: var(--gtx-text);
    text-decoration: none;
}

.gtx-tx-card__caption-author:hover {
    text-decoration: underline;
}

/* Clamp a long caption to a few lines; JS adds the "… mehr" toggle when it overflows. */
.gtx-tx-card__caption--clamped .gtx-tx-card__caption-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gtx-tx-card__more {
    display: inline;
    margin-left: 0.25rem;
    padding: 0;
    border: none;
    background: none;
    color: var(--gtx-text-dim);
    cursor: pointer;
    font: inherit;
}

.gtx-tx-card__comments {
    list-style: none;
    margin: var(--gtx-s1) 0 0;
    padding: 0 var(--gtx-s3);
}

.gtx-tx-comment {
    line-height: 1.4;
    margin-top: 2px;
}

.gtx-tx-comment__body {
    color: var(--gtx-text);
    word-break: break-word;
}

.gtx-tx-card__more-comments {
    display: block;
    padding: var(--gtx-s1) var(--gtx-s3) 0;
    color: var(--gtx-text-dim);
    text-decoration: none;
}

.gtx-tx-card__more-comments:hover {
    text-decoration: underline;
}

/* Inline "add a comment" row. */
.gtx-tx-card__add-comment {
    display: flex;
    align-items: center;
    gap: var(--gtx-s2);
    margin-top: var(--gtx-s2);
    padding: var(--gtx-s2) var(--gtx-s3);
    border-top: 1px solid var(--gtx-line);
}

.gtx-tx-card__comment-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    color: var(--gtx-text);
    font: inherit;
    padding: var(--gtx-s1) 0;
}

.gtx-tx-card__comment-input:focus {
    outline: none;
}

/* ---- Post detail (Instagram two-pane on wide screens) ------------------------------ */
.gtx-tx-detail {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
    max-height: min(80vh, 40rem);
}

.gtx-tx-detail__media {
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    user-select: none;
}

.gtx-tx-detail__img {
    width: 100%;
    height: 100%;
    max-height: min(80vh, 40rem);
    object-fit: contain;
}

.gtx-tx-detail__side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-left: 1px solid var(--gtx-line);
}

.gtx-tx-detail__head {
    display: flex;
    align-items: center;
    gap: var(--gtx-s2);
    padding: var(--gtx-s3);
    border-bottom: 1px solid var(--gtx-line);
}

.gtx-tx-detail__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--gtx-s3);
    display: flex;
    flex-direction: column;
    gap: var(--gtx-s3);
}

.gtx-tx-detail__caption {
    line-height: 1.45;
}

.gtx-tx-detail__caption .gtx-tx-card__caption-author {
    margin-right: 0.35rem;
}

.gtx-tx-detail__caption-text {
    color: var(--gtx-text);
}

.gtx-tx-detail__foot {
    border-top: 1px solid var(--gtx-line);
    padding-bottom: var(--gtx-s2);
}

.gtx-tx-detail__foot .gtx-tx-card__add-comment {
    border-top: 1px solid var(--gtx-line);
    margin-top: var(--gtx-s2);
}

/* ---- Comments thread (detail) ------------------------------------------------------ */
.gtx-tx-thread__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--gtx-s3);
}

.gtx-tx-thread__item {
    display: flex;
    align-items: flex-start;
    gap: var(--gtx-s2);
}

.gtx-tx-thread__bubble {
    flex: 1;
    min-width: 0;
}

.gtx-tx-thread__meta {
    display: flex;
    align-items: baseline;
    gap: var(--gtx-s2);
}

.gtx-tx-thread__body {
    color: var(--gtx-text);
    line-height: 1.4;
    word-break: break-word;
}

.gtx-tx-thread__del {
    margin: 0;
    opacity: 0;
    transition: opacity var(--gtx-t-fast) var(--gtx-ease);
}

.gtx-tx-thread__item:hover .gtx-tx-thread__del,
.gtx-tx-thread__del:focus-within {
    opacity: 1;
}

.gtx-tx-thread__del .gtx-tx-iconbtn:hover {
    color: var(--gtx-danger);
}

.gtx-tx-thread__empty {
    margin: 0;
}

.gtx-tx-article-comments {
    border-top: 1px solid var(--gtx-line);
}

/* ---- Explore grid overlay ---------------------------------------------------------- */
.gtx-postgrid--explore {
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: var(--gtx-s1);
}

.gtx-postgrid__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gtx-s4);
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-weight: 600;
    opacity: 0;
    transition: opacity var(--gtx-t-fast) var(--gtx-ease);
}

.gtx-postgrid__link:hover .gtx-postgrid__overlay,
.gtx-postgrid__link:focus-visible .gtx-postgrid__overlay {
    opacity: 1;
}

.gtx-postgrid__stat {
    display: inline-flex;
    align-items: center;
    gap: var(--gtx-s1);
}

.gtx-postgrid__stat svg {
    fill: #fff;
    stroke: #fff;
}

/* ---- Responsive: collapse the detail to a single column --------------------------- */
@media (max-width: 48rem) {
    .gtx-tx-detail {
        grid-template-columns: 1fr;
        max-height: none;
    }

    .gtx-tx-detail__side {
        border-left: none;
        border-top: 1px solid var(--gtx-line);
    }

    .gtx-tx-detail__scroll {
        max-height: 22rem;
    }
}

/* Respect reduced-motion: drop the burst/pop animations. */
@media (prefers-reduced-motion: reduce) {
    .gtx-tx-card__heart-burst.is-active,
    .gtx-tx-like.is-liked .gtx-tx-iconbtn svg {
        animation: none;
    }
}
