/* /app/static/significantstories_com/css/toc.css */
/* Stories page - Series, Topics, and Articles listing */

/* --- Page Header with Animated Logo --- */
.page-header-with-logo {
    position: relative;
    overflow: visible;
    margin-bottom: 1rem;
}

.page-header-with-logo h1,
.page-header-with-logo .page-subtitle {
    position: relative;
    z-index: 1;
}

.page-header-logo {
    position: absolute;
    top: 40%;
    left: 75%;
    transform: translate(-50%, -50%);
    height: 100%;
    max-width: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.page-header-logo .site-logo {
    width: auto;
    height: 100%;
    max-height: 110px;
}

.page-header-logo .logo-star {
    fill: #3498db;
    opacity: 0.08;
    transition: opacity 1.2s ease-out, fill 1.2s ease-out;
}

.page-header-logo .logo-star.animate-to-gold {
    fill: #d4a537;
    opacity: 0.35;
}

.page-header-logo .logo-flourish {
    fill: #3498db;
    opacity: 0.08;
    clip-path: inset(100% 0 0 0);
    animation: reveal-flourish 2s ease-out 0.3s forwards;
}

@keyframes reveal-flourish {
    to {
        clip-path: inset(0 0 0 0);
    }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .page-header-logo .logo-flourish {
        animation: none;
        clip-path: none;
    }
    .page-header-logo .logo-star {
        transition: none;
        fill: #d4a537;
        opacity: 0.35;
    }
}

/* --- View Toggle Pill --- */
.page-header-with-toggle {
    position: relative;
}

.view-toggle-pill {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    background-color: #f0f3f6;
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
    z-index: 2;
}

.view-toggle-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border-radius: 16px;
    color: #95a5a6;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.view-toggle-option:hover:not(.active) {
    color: #5a6a7a;
    background-color: rgba(0, 0, 0, 0.05);
}

.view-toggle-option.active {
    background-color: #ffffff;
    color: #3498db;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: default;
}

.view-toggle-option svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .view-toggle-pill {
        padding: 2px;
        /* Center vertically with the title on mobile */
        top: 1rem;
        transform: translateY(0);
    }

    .view-toggle-option {
        width: 28px;
        height: 24px;
    }

    .view-toggle-option svg {
        width: 14px;
        height: 14px;
    }
}

/* --- Stories Content Container --- */
.stories-content {
    max-width: 800px;
    margin: 0 auto;
}

/* --- Series Card --- */
.series-card {
    background-color: #ffffff;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 16px;
    margin-bottom: 1.5rem;
    padding: 1.75rem 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.series-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

/* --- Series Header --- */
.series-header {
    margin-bottom: 1rem;
}

.series-title-row {
    display: grid;
    grid-template-columns: 28px 1fr 28px;
    align-items: center;
    gap: 0.5rem;
}

.series-header h2 {
    font-family: var(--serif-font);
    font-size: 1.5rem;
    color: #2c3e50;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    text-align: center;
    grid-column: 2;
}

.series-header .series-description {
    font-size: 0.95rem;
    color: #5a6a7a;
    text-align: center;
    line-height: 1.5;
    /* Align within center column with extra padding */
    margin: 0 calc(28px + 2.5rem) 0.75rem calc(28px + 2.5rem);
}

/* --- Series Expand Button --- */
.series-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    grid-column: 3;
}

.series-expand-btn:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.series-expand-icon {
    font-size: 1.25rem;
    font-weight: 300;
    color: #95a5a6;
    transition: transform 0.3s ease, color 0.2s ease;
    line-height: 1;
}

.series-expand-btn:hover .series-expand-icon {
    color: #3498db;
}

.series-expand-btn[aria-expanded="true"] .series-expand-icon {
    transform: rotate(45deg);
    color: #3498db;
}

/* --- Series View Toggle Button --- */
.series-view-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    grid-column: 1;
    color: #95a5a6;
}

.series-view-toggle:hover {
    background-color: rgba(52, 152, 219, 0.1);
    color: #3498db;
}

/* Series view toggle tooltip */
.series-view-tooltip {
    display: none;
    position: fixed;
    padding: 0.4rem 0.7rem;
    background-color: #f5f2ee;
    color: #5a6a7a;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    border: 1px solid #e8e4df;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    pointer-events: none;
}

