/* Journal Tweet-Style Layout */
/* Theme tokens */
:root {
    --tweet-bg: var(--bg-primary);
    --tweet-bg-hover: var(--bg-secondary);
    --tweet-text: var(--text-primary);
    --tweet-text-secondary: var(--text-secondary);
    --tweet-text-muted: var(--text-muted);
    --tweet-border: var(--border-color);
    --tweet-shadow: rgba(0, 0, 0, 0.03);
    --tweet-ticker-bg: rgba(var(--color-primary-rgb), 0.05);
    --tweet-ticker-border: rgba(var(--color-primary-rgb), 0.15);
    --tweet-ticker-text: var(--color-primary);
    --tweet-ticker-bg-hover: rgba(var(--color-primary-rgb), 0.1);
    /* Table colors */
    --table-header-bg: #e5e7eb;
    --table-border: var(--border-color);
}

@media (prefers-color-scheme: dark) {
    :root {
        --table-header-bg: #374151;
    }
}

/* Tables inside journal entries */
.entry-content .ln-table,
.entry-content .coachella-schedule {
    border-collapse: collapse;
    width: auto;
}

.entry-content .ln-table {
    font-size: 0.7em;
    line-height: 1.3;
    margin: 0.2rem 0 0 0;
    max-width: 100%;
}

.entry-content .ln-table th,
.entry-content .ln-table td {
    padding: 1px 6px;
    border: 1px solid var(--table-border);
}

.entry-content .ln-table th {
    background: var(--table-header-bg);
    font-weight: 600;
    text-align: left;
}

.entry-content .ln-table th:last-child,
.entry-content .ln-table td:last-child {
    text-align: right;
}

.entry-content .ln-table tr:nth-child(even) {
    background: var(--tweet-bg-hover);
}

.entry-content .coachella-schedule {
    font-size: 0.65em;
    line-height: 1.2;
    margin: 0.3rem 0 0 0;
    table-layout: auto;
}

.entry-content .coachella-schedule th,
.entry-content .coachella-schedule td {
    padding: 1px 4px;
    border: 1px solid var(--table-border);
    text-align: left;
    white-space: nowrap;
}

.entry-content .coachella-schedule th:nth-child(4),
.entry-content .coachella-schedule td:nth-child(4) {
    text-align: center;
    width: 80px;
}

.entry-content .coachella-schedule th {
    background: var(--table-header-bg);
    font-weight: 600;
}

.entry-content .coachella-schedule th:last-child,
.entry-content .coachella-schedule td:last-child {
    text-align: center;
}

.entry-content .coachella-schedule tr:nth-child(even) {
    background: var(--tweet-bg-hover);
}

@media (max-width: 600px) {
    .entry-content .coachella-schedule {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .entry-content .coachella-schedule th:nth-child(5),
    .entry-content .coachella-schedule td:nth-child(5) {
        display: none;
    }
    
    .entry-content .coachella-schedule th,
    .entry-content .coachella-schedule td {
        font-size: 0.6em;
        padding: 1px 3px;
    }
}

/* Dark mode token overrides - consolidated for html.dark-mode and prefers-color-scheme */
html.dark-mode {
    --tweet-bg: var(--color-dark-bg-primary);
    --tweet-bg-hover: var(--color-dark-bg-secondary);
    --tweet-text: var(--color-dark-text-secondary);
    --tweet-text-secondary: var(--color-dark-text-muted);
    --tweet-text-muted: var(--color-dark-text-muted);
    --tweet-border: #3a4442;
    --tweet-shadow: rgba(0, 0, 0, 0.3);
    --tweet-ticker-bg: rgba(255, 255, 255, 0.14);
    --tweet-ticker-border: rgba(255, 255, 255, 0.28);
    --tweet-ticker-text: #ffffff;
    --tweet-ticker-bg-hover: rgba(255, 255, 255, 0.22);
    /* Table colors */
    --table-header-bg: rgba(255, 255, 255, 0.1);
    --table-border: rgba(255, 255, 255, 0.15);
}

@media (prefers-color-scheme: dark) {
    :root {
        --tweet-bg: var(--color-dark-bg-primary);
        --tweet-bg-hover: var(--color-dark-bg-secondary);
        --tweet-text: var(--color-dark-text-secondary);
        --tweet-text-secondary: var(--color-dark-text-muted);
        --tweet-text-muted: var(--color-dark-text-muted);
        --tweet-border: #3a4442;
        --tweet-shadow: rgba(0, 0, 0, 0.3);
        --tweet-ticker-bg: rgba(255, 255, 255, 0.14);
        --tweet-ticker-border: rgba(255, 255, 255, 0.28);
        --tweet-ticker-text: #ffffff;
        --tweet-ticker-bg-hover: rgba(255, 255, 255, 0.22);
        /* Table colors */
        --table-header-bg: rgba(255, 255, 255, 0.1);
        --table-border: rgba(255, 255, 255, 0.15);
    }
}

/* Base typography */
.entry-title,
.entry-content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Feed container */
#journal-feed {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

@media (max-width: 480px) {
    #journal-feed {
        max-width: 100% !important;
        padding: 0 var(--spacing-sm) !important;
    }
}

