/* ==========================================================================
   Pensio — Main CSS (base, typography, utilities, shared components)
   Components extracted to static/css/components/ and static/css/layout.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   Accessibility Utilities
   -------------------------------------------------------------------------- */

/* Inline SVG icons — align with surrounding text */
[aria-hidden="true"]>svg {
    display: inline-block;
    vertical-align: middle;
    width: 1.2em;
    height: 1.2em;
    flex-shrink: 0;
    color: var(--primary);
}

/* Slightly larger SVG icons in headings */
h1 [aria-hidden="true"]>svg,
h2 [aria-hidden="true"]>svg,
h3 [aria-hidden="true"]>svg,
h4 [aria-hidden="true"]>svg {
    width: 1.3em;
    height: 1.3em;
}

/* Screen reader only — visually hidden but accessible to AT */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Becomes visible on focus (for skip link) */
.sr-only-focusable:focus {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    width: auto;
    height: auto;
    padding: 0.75rem 1.5rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: var(--primary, #5C6B59);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Hide on mobile screens */
@media (max-width: 1023px) {
    .hide-on-mobile {
        display: none !important;
    }
}

/* Global focus-visible styles — replaces outline: none with visible indicator */
:focus-visible {
    outline: 2px solid var(--primary, #5C6B59);
    outline-offset: 2px;
}

/* Remove default outline only when :focus-visible is NOT matched (mouse/touch) */
:focus:not(:focus-visible) {
    outline: none;
}

/* --------------------------------------------------------------------------
   CSS Reset & Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    line-height: 1.3;
    letter-spacing: -0.02em;
    color: var(--text-color);
    margin-bottom: 0.5em;
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.125rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
}

/* --------------------------------------------------------------------------
   Dashboard Specific
   -------------------------------------------------------------------------- */
.dashboard {
    padding-bottom: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Entry list in dashboard (ul/li) */
.entry-list,
.person-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.entry-item,
.person-item {
    border-bottom: 1px solid var(--border-color);
}

.entry-item:last-child,
.person-item:last-child {
    border-bottom: none;
}

.entry-item a,
.person-item a {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    color: var(--text-color);
    min-height: 44px;
}

.entry-item a:hover,
.person-item a:hover {
    color: var(--primary);
}

.entry-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.entry-title {
    font-weight: 500;
    flex: 1;
}

.badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 3px;
}

.person-name {
    font-weight: 500;
    flex: 1;
}

.mention-badge {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Entry list layout (used on entry_list page) */
.entry-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   Tags / Pills
   -------------------------------------------------------------------------- */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.8rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 999px;
    transition: background-color var(--transition-base, 0.2s ease), color var(--transition-base, 0.2s ease), transform var(--transition-base, 0.2s ease);
}

.tag:hover {
    background: var(--primary);
    color: var(--text-inverse, #fff);
    transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
}

.pagination a {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    transition: border-color var(--transition-base, 0.2s ease), color var(--transition-base, 0.2s ease), background-color var(--transition-base, 0.2s ease);
}

.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--primary-light);
}

.pagination .current {
    background: var(--primary);
    color: var(--text-inverse);
}

/* ==========================================================================
   Responsive Typography — Tablet (768px+)
   ========================================================================== */
@media (min-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.text-muted {
    color: var(--text-secondary);
}

.text-primary {
    color: var(--primary);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mt-0 {
    margin-top: 0;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.d-inline {
    display: inline !important;
}

/* --------------------------------------------------------------------------
   Shared Badges
   -------------------------------------------------------------------------- */
.draft-badge {
    background: var(--warning-bg) !important;
    color: var(--warning-text) !important;
    border: 1px solid var(--warning-border);
}

/* Source badge for entries/people */
.source-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.source-badge.vault-sync {
    background: var(--info-bg);
    color: var(--info);
}

.source-badge.manual {
    background: var(--success-bg);
    color: var(--success);
}

/* --------------------------------------------------------------------------
   Prose Content (rendered markdown)
   -------------------------------------------------------------------------- */
.entry-content.prose {
    line-height: 1.7;
}

.entry-content.prose h1,
.entry-content.prose h2,
.entry-content.prose h3,
.entry-content.prose h4 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.entry-content.prose h1:first-child,
.entry-content.prose h2:first-child {
    margin-top: 0;
}

.entry-content.prose p {
    margin-bottom: 1em;
}

.entry-content.prose ul,
.entry-content.prose ol {
    margin-left: 0;
    margin-bottom: 1em;
    padding-left: 2em;
}

.entry-content.prose li {
    margin-bottom: 0.35em;
    padding-left: 0.25em;
}

.entry-content.prose ul li {
    list-style-type: disc;
}

.entry-content.prose ol li {
    list-style-type: decimal;
}

.entry-content.prose ul ul,
.entry-content.prose ol ol,
.entry-content.prose ul ol,
.entry-content.prose ol ul {
    margin-top: 0.25em;
    margin-bottom: 0.25em;
}

.entry-content.prose blockquote {
    border-left: 3px solid var(--primary);
    margin: 1em 0;
    padding: 0.5em 1em;
    background: var(--surface);
    font-style: italic;
}

.entry-content.prose pre {
    background: var(--surface);
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1em;
}

.entry-content.prose code {
    background: var(--surface);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

.entry-content.prose pre code {
    background: none;
    padding: 0;
}

/* --------------------------------------------------------------------------
   Quick Actions (Dashboard)
   -------------------------------------------------------------------------- */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.quick-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* ==========================================================================
   Shared Components (used across multiple templates)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Stats Bar & Badges
   -------------------------------------------------------------------------- */
.stats-bar {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stat-badge {
    background: var(--card-background);
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
}

.stat-badge strong {
    color: var(--primary);
    font-size: 1.1rem;
}

/* --------------------------------------------------------------------------
   Entry Type Badges (colored variants)
   -------------------------------------------------------------------------- */
.entry-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.entry-type-badge.daily_journal {
    background: rgba(92, 107, 89, 0.12);
    color: var(--primary-dark);
    border: 1px solid rgba(92, 107, 89, 0.25);
}

.entry-type-badge.prompted_journal {
    background: rgba(156, 169, 152, 0.12);
    color: var(--accent-dark);
    border: 1px solid rgba(156, 169, 152, 0.25);
}

.entry-type-badge.meeting_note {
    background: rgba(21, 128, 61, 0.12);
    color: var(--success-dark);
    border: 1px solid rgba(21, 128, 61, 0.25);
}

.entry-type-badge.other {
    background: rgba(75, 85, 99, 0.12);
    color: var(--text-secondary);
    border: 1px solid rgba(75, 85, 99, 0.25);
}

.entry-type-badge.deep_dive {
    background: rgba(58, 104, 80, 0.12);
    color: var(--sage-text, #3A6850);
    border: 1px solid rgba(58, 104, 80, 0.25);
}

/* --------------------------------------------------------------------------
   Emotion Tags
   -------------------------------------------------------------------------- */
.emotion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.emotion-tag {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.emotion-tag.primary {
    background: linear-gradient(135deg, #5C6B59, #3A4238);
    color: var(--text-inverse);
}

.emotion-tag.secondary {
    background: rgba(156, 169, 152, 0.15);
    color: var(--primary-dark);
}

.emotion-badge {
    display: inline-block;
    padding: 2px 8px;
    background: linear-gradient(135deg, #5C6B59, #9CA998);
    color: var(--text-inverse);
    border-radius: 10px;
    font-size: 0.7rem;
}

/* --------------------------------------------------------------------------
   Theme Tags
   -------------------------------------------------------------------------- */
.theme-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.theme-tag {
    padding: 4px 10px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Person Avatar (shared — gradient variant)
   -------------------------------------------------------------------------- */
.person-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5C6B59, #9CA998);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
}

.person-avatar.large {
    width: 80px;
    height: 80px;
    font-size: 2rem;
}

/* --------------------------------------------------------------------------
   Emotion Bars (charts)
   -------------------------------------------------------------------------- */
.emotion-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.emotion-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.emotion-bar .label {
    min-width: 100px;
    font-size: 0.85rem;
}

.emotion-bar .bar-container {
    flex: 1;
    height: 20px;
    background: var(--background);
    border-radius: 4px;
    overflow: hidden;
}

.emotion-bar .bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    padding-left: 8px;
    font-size: 0.75rem;
    color: var(--text-inverse);
    min-width: 25px;
}

/* --------------------------------------------------------------------------
   Intensity Bar (Gradient Meter)
   -------------------------------------------------------------------------- */
.intensity-meter-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.intensity-bar-gradient {
    width: 110px;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, #93c5fd 0%, #facc15 40%, #f97316 70%, #ef4444 100%);
    position: relative;
    flex-shrink: 0;
}

.intensity-bar-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid var(--warning);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease;
}

.intensity-value {
    font-weight: 600;
    color: var(--warning-text);
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Compact variant for metric-box (insight detail) */
.intensity-meter--compact {
    margin-top: 8px;
    justify-content: center;
}

.intensity-meter--compact .intensity-bar-gradient {
    width: 100%;
    max-width: 120px;
}

/* Card variant for entry list */
.intensity-meter--card {
    gap: 6px;
}

.intensity-meter--card .intensity-bar-gradient {
    width: 70px;
    height: 8px;
}

.intensity-meter--card .intensity-bar-thumb {
    width: 12px;
    height: 12px;
}

.intensity-meter--card .intensity-value {
    font-size: 0.8rem;
}

/* --------------------------------------------------------------------------
   Valence Display (Gradient Spectrum)
   -------------------------------------------------------------------------- */
.valence-meter-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.valence-bar-gradient {
    width: 110px;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg,
            #ef4444 0%,
            #fca5a5 20%,
            #fde68a 40%,
            #d1d5db 50%,
            #bbf7d0 60%,
            #86efac 80%,
            #22c55e 100%);
    position: relative;
    flex-shrink: 0;
}

.valence-bar-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid var(--text-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease;
}

.valence-value {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.valence-value.positive {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success-dark);
}

.valence-value.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.valence-value.neutral {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-secondary);
}

/* Compact variant for metric-box */
.valence-meter--compact {
    margin-top: 8px;
    justify-content: center;
}

.valence-meter--compact .valence-bar-gradient {
    width: 100%;
    max-width: 120px;
}

/* --------------------------------------------------------------------------
   Metric Items
   -------------------------------------------------------------------------- */
.metrics-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.metric-item .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   LLM/Indexer Card
   -------------------------------------------------------------------------- */
.indexer-card {
    background: linear-gradient(135deg, rgba(92, 107, 89, 0.05), rgba(156, 169, 152, 0.05));
    border: 1px solid rgba(92, 107, 89, 0.2);
    border-radius: var(--border-radius);
    padding: 20px;
}

.indexer-card h2 {
    font-size: 1rem;
    color: var(--title, #3A4238);
    margin-bottom: 15px;
}

.indexer-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.indexer-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.indexer-stat .label {
    color: var(--text-secondary);
}

.indexer-stat .value {
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Emotional Analysis Box
   -------------------------------------------------------------------------- */
.emotional-analysis {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.emotional-analysis h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--primary);
}

.emotion-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

/* --------------------------------------------------------------------------
   LLM Summary Box
   -------------------------------------------------------------------------- */
.llm-summary {
    background: linear-gradient(135deg, rgba(92, 107, 89, 0.05), rgba(156, 169, 152, 0.05));
    border: 1px solid rgba(92, 107, 89, 0.2);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.llm-summary h3 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.llm-summary p {
    font-style: italic;
    line-height: 1.6;
}

/* ============================================
   Wikilinks — inline [[link]] styles
   ============================================ */

.wikilink {
    border-radius: 3px;
    padding: 1px 4px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.wikilink-entry {
    background: rgba(92, 107, 89, 0.1);
    color: var(--primary, #5C6B59);
    border-bottom: 1px solid rgba(92, 107, 89, 0.3);
}

.wikilink-entry:hover {
    background: rgba(92, 107, 89, 0.2);
    color: var(--primary-dark, #3A4238);
    text-decoration: none;
}

.wikilink-relationship {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-dark);
    border-bottom: 1px solid rgba(34, 197, 94, 0.3);
}

.wikilink-relationship:hover {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success-dark);
    text-decoration: none;
}

.wikilink-unresolved {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-secondary);
    border-bottom: 1px dashed rgba(156, 163, 175, 0.5);
    cursor: default;
}

.wikilink-self {
    background: rgba(92, 107, 89, 0.05);
    color: var(--text-secondary);
    border-bottom: 1px dotted rgba(92, 107, 89, 0.2);
    cursor: default;
}

/* Reference links from autocomplete */
.entry-content a[href*="/relationships/"],
.prose a[href*="/relationships/"] {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-dark);
    border-radius: 3px;
    padding: 1px 4px;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(34, 197, 94, 0.3);
    transition: background 0.15s ease, color 0.15s ease;
}

.entry-content a[href*="/relationships/"]:hover,
.prose a[href*="/relationships/"]:hover {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success-dark);
    text-decoration: none;
}

.entry-content a[href*="/entries/"],
.prose a[href*="/entries/"] {
    background: rgba(92, 107, 89, 0.1);
    color: var(--primary, #5C6B59);
    border-radius: 3px;
    padding: 1px 4px;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(92, 107, 89, 0.3);
    transition: background 0.15s ease, color 0.15s ease;
}

.entry-content a[href*="/entries/"]:hover,
.prose a[href*="/entries/"]:hover {
    background: rgba(92, 107, 89, 0.2);
    color: var(--primary-dark, #3A4238);
    text-decoration: none;
}

/* ── Pro Badge (small, shared across pages) ── */
.pro-badge-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary, #5C6B59);
    background: rgba(92, 107, 89, 0.1);
    border: 1px solid rgba(92, 107, 89, 0.25);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}