/* Show current view icon (list icon in list view, cards icon in card view) */
.series-view-toggle[data-view="list"] .view-icon-list {
    display: block;
}

.series-view-toggle[data-view="list"] .view-icon-cards {
    display: none;
}

.series-view-toggle[data-view="cards"] .view-icon-cards {
    display: block;
}

.series-view-toggle[data-view="cards"] .view-icon-list {
    display: none;
}

/* --- Series View Containers --- */
.series-view-list,
.series-view-cards {
    /* Default visible */
}

.series-view-list[hidden],
.series-view-cards[hidden] {
    display: none;
}

/* Hide expand button when in card view */
.series-card[data-view="cards"] .series-expand-btn {
    visibility: hidden;
}

.series-header p {
    font-size: 0.95rem;
    color: #5a6a7a;
    margin: 0;
    line-height: 1.5;
}

/* --- Topics Container --- */
.topics-container {
    border-top: 1px solid #ecf0f1;
    padding-top: 0.5rem;
}

/* --- Topic Accordion --- */
.topic-accordion {
    border-bottom: 1px solid #f0f3f6;
}

.topic-accordion:last-child {
    border-bottom: none;
}

.topic-accordion-header {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    padding: 1rem 0.5rem;
    font-size: 1.05rem;
    font-family: var(--primary-font);
    font-weight: 500;
    color: #34495e;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color 0.2s ease;
    border-radius: 8px;
}

.topic-accordion-header:hover {
    color: #3498db;
}

.topic-accordion-icon {
    font-size: 1.25rem;
    font-weight: 300;
    color: #95a5a6;
    transition: transform 0.3s ease;
    width: 24px;
    text-align: center;
}

.topic-accordion-header.active .topic-accordion-icon {
    transform: rotate(45deg);
    color: #3498db;
}

/* --- Topic Accordion Content --- */
.topic-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    padding: 0 0.5rem;
}

/* --- Article List --- */
.article-list {
    list-style: none;
    padding: 0.5rem 0 1.25rem 1.25rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-left: 2px solid #e8eef3;
}

.article-list li {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    background-color: #f0f4f8;
    transition: all 0.2s ease;

    /* Animation initial state */
    opacity: 0;
    transform: translateY(8px);
}

.article-list li.visible {
    opacity: 1;
    transform: translateY(0);
}

.article-list li:hover {
    background-color: #e8f4fc;
}

.article-list li a {
    color: #34495e;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.article-list li:hover a {
    color: #3498db;
}

/* --- Start Badge --- */
.start-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    margin-left: 0.75rem;
}

.start-badge.start-here {
    background-color: #d4edda;
    color: #155724;
}

.start-badge.or-here {
    background-color: #fff3cd;
    color: #856404;
}

/* --- Behind Stories Link --- */
.series-header .behind-stories-link {
    display: block;
    text-align: center;
    margin-top: 1rem;
    padding: 0.6rem 1.25rem;
    background-color: #fdf6e3;
    border: 1px solid #e6d9b8;
    border-radius: 8px;
    font-size: 0.9rem;
    font-style: italic;
    color: #8b7355;
    text-decoration: none;
    transition: all 0.2s ease;
}

.series-header .behind-stories-link:hover {
    background-color: #f5edd6;
    border-color: #c9b896;
    color: #6b5a45;
    text-decoration: none;
}

/* Cards view header */
.series-card-header .behind-stories-link {
    display: block;
    text-align: center;
    margin-top: 1rem;
    padding: 0.6rem 1.25rem;
    background-color: #fdf6e3;
    border: 1px solid #e6d9b8;
    border-radius: 8px;
    font-size: 0.9rem;
    font-style: italic;
    color: #8b7355;
    text-decoration: none;
    transition: all 0.2s ease;
}

.series-card-header .behind-stories-link:hover {
    background-color: #f5edd6;
    border-color: #c9b896;
    color: #6b5a45;
    text-decoration: none;
}

/* --- Page Header Controls --- */
.page-header-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.page-header-controls .layout-toggle {
    margin-top: 0;
}

/* --- Expand All Button --- */
.expand-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #5a6a7a;
    text-decoration: none;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.expand-all-btn:hover {
    color: #3498db;
    border-color: #3498db;
    background-color: #f0f7fc;
}

