/**
 * Infinite Scroll Feed Styles
 * For A. A. Chips' Blog Feed System
 */

/* Feed Container */
#infinite-scroll-container {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Individual Feed Post */
.feed-post {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius, 8px);
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: var(--box-shadow);
    transition: background 0.2s ease, border-color 0.2s ease;
    display: flex;
    gap: 20px;
}

.feed-post:hover {
    background: var(--hover-background);
    border-color: var(--primary-color);
}

.feed-post .post-thumbnail {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    overflow: hidden;
    border-radius: 4px;
}

.feed-post .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feed-post .post-content-wrapper {
    flex: 1;
    min-width: 0;
}

.feed-post .post-header {
    margin-bottom: 15px;
}

.feed-post .post-title {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    font-weight: 600;
}

.feed-post .post-title a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.feed-post .post-title a:hover {
    color: var(--primary-color);
}

.feed-post .post-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85em;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.feed-post .post-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.feed-post .post-excerpt {
    margin-top: 15px;
    line-height: 1.6;
    background: transparent;
    border: none;
    padding: 0;
}

.feed-post .post-excerpt p {
    margin-bottom: 15px;
    color: var(--text-color);
    background: transparent;
    font-size: 0.95em;
    font-style: normal;
}

.feed-post .read-more {
    display: inline-block;
    color: var(--link-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
    font-size: 0.9em;
}

.feed-post .read-more:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

/* Responsive layout for smaller screens */
@media (max-width: 768px) {
    .feed-post {
        flex-direction: column;
    }

    .feed-post .post-thumbnail {
        width: 100%;
        height: 250px;
    }
}

/* Comments Section in Feed */
.feed-comments-section {
    margin-bottom: 30px;
    padding: 20px 30px;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-top: none;
}

.feed-comments-section .comments-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.feed-comments-section .comments-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: var(--text-color);
}

.feed-comments-section .comment-count-badge {
    color: var(--text-muted);
    font-weight: normal;
    font-size: 0.9em;
}

.feed-comments-section .comments-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.feed-comments-section .no-comments {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-style: italic;
}

