/* ==========================================================================
   Joule Playground — Pixel-perfect replica of joule-lang.org Holodeck
   ========================================================================== */

:root {
    /* Joule Color Palette — exact tokens from joule-lang.org */
    --joule-black:    #0D0D0D;
    --joule-dark:     #1A1A2E;
    --joule-energy:   #FBBF24;
    --joule-green:    #10B981;
    --joule-cyan:     #22D3EE;
    --joule-slate:    #94A3B8;
    --joule-white:    #FFFFFF;
    --joule-purple:   #6366F1;
    --joule-pink:     #F472B6;
    --joule-red:      #EF4444;

    /* Typography */
    --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body:    "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:    "JetBrains Mono", "Fira Code", monospace;
}

/* ---------- Reset ---------- */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--joule-black);
    color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

/* ---------- Loading Overlay ---------- */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--joule-black);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--joule-slate);
    font-size: 14px;
}

.spinner-svg {
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

.spinner-svg.small {
    width: 20px;
    height: 20px;
}

.spinner-track { opacity: 0.25; }
.spinner-fill  { opacity: 0.75; }

.loading-text {
    font-family: var(--font-body);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ---------- Section Wrapper ---------- */

.playground-section {
    width: 100%;
    padding: 2rem 0;
}

.playground-container {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ---------- Playground Card ---------- */

.playground-card {
    background: linear-gradient(to bottom right, #0a0a18, #0f0f25);
    border-radius: 1rem;
    border: 1px solid rgba(34, 211, 238, 0.3);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(34, 211, 238, 0.1);
}

/* ---------- Card Header ---------- */

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid rgba(34, 211, 238, 0.2);
    background: linear-gradient(to right, rgba(34, 211, 238, 0.05), transparent);
}

.card-header .header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-icon-badge {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: linear-gradient(to bottom right, var(--joule-cyan), var(--joule-energy));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--joule-black);
}

.header-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--joule-white);
    font-family: var(--font-display);
}

.card-header .header-subtitle {
    font-size: 0.75rem;
    color: var(--joule-slate);
}

.card-header .header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: rgba(34, 211, 238, 0.2);
    color: var(--joule-cyan);
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.mode-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--joule-green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ---------- Example Bar ---------- */

.example-bar {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(13, 13, 13, 0.3);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.example-category {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-label {
    font-size: 0.625rem;
    color: rgba(148, 163, 184, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    font-family: var(--font-body);
}

.category-buttons {
    display: flex;
    gap: 0.25rem;
}

.example-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 150ms ease;
    font-family: var(--font-body);
    white-space: nowrap;
}

.example-btn.inactive {
    background: rgba(26, 26, 46, 0.5);
    color: var(--joule-slate);
}

.example-btn.inactive:hover {
    background: var(--joule-dark);
    color: var(--joule-white);
}

.example-btn.active {
    background: var(--joule-cyan);
    color: var(--joule-black);
    font-weight: 600;
}

/* ---------- Main Grid ---------- */

.main-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
}

.grid-divider {
    width: 1px;
    background: rgba(148, 163, 184, 0.2);
}

/* ---------- Editor Column ---------- */

.editor-column {
    display: flex;
    flex-direction: column;
}

.column-toolbar {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(13, 13, 13, 0.3);
}

.toolbar-label {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--joule-slate);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.editor-wrapper {
    height: 500px;
    position: relative;
}

.editor-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(13, 13, 13, 0.5);
    color: var(--joule-slate);
    font-size: 14px;
}

.editor-loading.hidden {
    display: none;
}

/* ---------- Run Button ---------- */

.btn-run {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 1rem;
    background: linear-gradient(to right, var(--joule-energy), var(--joule-green));
    color: var(--joule-black);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-body);
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: opacity 150ms ease;
}

.btn-run:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-run:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-run-icon {
    width: 0.75rem;
    height: 0.75rem;
}

/* ---------- Output Column ---------- */

.output-column {
    display: flex;
    flex-direction: column;
    height: 564px;
}

.output-content {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background: rgba(13, 13, 13, 0.2);
    color: var(--joule-white);
    white-space: pre-wrap;
    line-height: 1.6;
}

.output-placeholder {
    color: var(--joule-slate);
}

.output-placeholder kbd {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--joule-dark);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    margin: 0 0.25rem;
}

.output-error {
    color: var(--joule-red);
}

.output-error .error-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* ---------- Execution Result Metrics ---------- */

.result-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.result-metric-card {
    background: rgba(26, 26, 46, 0.5);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.result-metric-label {
    font-size: 0.75rem;
    color: var(--joule-slate);
    margin-bottom: 0.25rem;
    font-family: var(--font-body);
}

.result-metric-value {
    font-size: 1.125rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.result-metric-value.time {
    color: var(--joule-cyan);
}

.result-metric-value.energy {
    color: var(--joule-energy);
}

/* ---------- Card Footer ---------- */

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    background: linear-gradient(to right, rgba(13, 13, 13, 0.5), transparent);
    font-size: 0.75rem;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footer-stat {
    font-family: var(--font-mono);
}

.footer-stat-energy { color: var(--joule-energy); }
.footer-stat-time   { color: var(--joule-cyan); }

.footer-right {
    display: flex;
    align-items: center;
}

.footer-note {
    color: var(--joule-slate);
}

.footer-accent {
    color: var(--joule-cyan);
}

/* ---------- Scrollbar ---------- */

.output-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.output-content::-webkit-scrollbar-track {
    background: transparent;
}

.output-content::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
}

.output-content::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.4);
}

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

@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

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

    .grid-divider {
        width: 100%;
        height: 1px;
    }

    .editor-wrapper {
        height: 300px;
    }

    .output-column {
        height: 300px;
    }

    .example-bar {
        gap: 0.25rem;
        padding: 0.5rem;
    }

    .category-label {
        display: none;
    }

    .result-metrics {
        grid-template-columns: 1fr;
    }
}