.expand-all-btn[aria-expanded="true"] {
    color: #3498db;
    border-color: #3498db;
    background-color: #e8f4fc;
}

.expand-all-btn[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.expand-all-btn svg {
    opacity: 0.7;
    transition: transform 0.2s ease;
}

/* --- Practices Toggle Button --- */
.practices-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #5a6a7a;
    text-decoration: none;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.practices-toggle-btn:hover {
    color: #3498db;
    border-color: #3498db;
    background-color: #f0f7fc;
}

.practices-toggle-btn[aria-expanded="true"] {
    color: #3498db;
    border-color: #3498db;
    background-color: #e8f4fc;
}

.practices-toggle-btn svg {
    opacity: 0.7;
}

.practices-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.7rem;
    font-weight: 600;
    background-color: #e0e0e0;
    color: #5a6a7a;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.practices-toggle-btn[aria-expanded="true"] .practices-badge {
    background-color: #3498db;
    color: #ffffff;
}

/* --- Practices Selection Area (Expandable) --- */
.practices-selection {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
}

.practices-selection[hidden] {
    display: none;
}

.practices-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.75rem 0.5rem;
    width: 100%;
}

.practices-selection-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e8e8e8;
}

/* --- Practice Option (Individual Practice in Selection) --- */
.practice-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    position: relative;
    min-width: 0; /* Allow text truncation */
}

.practice-option-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: #95a5a6;
    background-color: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.practice-option-btn:hover {
    border-color: #b8d4e8;
    opacity: 1;
}

.practice-option-btn.selected {
    color: #8b7355;
    background-color: #fdf6e3;
    border-color: #c9b896;
    opacity: 1;
}

.practice-option-btn.selected:hover {
    background-color: #f5edd6;
    border-color: #a89770;
}

.practice-option-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.practice-option-icon svg {
    width: 18px;
    height: 18px;
}

.practice-option-name {
    font-size: 0.65rem;
    font-weight: 500;
    color: #7f8c8d;
    text-align: center;
    width: 100%;
    max-width: 70px;
    line-height: 1.2;
    cursor: pointer;
    transition: color 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.practice-option-name:hover {
    color: #3498db;
}

.practice-option:has(.practice-option-btn.selected) .practice-option-name {
    color: #8b7355;
}

/* --- Practice Description Tooltip --- */
.practice-tooltip {
    position: fixed;
    z-index: 1000;
    max-width: 280px;
    padding: 1rem;
    background-color: #f5f2ee;
    border: 1px solid #e8e4df;
    color: #5a6a7a;
    font-size: 0.9rem;
    line-height: 1.5;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    text-align: center;
}

.practice-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

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

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

/* --- Action Buttons (Clear All / Select All) --- */
.practices-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #7f8c8d;
    background-color: transparent;
    border: 1px solid #dcdfe4;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.practices-action-btn:hover {
    color: #3498db;
    border-color: #3498db;
    background-color: #f0f7fc;
}

.practices-action-btn svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.practices-action-btn:hover svg {
    opacity: 1;
}

/* Legacy class for backwards compatibility */
.practices-clear-btn {
    display: none;
}

/* --- Practice Filter Tooltip (description on hover) --- */
.practice-filter-tooltip {
    display: none;
    position: fixed;
    max-width: 250px;
    padding: 0.5rem 0.75rem;
    background-color: #f5f2ee;
    color: #5a6a7a;
    font-size: 0.8rem;
    line-height: 1.4;
    border-radius: 6px;
    border: 1px solid #e8e4df;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    pointer-events: none;
    text-align: center;
}

/* --- Practices Empty State --- */
.practices-empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #7f8c8d;
    font-size: 0.95rem;
}

.practices-empty-state[hidden] {
    display: none;
}

.practices-reset-link {
    color: #3498db;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.practices-reset-link:hover {
    color: #2980b9;
}

/* --- Topic Practice Icons --- */
.topic-practices {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: auto;
    margin-right: 0.5rem;
}

.topic-practice-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: #8b7355;
    opacity: 0.7;
}

.topic-practice-icon svg {
    width: 18px;
    height: 18px;
}

/* --- Article Practice Icons (List View) --- */
.article-practices {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: 0.5rem;
    position: relative;
    z-index: 5;
}

