/* 2026-01-12 | diagrams-css | WHY: web-responsive-diagrams | FROM: design-system-extension */

/**
 * DIAGRAMS.CSS - Extension for Web-Responsive Diagrams
 *
 * Purpose: Standalone diagrams for articles/web (NOT carousel slides)
 *
 * Key differences from carousel system:
 * - Responsive (max-width) instead of fixed 320×400
 * - No branding elements (logo, handle, mascot)
 * - Inherits palette & typography from themes.css
 *
 * Usage:
 *   <link rel="stylesheet" href="themes.css">
 *   <link rel="stylesheet" href="diagrams.css">
 *
 *   <div class="diagram var-soft">
 *       <div class="diagram-title">...</div>
 *       <div class="diagram-content">...</div>
 *   </div>
 */

/* ==========================================================================
   BASE DIAGRAM CONTAINER
   ========================================================================== */

.diagram {
    /* Responsive sizing */
    width: 100%;
    max-width: 480px;
    min-height: 200px;

    /* Structure */
    padding: 24px;
    border-radius: 8px;
    box-sizing: border-box;

    /* Layout */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Size variants */
.diagram.diagram-sm {
    max-width: 320px;
    padding: 20px;
    gap: 12px;
}

.diagram.diagram-lg {
    max-width: 600px;
    padding: 32px;
    gap: 20px;
}

.diagram.diagram-wide {
    max-width: 800px;
}

/* ==========================================================================
   DIAGRAM TITLE
   ========================================================================== */

.diagram-title {
    font-family: var(--font-h1);
    font-size: 1.3rem;
    line-height: 1;
    text-align: center;
}

.diagram-subtitle {
    font-family: var(--font-h2);
    font-size: 0.75rem;
    text-transform: lowercase;
    text-align: center;
    opacity: 0.8;
}

/* ==========================================================================
   DIAGRAM CONTENT LAYOUTS
   ========================================================================== */

.diagram-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Horizontal split (two columns) */
.diagram-content.split {
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
}

/* Grid layout */
.diagram-content.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.diagram-content.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* ==========================================================================
   DIAGRAM BOXES (reusable containers)
   ========================================================================== */

.diagram-box {
    padding: 14px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diagram-box.flex-1 {
    flex: 1;
}

/* Box header with icon */
.box-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.box-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.box-icon svg {
    width: 16px;
    height: 16px;
}

.box-label {
    font-family: var(--font-h2);
    font-size: 0.75rem;
    text-transform: lowercase;
}

/* ==========================================================================
   DIAGRAM ITEMS (lists, steps, etc.)
   ========================================================================== */

.diagram-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.diagram-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: 0.65rem;
}

.item-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.item-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-h2);
    font-size: 0.7rem;
    flex-shrink: 0;
}

/* ==========================================================================
   DIAGRAM ARROWS & CONNECTORS
   ========================================================================== */

.diagram-arrows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    width: 60px;
}

.arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.arrow svg {
    width: 22px;
    height: 22px;
}

.arrow-label {
    font-family: var(--font-h2);
    font-size: 0.55rem;
    text-transform: lowercase;
    opacity: 0.7;
}

/* Horizontal flow */
.diagram-flow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.flow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.flow-box {
    padding: 6px 8px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.55rem;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.flow-arrow {
    font-size: 0.8rem;
    opacity: 0.5;
    flex-shrink: 0;
}

/* ==========================================================================
   DIAGRAM STAGES (funnel, timeline)
   ========================================================================== */

.diagram-stages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.stage {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 6px;
    position: relative;
}

.stage-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-h2);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.stage-content {
    flex: 1;
}

.stage-name {
    font-family: var(--font-h2);
    font-size: 0.7rem;
    text-transform: lowercase;
    margin-bottom: 2px;
}

.stage-desc {
    font-family: var(--font-body);
    font-size: 0.6rem;
    opacity: 0.75;
}

.stage-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage-icon svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   DIAGRAM BALANCE (comparison layout)
   ========================================================================== */

.diagram-balance {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 40px;
    flex: 1;
}

.balance-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.balance-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.balance-icon svg {
    width: 24px;
    height: 24px;
}

.balance-label {
    font-family: var(--font-h2);
    font-size: 0.7rem;
    text-transform: lowercase;
    letter-spacing: 0.5px;
}

