/* ============== SOURCES LOGO GRID ============== */
.sources {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 1rem;
    justify-content: center;
    align-content: start;
    width: 100%;
    padding: 0 0 1rem 0; /* reduced top padding */
    clear: both !important;
    margin-top: 2.5rem;
}

/* Logo styling */
.logo-96 {
    width: 96px !important;
    height: auto !important;
    display: block;
    object-fit: contain;
    filter: grayscale(30%);
    transition: filter 180ms ease;
}

.logo-96:hover {
    cursor: pointer;
    filter: grayscale(0%);
}

/* === FIX FOR THE FULL-WIDTH CARD === */
.card.col-span-3 {
    grid-column: 1 / -1 !important; /* Forces it to span all columns cleanly */
    /* Re-establish the baseline borders explicitly and override the global index logic */
    border-top: 2px solid var(--line) !important;
    border-bottom: none !important;
    border-left: 2px solid var(--line) !important;
    border-right: 2px solid var(--line) !important;
    /*  padding-top: 24px !important; keeps internal spacing consistent */
}
.sources img:first-child {
    border-top: none !important;
    border-left: none !important;
}

.gap-4 {
    gap: 1rem;
}

.mr-auto {
    margin-left: auto;
    width:fit-content;
}
.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

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

/* ============== MULTI-AGENT SYSTEM ============== */
.mas-system {
    min-height: 100%;
}

.mas-map {
    display: grid;
    align-content: center;
    gap: 0;
    min-height: 520px;
    padding: clamp(24px, 4vw, 48px);
    background:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 32px 32px;
}

.mas-map-stage {
    position: relative;
    display: grid;
    gap: 8px;
    padding: 18px 20px;
    border: 2px solid var(--line);
    background: var(--surface);
}

.mas-map-stage span,
.mas-map-stage small,
.mas-agent span {
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mas-map-stage span,
.mas-map-stage small {
    color: var(--muted);
}

.mas-map-stage strong {
    font-family: var(--font-display);
    font-size: clamp(24px, 2.2vw, 34px);
    line-height: 0.95;
    letter-spacing: -0.035em;
}

.mas-goal {
    border-color: var(--accent);
}

.mas-orchestrator {
    border-color: var(--fg);
    background: var(--fg);
    color: var(--bg);
}

.mas-orchestrator span,
.mas-orchestrator small {
    color: color-mix(in oklch, var(--bg), transparent 22%);
}

.mas-outcome {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--ink);
}

.mas-outcome span {
    color: var(--ink);
}

.mas-map-link {
    display: grid;
    place-items: center;
    min-height: 58px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mas-map-link::before {
    content: "";
    width: 2px;
    height: 22px;
    background: var(--line);
}

.mas-map-link span {
    padding: 4px 8px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--muted);
}

.mas-agent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 2px solid var(--line);
    border-left: 0;
    background: var(--surface);
}

.mas-agent {
    display: grid;
    gap: 12px;
    min-width: 0;
    padding: 16px;
    border-left: 2px solid var(--line);
}

.mas-agent span {
    color: var(--muted);
}

.mas-agent strong {
    overflow-wrap: anywhere;
    font-family: var(--font-display);
    font-size: clamp(20px, 1.8vw, 28px);
    line-height: 1;
}

.topology-card h3 {
    font-size: clamp(36px, 4vw, 62px);
}

.topology-hybrid-band {
    display: grid;
    grid-template-columns: minmax(150px, 0.7fr) minmax(0, 2fr) minmax(170px, 0.65fr);
    gap: clamp(24px, 4vw, 64px);
    align-items: start;
    padding: clamp(28px, 4vw, 56px);
    border: 2px solid var(--line);
    border-top: 0;
    background: var(--fg);
    color: var(--bg);
}

.topology-hybrid-band .kicker {
    color: color-mix(in oklch, var(--bg), transparent 20%);
}

.topology-hybrid-band h3 {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-size: clamp(34px, 4vw, 60px);
    line-height: 0.95;
    letter-spacing: -0.035em;
}

.topology-hybrid-band p {
    margin: 0;
    color: color-mix(in oklch, var(--bg), transparent 18%);
    line-height: 1.65;
}

