/* ==========================================================================
   ARCHIVE PAGES — News & Research Shared Styles
   ==========================================================================
   Used by category.php for news categories (breaking-news, market-news,
   interviews) and research categories (analysis, earnings-previews,
   alphagraphs). All colors use CSS custom properties from style.css.
   ========================================================================== */

/* ==========================================================================
   PRINT BLOCKING
   ========================================================================== */
@media print {
    .archive-page * {
        display: none !important;
        visibility: hidden !important;
    }
}

/* ==========================================================================
   PAGE WRAPPER
   ========================================================================== */
.archive-page {
    padding: 0 0 var(--as-space-12);
}

.archive-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--as-space-4);
}

/* ==========================================================================
   ARCHIVE HEADER
   ========================================================================== */
.ap-header {
    padding: var(--as-space-5) 0 0;
}

.ap-breadcrumb {
    font-size: var(--as-text-sm);
    margin-bottom: var(--as-space-4);
}

.ap-breadcrumb a {
    color: var(--as-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.ap-breadcrumb a:hover {
    color: var(--as-primary);
}

.ap-breadcrumb .sep {
    margin: 0 0.5rem;
    color: var(--as-text-tertiary);
}

.ap-breadcrumb .current {
    color: var(--as-text-primary);
}

.ap-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    margin: 0 0 var(--as-space-2);
    color: var(--as-text-primary);
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.ap-description {
    color: var(--as-text-secondary);
    margin: 0;
    max-width: 640px;
    line-height: 1.6;
    font-size: var(--as-text-base);
}

/* ==========================================================================
   CATEGORY TABS
   ========================================================================== */
.ap-tabs {
    display: flex;
    gap: 0.5rem;
    margin-top: var(--as-space-5);
    padding-bottom: var(--as-space-5);
    border-bottom: 1px solid var(--as-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.ap-tabs::-webkit-scrollbar {
    display: none;
}

.ap-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    border-radius: var(--as-radius-md);
    font-size: var(--as-text-sm);
    font-weight: 500;
    background: var(--as-bg-card);
    border: 1px solid var(--as-border);
    color: var(--as-text-secondary);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
}

.ap-tab:hover {
    border-color: var(--as-primary);
    background: var(--as-bg-tertiary);
    color: var(--as-text-primary);
}

.ap-tab.active {
    background: var(--as-primary);
    border-color: var(--as-primary);
    color: #fff;
}

.ap-tab svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.ap-tab .tab-count {
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 7px;
    border-radius: var(--as-radius-full);
    font-size: var(--as-text-xs);
    font-weight: 600;
}

.ap-tab:not(.active) .tab-count {
    background: var(--as-bg-tertiary);
    color: var(--as-text-muted);
}

/* ==========================================================================
   FEATURED SECTION — 1 large + 2 stacked small
   ========================================================================== */
.ap-featured {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: var(--as-space-5);
    margin-top: var(--as-space-6);
    margin-bottom: var(--as-space-6);
}

/* Large card spans 2 rows on the left */
.ap-featured-large {
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    background: var(--as-bg-card);
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius-lg);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ap-featured-large:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: var(--as-primary);
}

.ap-featured-large .ap-feat-image {
    aspect-ratio: 16/9;
    overflow: hidden;
}

.ap-featured-large .ap-feat-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.ap-featured-large:hover .ap-feat-image img {
    transform: scale(1.03);
}

.ap-featured-large .ap-feat-content {
    padding: var(--as-space-5);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ap-featured-large .ap-feat-title {
    font-size: var(--as-text-xl);
    font-weight: 700;
    margin: 0 0 var(--as-space-3);
    line-height: 1.3;
}

.ap-featured-large .ap-feat-excerpt {
    color: var(--as-text-secondary);
    font-size: var(--as-text-sm);
    line-height: 1.6;
    margin: 0 0 var(--as-space-4);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Small cards on the right — horizontal layout */
.ap-featured-small {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: var(--as-space-4);
    background: var(--as-bg-card);
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius-lg);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ap-featured-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    border-color: var(--as-primary);
}

.ap-featured-small .ap-feat-image {
    aspect-ratio: 1/1;
    overflow: hidden;
}

.ap-featured-small .ap-feat-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.ap-featured-small:hover .ap-feat-image img {
    transform: scale(1.05);
}

.ap-featured-small .ap-feat-content {
    padding: var(--as-space-4) var(--as-space-4) var(--as-space-4) 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ap-featured-small .ap-feat-title {
    font-size: var(--as-text-base);
    font-weight: 600;
    margin: 0 0 var(--as-space-2);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Shared featured elements */
.ap-feat-title a {
    color: var(--as-text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.ap-feat-title a:hover {
    color: var(--as-primary);
}

.ap-feat-meta {
    display: flex;
    align-items: center;
    gap: var(--as-space-3);
    font-size: var(--as-text-xs);
    color: var(--as-text-muted);
    margin-top: auto;
}

.ap-feat-meta .sep {
    color: var(--as-text-tertiary);
}

/* ==========================================================================
   CATEGORY BADGE
   ========================================================================== */
.ap-category-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    text-decoration: none;
    transition: opacity 0.2s;
}

.ap-category-badge:hover {
    opacity: 0.85;
}

/* News badges */
.badge-breaking-news {
    background: rgba(255, 59, 92, 0.15);
    color: #FF3B5C;
}

.badge-market-news {
    background: rgba(255, 140, 66, 0.15);
    color: #FF8C42;
}

.badge-interviews {
    background: rgba(139, 92, 246, 0.15);
    color: #8B5CF6;
}

/* Research badges */
.badge-analysis {
    background: rgba(59, 130, 246, 0.15);
    color: #3B82F6;
}

.badge-earnings-previews {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
}

.badge-alphagraphs {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
}

/* Fallback for unknown categories */
.badge-default {
    background: var(--as-bg-tertiary);
    color: var(--as-text-secondary);
}

/* ==========================================================================
   INLINE ADS
   ========================================================================== */
.ap-ad-banner {
    text-align: center;
    padding: var(--as-space-5) 0;
}

.ap-ad-banner .ad-label {
    display: block;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--as-text-tertiary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.ap-ad-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    background: var(--as-bg-tertiary);
    border: 2px dashed var(--as-border);
    border-radius: var(--as-radius-sm);
    color: var(--as-text-tertiary);
    font-size: var(--as-text-sm);
    font-weight: 500;
}

.ap-ad-leaderboard {
    width: 950px;
    height: 200px;
}

.ap-ad-banner-728 {
    width: 728px;
    height: 90px;
}

.ap-ad-sidebar-300 {
    width: 300px;
    height: 250px;
}

/* ==========================================================================
   MAIN LAYOUT — 70/30 split
   ========================================================================== */
.ap-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--as-space-8);
    margin-top: var(--as-space-6);
}

/* ==========================================================================
   SECTION HEADER
   ========================================================================== */
.ap-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--as-space-5);
    padding-bottom: var(--as-space-3);
    border-bottom: 2px solid var(--as-secondary);
}

.ap-section-title {
    display: flex;
    align-items: center;
    gap: var(--as-space-3);
    font-size: var(--as-text-lg);
    font-weight: 700;
    margin: 0;
    color: var(--as-text-primary);
}

.ap-section-title svg {
    color: var(--as-secondary);
    flex-shrink: 0;
}

.ap-post-count {
    font-size: var(--as-text-sm);
    color: var(--as-text-muted);
}

/* ==========================================================================
   CARD GRID — 3 columns
   ========================================================================== */
.ap-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--as-space-5);
}

