/*
 * The Source - page-specific styling.
 * Linear / Kanso redesign suite. Token-based only so the page
 * recolors with every theme (kanso-zen/ink/pearl, dusk, ember, frost, verdant).
 */

.source-page {
    max-width: none;
}

/* ----- PAGE HEADER ----- */
.source-pagehead {
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.source-pagehead h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -.022em;
    line-height: 1.05;
    margin-bottom: 8px;
    color: var(--text-bright);
}
.source-deck {
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    max-width: 76ch;
}

/* ----- SEARCH ----- */
.source-search {
    position: relative;
    margin-bottom: 22px;
    max-width: 480px;
}
.source-search-icon {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-fade);
    pointer-events: none;
}
.source-search-icon svg { width: 15px; height: 15px; display: block; }
.source-search input {
    width: 100%;
    height: 38px;
    padding: 0 40px 0 34px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-bright);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
}
.source-search input::placeholder { color: var(--text-fade); }
.source-search input:focus {
    border-color: var(--highlight);
    box-shadow: var(--focus-ring);
}
.source-search .kbd {
    position: absolute;
    right: 10px; top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-fade);
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 6px;
    pointer-events: none;
}

/* ----- LAYOUT: nav aside + main ----- */
.source-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
@media (max-width: 820px) {
    .source-layout { grid-template-columns: minmax(0, 1fr); }
    .source-aside { order: 2; }
}

.source-aside {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 24px;
}
@media (max-width: 820px) {
    .source-aside { position: static; }
}

.source-main {
    min-width: 0;
}

/* ----- PANELS ----- */
.source-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}
.source-panel-head {
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-fade);
    margin-bottom: 8px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}
.source-panel-meta {
    color: var(--text-fade);
}
details.source-panel { padding-bottom: 14px; }
.source-panel-fold {
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.source-panel-fold::-webkit-details-marker { display: none; }
.source-panel-fold::before {
    content: '\25B8';
    margin-right: 5px;
    color: var(--text-fade);
    display: inline-block;
    transition: transform var(--t-base);
}
details.source-panel[open] .source-panel-fold::before { transform: rotate(90deg); }
details.source-panel:not([open]) .source-panel-head { margin-bottom: 0; }

/* ----- NAV LISTS ----- */
.source-navlist {
    list-style: none;
    margin: 0; padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.source-navlist-scroll {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.source-navlist-scroll::-webkit-scrollbar { width: 5px; }
.source-navlist-scroll::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

.source-navrow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    transition: background var(--t-base), color var(--t-base);
}
.source-navrow:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
}
.source-navrow.active {
    background: var(--accent-muted);
    color: var(--text-bright);
}
.source-navlabel {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.source-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-fade);
}
.source-navrow.active .source-count { color: var(--highlight); }

.source-year {
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    padding: 8px 8px 3px;
}
.source-year:first-child { padding-top: 2px; }
.source-monthrow { padding-left: 16px; }

/* ----- STAT BAR ----- */
.source-statbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-dim);
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.source-statbar strong { color: var(--text-bright); font-weight: 500; }
.source-statbar .dot { color: var(--text-fade); }
.source-statbar-faint { color: var(--text-fade); }

/* ----- TOPIC CARD GRID (dashboard) ----- */
.source-cardgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.source-card {
    display: flex;
    flex-direction: column;
    min-height: 140px;
    padding: 16px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: border-color var(--t-base), background var(--t-base);
}
.source-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}
.source-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.source-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.2;
    color: var(--text-bright);
}
.source-card-preview {
    margin: 0 0 12px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.source-card-foot {
    margin-top: auto;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-fade);
}
.source-card-when {
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ----- FEED META ----- */
.source-feedmeta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.source-feedback {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    text-decoration: none;
}
.source-feedback:hover { color: var(--highlight); }
.source-feedback::before { content: '\2190'; margin-right: 5px; }
.source-feedlabel {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--text-bright);
}

/* ----- FRAGMENTS ----- */
.fragment {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 10px;
    scroll-margin-top: 24px;
    transition: border-color var(--t-base);
}
.fragment:hover { border-color: var(--border-hover); }
.fragment.fragment-flagged { border-left: 2px solid var(--error); }
.fragment:target {
    border-color: var(--highlight);
    box-shadow: var(--focus-ring);
}

.fragment-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.fragment-author {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-bright);
    text-decoration: none;
}
.fragment-author:hover { color: var(--highlight); }
.fragment-time {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-fade);
}
.fragment-tag {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 7px;
}
.fragment-tag.verified {
    color: var(--accent);
    border-color: rgba(var(--accent-rgb), .4);
    background: rgba(var(--accent-rgb), .1);
}
.fragment-tag.unsanctioned {
    color: var(--error);
    border-color: rgba(var(--error-rgb), .4);
    background: rgba(var(--error-rgb), .1);
}

.fragment-body {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
}
.fragment-body p + p { margin-top: 8px; }
.fragment-body a { color: var(--link); }
.fragment-body a:hover { color: var(--link-hover); }
.fragment-body code:not(pre code) {
    font-family: var(--font-mono);
    font-size: .88em;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .05em .4em;
    color: var(--highlight);
}
.fragment-body pre {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 14px;
    margin: 10px 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-bright);
}
.fragment-body blockquote {
    border-left: 2px solid var(--border-hover);
    padding-left: 14px;
    margin: 10px 0;
    color: var(--text-dim);
}

.fragment-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.fragment-image {
    display: block;
    max-width: 320px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color var(--t-base);
}
.fragment-image:hover { border-color: var(--border-hover); }
.fragment-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: cover;
    background: var(--bg-body);
}
.fragment-file {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    text-decoration: none;
}
.fragment-file:hover { color: var(--highlight); border-color: var(--border-hover); }

.fragment-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.fragment-foot a,
.fragment-foot button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    text-decoration: none;
    transition: color var(--t-base);
}
.fragment-foot a:hover,
.fragment-foot button:hover { color: var(--highlight); }
.fragment-modform { display: inline; }
.fragment-foot-spacer { flex: 1; }
.fragment-foot-id {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-fade);
}

.fragment-thread {
    margin: 0 0 10px 24px;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}
.fragment-reply {
    background: var(--bg-panel);
    margin-bottom: 8px;
}

/* ----- NOTE / FOOTER ----- */
.source-note {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-dim);
}
.source-note p + p { margin-top: 4px; }
.source-note code {
    font-family: var(--font-mono);
    font-size: .9em;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--highlight);
}

/* ----- EMPTY STATE ----- */
.source-empty {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 36px 24px;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
}
.source-empty p { margin: 4px 0; }
.source-empty-hint {
    font-size: 12.5px;
    color: var(--text-fade);
}
