/* code-bundle.css — compact "whole snippet" component.
 *
 * Renders one file per CARD with filename + lang chip + LOC + Copy +
 * Expand controls in a header row, plus a peek body that grows on
 * expand. Multi-file bundles surface a 1/2/3-col responsive grid so
 * the buyer eyeballs ALL files at a glance and copies only what they
 * need.
 *
 * Replaces the old "long pre" rendering in example.php (`$exampleCode-
 * Blocks` foreach). Triple-surface parity stays — same code, same lang,
 * just compact UI.
 */

/* ─── Section wrapper ─────────────────────────────────────────── */

.demo-example__code--bundle {
    /* Override any margin from the legacy stack rendering — bundle has its own
       internal spacing. */
}

.demo-example__code-lede--bundle {
    margin-bottom: var(--demo-space-4, 16px);
}

.demo-example__code-actions {
    display: flex;
    gap: var(--demo-space-2, 8px);
    margin-bottom: var(--demo-space-4, 16px);
    flex-wrap: wrap;
    align-items: center;
}

.demo-example__code-actions-meta {
    margin-right: auto;
    font-size: 13px;
    color: var(--demo-text-muted, #71717a);
}

.demo-example__code-actions-meta strong {
    color: var(--demo-text, #18181b);
    font-weight: 600;
}

/* ─── Bundle grid (1/2/3 cols) ────────────────────────────────── */

.demo-code-bundle {
    display: grid;
    gap: var(--demo-space-4, 16px);
    grid-template-columns: 1fr;
}

.demo-code-bundle--cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.demo-code-bundle--cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1024px) {
    .demo-code-bundle--cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .demo-code-bundle--cols-2,
    .demo-code-bundle--cols-3 {
        grid-template-columns: 1fr;
    }
}

/* ─── File card ───────────────────────────────────────────────── */

.demo-code-bundle__file {
    display: flex;
    flex-direction: column;
    background: var(--demo-bg-elevated, #fff);
    border: 1px solid var(--demo-border, #e5e7eb);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    min-width: 0;
}

.demo-code-bundle__file:hover {
    border-color: var(--demo-border-strong, #d4d4d8);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.demo-code-bundle__file[data-expanded="true"] {
    border-color: var(--demo-accent, #4338ca);
    box-shadow: 0 4px 14px rgba(67, 56, 202, 0.08);
}

/* ─── Header row ──────────────────────────────────────────────── */

.demo-code-bundle__file-header {
    display: flex;
    align-items: center;
    gap: var(--demo-space-3, 12px);
    padding: var(--demo-space-2, 8px) var(--demo-space-3, 12px);
    background: var(--demo-bg-subtle, #f4f4f5);
    border-bottom: 1px solid var(--demo-border, #e5e7eb);
    min-width: 0;
    flex-wrap: wrap;
}

.demo-code-bundle__file-meta {
    display: flex;
    align-items: center;
    gap: var(--demo-space-2, 8px);
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.demo-code-bundle__file-icon {
    font-size: 18px;
    color: var(--demo-text-muted, #71717a);
    flex-shrink: 0;
}

.demo-code-bundle__file-name {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--demo-text, #18181b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.demo-code-bundle__file-lang.demo-pill {
    font-size: 10px;
    padding: 2px 8px;
    flex-shrink: 0;
}

.demo-code-bundle__file-loc {
    font-size: 11px;
    color: var(--demo-text-muted, #71717a);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ─── Header actions ──────────────────────────────────────────── */

.demo-code-bundle__file-actions {
    display: flex;
    gap: var(--demo-space-1, 4px);
    flex-shrink: 0;
}

.demo-code-bundle__copy-btn,
.demo-code-bundle__expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--demo-border, #d4d4d8);
    background: var(--demo-bg-elevated, #fff);
    color: var(--demo-text, #18181b);
    border-radius: 6px;
    cursor: pointer;
    transition: all 120ms ease;
}

.demo-code-bundle__copy-btn:hover,
.demo-code-bundle__expand-btn:hover {
    border-color: var(--demo-accent, #4338ca);
    color: var(--demo-accent, #4338ca);
}

.demo-code-bundle__copy-btn:focus-visible,
.demo-code-bundle__expand-btn:focus-visible {
    outline: 2px solid var(--demo-accent, #4338ca);
    outline-offset: 2px;
}

.demo-code-bundle__copy-btn .material-symbols-outlined,
.demo-code-bundle__expand-btn .material-symbols-outlined {
    font-size: 16px;
}

.demo-code-bundle__copy-btn[data-copied="true"] {
    border-color: var(--demo-success, #15803d);
    color: var(--demo-success, #15803d);
    background: var(--demo-success-soft, #dcfce7);
}

.demo-code-bundle__file[data-expanded="true"] .demo-code-bundle__expand-btn {
    border-color: var(--demo-accent, #4338ca);
    color: var(--demo-accent, #4338ca);
    background: var(--demo-accent-soft, #e0e7ff);
}

/* ─── Per-card note (variant context) ─────────────────────────── */

/* Variant blocks (PHP / Pure HTML) carry a `note` field — tiny prose
   that explains "when to pick this flavour." The note renders BETWEEN
   the card header and the body, so it's visible in both collapsed +
   expanded states. */

.demo-code-bundle__note {
    margin: 0;
    padding: var(--demo-space-2, 8px) var(--demo-space-3, 12px);
    font-size: 12px;
    line-height: 1.55;
    color: var(--demo-text-muted, #71717a);
    background: var(--demo-bg-subtle, #f4f4f5);
    border-bottom: 1px solid var(--demo-border, #e5e7eb);
}

.demo-code-bundle__note code {
    background: var(--demo-bg-elevated, #fff);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.92em;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    color: var(--demo-text, #18181b);
    border: 1px solid var(--demo-border, #e5e7eb);
}

.demo-code-bundle__note strong {
    color: var(--demo-text, #18181b);
    font-weight: 600;
}

/* ─── Body (peek + expand) ────────────────────────────────────── */

.demo-code-bundle__file-body {
    position: relative;
    overflow: hidden;
    background: var(--demo-code-bg, #0f172a);
    transition: max-height 240ms ease;
    max-height: 160px;
}

.demo-code-bundle__file[data-expanded="true"] .demo-code-bundle__file-body {
    max-height: 520px;
    overflow: auto;
}

.demo-code-bundle__code {
    margin: 0;
    padding: var(--demo-space-3, 12px) var(--demo-space-4, 16px);
    background: transparent;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    color: var(--demo-code-text, #e2e8f0);
    overflow: visible;
    white-space: pre;
    tab-size: 4;
}

.demo-code-bundle__code code {
    background: transparent;
    color: inherit;
    font-size: inherit;
    padding: 0;
    border: 0;
    font-family: inherit;
}

/* Bottom fade shows ONLY when collapsed — vanishes on expand. */

.demo-code-bundle__fade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        rgba(15, 23, 42, 0) 0%,
        var(--demo-code-bg, #0f172a) 90%
    );
    transition: opacity 160ms ease;
}

.demo-code-bundle__file[data-expanded="true"] .demo-code-bundle__fade {
    opacity: 0;
}

/* ─── Reduced motion ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .demo-code-bundle__file-body,
    .demo-code-bundle__fade,
    .demo-code-bundle__copy-btn,
    .demo-code-bundle__expand-btn {
        transition: none;
    }
}
