/* /app/static/significantstories_com/css/toc-feed.css */
/* Feed View - Chronological article feed with chips */

/* --- Feed Content Container --- */
.feed-content {
    max-width: 680px;
    margin: 0 auto;
}

.feed-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- Feed Chip (Article Card) --- */
.feed-chip {
    background-color: #ffffff;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.feed-chip:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #d0d0d0;
}

/* --- Feed Chip Header --- */
.feed-chip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.feed-chip-context {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
}

.feed-chip-series {
    font-size: 0.75rem;
    font-weight: 600;
    color: #3498db;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.feed-chip-topic {
    font-size: 0.75rem;
    font-weight: 500;
    color: #7f8c8d;
}

.feed-chip-series + .feed-chip-topic::before {
    content: "·";
    margin-right: 0.375rem;
    color: #bdc3c7;
}

/* --- Feed Chip Actions --- */
.feed-chip-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.feed-chip-reading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.feed-chip-reading-state svg {
    width: 16px;
    height: 16px;
}

/* Reading state colors */
.feed-chip-reading-state.not_started svg {
    stroke: #bdc3c7;
    fill: none;
}

.feed-chip-reading-state.in_progress svg .check {
    stroke: #95a5a6;
}
.feed-chip-reading-state.in_progress svg .box {
    stroke: #95a5a6;
    fill: none;
}

.feed-chip-reading-state.finished svg .check {
    stroke: #27ae60;
}
.feed-chip-reading-state.finished svg .box {
    stroke: #27ae60;
    fill: none;
}

/* Favorite button */
.feed-chip-favorite {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: #bdc3c7;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.feed-chip-favorite:hover {
    color: #d4a537;
    background: rgba(212, 165, 55, 0.1);
}

.feed-chip-favorite.favorited {
    color: #d4a537;
}

.feed-chip-favorite.favorited .star-icon polygon {
    fill: #d4a537;
}

/* Book button */
.feed-chip-book {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: #bdc3c7;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.feed-chip-book:hover {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.feed-chip-book.in-books {
    color: #3498db;
}

.feed-chip-book.in-books .bookmark-icon path {
    fill: #3498db;
}

/* --- Feed Chip Link (Title + Preview) --- */
.feed-chip-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.feed-chip-link:hover {
    text-decoration: none;
}

.feed-chip-title {
    font-family: var(--serif-font);
    font-size: 1.125rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 0.375rem 0;
    line-height: 1.35;
    transition: color 0.2s ease;
}

.feed-chip-link:hover .feed-chip-title {
    color: #3498db;
}

.feed-chip-preview {
    font-size: 0.9rem;
    color: #5a6a7a;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Feed Chip Practices --- */
.feed-chip-practices {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f0f3f6;
}

.feed-chip-practice {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    background-color: #f8f5f0;
    color: #8b7355;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.feed-chip-practice:hover {
    background-color: #efe9df;
    color: #6b5a45;
    text-decoration: none;
}

.feed-chip-practice-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.feed-chip-practice-icon svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.feed-chip-practice-name {
    line-height: 1.2;
    pointer-events: none;
}

/* Practice tooltip - matches article tooltip style */
.feed-practice-tooltip {
    position: fixed;
    display: none;
    width: 280px;
    padding: 1rem;
    background-color: #f5f2ee;
    border: 1px solid #e8e4df;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    text-align: center;
    pointer-events: none;
}

.feed-practice-tooltip-title {
    font-family: var(--serif-font);
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.feed-practice-tooltip-description {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #5a6a7a;
}

.feed-practice-tooltip-link {
    display: inline-block;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #8b7355;
    text-decoration: none;
    font-weight: 500;
    pointer-events: auto;
}

.feed-practice-tooltip-link:hover {
    text-decoration: underline;
}

/* Tooltip arrow */
.feed-practice-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #f5f2ee;
    border-bottom: none;
}

.feed-practice-tooltip::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border: 9px solid transparent;
    border-top-color: #e8e4df;
    border-bottom: none;
}

/* --- Feed Loading Trigger & Spinner --- */
.feed-load-trigger {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0;
}

.feed-loading-spinner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.spinner-icon {
    animation: feed-spin 1s linear infinite;
}

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

/* --- Feed End Marker --- */
.feed-end-marker {
    text-align: center;
    padding: 1.5rem 0;
    color: #95a5a6;
    font-size: 0.875rem;
    font-style: italic;
}

/* --- Feed Empty State --- */
.feed-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #7f8c8d;
}

