/* =============================================================================
   Posts - Post cards, post detail, attachments, galleries, lightbox
   ============================================================================= */

/* Posts List */
.posts {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.post-card {
}

.post-meta {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.post-meta-left {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-shrink: 0;
}

.post-meta-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.post-meta .category {
    padding: 0 0.4rem;
}

.post-meta .federated {
    color: var(--text-muted);
    cursor: help;
}

.post-meta .lang-flag {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: help;
}

.post-meta .post-date {
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.post-meta .post-date .icon {
    width: 0.9em;
    height: 0.9em;
}

.post-meta .post-date:hover {
    color: var(--link);
}

.post-meta .edit-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85em;
}

.post-meta .edit-link:hover {
    color: var(--accent);
}

.post-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.post-footer-line {
    display: none;
}

.post-footer .tags {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-top: 0;
    margin-left: auto;
}

.post-card h2 {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.post-card h2 a {
    color: var(--text);
    text-decoration: none;
}

.post-card h2 a:hover {
    color: var(--link);
}

.post-excerpt {
    color: var(--text);
    font-size: 1rem;
}

.post-excerpt p {
    margin-bottom: 0.5rem;
}

.read-more {
    font-family: var(--font-sans);
    color: var(--link);
    text-decoration: none;
    font-size: 0.85rem;
}

.read-more:hover {
    text-decoration: underline;
}

/* Single Post */
.post-full {
    margin-bottom: 2rem;
}

.post-header {
    margin-bottom: 2rem;
}

.post-header h1 {
    font-family: var(--font-sans);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 0.5rem;
}

.post-location {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.post-nav {
    margin-top: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.post-nav a {
    font-family: var(--font-sans);
    color: var(--link);
    text-decoration: none;
    font-size: 0.9rem;
}

.post-nav a:hover {
    text-decoration: underline;
}

.post-nav .pill {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.65rem;
    border-radius: 9999px;
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
}

.post-nav .pill:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    text-decoration: none;
}

/* Writing List */
.writing-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.writing-item {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.writing-item h2 {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
}

.writing-item h2 a {
    color: var(--text);
    text-decoration: none;
}

.writing-item h2 a:hover {
    color: var(--link);
}

.writing-item > .category {
    flex-shrink: 0;
    margin-left: auto;
}

@media (max-width: 700px) {
    .post-header h1 {
        font-size: 1.4rem;
    }
}

@media (max-width: 500px) {
    .writing-item h2 {
        mask-image: linear-gradient(to right, black 75%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 75%, transparent 100%);
    }
}

/* =============================================================================
   Post Attachments Display
   ============================================================================= */

.post-attachments {
    margin: 2rem 0;
}

.post-attachments figure {
    margin-bottom: 1.5rem;
}

.post-attachments img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.post-attachments figcaption {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.post-attachments video {
    max-width: 100%;
    border-radius: 6px;
}

/* List page: single thumbnail float right */
.post-attachment-single {
    float: right;
    margin: 0 0 0.75rem 1rem;
    display: block;
    position: relative;
}

.post-attachment-single img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border: 2px solid #000;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: block;
}

/* Image count pill (Instagram-style) */
.attachment-count {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    line-height: 1;
}

.attachment-count .icon {
    width: 0.85em;
    height: 0.85em;
}

/* =============================================================================
   Detail Page Gallery
   ============================================================================= */

.post-gallery {
    margin-bottom: 1.5rem;
}

.post-gallery img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    cursor: pointer;
}

/* Single image: full width above content */
.post-gallery-1 {
    margin-bottom: 1.5rem;
}

.post-gallery-1.polaroid img {
    border: none;
    box-shadow: none;
}

/* 2 images: side by side */
.post-gallery-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* 3 images: 1 large on top, 2 small below */
.post-gallery-3 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 0.75rem;
}

.post-gallery-3 .gallery-item:first-child,
.post-gallery-3 .gallery-item-wrapper:first-child {
    grid-column: 1 / -1;
}

/* 4 images: 2x2 grid */
.post-gallery-4 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Gallery item styling for grids */
.post-gallery-2 img,
.post-gallery-3 img,
.post-gallery-4 img {
    aspect-ratio: 4/3;
    object-fit: cover;
}

.post-gallery-2 .polaroid img,
.post-gallery-3 .polaroid img,
.post-gallery-4 .polaroid img {
    border: none;
}

.gallery-item {
    display: block;
    overflow: hidden;
    border-radius: 6px;
}

/* Polaroid-style image frame */
.polaroid {
    background: #fff;
    padding: 0.5rem 0.5rem 0.25rem 0.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.polaroid .gallery-item {
    border-radius: 2px;
}

.polaroid img {
    border-radius: 2px;
}

.image-info-box {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    padding: 0.5rem 0.25rem 0.25rem 0.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    line-height: 1;
}

.image-number {
    font-weight: 600;
    color: var(--text);
    margin-right: 0.25rem;
}

.image-pill {
    display: inline-block;
    background: rgba(59, 130, 246, 0.12);
    color: #1a1a1a;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* =============================================================================
   Lightbox
   ============================================================================= */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    opacity: 0.7;
}

.lightbox-close:hover {
    opacity: 1;
}

/* =============================================================================
   Attachment Upload (Editor)
   ============================================================================= */

.attachment-dropzone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
}

.attachment-dropzone:hover,
.attachment-dropzone.dragover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb, 0, 0, 0), 0.05);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.dropzone-icon {
    width: 2rem;
    height: 2rem;
    color: var(--text-muted);
}

.dropzone-link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

.dropzone-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    min-width: 200px;
}