/* Entry cards */
.journal-entry {
    background: var(--tweet-bg);
    border: 1px solid var(--tweet-border);
    border-radius: 16px;
    margin: 0 0 16px 0;
    padding: 0;
    box-shadow: 0 1px 3px var(--tweet-shadow);
    transition: background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
    content-visibility: auto;
}

.journal-entry:hover {
    background: var(--tweet-bg-hover);
    border-color: var(--tweet-text-secondary);
    box-shadow: 0 2px 8px var(--tweet-shadow);
}

/* Entry card header */
.journal-entry .card-title {
    background: transparent;
    border: none;
    padding: 12px 16px 8px 16px;
    margin: 0;
    font-size: 0.875rem;
    color: var(--tweet-text-muted);
    font-weight: 400;
    text-align: left;
    box-shadow: none;
}

.journal-entry .card-title time {
    color: var(--tweet-text-muted);
    font-size: 0.875rem;
    font-weight: 400;
}

/* Entry card body */
.journal-entry .content {
    padding: 0 16px 16px 16px;
    margin: 0;
}

/* Individual feed items */
.entry {
    margin: 0 0 16px 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: hidden;
}

.entry::after {
    content: '';
    display: table;
    clear: both;
}

.entry--collapsed .entry-content {
    display: none;
}

.entry-time {
    float: left;
    font-size: 0.75rem;
    color: var(--tweet-text-muted);
    margin-right: 8px;
    margin-top: 2px;
    font-weight: 400;
    white-space: nowrap;
}

.entry-title::after {
    transition: transform 0.2s ease;
}
.entry--file .entry-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--tweet-text);
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 4px 0 12px 0;
    transition: color 0.2s ease;
    text-decoration: none;
}

.entry--file.entry--collapsed .entry-title {
    margin-bottom: 0;
}

.entry--file:hover .entry-title {
    background: transparent;
    border-color: transparent;
    color: var(--tweet-ticker-text);
    transform: none;
    box-shadow: none;
}

.entry--file.entry--collapsed .entry-title::after {
    content: '▸';
    font-size: 1.25rem;
    color: var(--accent-primary);
    transition: transform 0.2s ease;
}

.entry--file:not(.entry--collapsed) .entry-title::after {
    content: '▾';
    font-size: 1.25rem;
    color: var(--accent-primary);
    transform: scale(1.2);
}

[data-collapsible] .entry-title {
    cursor: pointer;
}

[data-collapsible] .entry-title:hover {
    opacity: 0.8;
}

.entry:last-child {
    margin-bottom: 0;
}

/* Item title and content */
.entry-title {
    font-size: 1.05rem;
    line-height: 1.45;
    color: var(--tweet-text);
    margin: 0 0 4px 0;
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
}

/* Entry content - tweet text */
.entry-content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--tweet-text);
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Paragraph styling within entry content */
.entry-content p {
    margin: 0 0 1.2em 0;
    line-height: 1.6;
}

.entry-content p:last-child {
    margin-bottom: 0;
}

/* Embedded media */
.entry-content iframe,
.entry-content video {
    max-width: 100%;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
}

/* Links in entries */
.entry-content a,
.entry-title a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.entry-content a:hover,
.entry-title a:hover {
    opacity: 0.7;
    text-decoration: none;
}

/* Ticker links get a compact chip treatment */
.entry-content a[href^="https://www.perplexity.ai/finance/"],
.entry-title a[href^="https://www.perplexity.ai/finance/"] {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.08rem 0.42rem;
    margin: 0 0.08rem;
    border: 1px solid var(--tweet-ticker-border);
    border-radius: 999px;
    background: var(--tweet-ticker-bg);
    color: var(--tweet-ticker-text);
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: baseline;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.entry-content a[href^="https://www.perplexity.ai/finance/"]:hover,
.entry-title a[href^="https://www.perplexity.ai/finance/"]:hover {
    opacity: 1;
    background: var(--tweet-ticker-bg-hover);
    border-color: var(--tweet-ticker-text);
    color: var(--tweet-ticker-text);
    text-decoration: none;
}

.entry-content a[href^="https://www.perplexity.ai/finance/"]:focus-visible,
.entry-title a[href^="https://www.perplexity.ai/finance/"]:focus-visible {
    outline: 2px solid var(--tweet-ticker-text);
    outline-offset: 2px;
}

/* Legacy card overrides */
#journal-feed .card,
#journal-feed .card:hover {
    background: var(--tweet-bg) !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

#journal-feed .journal-entry:hover .card {
    background: var(--tweet-bg-hover) !important;
}



