/* ==========================================================================
   Frame Manager view stylesheet (inc/view.css)
   Base + read-only view presentation. Loaded on every page. When the page is
   opened in strict read-only mode (?preset=...&view=1) this is the ONLY
   stylesheet, so editor chrome, frame borders and resize dividers never exist
   in that mode. Editor / interactive styles live in inc/edit.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Theme tokens
   -------------------------------------------------------------------------- */
:root {
    color-scheme: dark;

    --bg: #0a0d17;

    --surface: rgba(17, 22, 36, .78);
    --surface-2: rgba(24, 30, 48, .94);
    --surface-3: rgba(36, 44, 68, .94);

    --stroke: rgba(151, 165, 205, .18);
    --stroke-strong: rgba(151, 165, 205, .32);

    --text: #eef2fb;
    --text-2: #bcc4db;
    --text-3: #737c98;

    --accent: #7c9cff;
    --accent-2: #5eead4;
    --grad: linear-gradient(135deg, #778df4 0%, #b594f6 100%);

    --danger: #f87171;
    --warn: #fbbf24;
    --ok: #34d399;

    --blob-a: #4a63e4;
    --blob-b: #2dd4bf;
    --blob-c: #b89dfa;

    --radius-m: 14px;
    --radius-l: 22px;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .38), 0 10px 28px rgba(0, 0, 0, .34);
    --shadow-2: 0 16px 48px rgba(0, 0, 0, .54);
}

html[data-theme="light"] {
    color-scheme: light;

    --bg: #f2f4fb;

    --surface: rgba(255, 255, 255, .78);
    --surface-2: rgba(255, 255, 255, .94);
    --surface-3: #e9edf7;

    --stroke: rgba(22, 31, 62, .1);
    --stroke-strong: rgba(22, 31, 62, .2);

    --text: #121830;
    --text-2: #47516e;
    --text-3: #8790ab;

    --accent: #4f6ef2;
    --accent-2: #0d9488;
    --grad: linear-gradient(135deg, #4f6ef2 0%, #8b5cf6 100%);

    --danger: #dc2626;
    --warn: #b45309;
    --ok: #059669;

    --blob-a: #7c9cff;
    --blob-b: #5eead4;
    --blob-c: #c4b5fd;

    --shadow-1: 0 1px 2px rgba(22, 31, 62, .08), 0 10px 28px rgba(22, 31, 62, .12);
    --shadow-2: 0 16px 48px rgba(22, 31, 62, .22);
}

@media (prefers-color-scheme: light) {
    html[data-theme="auto"] {
        color-scheme: light;

        --bg: #f2f4fb;

        --surface: rgba(255, 255, 255, .78);
        --surface-2: rgba(255, 255, 255, .94);
        --surface-3: #e9edf7;

        --stroke: rgba(22, 31, 62, .1);
        --stroke-strong: rgba(22, 31, 62, .2);

        --text: #121830;
        --text-2: #47516e;
        --text-3: #8790ab;

        --accent: #4f6ef2;
        --accent-2: #0d9488;
        --grad: linear-gradient(135deg, #4f6ef2 0%, #8b5cf6 100%);

        --danger: #dc2626;
        --warn: #b45309;
        --ok: #059669;

        --blob-a: #7c9cff;
        --blob-b: #5eead4;
        --blob-c: #c4b5fd;

        --shadow-1: 0 1px 2px rgba(22, 31, 62, .08), 0 10px 28px rgba(22, 31, 62, .12);
        --shadow-2: 0 16px 48px rgba(22, 31, 62, .22);
    }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; width: 100%; overflow: hidden; }

body {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Everything the app draws sits above the backdrop. */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Aurora backdrop: soft drifting blobs + subtle film grain
   -------------------------------------------------------------------------- */
.bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--bg);
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .28;
    will-change: transform;
}
.blob-a {
    width: 46vw; height: 46vw;
    top: -18vw; right: -10vw;
    background: radial-gradient(circle at 35% 35%, var(--blob-a), transparent 68%);
    animation: drift-a 36s ease-in-out infinite alternate;
}
.blob-b {
    width: 42vw; height: 42vw;
    bottom: -20vw; left: -12vw;
    background: radial-gradient(circle at 60% 60%, var(--blob-b), transparent 68%);
    animation: drift-b 44s ease-in-out infinite alternate;
}
.blob-c {
    width: 36vw; height: 36vw;
    top: 26%; left: 33%;
    background: radial-gradient(circle at 50% 50%, var(--blob-c), transparent 68%);
    opacity: .16;
    animation: drift-c 52s ease-in-out infinite alternate;
}

.grain {
    position: absolute;
    inset: 0;
    opacity: .05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
}

@keyframes drift-a { to { transform: translate(-7vw, 5vh) scale(1.06); } }
@keyframes drift-b { to { transform: translate(6vw, -6vh) scale(1.08); } }
@keyframes drift-c { to { transform: translate(4vw, 6vh) scale(1.12); } }

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* --------------------------------------------------------------------------
   Workspace & split tree
   -------------------------------------------------------------------------- */
#workspace { position: relative; flex: 1; min-width: 0; min-height: 0; }

/* landing, shown when no preset is loaded */
.landing {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 40px;
}
.landing-inner {
    text-align: center;
    max-width: 360px;
}
.landing-logo {
    width: 52px;
    height: 52px;
    margin-bottom: 18px;
    filter: drop-shadow(0 4px 14px color-mix(in srgb, var(--accent) 50%, transparent));
}
.landing-inner h2 {
    font-size: 18px;
    font-weight: 650;
    letter-spacing: .01em;
    margin-bottom: 10px;
}
.landing-inner p {
    font-size: 13.5px;
    color: var(--text-2);
    line-height: 1.6;
}
.landing-inner b {
    color: var(--text);
    font-weight: 600;
}

.split {
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}
.split-row { flex-direction: row; }
.split-col { flex-direction: column; }
.split > :first-child { flex: 0 0 50%; min-width: 0; min-height: 0; }
.split > :last-child  { flex: 1 1 0%; min-width: 0; min-height: 0; }

/* dividers: resize handles. Always present so frames stay adjustable in
   every mode (edit, live, view=1). The visible line is added by edit.css,
   or by the view-only hover rules below. */
.divider {
    position: relative;
    z-index: 30;
    background: transparent;
    touch-action: none;
    flex-shrink: 0;
}
.divider-row { flex: 0 0 7px; width: 7px; cursor: ew-resize; }
.divider-col { flex: 0 0 7px; height: 7px; cursor: ns-resize; }

/* --------------------------------------------------------------------------
   Frames
   -------------------------------------------------------------------------- */
.leaf { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; }

.leaf-live { background: var(--bg); }
.leaf-live iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    overflow: hidden;
}

