/* ==============================================
   ENGINEERING AT SCALE — Problem Section
   "The Scale Reality"
   Hero: the template drift diagram, full-width,
   showing one template fanning into hundreds of
   divergent pipeline shapes across the org.
   Below: three tight, uniform "why every playbook
   stalls" cards. Closing thesis.
   ============================================== */

/* ---------- Hero container ---------- */

.scale-hero {
    max-width: 1016px;
    margin: 0 auto 56px;
    background: linear-gradient(180deg, #0c1018 0%, #080b13 100%);
    border: 1px solid rgba(0, 212, 255, 0.22);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 70px -24px rgba(0, 0, 0, 0.55);
}

/* ---------- Side-by-side panels ---------- */

.scale-visuals {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
}

.scale-panel {
    margin: 0;
    padding: 26px 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.scale-panel + .scale-panel {
    border-left: 1px solid rgba(160, 174, 192, 0.14);
}

/* ---------- Shared panel header (kicker + headline) ---------- */

.scale-panel-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 10px;
    border-bottom: 1px dashed rgba(160, 174, 192, 0.14);
}

.scale-panel-kicker {
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 10px;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: var(--el-cyan);
    font-weight: 700;
}

.scale-panel-headline {
    font-size: 15px;
    line-height: 20px;
    color: var(--text-primary);
    font-weight: 600;
}

/* ---------- Drift visual (left panel) ---------- */

.scale-drift-ends {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    padding: 0 4px;
}

.scale-drift-end {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.scale-drift-end-start {
    align-items: flex-start;
    text-align: left;
}

.scale-drift-end-end {
    align-items: flex-end;
    text-align: right;
}

.scale-drift-end-kicker {
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 11px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    font-weight: 700;
}

.scale-drift-end-start .scale-drift-end-kicker {
    color: var(--el-cyan);
}

.scale-drift-end-end .scale-drift-end-kicker {
    color: var(--before-red);
}

.scale-drift-end-main {
    font-size: 15px;
    line-height: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.scale-drift-svg {
    width: 100%;
    height: auto;
    display: block;
    margin-top: -4px;
}

/* ---------- Drift legend (footer) ---------- */

.scale-panel-legend {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px dashed rgba(160, 174, 192, 0.14);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 16px;
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    color: var(--text-link-subtle);
    text-transform: uppercase;
}

.scale-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.scale-swatch {
    width: 14px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.swatch-cyan {
    background: var(--el-cyan);
    opacity: 0.9;
}

.swatch-amber {
    background: var(--warning);
    opacity: 0.9;
}

.swatch-red {
    background: var(--before-red);
    opacity: 0.9;
}

.swatch-gray {
    background: #7d7d7d;
    opacity: 0.85;
}

/* ---------- Stack diversity visual (right panel) ---------- */

.scale-stacks-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scale-stack-row {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 12px;
    align-items: flex-start;
}

.scale-stack-category {
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 10px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-top: 6px;
    text-align: right;
}

.scale-stack-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.scale-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.4;
    white-space: nowrap;
}

.pill-lang {
    background: rgba(0, 212, 255, 0.08);
    color: var(--el-cyan);
    border: 1px solid rgba(0, 212, 255, 0.28);
}

.pill-framework {
    background: rgba(52, 248, 182, 0.07);
    color: var(--el-green);
    border: 1px solid rgba(52, 248, 182, 0.28);
}

.pill-data {
    background: rgba(251, 191, 36, 0.07);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.pill-infra {
    background: rgba(168, 85, 247, 0.08);
    color: var(--ai-purple-text);
    border: 1px solid rgba(168, 85, 247, 0.32);
}

.pill-scanner {
    background: rgba(255, 100, 100, 0.07);
    color: var(--before-red);
    border: 1px solid rgba(255, 100, 100, 0.32);
}

.pill-build {
    background: rgba(160, 174, 192, 0.06);
    color: var(--text-link-subtle);
    border: 1px solid rgba(160, 174, 192, 0.3);
    font-style: normal;
}

.pill-monitor {
    background: rgba(236, 72, 153, 0.07);
    color: var(--ai-pink);
    border: 1px solid rgba(236, 72, 153, 0.3);
}

/* Group: keeps last pill + '+ N more' suffix together so the suffix never
   wraps onto its own line by itself. */
.scale-pill-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

/* '+ N more' suffix at the end of each pill row */
.scale-stack-more {
    display: inline-flex;
    align-items: center;
    padding: 3px 4px;
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: var(--text-muted);
    line-height: 1.4;
    white-space: nowrap;
}

/* The Build row's '+ 100s of custom wrappers' \u2014 the punchline.
   Allowed to wrap (it's wordy) since Build is the exception. */
.more-custom {
    color: var(--warning);
    font-weight: 700;
    font-style: italic;
    text-transform: none;
    white-space: normal;
}

/* Stacks panel footer (the conclusion line) */
.scale-stacks-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px dashed rgba(160, 174, 192, 0.14);
    font-size: 13px;
    line-height: 18px;
    color: var(--text-secondary);
    text-align: center;
}

/* ---------- Playbooks section ---------- */

.scale-playbooks-header {
    max-width: 1016px;
    margin: 0 auto 18px;
    display: flex;
    justify-content: center;
    position: relative;
}

.scale-playbooks-header::before,
.scale-playbooks-header::after {
    content: '';
    flex: 1;
    align-self: center;
    height: 1px;
    max-width: 180px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(160, 174, 192, 0.25) 50%,
        transparent 100%
    );
}

.scale-playbooks-header::before {
    margin-right: 20px;
}

.scale-playbooks-header::after {
    margin-left: 20px;
}

.scale-playbooks-kicker {
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 11px;
    font-weight: 700;
    color: var(--warning);
    letter-spacing: 1.8px;
    text-transform: uppercase;
    padding: 5px 14px;
    border: 1px solid rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.08);
    border-radius: 3px;
    white-space: nowrap;
}

/* ---------- Uniform-height playbook cards ---------- */

.scale-playbooks {
    max-width: 1016px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.scale-playbook {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 24px 22px;
    background:
        linear-gradient(180deg, rgba(255, 100, 100, 0.04) 0%, rgba(255, 100, 100, 0.01) 100%),
        rgba(10, 14, 24, 0.5);
    border: 1px solid rgba(255, 100, 100, 0.22);
    border-top: 3px solid var(--before-red);
    border-radius: 8px;
    transition:
        border-color 0.2s ease,
        transform 0.2s ease;
}

.scale-playbook:hover {
    border-color: rgba(255, 100, 100, 0.4);
    transform: translateY(-1px);
}

.scale-playbook-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 2px;
}

.scale-playbook-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.1px;
}