.content {
    padding: 0;
    max-width: 100%;
}

/* Prevent inherited heavy shadows */
.journal-entry * {
    box-shadow: none !important;
}

/* Warning box */
#curry-goat-warning {
    background: #fff3cd !important;
    border: 1px solid #ffc107 !important;
    color: #333 !important;
}

#curry-goat-warning p {
    color: inherit !important;
}

#curry-goat-warning b {
    color: inherit !important;
}

.warning-button {
    background: #dc3545 !important;
    color: white !important;
    border: none !important;
}

.warning-button:hover {
    background: #c82333 !important;
}

.warning-button:focus {
    outline: 2px solid #ffc107;
    outline-offset: 2px;
}

html.dark-mode #curry-goat-warning {
    background: var(--color-dark-bg-secondary) !important;
    border: 1px solid var(--color-dark-accent-secondary) !important;
    color: var(--color-dark-text-secondary) !important;
}

@media (prefers-color-scheme: dark) {
    #curry-goat-warning {
        background: var(--color-dark-bg-secondary) !important;
        border: 1px solid var(--color-dark-accent-secondary) !important;
        color: var(--color-dark-text-secondary) !important;
    }
}

/* Images */
.entry-content img,
.entry-title img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid var(--tweet-border);
    box-shadow: 0 2px 8px var(--tweet-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.entry-content img:hover,
.entry-title img:hover {
    transform: scale(1.01);
    box-shadow: 0 4px 16px var(--tweet-shadow);
}

.entry--link .entry-content img {
    margin-left: auto;
    margin-right: auto;
}

.entry-content a img,
.entry-title a img {
    margin-top: 0.75rem;
    cursor: zoom-in;
}

html.dark-mode .entry-content img,
html.dark-mode .entry-title img {
    border-color: rgba(255, 255, 255, 0.15);
}

.journal-entry:has(#sons-hand):hover {
    background-image: url('../images/baby-hand.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.journal-entry:has(#sons-hand)::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--tweet-bg);
    opacity: 0.65;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

.journal-entry:has(#sons-hand) .card-title,
.journal-entry:has(#sons-hand) .content {
    position: relative;
    z-index: 1;
}

.entry-title-link {
    display: inline;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s ease;
}

.entry-title-link:hover {
    background: transparent;
    border-color: transparent;
    color: inherit;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

.entry-link-icon,
.entry-link-asset-icon {
    flex-shrink: 0;
    margin-left: 12px;
    margin-top: 0;
}

.entry-link-icon {
    width: 1.1em;
    height: 1.1em;
    color: var(--accent-primary);
    opacity: 0.8;
    transition: transform 0.2s ease;
}

.entry-link-asset-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    filter: opacity(0.7);
    transition: filter 0.2s ease, transform 0.2s ease;
}

.entry-title-link:hover .entry-link-icon,
.entry-title-link:hover .entry-link-asset-icon {
    opacity: 1;
    filter: none;
    transform: scale(1.1);
}

html.dark-mode .entry-title-link {
    background: transparent;
}

html.dark-mode .entry-title-link:hover {
    background: transparent;
    color: inherit;
}

/* Inline change metric */
.change-metric-value {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.change-metric-value svg {
    flex-shrink: 0;
}

/* Category badges for essay cards */
.category-badge {
    display: inline-block;
    font-size: 0.75em;
    font-weight: bold;
    padding: 0.25em 0.6em;
    border-radius: 999px;
    margin-left: 0.5em;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    transition: transform 0.2s ease;
    cursor: default;
}

.category-badge:hover {
    transform: translateY(-2px);
}

.category-badge.ipo { background: var(--color-category-ipo, #6366f1); color: white; }
.category-badge.earnings { background: var(--color-category-earnings, #10b981); color: white; }
.category-badge.policy { background: var(--color-category-policy, #f59e0b); color: white; }
.category-badge.healthcare { background: var(--color-category-healthcare, #ec4899); color: white; }
.category-badge.legal { background: var(--color-category-legal, #8b5cf6); color: white; }
.category-badge.political { background: var(--color-category-political, #ef4444); color: white; }
.category-badge.corrections { background: var(--color-category-corrections, #6b7280); color: white; }
.category-badge.uncategorized { background: var(--color-category-uncategorized, #9ca3af); color: white; }