.balance-metrics {
    font-family: var(--font-body);
    font-size: 0.65rem;
    text-align: center;
    opacity: 0.8;
    line-height: 1.4;
}

.balance-fulcrum {
    position: relative;
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fulcrum-line {
    width: 100%;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
}

.fulcrum-center {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fulcrum-center svg {
    width: 14px;
    height: 14px;
}

/* ==========================================================================
   DIAGRAM AMPLIFIER (bottom highlight)
   ========================================================================== */

.diagram-amplifier {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 6px;
    margin-top: auto;
}

.amplifier-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.amplifier-icon svg {
    width: 16px;
    height: 16px;
}

.amplifier-label {
    font-family: var(--font-h2);
    font-size: 0.7rem;
    text-transform: lowercase;
}

/* ==========================================================================
   THEME OVERRIDES FOR DIAGRAMS

   These extend themes.css with diagram-specific styling.
   Each theme defines colors for diagram components.
   ========================================================================== */

/* --- var-soft (light dragée background) --- */
.var-soft.diagram {
    background: var(--oi-dragee);
    color: var(--oi-marine);
}

.var-soft .diagram-box.primary {
    background: var(--oi-empire);
    color: var(--oi-albatre);
}

.var-soft .diagram-box.secondary {
    background: var(--oi-albatre);
    color: var(--oi-marine);
}

.var-soft .diagram-box.primary .box-icon {
    background: var(--oi-chartreuse);
}

.var-soft .diagram-box.primary .box-icon svg {
    stroke: var(--oi-marine);
}

.var-soft .diagram-box.primary .item-dot {
    background: var(--oi-chartreuse);
}

.var-soft .diagram-box.secondary .box-icon {
    background: var(--oi-marine);
}

.var-soft .diagram-box.secondary .box-icon svg {
    stroke: var(--oi-albatre);
}

.var-soft .diagram-box.secondary .item-dot {
    background: var(--oi-empire);
}

.var-soft .arrow svg {
    stroke: var(--oi-marine);
}

/* --- var-clear (light albâtre background) --- */
.var-clear.diagram {
    background: var(--oi-albatre);
    color: var(--oi-marine);
}

.var-clear .diagram-box {
    background: rgba(27, 34, 44, 0.05);
}

.var-clear .diagram-box.primary {
    background: var(--oi-empire);
    color: var(--oi-albatre);
}

.var-clear .diagram-box.secondary {
    background: var(--oi-dragee);
    color: var(--oi-marine);
}

.var-clear .diagram-box.primary .box-icon {
    background: var(--oi-chartreuse);
}

.var-clear .diagram-box.primary .box-icon svg {
    stroke: var(--oi-marine);
}

.var-clear .diagram-box.primary .item-dot {
    background: var(--oi-chartreuse);
}

.var-clear .diagram-box.secondary .box-icon {
    background: var(--oi-empire);
}

.var-clear .diagram-box.secondary .box-icon svg {
    stroke: var(--oi-albatre);
}

.var-clear .diagram-box.secondary .item-dot {
    background: var(--oi-empire);
}

.var-clear .stage {
    background: rgba(27, 34, 44, 0.05);
}

.var-clear .stage-number,
.var-clear .item-number {
    background: var(--oi-chartreuse);
    color: var(--oi-marine);
}

.var-clear .stage-icon svg {
    stroke: var(--oi-empire);
}

.var-clear .balance-icon {
    background: var(--oi-empire);
}

.var-clear .balance-icon svg {
    stroke: var(--oi-chartreuse);
}

.var-clear .fulcrum-center {
    background: var(--oi-chartreuse);
}

.var-clear .fulcrum-center svg {
    stroke: var(--oi-marine);
}

.var-clear .flow-box {
    background: rgba(27, 34, 44, 0.1);
}

/* --- var-deep (dark marine background) --- */
.var-deep.diagram {
    background: var(--oi-marine);
    color: var(--oi-albatre);
}

.var-deep .diagram-box {
    background: rgba(255, 255, 255, 0.05);
}

.var-deep .stage {
    background: rgba(255, 255, 255, 0.05);
}

.var-deep .stage-icon svg {
    stroke: var(--oi-chartreuse);
}

.var-deep .diagram-amplifier {
    background: var(--oi-chartreuse);
    color: var(--oi-marine);
}

.var-deep .amplifier-icon {
    background: var(--oi-marine);
}

.var-deep .amplifier-icon svg {
    stroke: var(--oi-chartreuse);
}

/* --- var-growth (dark empire background) --- */
.var-growth.diagram {
    background: var(--oi-empire);
    color: var(--oi-albatre);
}

.var-growth .diagram-box {
    background: rgba(255, 255, 255, 0.08);
}

.var-growth .stage {
    background: rgba(255, 255, 255, 0.08);
}

.var-growth .stage-number,
.var-growth .item-number {
    background: var(--oi-chartreuse);
    color: var(--oi-marine);
}

.var-growth .stage-icon svg {
    stroke: var(--oi-chartreuse);
}

/* --- var-impact (bright chartreuse background) --- */
.var-impact.diagram {
    background: var(--oi-chartreuse);
    color: var(--oi-marine);
}

.var-impact .diagram-box {
    background: rgba(27, 34, 44, 0.1);
}

.var-impact .stage-number,
.var-impact .item-number {
    background: var(--oi-marine);
    color: var(--oi-chartreuse);
}

/* ==========================================================================
   DIAGRAM-INLINE (Article Integration)

   Wrapper for diagrams embedded in articles.
   Handles centering, spacing, and card effects.
   ========================================================================== */

.diagram-inline {
    display: flex;
    justify-content: center;
    margin: 56px 0;
}

.diagram-inline--wide {
    max-width: var(--article-wide-width, 900px);
    margin-left: calc((var(--article-max-width, 720px) - var(--article-wide-width, 900px)) / 2);
    margin-right: calc((var(--article-max-width, 720px) - var(--article-wide-width, 900px)) / 2);
}

/* Article context: override base diagram styles */
.diagram-inline .diagram {
    padding: 32px 28px;
    border-radius: 16px;
}

/* Card effects by theme (article context) */
.diagram-inline .diagram.var-clear {
    background: linear-gradient(135deg, #FFFFFF 0%, var(--oi-albatre) 100%);
    box-shadow:
        0 1px 3px rgba(27, 34, 44, 0.04),
        0 4px 12px rgba(27, 34, 44, 0.06);
}

.diagram-inline .diagram.var-soft {
    background: linear-gradient(135deg,
        rgba(188, 228, 254, 0.4) 0%,
        rgba(188, 228, 254, 0.2) 100%);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(188, 228, 254, 0.5);
    box-shadow:
        0 2px 8px rgba(27, 34, 44, 0.04),
        0 8px 24px rgba(188, 228, 254, 0.15);
}

.diagram-inline .diagram.var-deep {
    background: linear-gradient(135deg,
        var(--oi-marine) 0%,
        #141922 100%);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        0 8px 32px rgba(0, 0, 0, 0.3);
}

.diagram-inline .diagram.var-growth {
    background: linear-gradient(135deg,
        var(--oi-empire) 0%,
        #003d13 100%);
    box-shadow:
        0 2px 8px rgba(0, 86, 27, 0.2),
        0 8px 32px rgba(0, 86, 27, 0.25);
}

/* Article context: diagram title override */
.diagram-inline .diagram-title {
    font-family: var(--font-h2);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.1em;
}

/* Article context: spacing overrides */
.diagram-inline .diagram-balance {
    gap: 48px;
}

.diagram-inline .diagram-stages {
    gap: 12px;
}

.diagram-inline .diagram-content.split {
    gap: 32px;
}

/* Article context: component refinements */
.diagram-inline .stage {
    padding: 18px 22px;
    border-radius: 10px;
}

.diagram-inline .stage-number {
    font-weight: 700;
    font-size: 1.1rem;
}

.diagram-inline .flow-box {
    border-radius: 6px;
}

.diagram-inline .diagram-box {
    border-radius: 12px;
}

.diagram-inline .arrow-label {
    font-weight: 500;
    opacity: 0.8;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 480px) {
    /* Diagram-inline mobile */
    .diagram-inline--wide {
        margin-left: -24px;
        margin-right: -24px;
    }
    .diagram {
        padding: 16px;
        gap: 12px;
    }

    .diagram-title {
        font-size: 1.1rem;
    }

    .diagram-content.split {
        flex-direction: column;
    }

    .diagram-arrows {
        flex-direction: row;
        width: 100%;
        height: auto;
        padding: 8px 0;
    }

    .diagram-balance {
        gap: 20px;
    }

    .balance-icon {
        width: 40px;
        height: 40px;
    }
}