/* expand button, shown on hover, top-right corner */
.btn-expand {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 6;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--stroke-strong);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg) 75%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .18s ease, transform .18s ease;
}
.leaf-live:hover .btn-expand { opacity: 1; transform: none; }
.btn-expand:hover {
    background: var(--surface-2);
    border-color: var(--accent);
    color: var(--accent);
}

/* expanded frame covers entire workspace */
.leaf-live.expanded {
    position: fixed !important;
    inset: 0 !important;
    z-index: 100 !important;
    flex: none !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden !important;
}
body:has(.leaf-live.expanded) { overflow: hidden; }
.leaf-live.expanded .btn-expand {
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    opacity: 1;
    transform: none;
    background: var(--surface-2);
}

.frame-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    padding: 4px 12px;
    max-width: 72%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11.5px;
    font-weight: 550;
    letter-spacing: .02em;
    color: var(--text);
    background: color-mix(in srgb, var(--bg) 62%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--stroke-strong);
    border-radius: 999px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}
.leaf-live:hover .frame-badge { opacity: 1; transform: none; }

/* transparent sheet over the iframes while a divider is dragged, so the
   iframes cannot steal the pointer stream mid-drag */
.drag-overlay { position: absolute; inset: 0; z-index: 60; background: transparent; }

/* --------------------------------------------------------------------------
   Shared / read-only view
   -------------------------------------------------------------------------- */
.shared-bar {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--surface);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid var(--stroke);
    border-radius: 999px;
    box-shadow: var(--shadow-1), 0 2px 12px rgba(0, 0, 0, .12);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.shared-bar:hover {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.shared-brand {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: var(--surface);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid var(--stroke);
    border-radius: 999px;
    box-shadow: var(--shadow-1), 0 2px 12px rgba(0, 0, 0, .12);
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.shared-brand:hover {
    transform: translateY(-2px);
    border-color: var(--stroke-strong);
    box-shadow: var(--shadow-1), 0 8px 26px color-mix(in srgb, var(--accent) 38%, transparent);
}
.shared-brand .brand-logo { width: 18px; height: 18px; }

body.shared .shared-bar { display: flex; }
body.shared .shared-brand { display: flex; }
body.shared .app-header,
body.shared .save-inline,
body.shared .hintbar { display: none; }

/* view=1: strict read-only: no chrome at all */
body.view-only .shared-bar { display: none !important; }
body.view-only .shared-brand { display: none !important; }

/* view=1: no permanent frame border; hovering a frame or a divider reveals
   a subtle outline + resize line so layouts stay adjustable */
body.view-only .leaf-live:hover { box-shadow: inset 0 0 0 1px var(--stroke); }
body.view-only .divider::before {
    content: "";
    position: absolute;
    background: var(--stroke);
    opacity: 0;
    transition: opacity .18s ease;
}
body.view-only .divider-row::before { top: 0; bottom: 0; left: 50%; width: 1.5px; transform: translateX(-50%); }
body.view-only .divider-col::before { left: 0; right: 0; top: 50%; height: 1.5px; transform: translateY(-50%); }
body.view-only .divider:hover::before { opacity: 1; }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
::-webkit-scrollbar { width: 0 !important; height: 0 !important; display: none !important; }
* { scrollbar-width: none !important; -ms-overflow-style: none !important; }

@media (prefers-reduced-motion: reduce) {
    .blob { animation: none; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}


