/* AG2 Playground — Visual Redesign */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #1e1a24;
    --surface: #352f3b;
    --pink: #e85d9a;
    --gold: #d4af37;
    --purple: #a78bfa;
    --teal: #5eead4;
    --text-primary: #f0ece6;
    --text-secondary: #a89fa8;
    --text-muted: #6b6176;
    --glass-bg: rgba(55, 48, 64, 0.78);
    --glass-border: rgba(232, 93, 154, 0.15);
    --glass-border-hover: rgba(232, 93, 154, 0.4);
}

html, body {
    height: 100%;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
}

body {
    overflow: hidden;
}

::selection {
    background: rgba(232, 93, 154, 0.3);
    color: #fff;
}

/* ── Canvas background ─────────────────────────── */
#agent-network {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    opacity: 0.75;
    transition: opacity 0.4s ease;
}

#agent-network.dimmed {
    opacity: 0.15;
}

/* ── Home view ─────────────────────────────────── */
#home-view {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    overflow-y: auto;
    padding: 60px 40px 40px;
    scrollbar-width: thin;
    scrollbar-color: rgba(232, 93, 154, 0.25) transparent;
}

.home-header {
    text-align: center;
    margin-bottom: 48px;
}

.home-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.home-logo img {
    height: 22px;
    width: auto;
}

.home-logo span {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.home-title {
    font-family: 'Jersey 10', cursive;
    font-size: 52px;
    font-weight: 400;
    letter-spacing: 1px;
    line-height: 1.1;
    background: linear-gradient(90deg, var(--pink), var(--gold), var(--purple));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 6s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% center; }
    50% { background-position: 200% center; }
}

.home-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-top: 10px;
}

/* ── Card grid ─────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    max-width: 1100px;
    width: 100%;
}

.demo-card {
    position: relative;
    background: var(--glass-bg);
    border: none;
    border-radius: 0;
    padding: 28px 24px 24px 24px;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    cursor: pointer;
    transition: transform 0.25s ease, filter 0.25s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeInUp 0.4s ease backwards;
    /* clip-path set dynamically via JS for rounded corners + notch */
    clip-path: polygon(0 0, calc(100% - 32px) 0, 100% 32px, 100% 100%, 0 100%);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

/* Inner gradient for depth */
.demo-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 40%, rgba(0,0,0,0.1) 100%);
    pointer-events: none;
    z-index: 0;
}

/* SVG border that follows the notch shape */
.demo-card .card-border {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}

.demo-card .card-border path {
    transition: stroke 0.2s ease;
}

/* Diagonal accent fill on the chamfer */
.demo-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 46px;
    height: 46px;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    background: linear-gradient(135deg, transparent 50%, rgba(232, 93, 154, 0.06) 50%);
    pointer-events: none;
    transition: background 0.2s ease;
}

/* Card header row: title left, icon right */
.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}

.demo-card:nth-child(1) { animation-delay: 0s; }
.demo-card:nth-child(2) { animation-delay: 0.05s; }
.demo-card:nth-child(3) { animation-delay: 0.1s; }
.demo-card:nth-child(4) { animation-delay: 0.15s; }
.demo-card:nth-child(5) { animation-delay: 0.2s; }
.demo-card:nth-child(6) { animation-delay: 0.25s; }
.demo-card:nth-child(7) { animation-delay: 0.3s; }
.demo-card:nth-child(8) { animation-delay: 0.35s; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.demo-card:hover {
    transform: scale(1.04) translateY(-2px);
    filter: drop-shadow(0 8px 24px rgba(232, 93, 154, 0.2))
            drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.demo-card:hover .card-border path {
    stroke: var(--glass-border-hover);
}

.demo-card:hover::before {
    background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 40%, rgba(0,0,0,0.06) 100%);
}

.demo-card:hover::after {
    background: linear-gradient(135deg, transparent 50%, rgba(232, 93, 154, 0.15) 50%);
}

.card-icon {
    display: block;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.demo-card:hover .card-icon {
    transform: rotate(12deg);
}

.card-icon svg {
    width: 32px;
    height: 32px;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 14px;
}

.card-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

.badge-pink { background: rgba(232, 93, 154, 0.2); color: var(--pink); }
.badge-purple { background: rgba(167, 139, 250, 0.2); color: var(--purple); }
.badge-gold { background: rgba(212, 175, 55, 0.2); color: var(--gold); }
.badge-teal { background: rgba(94, 234, 212, 0.2); color: var(--teal); }
.badge-beta { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }

.beta-ribbon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 120px;
    height: 120px;
    pointer-events: none;
    z-index: 2;
}

/* ── Footer ────────────────────────────────────── */
.home-footer {
    margin-top: 48px;
    font-size: 12px;
    color: var(--text-muted);
}

.home-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

.home-footer a:hover {
    color: var(--pink);
}

/* ── Modal overlay ─────────────────────────────── */
#demo-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

#demo-modal.open {
    display: flex;
}