/* Grid ad spans full width */
.ap-grid-ad {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--as-space-4) 0;
}

/* ==========================================================================
   ARCHIVE CARD
   ========================================================================== */
.ap-card {
    background: var(--as-bg-card);
    border-radius: var(--as-radius-lg);
    overflow: hidden;
    border: 1px solid var(--as-border);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.ap-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: var(--as-primary);
}

.ap-card-image {
    display: block;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.ap-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.ap-card:hover .ap-card-image img {
    transform: scale(1.05);
}

/* Placeholder when no thumbnail */
.ap-card-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16/9;
    background: var(--as-bg-tertiary);
    color: var(--as-text-tertiary);
}

.ap-card-image-placeholder svg {
    width: 32px;
    height: 32px;
    opacity: 0.5;
}

.ap-card-body {
    padding: var(--as-space-4);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ap-card-title {
    font-size: var(--as-text-base);
    font-weight: 600;
    margin: 0 0 var(--as-space-2);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ap-card-title a {
    color: var(--as-text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.ap-card-title a:hover {
    color: var(--as-primary);
}

.ap-card-excerpt {
    font-size: var(--as-text-sm);
    color: var(--as-text-secondary);
    line-height: 1.5;
    margin: 0 0 var(--as-space-3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.ap-card-meta {
    display: flex;
    align-items: center;
    gap: var(--as-space-3);
    font-size: var(--as-text-xs);
    color: var(--as-text-muted);
    margin-top: auto;
}

.ap-card-meta .sep {
    color: var(--as-text-tertiary);
}

/* Ticker badge on research cards */
.ap-card-ticker {
    display: inline-block;
    padding: 2px 6px;
    background: var(--as-bg-tertiary);
    color: var(--as-secondary);
    font-family: var(--as-font-mono);
    font-size: var(--as-text-xs);
    font-weight: 700;
    border-radius: 3px;
    text-decoration: none;
    transition: all 0.2s;
}

.ap-card-ticker:hover {
    background: var(--as-secondary);
    color: #fff;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.ap-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--as-space-6);
}

/* Sticky wrapper for newsletter + bottom ad */
.ap-sidebar-sticky {
    position: sticky;
    top: 82px;
    display: flex;
    flex-direction: column;
    gap: var(--as-space-6);
}

/* Sidebar widget */
.ap-sidebar-widget {
    background: var(--as-bg-secondary);
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius-lg);
    padding: var(--as-space-5);
}

.ap-widget-title {
    display: flex;
    align-items: center;
    gap: var(--as-space-2);
    font-size: var(--as-text-base);
    font-weight: 600;
    margin: 0 0 var(--as-space-4);
    padding-bottom: var(--as-space-3);
    border-bottom: 2px solid var(--as-secondary);
    color: var(--as-text-primary);
}

.ap-widget-title svg {
    color: var(--as-secondary);
    flex-shrink: 0;
}

/* Trending list */
.ap-trending-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ap-trending-item {
    padding: var(--as-space-3) 0;
    border-bottom: 1px solid var(--as-border);
}

.ap-trending-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ap-trending-item:first-child {
    padding-top: 0;
}

.ap-trending-link {
    display: flex;
    align-items: flex-start;
    gap: var(--as-space-3);
    text-decoration: none;
}

.ap-trending-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--as-bg-tertiary);
    border-radius: var(--as-radius-sm);
    font-size: var(--as-text-xs);
    font-weight: 700;
    color: var(--as-text-muted);
    flex-shrink: 0;
}

.ap-trending-item .ap-trending-num {
    background: var(--as-primary);
    color: #fff;
}

.ap-trending-info {
    flex: 1;
    min-width: 0;
}

.ap-trending-title {
    display: block;
    font-size: var(--as-text-sm);
    font-weight: 500;
    color: var(--as-text-primary);
    line-height: 1.4;
    transition: color 0.2s;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ap-trending-link:hover .ap-trending-title {
    color: var(--as-primary);
}

.ap-trending-date {
    display: block;
    font-size: var(--as-text-xs);
    color: var(--as-text-muted);
    margin-top: 2px;
}

/* Newsletter widget */
.ap-newsletter-widget {
    background: linear-gradient(135deg, var(--as-bg-secondary), var(--as-bg-tertiary));
}

.ap-newsletter-text {
    font-size: var(--as-text-sm);
    color: var(--as-text-secondary);
    line-height: 1.5;
    margin: 0 0 var(--as-space-4);
}

.ap-newsletter-form {
    display: flex;
    flex-direction: column;
    gap: var(--as-space-3);
}

.ap-newsletter-input {
    width: 100%;
    padding: var(--as-space-3);
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius-md);
    background: var(--as-bg-primary);
    color: var(--as-text-primary);
    font-size: var(--as-text-sm);
    transition: border-color 0.2s;
}

.ap-newsletter-input:focus {
    outline: none;
    border-color: var(--as-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.ap-newsletter-btn {
    padding: var(--as-space-3);
    background: var(--as-primary);
    color: #fff;
    border: none;
    border-radius: var(--as-radius-md);
    font-size: var(--as-text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.ap-newsletter-btn:hover {
    background: var(--as-primary-hover);
}

/* Sidebar ad */
.ap-sidebar-ad {
    text-align: center;
}

.ap-sidebar-ad .ad-label {
    display: block;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--as-text-tertiary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* ==========================================================================
   PAGINATION
   ========================================================================== */
.ap-pagination {
    margin-top: var(--as-space-8);
    display: flex;
    justify-content: center;
    gap: var(--as-space-2);
}

.ap-pagination a,
.ap-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 var(--as-space-3);
    background: var(--as-bg-card);
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius-md);
    font-size: var(--as-text-sm);
    text-decoration: none;
    color: var(--as-text-primary);
    transition: all 0.2s;
}

.ap-pagination a:hover {
    border-color: var(--as-primary);
    color: var(--as-primary);
}

.ap-pagination .current {
    background: var(--as-primary);
    border-color: var(--as-primary);
    color: #fff;
}

/* ==========================================================================
   NO RESULTS
   ========================================================================== */
.ap-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--as-space-12) var(--as-space-6);
    background: var(--as-bg-secondary);
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius-lg);
}

.ap-no-results h2 {
    margin: 0 0 var(--as-space-3);
    color: var(--as-text-primary);
}

.ap-no-results p {
    color: var(--as-text-muted);
    margin: 0 0 var(--as-space-6);
}

.ap-no-results .ap-btn {
    display: inline-block;
    padding: var(--as-space-3) var(--as-space-6);
    background: var(--as-primary);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--as-radius-md);
    transition: background 0.2s;
}

.ap-no-results .ap-btn:hover {
    background: var(--as-primary-hover);
}

/* ==========================================================================
   RESPONSIVE — Tablet (768–1023px)
   ========================================================================== */
@media screen and (max-width: 1023px) {
    /* Layout goes single column */
    .ap-layout {
        grid-template-columns: 1fr;
    }

    /* Sidebar un-sticks, goes horizontal */
    .ap-sidebar-sticky {
        position: static;
    }

    .ap-sidebar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--as-space-4);
    }

    .ap-sidebar-sticky {
        display: contents;
    }

    .ap-newsletter-widget {
        grid-column: span 2;
    }

    /* Featured: large card full width, 2 small side-by-side below */
    .ap-featured {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }

    .ap-featured-large {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .ap-featured-small {
        grid-row: 2;
    }

    /* Grid 2 columns */
    .ap-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   RESPONSIVE — Mobile (<768px)
   ========================================================================== */
@media screen and (max-width: 767px) {
    .archive-page {
        padding-bottom: var(--as-space-8);
    }

    .ap-title {
        font-size: 1.5rem;
    }

    .ap-description {
        font-size: var(--as-text-sm);
    }

    /* Tabs: smaller, scroll horizontally */
    .ap-tab {
        padding: 0.5rem 0.875rem;
        font-size: var(--as-text-xs);
    }

    .ap-tab svg {
        width: 12px;
        height: 12px;
    }

    /* Featured: everything stacks */
    .ap-featured {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: var(--as-space-4);
    }

    .ap-featured-large {
        grid-column: 1;
        grid-row: auto;
    }

    .ap-featured-small {
        grid-template-columns: 120px 1fr;
    }

    .ap-featured-large .ap-feat-title {
        font-size: var(--as-text-lg);
    }

    /* Grid 1 column */
    .ap-grid {
        grid-template-columns: 1fr;
        gap: var(--as-space-4);
    }

    /* Sidebar single column */
    .ap-sidebar {
        grid-template-columns: 1fr;
    }

    .ap-newsletter-widget {
        grid-column: span 1;
    }

    /* Ads scale down */
    .ap-ad-leaderboard {
        width: 100%;
        height: auto;
        min-height: 100px;
    }

    .ap-ad-banner-728 {
        width: 468px;
        height: 60px;
    }

    .ap-ad-sidebar-300 {
        width: 100%;
        height: 200px;
    }

    /* Pagination smaller */
    .ap-pagination a,
    .ap-pagination span {
        min-width: 36px;
        height: 36px;
        font-size: var(--as-text-xs);
    }
}

/* ==========================================================================
   RESPONSIVE — Small Mobile (<480px)
   ========================================================================== */
@media screen and (max-width: 479px) {
    .ap-featured-small {
        grid-template-columns: 100px 1fr;
        gap: var(--as-space-3);
    }

    .ap-featured-small .ap-feat-content {
        padding: var(--as-space-3) var(--as-space-3) var(--as-space-3) 0;
    }

    .ap-featured-small .ap-feat-title {
        font-size: var(--as-text-sm);
    }

    .ap-ad-banner-728 {
        width: 320px;
        height: 50px;
    }

    .ap-tab {
        padding: 0.5rem 0.75rem;
    }

    .ap-tab svg {
        display: none;
    }
}
