/* Shared by docs.html and brief.html: markdown content, callouts, source cards,
   tables, the version history and the composition widget. */
/* Docs-specific styles that extend the base CSS */

/* Variable colors for docs (aligned with main CSS) */
:root {
    --inflow: var(--inflow-color);
    --outflow: var(--outflow-color);
    --net: var(--net-color);
}

/* Variable dots in tables */
.docs-content td code.inflow,
.docs-content td code.outflow,
.docs-content td code.net {
    white-space: nowrap;
}

.docs-content td code.inflow::before,
.docs-content td code.outflow::before,
.docs-content td code.net::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.docs-content td code.inflow::before { background: var(--inflow-color); }
.docs-content td code.outflow::before { background: var(--outflow-color); }
.docs-content td code.net::before { background: var(--net-color); }

/* Source cards */
.source-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.source-card {
    background: var(--bg-secondary);
    border: 1px solid var(--hairline);
    border-radius: 2px;
    padding: 1.1rem 1.25rem;
    transition: border-color 0.18s ease;
}

.source-card:hover { border-color: var(--text-primary); }

.source-card h4 {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.45rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.source-card .badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.55rem;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 999px;
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.source-card p {
    font-size: 0.82rem;
    margin: 0;
    color: var(--text-muted);
    line-height: 1.55;
}

/* Process steps */
.process-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
}

.process-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-number {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #fbf9f4;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.step-content h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.step-content p {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text-secondary);
}

/* Docs footer */
.docs-footer {
    margin-top: 4rem;
    padding: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid var(--glass-border-soft);
}

.docs-footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.docs-footer a {
    color: var(--accent);
    text-decoration: none;
}

.docs-footer a:hover { text-decoration: underline; }

/* Loading */
.loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
}

/* Docs-specific h1 adjustment */
.docs-content h1 {
    margin: 3rem 0 1.5rem;
}

.docs-content h1:first-child { margin-top: 0; }