.feed-comments-section .comments-error {
    text-align: center;
    padding: 20px;
    color: var(--error-text, #f87171);
}

.feed-comments-section .comment-form {
    margin-top: 20px;
}

.feed-comments-section .comment-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    background: var(--background-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9em;
    resize: vertical;
}

.feed-comments-section .comment-form input[type="text"],
.feed-comments-section .comment-form input[type="email"] {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: var(--background-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9em;
}

.feed-comments-section .comment-form button {
    padding: 10px 20px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
}

.feed-comments-section .comment-form button:hover {
    opacity: 0.85;
}

.feed-comments-section .existing-comments {
    margin-top: 20px;
}

.feed-comments-section .comment {
    padding: 15px;
    margin-bottom: 15px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.feed-comments-section .comment-author {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 5px;
}

.feed-comments-section .comment-date {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.feed-comments-section .comment-text {
    color: var(--text-color);
    line-height: 1.5;
}

.feed-comments-section .comment-form h4 {
    margin: 20px 0 10px 0;
    color: var(--text-color);
    font-size: 1em;
}

.feed-comments-section .comment-note {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.feed-comments-section .comment-link {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: opacity 0.2s ease;
}

.feed-comments-section .comment-link:hover {
    opacity: 0.85;
    color: #fff;
}

/* Loading Spinner */
.feed-loader {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #666);
}

.feed-loader .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid var(--border-color, #e0e0e0);
    border-top-color: var(--link-color, #0066cc);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Feed section heading */
.feed-section-heading {
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    border-bottom: 2px solid var(--primary-color, #6b5b95);
    padding-bottom: 0.5rem;
}

/* Load More wrapper — centres the button and gives it breathing room */
.load-more-wrapper {
    display: flex;
    justify-content: center;
    margin: 2.5rem 0 1.5rem;
}

/* Load More Button — very visible, hard to miss */
#load-more-btn {
    display: none; /* shown by JS after first 5 posts load */
    padding: 18px 52px;
    background: linear-gradient(135deg, var(--primary-color, #6b5b95), #8e6bbf);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 1.2em;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(107, 91, 149, 0.45);
    transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
    animation: loadMorePulse 2.8s ease-in-out infinite;
}

@keyframes loadMorePulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(107, 91, 149, 0.45); }
    50%       { box-shadow: 0 8px 30px rgba(107, 91, 149, 0.75); }
}

#load-more-btn:hover {
    background: linear-gradient(135deg, #8e6bbf, var(--primary-color, #6b5b95));
    transform: translateY(-3px);
    box-shadow: 0 10px 32px rgba(107, 91, 149, 0.6);
    animation: none; /* stop pulse on hover so the lift feels deliberate */
}

#load-more-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 14px rgba(107, 91, 149, 0.4);
}

/* Related Posts Final Section */
#related-posts-final {
    display: none;
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid var(--border-color, #e0e0e0);
}

/* Error State */
.feed-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--error-color, #d32f2f);
}

/* ============================================================
   ARCHIVE VIEW TOGGLE BAR
   ============================================================ */

.archive-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 36px;
    padding: 16px 20px;
    background: var(--card-background, #f8f9fa);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 10px;
}

.archive-control-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.archive-control-label {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #666);
    margin-right: 4px;
}

.archive-toggle-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1.5px solid var(--border-color, #dee2e6);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-color, #333);
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.archive-toggle-btn:hover {
    border-color: var(--primary-color, #6b5b95);
    color: var(--primary-color, #6b5b95);
    background: var(--primary-alpha-15, rgba(107,91,149,.15));
}

.archive-toggle-btn.active {
    background: var(--primary-color, #6b5b95);
    border-color: var(--primary-color, #6b5b95);
    color: #fff;
}

@media (max-width: 600px) {
    .archive-controls { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   GRID VIEW
   ============================================================ */

.view-grid {
    width: 100%;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    width: 100%;
}

@media (max-width: 900px) {
    .posts-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .posts-grid { grid-template-columns: 1fr; }
}

.grid-card {
    background: var(--card-background, #fff);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.grid-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px var(--shadow-medium, rgba(0,0,0,.15));
    border-color: var(--primary-color, #6b5b95);
}

.grid-card-thumbnail {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: var(--primary-alpha-15, rgba(107,91,149,.15));
    flex-shrink: 0;
}

.grid-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.grid-card:hover .grid-card-thumbnail img {
    transform: scale(1.04);
}

.grid-card-no-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-alpha-20, rgba(107,91,149,.2)), var(--secondary-alpha-25, rgba(136,216,176,.25)));
}

.grid-card-no-thumb a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.grid-card-thumb-letter {
    font-size: 3.5em;
    font-weight: 800;
    color: var(--primary-color, #6b5b95);
    font-family: 'Virgil', cursive, sans-serif;
    opacity: 0.7;
}

.grid-card-body {
    padding: 16px 18px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

.grid-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.grid-card-category {
    display: inline-block;
    padding: 2px 10px;
    background: var(--primary-alpha-15, rgba(107,91,149,.15));
    color: var(--primary-color, #6b5b95);
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.grid-card-date {
    font-size: 0.78em;
    color: var(--text-muted, #888);
}

.grid-card-title {
    margin: 0;
    font-size: 1.05em;
    line-height: 1.35;
    font-weight: 700;
}

.grid-card-title a {
    color: var(--text-color, #222);
    text-decoration: none;
    transition: color 0.18s ease;
}

.grid-card:hover .grid-card-title a {
    color: var(--primary-color, #6b5b95);
}

.grid-card-excerpt {
    margin: 0;
    font-size: 0.88em;
    color: var(--text-muted, #666);
    line-height: 1.55;
    flex: 1;
    /* Clamp to 3 lines */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.grid-card-read-more {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.85em;
    font-weight: 700;
    color: var(--primary-color, #6b5b95);
    text-decoration: none;
    transition: color 0.18s ease;
}

.grid-card-read-more:hover {
    color: var(--link-hover-color, #88d8b0);
    text-decoration: underline;
}

/* ============================================================
   TABLE VIEW
   ============================================================ */

.view-table {
    width: 100%;
}

.posts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.posts-table thead tr {
    background: var(--card-background, #f8f9fa);
    border-bottom: 2px solid var(--primary-color, #6b5b95);
}

.posts-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #666);
}

.posts-table-row {
    border-bottom: 1px solid var(--border-color, #dee2e6);
    transition: background 0.15s ease;
}

.posts-table-row:hover {
    background: var(--hover-background, #f1f3f4);
}

.posts-table-row td {
    padding: 12px 14px;
    vertical-align: middle;
}

.table-col-date {
    white-space: nowrap;
    color: var(--text-muted, #888);
    font-size: 0.85em;
    width: 130px;
}

.table-col-category {
    width: 150px;
}

.table-cat-badge {
    display: inline-block;
    padding: 2px 10px;
    background: var(--primary-alpha-15, rgba(107,91,149,.15));
    color: var(--primary-color, #6b5b95);
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.table-col-title a {
    color: var(--text-color, #222);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.18s ease;
}

.table-col-title a:hover {
    color: var(--primary-color, #6b5b95);
    text-decoration: underline;
}

/* View button column */
.table-col-view {
    width: 80px;
    text-align: right;
    white-space: nowrap;
}

.table-view-btn {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--primary-color, #6b5b95);
    color: #fff;
    font-size: 0.8em;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.18s ease;
}

.table-view-btn:hover {
    opacity: 0.8;
    color: #fff;
}

@media (max-width: 600px) {
    .table-col-date { display: none; }
    .table-col-category { width: auto; }
    .posts-table thead th:first-child { display: none; }
    .table-col-view { width: auto; }
}

/* ── Feed mode: full post body ─────────────────────────────── */
.post-body {
    margin-top: 16px;
    line-height: 1.8;
    color: var(--text-color, #f0f0f0);
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
    margin-top: 1.6em;
    margin-bottom: 0.5em;
    color: var(--text-color, #f0f0f0);
}

/* Feed post body — inherit theme colours so dark/light mode both look correct */
.feed-post .post-body {
    color: var(--text-color);
}
.feed-post .post-body h1,
.feed-post .post-body h2,
.feed-post .post-body h3,
.feed-post .post-body h4,
.feed-post .post-body h5,
.feed-post .post-body h6 {
    color: var(--text-color);
}
.feed-post .post-body p,
.feed-post .post-body li,
.feed-post .post-body td,
.feed-post .post-body th {
    color: var(--text-color);
}
.feed-post .post-body blockquote {
    color: var(--text-muted);
    border-left-color: var(--primary-color);
    font-style: italic;
}
.feed-post .post-body a {
    color: var(--link-color);
}
.feed-post .post-body a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}
.feed-post .post-body code,
.feed-post .post-body pre {
    background: var(--code-background);
    color: var(--text-color);
}

.post-body p {
    margin-bottom: 1em;
}

.post-body a {
    color: var(--link-color, #a991e5);
}

.post-body a:hover {
    color: var(--link-hover-color, #c2e59c);
    text-decoration: underline;
}

.post-body img {
    max-width: 100%;
    border-radius: 8px;
    margin: 12px auto;
    display: block;
}

.post-body figure {
    display: block;
    margin: 1.2em auto;
    text-align: center;
}

.post-body figcaption {
    color: var(--text-muted, #bbb);
    font-size: 0.85em;
    margin-top: 0.4em;
    font-style: italic;
}

.post-body blockquote {
    border-left: 4px solid var(--primary-color, #6b5b95);
    margin: 1em 0;
    padding: 0.5em 1em;
    color: var(--text-muted, #bbb);
    font-style: italic;
}

.post-body code {
    background: var(--card-background, #333);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.post-body pre {
    background: var(--card-background, #333);
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
}



/* ── Admin edit links (visible only when IS_ADMIN is true) ───────────────── */
.admin-edit-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78em;
    font-weight: 700;
    color: #000 !important;
    background: #c89b3c;
    padding: 2px 8px;
    border-radius: 4px;
    text-decoration: none !important;
    white-space: nowrap;
    transition: background 0.15s;
}
.admin-edit-link:hover {
    background: #dbb04c !important;
    color: #000 !important;
}
/* In the table view the edit column is narrow */
.table-col-edit { width: 80px; text-align: center; }

/* ── Feed admin action bar (Flag / Edit / Push Down) ──────────────────────── */
.feed-admin-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0 10px;
    border-bottom: 1px solid var(--border-color, #444);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.feed-admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78em;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    font-family: inherit;
}

.feed-admin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Edit — golden, matches the existing admin-edit-link */
a.feed-admin-btn.feed-admin-edit {
    color: #000 !important;
    background: #c89b3c;
}
a.feed-admin-btn.feed-admin-edit:hover {
    background: #dbb04c;
}

/* Flag — blue; turns amber when flagged */
.feed-admin-flag {
    color: #000 !important;
    background: #6b9fd4;
}
.feed-admin-flag:hover { background: #82b3e8; }
.feed-admin-flag.is-flagged {
    background: #f0a030;
    color: #000 !important;
}

/* Push Down — muted red */
.feed-admin-push {
    color: #fff !important;
    background: #c06070;
}
.feed-admin-push:hover { background: #d07080; }