.topology-hybrid-band > strong {
    align-self: stretch;
    display: grid;
    place-items: center;
    min-height: 120px;
    padding: 20px;
    border: 2px solid var(--bg);
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1.35;
    text-align: center;
    text-transform: uppercase;
}

.okf-flow {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    margin: 0;
    padding: 0;
    border: 2px solid var(--line);
    border-top: 0;
    list-style: none;
}

.okf-flow li {
    position: relative;
    display: grid;
    align-content: start;
    gap: 12px;
    min-width: 0;
    min-height: 190px;
    padding: 22px;
    border-left: 2px solid var(--line);
    background: var(--surface);
}

.okf-flow li:first-child {
    border-left: 0;
}

.okf-flow li:not(:last-child)::after {
    content: "→";
    position: absolute;
    z-index: 1;
    top: 50%;
    right: -15px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 2px solid var(--line);
    background: var(--bg);
    font-family: var(--font-mono);
    transform: translateY(-50%);
}

.okf-flow li:nth-child(4) {
    background: var(--fg);
    color: var(--bg);
}

.okf-flow li > span {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
}

.okf-flow li:nth-child(4) > span,
.okf-flow li:nth-child(4) small {
    color: color-mix(in oklch, var(--bg), transparent 22%);
}

.okf-flow strong {
    font-family: var(--font-display);
    font-size: clamp(27px, 2.5vw, 38px);
    line-height: 0.95;
    letter-spacing: -0.03em;
}

.okf-flow small {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.mas-value-report {
    align-items: stretch;
}

.mas-value-aside {
    display: grid;
    align-content: start;
    gap: 22px;
}

.mas-value-aside ol {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    border: 2px solid var(--line);
    list-style: none;
}

.mas-value-aside li {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 14px;
    align-items: center;
    padding: 16px;
    border-top: 2px solid var(--line);
}

.mas-value-aside li:first-child {
    border-top: 0;
}

.mas-value-aside b {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.mas-value-aside span {
    font-weight: 700;
    line-height: 1.35;
}

.insights-bridge {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 2px solid var(--line);
    border-top: 0;
    background: var(--surface);
}

.insights-bridge-direction {
    display: grid;
    align-content: start;
    gap: 20px;
    min-width: 0;
    padding: clamp(28px, 4vw, 52px);
    border-left: 2px solid var(--line);
}

.insights-bridge-direction:first-child {
    border-left: 0;
}

.insights-bridge-direction h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(38px, 4vw, 62px);
    line-height: 0.92;
    letter-spacing: -0.04em;
}

.insights-bridge-direction > p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.insights-bridge-direction ul {
    display: grid;
    margin: 4px 0 0;
    padding: 0;
    border: 2px solid var(--line);
    list-style: none;
}

.insights-bridge-direction li {
    position: relative;
    padding: 14px 16px 14px 42px;
    border-top: 2px solid var(--line);
    font-weight: 700;
    line-height: 1.4;
}

.insights-bridge-direction li:first-child {
    border-top: 0;
}

.insights-bridge-direction li::before {
    content: "✓";
    position: absolute;
    left: 16px;
    color: var(--accent);
    font-family: var(--font-mono);
}

.insights-boundary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: clamp(28px, 5vw, 80px);
    align-items: end;
    padding: clamp(30px, 5vw, 64px);
    border: 2px solid var(--line);
    border-top: 0;
    background: var(--fg);
    color: var(--bg);
}

.insights-boundary .kicker {
    color: color-mix(in oklch, var(--bg), transparent 20%);
}

.insights-boundary h3 {
    max-width: 950px;
    margin: 16px 0;
    font-family: var(--font-display);
    font-size: clamp(40px, 5vw, 74px);
    line-height: 0.92;
    letter-spacing: -0.04em;
}

.insights-boundary p {
    max-width: 900px;
    margin: 0;
    color: color-mix(in oklch, var(--bg), transparent 18%);
    line-height: 1.7;
}

.insights-boundary .button {
    border-color: var(--bg);
    background: transparent;
    color: var(--bg);
    white-space: nowrap;
}