.article-practice-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #8b7355;
    opacity: 0.6;
    position: relative;
    cursor: pointer;
    z-index: 10;
    pointer-events: auto !important;
}

.article-practice-icon svg {
    width: 16px;
    height: 16px;
    pointer-events: none; /* Let parent handle events */
}


/* --- Filtered Out State (both practice and reading filters use hide behavior) --- */
.topic-accordion.filtered-out,
.article-item.filtered-out,
.article-card.filtered-out,
.series-card.filtered-out {
    display: none !important;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .series-card {
        padding: 1.25rem 1rem;
        margin-bottom: 1rem;
        border-radius: 12px;
    }

    .series-header h2 {
        font-size: 1.35rem;
    }

    .series-header .series-description {
        /* Tighter margins on mobile */
        margin: 0 calc(28px + 0.5rem) 0.75rem calc(28px + 0.5rem);
    }

    .topic-accordion-header {
        padding: 0.875rem 0.25rem;
        font-size: 1rem;
    }

    .article-list li {
        padding: 0.5rem 0.75rem;
    }

    .article-list li a {
        font-size: 0.9rem;
    }

    /* Practices selection - mobile layout */
    .practices-selection {
        padding: 0.75rem;
    }

    .practices-selection-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 0.5rem 0.25rem;
    }

    .practice-option-btn {
        width: 32px;
        height: 32px;
    }

    .practice-option-icon svg {
        width: 16px;
        height: 16px;
    }

    .practice-option-name {
        font-size: 0.6rem;
        max-width: 50px;
    }

    .practices-selection-actions {
        padding-top: 0.375rem;
    }

    .practices-action-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.7rem;
    }

    .practices-action-btn svg {
        width: 12px;
        height: 12px;
    }

    /* Filter bar - mobile layout */
    .filter-bar {
        gap: 0.375rem;
    }

    .filter-chip {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
    }

    .filter-divider {
        display: none;
    }
}

/* --- Reading State Icons --- */
/* Icon strategy: empty box (unread), grey check in box (in progress), green check in box (completed) */

.reading-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    vertical-align: middle;
    flex-shrink: 0;
}

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

/* Unread: empty box */
.reading-state-icon.not_started svg {
    stroke: #bdc3c7;
    fill: none;
}

/* In Progress: grey checkmark in box */
.reading-state-icon.in_progress svg .check {
    stroke: #95a5a6;
}
.reading-state-icon.in_progress svg .box {
    stroke: #95a5a6;
    fill: none;
}

/* Completed: green checkmark in box */
.reading-state-icon.finished svg .check {
    stroke: #27ae60;
}
.reading-state-icon.finished svg .box {
    stroke: #27ae60;
    fill: none;
}

/* List view layout */
.article-item {
    display: flex;
    align-items: center;
}

.article-item > .reading-state-icon {
    flex-shrink: 0;
}

.article-item > a {
    flex-shrink: 0;
}

/* Star is inside the title link - appears right after title text */
.article-item a .favorite-state-icon {
    margin-left: 0.35rem;
}

.article-item > .article-practices {
    margin-left: auto;
}

/* --- Reading State Tooltips --- */

.reading-state-icon {
    position: relative;
    cursor: pointer;
}

/* Reading state tooltip - matches practice tooltip style */
.reading-state-tooltip {
    display: none;
    position: fixed;
    padding: 0.4rem 0.7rem;
    background-color: #f5f2ee;
    color: #5a6a7a;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    border: 1px solid #e8e4df;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    pointer-events: none;
}

/* Tooltip display controlled by JavaScript */

/* --- Practice Icon Tooltips on TOC --- */

.article-practice-icon,
.article-card-practice-icon,
.topic-practice-icon,
.topic-tab-practice-icon {
    position: relative;
    cursor: pointer;
}

.practice-tooltip-mini {
    display: none;
    position: fixed;
    padding: 0.4rem 0.7rem;
    background-color: #f5f2ee;
    color: #5a6a7a;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    border: 1px solid #e8e4df;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    pointer-events: none;
}

/* Arrows removed - fixed positioning makes alignment unreliable */

/* Tooltip display is controlled by JavaScript for proper fixed positioning */

/* --- Unified Filter Bar --- */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2.5rem;
    padding: 0.5rem 0 0 0;
}