.attachment-preview {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: var(--color-reaction);
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.attachment-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.attachment-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.attachment-status.error {
    color: #c00;
}

.attachment-actions {
    display: flex;
    gap: 0.25rem;
}

.attachment-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background-color 0.2s, color 0.2s;
}

.attachment-btn:hover {
    background: var(--color-reaction);
    color: var(--text);
}

.attachment-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.attachment-btn svg {
    width: 16px;
    height: 16px;
}

.attachment-delete:hover {
    color: #c00;
}

.attachment-geotag:hover {
    color: var(--accent);
}

.attachment-item.attachment-ready {
    border-color: var(--accent);
}

.attachment-item.attachment-failed {
    border-color: #c00;
    background: rgba(204, 0, 0, 0.05);
}

/* Alt text input */
.attachment-alt-input {
    width: 100%;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    margin-bottom: 0.25rem;
}

.attachment-alt-input:focus {
    outline: none;
    border-color: var(--accent);
}

.attachment-alt-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* =============================================================================
   Image References Section
   ============================================================================= */

.image-references {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.image-references h3 {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.image-ref {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.25rem;
}

.image-ref:last-child {
    margin-bottom: 0;
}

.image-ref .ref-label {
    font-weight: 600;
    color: var(--text);
}

.image-ref code {
    font-family: var(--font-mono, monospace);
    font-size: 0.75rem;
    background: var(--bg-secondary, #f5f5f5);
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
}

.image-ref a {
    color: var(--link);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 0.15rem 0.35rem;
    background: var(--bg-secondary, #f0f0f0);
    border-radius: 3px;
    margin-left: 0.15rem;
}

.image-ref a:hover {
    background: var(--link);
    color: white;
}

/* =============================================================================
   Post Actions (Reply, Quote, Share)
   ============================================================================= */

.post-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.post-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.post-action-btn:hover {
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text);
    border-color: var(--text-muted);
}

.post-action-btn svg {
    flex-shrink: 0;
}

.post-action-btn.copied {
    border-color: var(--accent);
    color: var(--accent);
}

/* =============================================================================
   Thread Display (Unified multi-part posts)
   ============================================================================= */

/* Thread indicator in page header */
.thread-indicator {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--accent);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Thread separator between parts */
.thread-separator {
    margin: 2.5rem 0 1.5rem 0;
    position: relative;
}

.thread-separator-line {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border) 20%, var(--border) 80%, transparent);
}

.thread-separator-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.thread-separator-time {
    font-weight: 500;
}

.thread-separator-stats {
    display: flex;
    gap: 0.75rem;
}

.thread-separator-stats .stat-likes,
.thread-separator-stats .stat-boosts {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.thread-separator-stats .stat-likes::before {
    content: '';
    display: inline-block;
    width: 0.85em;
    height: 0.85em;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") no-repeat center;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") no-repeat center;
}

.thread-separator-stats .stat-boosts::before {
    content: '';
    display: inline-block;
    width: 0.85em;
    height: 0.85em;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M17 1l4 4-4 4'/%3E%3Cpath d='M3 11V9a4 4 0 0 1 4-4h14'/%3E%3Cpath d='M7 23l-4-4 4-4'/%3E%3Cpath d='M21 13v2a4 4 0 0 1-4 4H3'/%3E%3C/svg%3E") no-repeat center;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M17 1l4 4-4 4'/%3E%3Cpath d='M3 11V9a4 4 0 0 1 4-4h14'/%3E%3Cpath d='M7 23l-4-4 4-4'/%3E%3Cpath d='M21 13v2a4 4 0 0 1-4 4H3'/%3E%3C/svg%3E") no-repeat center;
}

.thread-separator-reply {
    color: var(--link);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.thread-separator-reply:hover {
    text-decoration: underline;
}

/* Thread parts */
.thread-part {
    /* Content wrapper for each part */
}

.thread-part--viewed {
    /* Highlight when viewing a specific continuation directly */
    background: rgba(var(--accent-rgb, 22, 163, 74), 0.05);
    margin: -0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
}