.feed-empty-state p {
    margin: 0;
    font-size: 1rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .feed-content {
        padding: 0;
    }

    .feed-chip {
        padding: 0.875rem 1rem;
        border-radius: 10px;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    .feed-chip-title {
        font-size: 1rem;
    }

    .feed-chip-preview {
        font-size: 0.85rem;
        -webkit-line-clamp: 3;
    }

    .feed-chip-series {
        font-size: 0.7rem;
    }

    .feed-chip-topic {
        font-size: 0.7rem;
    }

    .feed-chip-practices {
        gap: 0.5rem;
        margin-top: 0.625rem;
        padding-top: 0.625rem;
    }

    .feed-chip-practice {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }

    .feed-chip-practice-icon {
        width: 16px;
        height: 16px;
    }

    .feed-chip-practice-icon svg {
        width: 14px;
        height: 14px;
    }

    .view-switcher {
        margin-bottom: 1rem;
    }
}

/* --- Guest Mode Styling --- */
body.guest-user .feed-chip-favorite,
body.guest-user .feed-chip-book {
    opacity: 0.4;
}

body.guest-user .feed-chip-favorite:hover,
body.guest-user .feed-chip-book:hover {
    opacity: 0.6;
}

body.guest-user .feed-chip-reading-state {
    opacity: 0.4;
}

/* --- Publish State Badge in Feed --- */
.feed-chip-title .publish-state-badge {
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Animation for favorite toggle */
@keyframes feed-favorite-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.feed-chip-favorite.animating .star-icon {
    animation: feed-favorite-pulse 0.3s ease;
}

/* =============================================================================
   PUBLISH STATE STYLING (Early/Preview content)
   ============================================================================= */

/* Combined: Background Tint + Left Border Accent */
.feed-chip.state-early {
    background: linear-gradient(135deg, #f6faf5 0%, #eef4ec 100%);
    border-left: 4px solid #9ab392;
}

.feed-chip.state-preview {
    background: linear-gradient(135deg, #f4faf9 0%, #e8f4f2 100%);
    border-left: 4px solid #7dbdb4;
}

/* ============================================
   FEED ARTICLE MODAL
   ============================================ */

/* Overlay */
.feed-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.feed-modal-overlay:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
}

/* Modal Container */
.feed-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.feed-modal:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* Close button */
.feed-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #5a6a7a;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: all 0.15s ease;
}

.feed-modal-close:hover {
    background: #ffffff;
    color: #2c3e50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Preview image */
.feed-modal-image {
    width: 100%;
    max-height: 200px;
    overflow: hidden;
    background-color: #f0f3f6;
}

.feed-modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Modal content */
.feed-modal-content {
    padding: 1.5rem;
    overflow-y: auto;
}

/* Context (Series + Topic) */
.feed-modal-context {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.feed-modal-series {
    font-size: 0.8rem;
    font-weight: 600;
    color: #3498db;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.feed-modal-topic {
    font-size: 0.8rem;
    font-weight: 500;
    color: #7f8c8d;
}

.feed-modal-series + .feed-modal-topic::before {
    content: "·";
    margin-right: 0.5rem;
    color: #bdc3c7;
}

/* Title */
.feed-modal-title {
    font-family: var(--serif-font);
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 0.75rem 0;
    line-height: 1.3;
}

/* Preview text */
.feed-modal-preview {
    font-size: 0.95rem;
    color: #5a6a7a;
    line-height: 1.6;
    margin: 0 0 1rem 0;
}

/* Practices */
.feed-modal-practices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.feed-modal-practices:empty {
    display: none;
}

.feed-modal-practice {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
    background-color: #f8f5f0;
    color: #8b7355;
    font-size: 0.8rem;
    font-weight: 500;
}

.feed-modal-practice-icon {
    display: flex;
    align-items: center;
    width: 16px;
    height: 16px;
}

.feed-modal-practice-icon svg {
    width: 14px;
    height: 14px;
}

/* Reading status icon in modal footer */
.feed-modal-status {
    cursor: default;
}

.feed-modal-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.feed-modal-status-icon svg {
    width: 20px;
    height: 20px;
}

/* Reading state colors in modal */
.feed-modal-status.not_started {
    color: #bdc3c7;
}
.feed-modal-status.not_started .feed-modal-status-icon svg {
    stroke: #bdc3c7;
}

.feed-modal-status.in_progress {
    color: #f39c12;
    background-color: rgba(243, 156, 18, 0.1);
}
.feed-modal-status.in_progress .feed-modal-status-icon svg .check {
    stroke: #f39c12;
}
.feed-modal-status.in_progress .feed-modal-status-icon svg .box {
    stroke: #f39c12;
}

.feed-modal-status.finished {
    color: #27ae60;
    background-color: rgba(39, 174, 96, 0.1);
}
.feed-modal-status.finished .feed-modal-status-icon svg .check {
    stroke: #27ae60;
}
.feed-modal-status.finished .feed-modal-status-icon svg .box {
    stroke: #27ae60;
}

/* Action buttons */
.feed-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feed-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.feed-modal-btn-primary {
    background-color: #3498db;
    color: #ffffff;
}

.feed-modal-btn-primary:hover {
    background-color: #2980b9;
    text-decoration: none;
    color: #ffffff;
}

.feed-modal-secondary-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.feed-modal-btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    background-color: #f8f9fa;
    color: #7f8c8d;
    border-radius: 50%;
}

.feed-modal-btn-icon:hover {
    background-color: #ecf0f1;
    color: #5a6a7a;
}

/* Favorite button states in modal */
.feed-modal-btn-icon.favorited {
    color: #d4a537;
    background-color: rgba(212, 165, 55, 0.1);
}

.feed-modal-btn-icon.favorited .star-icon polygon {
    fill: #d4a537;
}

/* Book button states in modal */
.feed-modal-btn-icon.in-books {
    color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
}

.feed-modal-btn-icon.in-books .bookmark-icon path {
    fill: #3498db;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .feed-modal {
        width: 100%;
        max-width: none;
        max-height: 90vh;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translateY(100%);
        border-radius: 20px 20px 0 0;
    }

    .feed-modal:not([hidden]) {
        transform: translateY(0);
    }

    .feed-modal-content {
        padding: 1.25rem;
    }

    .feed-modal-title {
        font-size: 1.25rem;
    }

    .feed-modal-close {
        top: 0.5rem;
        right: 0.5rem;
    }
}