.filter-label {
    font-size: 0.85rem;
    color: #5a6a7a;
    font-weight: 500;
}

.filter-divider {
    width: 1px;
    height: 24px;
    background-color: #dcdfe4;
    margin: 0 0.25rem;
}

/* Unified filter chip (reading + practices toggle) */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    background-color: #f0f3f6;
    border: 1px solid #dcdfe4;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #5a6a7a;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip:hover {
    background-color: #e8ebed;
    border-color: #cacfd6;
}

.filter-chip-icon {
    flex-shrink: 0;
}

/* Default stroke colors for reading filter types */
.filter-chip[data-filter="not_started"] .filter-chip-icon {
    stroke: #bdc3c7;
}

.filter-chip[data-filter="in_progress"] .filter-chip-icon {
    stroke: #95a5a6;
}

.filter-chip[data-filter="finished"] .filter-chip-icon {
    stroke: #27ae60;
}

/* Favorites filter chip */
.filter-chip-favorites .filter-chip-icon {
    stroke: #d4a537;
}

.filter-chip-favorites[aria-pressed="true"] {
    background-color: #d4a537;
    border-color: #b8922f;
    color: #ffffff;
}

.filter-chip-favorites[aria-pressed="true"] .filter-chip-icon {
    stroke: #ffffff;
    fill: #ffffff;
}

/* Active states for reading filters */
.filter-chip[aria-pressed="true"] {
    color: #ffffff;
}

.filter-chip[aria-pressed="true"] .filter-chip-icon {
    stroke: #ffffff;
}

.filter-chip[data-filter="not_started"][aria-pressed="true"] {
    background-color: #bdc3c7;
    border-color: #95a5a6;
}

.filter-chip[data-filter="in_progress"][aria-pressed="true"] {
    background-color: #95a5a6;
    border-color: #7f8c8d;
}

.filter-chip[data-filter="finished"][aria-pressed="true"] {
    background-color: #27ae60;
    border-color: #1e8449;
}

/* Practices toggle chip */
.filter-chip-toggle {
    padding-right: 0.5rem;
}

.filter-chip-toggle[aria-expanded="true"] {
    background-color: #fdf6e3;
    border-color: #c9b896;
    color: #8b7355;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.3rem;
    font-size: 0.65rem;
    font-weight: 600;
    background-color: #e0e0e0;
    color: #5a6a7a;
    border-radius: 10px;
    margin-left: 0.25rem;
    transition: all 0.2s ease;
}

.filter-chip-toggle[aria-expanded="true"] .filter-badge {
    background-color: #8b7355;
    color: #ffffff;
}

/* Clear all filters button */
.filter-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.6rem;
    background-color: transparent;
    border: 1px solid #dcdfe4;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}

.filter-clear-btn:hover {
    color: #e74c3c;
    border-color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.05);
}

.filter-clear-btn[hidden] {
    display: none;
}

.filter-clear-btn svg {
    opacity: 0.7;
}

.filter-clear-btn:hover svg {
    opacity: 1;
}

/* Empty state for filters */
.filter-empty-state {
    padding: 1rem;
    text-align: center;
    color: #5a6a7a;
    font-size: 0.9rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.filter-empty-state[hidden] {
    display: none;
}

.filter-reset-link {
    color: #3498db;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.filter-reset-link:hover {
    color: #2980b9;
}

/* Hidden articles when filtered */
.article-item.reading-filtered,
.article-card.reading-filtered,
.article-card-wrapper.reading-filtered {
    display: none !important;
}

/* Hidden topics when all articles are filtered */
.topic-accordion.reading-filtered,
.topic-tab.reading-filtered,
.articles-grid.reading-filtered {
    display: none !important;
}

/* Hidden series when all topics are filtered */
.series-card.reading-filtered {
    display: none !important;
}

/* Guest mode - reading/favorites features appear muted to indicate they're promotional */
body.guest-user .filter-chip[data-filter-type="reading"],
body.guest-user .filter-chip[data-filter-type="favorites"] {
    opacity: 0.5;
    cursor: pointer;
}

body.guest-user .filter-chip[data-filter-type="reading"]:hover,
body.guest-user .filter-chip[data-filter-type="favorites"]:hover {
    opacity: 0.7;
    background-color: #f0f0f0;
}

body.guest-user .reading-state-icon {
    opacity: 0.4;
    cursor: pointer;
}

body.guest-user .reading-state-icon:hover {
    opacity: 0.6;
}

/* --- Favorite State Icons (display-only) --- */

.favorite-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 0.25rem;
    vertical-align: middle;
    position: relative;
    top: -0.08em;
    flex-shrink: 0;
    color: #d4a537;
    cursor: default;
}

