/* ========================================
   POSTS PAGE LAYOUT
   ======================================== */

body.page-posts #app-container {
    grid-template-rows: var(--header-height) 1fr;
}

#analysis-main {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: 100%;
    overflow: hidden;
}

#analysis-left {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
}

#analysis-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--results-bg);
    border-left: 1px solid var(--border-color);
}

/* ========================================
   FEED LIST
   ======================================== */

#analysis-feed {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px 24px 0;
    box-sizing: border-box;
}

.analysis-item {
    padding: 10px 12px 10px 18px;
    border-bottom: 1px solid #e8e8e8;
    border-left: 8px solid transparent;
    cursor: pointer;
    transition:
        background-color 0.22s ease,
        border-left-color 0.22s ease;
}

.analysis-item:hover {
    background-color: #f0f4f8;
}

.analysis-item.selected {
    border-left-color: var(--accent-blue);
    background: #e2ecf7;
    box-shadow: inset 0 0 0 1px #b8cce0;
}

.analysis-item.selected:hover {
    background: #d4e3f0;
}

.analysis-item.selected .analysis-title {
    color: var(--text-dark);
    font-weight: 600;
}

.analysis-item.selected .analysis-date {
    color: #333;
}

.analysis-item:focus {
    outline: none;
}

.analysis-item:focus-visible:not(.selected) {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.analysis-item:last-child {
    border-bottom: none;
}

.analysis-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.analysis-date {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.2;
    color: var(--text-muted);
    margin: 0;
    transition: color 0.22s ease;
}

.analysis-item .analysis-title {
    margin: 0;
    padding: 0;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
    color: #444;
    transition: color 0.22s ease;
}

.analysis-empty {
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 15px;
}

/* ========================================
   DETAIL VIEW
   ======================================== */

#analysis-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 720px;
    overflow: hidden;
    box-sizing: border-box;
    opacity: 1;
    transition: opacity 0.22s ease;
}

#analysis-detail.is-swapping {
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .analysis-item,
    .analysis-item .analysis-title,
    .analysis-item .analysis-date,
    #analysis-detail {
        transition: none;
    }
}

.analysis-detail-header {
    flex-shrink: 0;
    margin-bottom: 0;
    padding: 10px 32px 14px;
    border-bottom: 1px solid var(--border-color);
}

.analysis-detail-header h1 {
    margin: 0 0 5px;
    font-size: 26px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-dark);
}

.analysis-detail-meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25em;
}

.analysis-detail-date {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0;
}

.analysis-detail-author {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
}

.analysis-detail-author:not(:empty)::before {
    content: '·';
    margin-right: 0.25em;
}

.analysis-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 32px 64px;
    font-size: 16px;
    line-height: 1.65;
    color: #444;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.analysis-detail-body::-webkit-scrollbar {
    width: 5px;
}

.analysis-detail-body::-webkit-scrollbar-track {
    background: transparent;
}

.analysis-detail-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

.analysis-detail-body p {
    margin: 0 0 1.2em;
}

.analysis-detail-body h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 2em 0 0.6em;
    color: var(--text-dark);
}

.analysis-detail-body h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 1.6em 0 0.5em;
    color: var(--text-dark);
}

.analysis-detail-body a {
    color: var(--accent-blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.analysis-detail-body a:hover {
    color: var(--primary-blue);
}

.analysis-detail-body ul,
.analysis-detail-body ol {
    margin: 0 0 1.2em;
    padding-left: 1.6em;
}

.analysis-detail-body li {
    margin-bottom: 0.4em;
}

.analysis-detail-body blockquote {
    margin: 1.2em 0;
    padding: 0.4em 0 0.4em 1em;
    border-left: 3px solid var(--border-color);
    color: #555;
    font-style: italic;
}

.analysis-detail-body img:not(.story-image):not(.story-card-image) {
    display: block;
    width: calc(100% - 40px);
    max-width: calc(100% - 40px);
    height: auto;
    margin: 1.2em 20px;
    border-radius: 4px;
}

/* ========================================
   LINK PREVIEW
   ======================================== */

.analysis-link-preview {
    margin: 16px 0;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #fff;
    font-size: 15px;
}

.analysis-link-preview a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.analysis-link-preview a:hover {
    text-decoration: underline;
}

.analysis-shortcode-missing {
    font-size: 14px;
    color: var(--text-muted);
    margin: 12px 0;
}

.analysis-shortcode-note {
    font-style: italic;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    #analysis-main {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(180px, 35vh) 1fr;
    }

    #analysis-left {
        border-bottom: 1px solid var(--border-color);
    }

    #analysis-right {
        border-left: none;
    }

    #analysis-detail {
        max-width: none;
    }

    .analysis-detail-header {
        padding: 10px 16px 14px;
    }

    .analysis-detail-body {
        padding: 12px 16px 48px;
    }
}