.insights-boundary .button:hover {
    background: var(--bg);
    color: var(--fg);
}

@media (max-width: 1060px) {
    .topology-hybrid-band {
        grid-template-columns: 1fr;
    }

    .topology-hybrid-band > strong {
        min-height: 90px;
    }

    .okf-flow {
        grid-template-columns: 1fr 1fr;
    }

    .okf-flow li {
        min-height: 160px;
        border-top: 2px solid var(--line);
    }

    .okf-flow li:nth-child(-n + 2) {
        border-top: 0;
    }

    .okf-flow li:nth-child(odd) {
        border-left: 0;
    }

    .okf-flow li:last-child {
        grid-column: 1 / -1;
        border-left: 0;
    }

    .okf-flow li::after {
        display: none !important;
    }

    .insights-bridge {
        grid-template-columns: 1fr;
    }

    .insights-bridge-direction {
        border-top: 2px solid var(--line);
        border-left: 0;
    }

    .insights-bridge-direction:first-child {
        border-top: 0;
    }

    .insights-boundary {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .insights-boundary .button {
        justify-self: start;
    }
}

@media (max-width: 760px) {
    .mas-map {
        min-height: auto;
        padding: 24px;
        background-size: 24px 24px;
    }

    .mas-agent-grid {
        grid-template-columns: 1fr;
        border-bottom: 0;
    }

    .mas-agent {
        border-bottom: 2px solid var(--line);
    }

    .okf-flow {
        grid-template-columns: 1fr;
    }

    .okf-flow li,
    .okf-flow li:nth-child(-n + 2) {
        min-height: auto;
        border-top: 2px solid var(--line);
        border-left: 0;
    }

    .okf-flow li:first-child {
        border-top: 0;
    }

    .okf-flow li:last-child {
        grid-column: auto;
    }

    .insights-bridge-direction,
    .insights-boundary {
        padding: 24px;
    }
}

/* ============== SYSTEM DIAGRAM (MERMAID) ============== */
.diagram {
    display: grid;
    place-items: center;
    padding: 24px 0;
    overflow-x: auto;
}
.diagram .mermaid {
    width: 100%;
    max-width: 880px;
}

.diagram .mermaid svg {
    max-width: 100%;
    height: auto;
    background: transparent;
}

.diagram .mermaid svg .node rect,
.diagram .mermaid svg .node polygon,
.diagram .mermaid svg .node ellipse,
.diagram .mermaid svg .node circle {
    fill: var(--surface) !important;
    stroke: var(--border) !important;
    stroke-width: 2px !important;
}

.diagram .mermaid svg .node rect {
    rx: 0 !important;
    ry: 0 !important;
}

.diagram .mermaid svg .cluster rect {
    fill: var(--panel) !important;
    stroke: var(--border) !important;
    stroke-width: 2px !important;
    rx: 0 !important;
}

.diagram .mermaid svg .node.accent rect,
.diagram .mermaid svg .node.accent polygon {
    stroke: var(--accent) !important;
}

.diagram .mermaid svg .nodeLabel,
.diagram .mermaid svg .nodeLabel div,
.diagram .mermaid svg .nodeLabel span,
.diagram .mermaid svg .nodeLabel p,
.diagram .mermaid svg .nodeLabel b,
.diagram .mermaid svg .nodeLabel i {
    font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace !important;
    line-height: 1.35;
}

.diagram .mermaid svg .nodeLabel b {
    color: var(--fg) !important;
}

.diagram .mermaid svg .nodeLabel i {
    color: var(--muted) !important;
    font-style: normal;
    font-size: 12px;
}

.diagram .mermaid svg .cluster-label span {
    color: var(--muted) !important;
    font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace !important;
}

.diagram .mermaid svg .edgePath path {
    stroke: var(--line) !important;
}

.diagram .mermaid svg .marker {
    fill: var(--border) !important;
}

.diagram .mermaid svg .edgeLabel {
    font-size: 11px;
}

.diagram .mermaid svg .edgeLabel span {
    color: var(--muted) !important;
}

.diagram .mermaid svg .edgeLabel rect {
    fill: var(--bg) !important;
}

.text-white {
    color: white !important;
}