.favorite-state-icon svg {
    width: 14px;
    height: 14px;
}

/* Card view: position after title (ordering in toc-cards.css) */
.article-card .favorite-state-icon {
    flex-shrink: 0;
}

/* Favorite tooltip - matches reading state tooltip style */
.favorite-state-tooltip {
    display: none;
    position: fixed;
    padding: 0.4rem 0.7rem;
    background-color: #fdf6e3;
    color: #8b7355;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    border: 1px solid #e6d9b8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    pointer-events: none;
}

/* =============================================================================
   TOC ACTION BUTTONS (Favorite + Bookmark toggles)
   ============================================================================= */

/* List View: Actions container - positioned right after title */
.article-item-actions {
    display: flex;
    align-items: center;
    gap: 0;
    margin-left: 0.125rem;
    flex-shrink: 0;
}

/* Card View: Wrapper is the flex container with card styling */
.article-card-wrapper {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    background-color: #f0f4f8;
    border-radius: 8px;
    transition: all 0.2s ease;
    gap: 0.25rem;
}

.article-card-wrapper:hover {
    background-color: #e8f4fc;
}

/* Card View: Actions container - inline after title */
.article-card-actions {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

/* Shared button base styles for TOC toggles */
.toc-favorite-toggle,
.toc-book-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    color: #bdc3c7;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.toc-favorite-toggle:hover,
.toc-book-toggle:hover {
    background: rgba(52, 152, 219, 0.1);
}

/* Favorite toggle states */
.toc-favorite-toggle:hover {
    color: #d4a537;
}

.toc-favorite-toggle.favorited {
    color: #d4a537;
}

.toc-favorite-toggle.favorited:hover {
    color: #b8922f;
}

/* Book toggle states */
.toc-book-toggle:hover {
    color: #3498db;
}

.toc-book-toggle.in-books {
    color: #3498db;
}

.toc-book-toggle.in-books:hover {
    color: #2980b9;
}

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

.toc-favorite-toggle.animating .star-icon {
    animation: toc-favorite-pulse 0.3s ease;
}

/* Guest mode: show buttons but muted */
body.guest-user .toc-favorite-toggle,
body.guest-user .toc-book-toggle {
    opacity: 0.4;
}

body.guest-user .toc-favorite-toggle:hover,
body.guest-user .toc-book-toggle:hover {
    opacity: 0.6;
}

/* Keep article-item flex layout with actions before practices */
.article-item {
    display: flex;
    align-items: center;
}

.article-item > .reading-state-icon {
    flex-shrink: 0;
}

.article-item > .article-item-link {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-item > .article-item-actions {
    flex-shrink: 0;
}

.article-item > .article-practices {
    flex-shrink: 0;
    margin-left: auto;
}

/* Responsive adjustments for TOC action buttons */
@media (max-width: 768px) {
    /* Smaller toggle buttons on mobile */
    .toc-favorite-toggle,
    .toc-book-toggle {
        width: 18px;
        height: 18px;
    }

    .toc-favorite-toggle svg,
    .toc-book-toggle svg {
        width: 14px;
        height: 14px;
    }

    /* Tighter reading state icon margin */
    .reading-state-icon {
        width: 16px;
        height: 16px;
        margin-right: 0.25rem;
    }

    .reading-state-icon svg {
        width: 14px;
        height: 14px;
    }

    /* Tighter card wrapper spacing */
    .article-card-wrapper {
        padding: 0.5rem 0.625rem;
        gap: 0.125rem;
    }

    /* Tighter action spacing */
    .article-item-actions,
    .article-card-actions {
        margin-left: 0.0625rem;
    }

    /* Smaller practice icons on mobile (list view) */
    .article-practices {
        gap: 0.25rem;
        margin-left: 0.25rem;
    }

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

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

    /* Allow title to wrap on mobile instead of truncating */
    .article-item > .article-item-link {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
}

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

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

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