/*
 * PageCraft playground — tabbed embed chrome.
 *
 * Shared by the standalone wrapper page and by embed-snippet.html, so both
 * presentations stay in sync. Palette matches the wrapper: EE's control-panel
 * tokens, with the canvas as the only white surface.
 */

.pc-embed {
    --pc-paper:    #ffffff;
    --pc-ink:      #0d0d19;
    --pc-ink-soft: #5a5b7f;
    --pc-rule:     #cbcbda;
    --pc-accent:   #5d63f1;
    --pc-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --pc-height: 800px;
}

/* ── Tabs ─────────────────────────────────────────────────────── */
/* Centred over the canvas rather than left-aligned, so the editor reads as the
   subject and the tabs as chrome above it. */

.pc-embed__tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: -1px;
}

.pc-embed__tab {
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
    background: transparent;
    color: var(--pc-ink-soft);
    cursor: pointer;
}
.pc-embed__tab:hover { color: var(--pc-ink); }

.pc-embed__tab[aria-selected="true"] {
    background: var(--pc-paper);
    border-color: var(--pc-rule);
    color: var(--pc-ink);
}

.pc-embed__spacer { flex: 1; }

.pc-embed__btn {
    font: inherit;
    font-size: 12px;
    padding: 6px 13px;
    border: 1px solid var(--pc-rule);
    border-radius: 4px;
    background: var(--pc-paper);
    color: var(--pc-ink);
    cursor: pointer;
}
.pc-embed__btn:hover { border-color: var(--pc-ink-soft); }

/* ── Device toolbar ───────────────────────────────────────────── */
/* Mirrors the toolbar the real fieldtype renders above the canvas
   (ft.page_craft.php): the same five presets plus Full Canvas, driving
   ContentBox through iframePanel via postMessage. Deliberately without the
   Preview and Settings buttons — neither has anything to do in a playground. */

.pc-embed__devices {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 8px;
    border-bottom: 1px solid var(--pc-rule);
    background: var(--pc-paper);
    flex-shrink: 0;
}

.pc-embed__device {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--pc-ink-soft);
    cursor: pointer;
    transition: color .15s, background .15s;
}
.pc-embed__device:hover { background: #f0f0f4; }
.pc-embed__device[aria-pressed="true"],
.pc-embed__device[aria-pressed="true"]:hover {
    background: var(--pc-ink);
    color: #fff;
}

/* ── Panels ───────────────────────────────────────────────────── */

.pc-embed__panels {
    position: relative;
    /* Fallback matters: every panel inside is position:absolute, so if
       --pc-height is unset or invalid (an empty CMS field rendering as
       "--pc-height:px", say) this box collapses to nothing and the editor
       vanishes. min-height is the backstop for that. */
    height: var(--pc-height, 800px);
    min-height: 480px;
    border: 1px solid var(--pc-rule);
    border-radius: 6px;
    background: var(--pc-paper);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(13, 13, 25, 0.04),
                0 12px 32px rgba(13, 13, 25, 0.10);
}

.pc-embed__panel {
    position: absolute;
    inset: 0;
    display: none;
}
.pc-embed__panel[data-active] { display: block; }
.pc-embed__panel[data-pc-panel="editor"][data-active] {
    display: flex;
    flex-direction: column;
}
.pc-embed__panel[data-pc-panel="editor"] iframe { flex: 1; height: auto; }

.pc-embed__panel iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: var(--pc-paper);
}

/* Markup view. Scrolls independently; the wrapping is deliberate so long lines
   stay readable rather than forcing a horizontal scrollbar. */
.pc-embed__code {
    margin: 0;
    height: 100%;
    overflow: auto;
    padding: 18px 20px;
    font-family: var(--pc-mono);
    font-size: 12px;
    line-height: 1.65;
    color: var(--pc-ink);
    white-space: pre-wrap;
    word-break: break-word;
    tab-size: 2;
}
.pc-embed__code:empty::before {
    content: 'Build something in the Editor tab and the markup appears here.';
    color: var(--pc-ink-soft);
}

/* ── Status strip ─────────────────────────────────────────────── */

.pc-embed__status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 22px;
    margin: 12px 0 0;
    font-family: var(--pc-mono);
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--pc-ink-soft);
}
.pc-embed__status span { display: inline-flex; align-items: center; gap: 7px; }
.pc-embed__status span::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--pc-accent);
    flex-shrink: 0;
}

.pc-embed :focus-visible {
    outline: 2px solid var(--pc-accent);
    outline-offset: 2px;
}

/* ── Small screens ────────────────────────────────────────────── */
/* The editor needs room to be usable. Below this width, say so rather than
   showing a squashed canvas that demos the product badly. */

@media (max-width: 1023px) {
    .pc-embed__tabs,
    .pc-embed__panels,
    .pc-embed__status { display: none; }

    .pc-embed::after {
        content: 'The editor needs a wider screen — try it on a desktop.';
        display: block;
        padding: 24px;
        border: 1px solid var(--pc-rule);
        border-radius: 6px;
        background: var(--pc-paper);
        font-size: 15px;
        color: var(--pc-ink-soft);
    }
}