.scale-playbook-body {
    font-size: 14px;
    line-height: 21px;
    color: var(--text-secondary);
    margin: 0;
}

.scale-playbook-body code {
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 12.5px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(0, 212, 255, 0.08);
    color: var(--el-cyan);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .scale-hero {
        margin-bottom: 44px;
    }

    .scale-visuals {
        grid-template-columns: 1fr;
    }

    .scale-panel {
        padding: 22px 20px 20px;
        min-height: 0;
    }

    .scale-panel + .scale-panel {
        border-left: none;
        border-top: 1px solid rgba(160, 174, 192, 0.14);
    }

    .scale-drift-svg {
        max-height: 360px;
        height: auto;
    }

    .scale-stack-row {
        grid-template-columns: 64px 1fr;
    }

    .scale-playbooks {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .scale-playbook {
        padding: 20px 18px;
    }

    .scale-playbooks-header::before,
    .scale-playbooks-header::after {
        max-width: 60px;
    }

    .scale-playbooks-kicker {
        font-size: 10px;
        letter-spacing: 1.4px;
    }
}

/* ----------------------------------------------------
   Mobile: trim pills to fit on one line. Build wraps.
   ---------------------------------------------------- */

@media (max-width: 700px) {
    .scale-stack-row:not(.scale-stack-row--wrap) .scale-stack-pills {
        flex-wrap: nowrap;
        overflow: hidden;
    }

    /* Keep only the first 2 direct pills + the trailing .scale-pill-group
       (which contains the last pill + '+ N more' suffix). */
    .scale-stack-row:not(.scale-stack-row--wrap) .scale-stack-pills > .scale-pill:nth-child(n + 3) {
        display: none;
    }
}

@media (max-width: 450px) {
    /* Tighter: keep only the first direct pill + the group. */
    .scale-stack-row:not(.scale-stack-row--wrap) .scale-stack-pills > .scale-pill:nth-child(n + 2) {
        display: none;
    }
}

@media (max-width: 500px) {
    .scale-playbook-title {
        font-size: 16px;
    }

    .scale-playbook-body {
        font-size: 13.5px;
        line-height: 20px;
    }
}