.modal-scrim {
    position: absolute;
    inset: 0;
    background: rgba(15, 12, 18, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    display: flex;
    width: min(1280px, 94vw);
    height: min(860px, 88vh);
    border-radius: 20px;
    background: #2e2836;
    border: 1px solid rgba(232, 93, 154, 0.12);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ── Modal left panel ──────────────────────────── */
.modal-left {
    width: 320px;
    min-width: 320px;
    background: linear-gradient(180deg, #3a2d45, #2a2233);
    border-right: 1px solid rgba(107, 97, 118, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 20px 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(232, 93, 154, 0.2) transparent;
}

.modal-icon {
    margin-bottom: 10px;
    width: 48px;
    height: 48px;
}

.modal-icon svg {
    width: 48px;
    height: 48px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 10px;
}

.modal-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.modal-desc {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-divider {
    width: 100%;
    height: 1px;
    background: rgba(107, 97, 118, 0.2);
    margin: 4px 0 16px;
}

.modal-section-label {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

/* Pattern SVG area */
.modal-pattern {
    width: 100%;
    max-width: 260px;
    margin-bottom: 16px;
}

.modal-pattern svg {
    width: 100%;
    height: auto;
}

/* Links row */
.modal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

.modal-link-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 6px 14px;
    border-radius: 14px;
    text-decoration: none;
    transition: opacity 0.15s;
}

.modal-link-pill:hover {
    opacity: 0.8;
}

.link-docs {
    background: rgba(94, 234, 212, 0.1);
    border: 1px solid rgba(94, 234, 212, 0.2);
    color: var(--teal);
}

.link-source {
    background: rgba(167, 139, 250, 0.1);
    border: 1px solid rgba(167, 139, 250, 0.2);
    color: var(--purple);
}

/* Stack chips */
.modal-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.stack-chip {
    font-size: 10px;
    color: var(--text-secondary);
    background: rgba(107, 97, 118, 0.15);
    padding: 3px 8px;
    border-radius: 8px;
}

/* ── Modal right panel ─────────────────────────── */
.modal-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Close button */
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(107, 97, 118, 0.25);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 10;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(107, 97, 118, 0.4);
    color: var(--text-primary);
}

/* Pill tab switcher */
.tab-switcher {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 16px 20px 0;
    padding: 3px;
    background: rgba(42, 37, 48, 0.8);
    border: 1px solid rgba(107, 97, 118, 0.2);
    border-radius: 18px;
    width: fit-content;
}

.tab-btn {
    padding: 7px 20px;
    border-radius: 15px;
    border: none;
    background: none;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--pink), var(--purple));
    color: #fff;
    font-weight: 600;
}

/* Tab content */
.tab-content {
    flex: 1;
    margin: 12px 16px 16px;
    border-radius: 12px;
    overflow: hidden;
    min-height: 0;
}

.tab-pane {
    display: none;
    width: 100%;
    height: 100%;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
}

/* Code description box */
.code-desc {
    background: rgba(42, 37, 48, 0.8);
    border: 1px solid rgba(107, 97, 118, 0.25);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.code-desc strong {
    color: var(--text-primary);
}

/* Demo iframe */
#modal-iframe {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: none;
    background: #1a1825;
    border-radius: 12px;
}

/* Copy button */
.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    z-index: 2;
    padding: 0;
}

.copy-btn:hover {
    background: var(--glass-border-hover);
    color: var(--text-primary);
    border-color: var(--glass-border-hover);
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.copy-btn .check-icon {
    display: none;
    color: #3fb950;
}

.copy-btn.copied .copy-icon { display: none; }
.copy-btn.copied .check-icon { display: block; }
.copy-btn.copied {
    border-color: rgba(63, 185, 80, 0.4);
    background: rgba(63, 185, 80, 0.1);
}

/* Code viewer */
.code-viewer {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #1a1825;
    border-radius: 12px;
    overflow: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(232, 93, 154, 0.2) transparent;
}

.code-viewer pre {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.6;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: #d4d0cc;
    white-space: pre;
    tab-size: 4;
}

/* Basic syntax highlighting */
.code-viewer .kw { color: var(--pink); }
.code-viewer .fn { color: var(--gold); }
.code-viewer .st { color: #a8cc8c; }
.code-viewer .cm { color: var(--text-muted); font-style: italic; }
.code-viewer .op { color: var(--teal); }
.code-viewer .nr { color: var(--purple); }

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(232, 93, 154, 0.25);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(232, 93, 154, 0.4);
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
    #home-view {
        padding: 40px 20px 20px;
    }

    .home-title {
        font-size: 36px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .modal-container {
        flex-direction: column;
        width: 96vw;
        height: 94vh;
    }

    .modal-left {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid rgba(107, 97, 118, 0.2);
    }

    .modal-pattern {
        display: none;
    }
}