/* Docs blockquote */
.docs-content blockquote {
    background: var(--accent-dim);
    border-left: 3px solid var(--accent);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.docs-content blockquote p {
    color: var(--text-primary);
    margin: 0;
    font-size: 0.95rem;
}

.docs-content blockquote.warning {
    background: rgba(197, 128, 18, 0.1);
    border-color: #c58012;
}

/* Callouts */
.callout {
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-left: 4px solid;
}

.callout-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.callout-content {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.callout-note {
    background: var(--accent-dim);
    border-color: var(--accent);
}
.callout-note .callout-title { color: var(--accent-ink); }

.callout-tip {
    background: rgba(90, 125, 42, 0.1);
    border-color: #5a7d2a;
}
.callout-tip .callout-title { color: #4a6822; }

.callout-warning {
    background: rgba(197, 128, 18, 0.1);
    border-color: #c58012;
}
.callout-warning .callout-title { color: #a86f10; }

.callout-caution {
    background: rgba(179, 64, 47, 0.1);
    border-color: #b3402f;
}
.callout-caution .callout-title { color: #a03728; }

.callout-important {
    background: rgba(125, 74, 120, 0.1);
    border-color: #7d4a78;
}
.callout-important .callout-title { color: #6d3f69; }

/* Flat editorial tables — no rounded corners */

/* Version pill — used in the changelog summary and in the latest row */
.ver-pill {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 0.16rem 0.55rem;
    border-radius: 999px;
    vertical-align: middle;
    margin-right: 0.25rem;
}

.ver-summary-num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin-left: 0.25rem;
}

.ver-summary-date {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* Labels at the top of each version: the kinds of change it brings */
.ver-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
}

.ver-tipo {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    border: 1px solid var(--hairline-strong);
    border-radius: 3px;
    padding: 0.04rem 0.4rem;
}

/* Marks the version a publication was built with */
.ver-pill-brief {
    color: var(--inflow-color);
    background: transparent;
    border: 1px solid currentColor;
    margin-right: 0;
}

.ver-intro {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.85rem 1.1rem 0;
    margin: 0;
}

/* Version history — collapsible past versions */
details.version-history {
    margin: 1.5rem 0;
    border: 1px solid var(--hairline);
    border-radius: var(--border-radius-sm);
    background: var(--bg-secondary);
    overflow: hidden;
}

details.version-history summary {
    cursor: pointer;
    padding: 0.85rem 1.1rem;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    transition: color 0.15s ease;
}

details.version-history summary::-webkit-details-marker { display: none; }
details.version-history summary::marker { content: ''; }

details.version-history summary::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid var(--accent);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.18s ease;
}

details.version-history[open] summary::before {
    transform: rotate(90deg);
}

details.version-history summary:hover { color: var(--accent); }

details.version-history[open] summary {
    border-bottom: 1px solid var(--hairline);
}

details.version-history table {
    margin: 0;
    border-radius: 0;
    width: 100%;
    box-shadow: none;
    border: none;
}

details.version-history table th:first-child,
details.version-history table td:first-child {
    white-space: nowrap;
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--accent);
    font-size: 0.85rem;
}

details.version-history table td:nth-child(2) {
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* =====================================================================
   Composition widget — interactive tax / spending breakdown
   Hooked into markdown via :::composition syntax. The widget reads from
   site/data/composition_2024.json and renders two horizontal stacked
   bars (outflows + inflows). Clicking any segment expands a detail
   panel with NTL / SEEPROS instruments beneath the bar.
   ===================================================================== */

.composition-widget {
    margin: 2.25rem 0 2rem;
    font-family: var(--font-sans);
}

.comp-block {
    margin-bottom: 2.1rem;
}

.comp-block:last-child { margin-bottom: 0; }

.comp-block-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.55rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--hairline);
}

.comp-block-title {
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    margin: 0;
}

.comp-block-total {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.comp-block-total .comp-unit {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-left: 0.3rem;
}

.comp-bar {
    display: flex;
    width: 100%;
    height: 60px;
    border: 1px solid var(--hairline-strong);
    overflow: hidden;
    background: var(--bg-secondary);
    position: relative;
}

.comp-segment {
    position: relative;
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    border: none;
    background: transparent;
    text-align: left;
    color: inherit;
    font: inherit;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.18s ease,
                filter 0.18s ease;
    min-width: 0;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.42);
}

.comp-segment:last-child { border-right: none; }

.comp-segment.outflow {
    background: var(--outflow-color);
    color: #fff;
}
.comp-segment.outflow:nth-of-type(1) { background: #285a89; }
.comp-segment.outflow:nth-of-type(2) { background: #337ec0; }
.comp-segment.outflow:nth-of-type(3) { background: #5aa3d8; }

.comp-segment.inflow {
    background: var(--inflow-color);
    color: #fff;
}
.comp-segment.inflow:nth-of-type(1) { background: #a51c14; }
.comp-segment.inflow:nth-of-type(2) { background: #c93423; }
.comp-segment.inflow:nth-of-type(3) { background: #de2d26; }
.comp-segment.inflow:nth-of-type(4) { background: #f06045; }
.comp-segment.inflow:nth-of-type(5) { background: #fc9272; }

.comp-segment:hover { filter: brightness(1.06); }

.comp-segment.is-active {
    box-shadow: inset 0 -3px 0 var(--net-color);
}

.comp-segment-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comp-segment-value {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comp-segment-value .comp-segment-pct {
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.75;
    margin-left: 0.3rem;
    letter-spacing: 0.02em;
}

/* Narrow segments hide the value if the segment is too thin */
.comp-segment[data-narrow="true"] .comp-segment-value { font-size: 0.85rem; }
.comp-segment[data-narrow="true"] .comp-segment-pct { display: none; }

.comp-segment-name {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    margin-top: 0.45rem;
    color: var(--text-secondary);
    white-space: normal;
}

.comp-bar-names {
    display: flex;
    width: 100%;
    margin-top: 0.35rem;
    gap: 0;
}

.comp-bar-name {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0 0.8rem;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.comp-detail {
    margin-top: 1rem;
    padding: 1.25rem 1.4rem 1.35rem;
    border: 1px solid var(--hairline);
    background: var(--bg-secondary);
    display: none;
    position: relative;
}

.comp-detail.is-open {
    display: block;
    animation: comp-detail-in 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes comp-detail-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.comp-detail::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--net-color);
    opacity: 0.85;
}

.comp-detail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 0.45rem;
}

.comp-detail-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.005em;
}

.comp-detail-total {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.comp-detail-caption {
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0.2rem 0 1.1rem;
}

.comp-group {
    border-top: 1px solid var(--hairline);
    padding: 0.85rem 0 0.2rem;
}

.comp-group:first-of-type { border-top: 1px solid var(--hairline-strong); }

.comp-group-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.45rem;
}

.comp-group-name {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.005em;
}

.comp-group-name .comp-group-note {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.45rem;
    padding: 0.08rem 0.42rem;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    vertical-align: 0.05em;
}

.comp-group-value {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.comp-instruments {
    list-style: none;
    padding: 0;
    margin: 0 0 0.4rem;
}

.comp-instrument {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem 1rem;
    align-items: baseline;
    padding: 0.42rem 0;
    border-bottom: 1px dashed var(--hairline);
    font-size: 0.82rem;
}

.comp-instrument:last-child { border-bottom: none; }

.comp-instrument-name {
    min-width: 0;
    line-height: 1.4;
}

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

.comp-instrument-name-secondary {
    display: block;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-style: italic;
    margin-top: 0.08rem;
}

.comp-instrument-code {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.6rem;
    color: var(--text-muted);
    background: var(--glass-tint);
    padding: 0.06rem 0.36rem;
    border-radius: 999px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-right: 0.4rem;
    vertical-align: 0.1em;
}

.comp-instrument-value {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.comp-instrument-value .comp-instrument-unit {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.25rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.comp-empty {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-style: italic;
    padding: 0.3rem 0 0;
}

.comp-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin-top: 0.95rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--hairline);
}

.comp-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 0.3rem 0 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.comp-hint::before {
    content: '↳';
    color: var(--accent);
    font-weight: 700;
}

@media (max-width: 720px) {
    .comp-bar { height: auto; flex-direction: column; }
    .comp-segment { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.4); padding: 0.85rem 1rem; }
    .comp-bar-names { display: none; }
    .comp-instrument { grid-template-columns: 1fr; }
    .comp-instrument-value { text-align: left; }
    .comp-detail-head { flex-direction: column; gap: 0.35rem; }
}

/* Phones: the version table fits the screen (dates wrap) and scrolls if it must */
@media (max-width: 640px) {
    details.version-history { overflow-x: auto; }
    details.version-history table td:nth-child(2),
    details.version-history table th:nth-child(2) { white-space: normal; }
    .docs-content table { display: block; max-width: 100%; overflow-x: auto; }
}
