/* MCP Chess — modern glassmorphism UI with a Gemini-style prompt dock. */

:root {
    --bg: #070912;
    --bg-2: #0e1322;
    --ink: #eef1fa;
    --ink-dim: #aeb7d0;
    --ink-faint: #6b7493;
    --line: rgba(255, 255, 255, 0.10);
    --surface: rgba(20, 25, 42, 0.72);
    --surface-2: rgba(30, 36, 58, 0.85);

    /* Gemini-ish gradient */
    --g1: #4f8cff;
    --g2: #9d6bff;
    --g3: #ff7eb3;
    --grad: linear-gradient(100deg, var(--g1), var(--g2) 55%, var(--g3));

    --ok: #34d399;
    --warn: #fbbf24;
    --err: #fb7185;

    --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    --radius: 26px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── Stage: the full-screen Webfuse session iframe ───────────────────────── */

.stage {
    position: fixed;
    inset: 0;
    z-index: 1;
    background:
        radial-gradient(900px 600px at 70% -10%, rgba(157, 107, 255, 0.16), transparent 60%),
        radial-gradient(700px 500px at 0% 100%, rgba(79, 140, 255, 0.14), transparent 55%),
        var(--bg);
}
.session-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* ── Boot overlay ────────────────────────────────────────────────────────── */

.boot {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
    /* Calm, near-neutral backdrop — the colour now lives on the borders. */
    background:
        radial-gradient(900px 650px at 50% -15%, rgba(125, 140, 180, 0.08), transparent 60%),
        linear-gradient(180deg, #080b15, #0b0f1c);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
body[data-phase="playing"] .boot {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.boot-card {
    position: relative;
    width: min(560px, 100%);
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 28px;
    padding: 34px 34px 30px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.brand { display: flex; gap: 18px; align-items: center; margin-bottom: 24px; }
.brand-glyph {
    position: relative;
    flex: none;
    width: 60px; height: 60px;
    display: grid; place-items: center;
    font-size: 34px;
    border-radius: 18px;
    background: var(--bg-2);
    color: var(--ink);
}
.brand-glyph::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: var(--grad);
    background-size: 200% 200%;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: sheen 6s ease infinite;
    pointer-events: none;
}
.brand-text h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.brand-text p { margin: 6px 0 0; color: var(--ink-dim); font-size: 14px; line-height: 1.5; }

.checks { list-style: none; margin: 0 0 26px; padding: 0; display: grid; gap: 10px; }
.check {
    display: flex; align-items: center; gap: 11px;
    font-size: 13.5px; color: var(--ink-dim);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 11px 14px;
}
.dot {
    flex: none; width: 9px; height: 9px; border-radius: 50%;
    background: var(--ink-faint);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.3);
}
.dot.pending { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
.dot.ready { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.error { background: var(--err); }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

.start-btn {
    position: relative;
    width: 100%;
    border: 0;
    border-radius: 18px;
    padding: 16px 20px;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.035);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease, background 0.15s ease;
}
/* The animated gradient lives on the border, not the fill. */
.start-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.6px;
    background: var(--grad);
    background-size: 200% 200%;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: sheen 5s ease infinite;
    pointer-events: none;
}
.start-spark {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.start-btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.07); }
.start-btn:active { transform: translateY(0); }
.start-btn:disabled { cursor: progress; opacity: 0.8; }
.start-btn.working .start-spark { animation: spin 1s linear infinite; display: inline-block; }
@keyframes sheen { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes spin { to { transform: rotate(360deg); } }

.boot-hint { margin: 16px 2px 0; font-size: 12.5px; color: var(--ink-faint); line-height: 1.55; text-align: center; }
.boot-hint em { color: var(--ink-dim); font-style: normal; }

/* ── Prompt dock (Gemini-style), bottom-center ───────────────────────────── */

.dock {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%) translateY(14px);
    z-index: 40;
    width: min(680px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
    pointer-events: none; /* gaps pass clicks through to the board */
}
.dock.in { opacity: 1; transform: translateX(-50%) translateY(0); }
.dock > * { pointer-events: auto; }

/* When dragged, the dock is pinned by explicit left/top (set inline) and the
   centering transform is dropped so it tracks the pointer 1:1. */
.dock.dragged { transform: none; bottom: auto; transition: none; }
.dock.dragging { cursor: grabbing; }

/* Drag handle — a small grip of dots, centered above the bubble. */
.dock-grip {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 18px;
    margin-bottom: -2px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    cursor: grab;
    touch-action: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0.6;
    transition: opacity 0.18s ease, background 0.18s ease;
}
.dock-grip:hover { opacity: 1; background: var(--surface-2); }
.dock-grip:active { cursor: grabbing; }
.dock-grip span {
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--ink-faint);
}
.dock-grip:hover span { background: var(--ink-dim); }

/* Assistant bubble */
.bubble {
    max-width: 100%;
    display: flex;
    gap: 11px;
    align-items: flex-start;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--g2);
    border-radius: 18px;
    padding: 13px 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.bubble.in { opacity: 1; transform: translateY(0); }
.bubble-spark { color: var(--g2); font-size: 14px; line-height: 1.5; flex: none; }
.bubble[data-kind="think"] { border-left-color: var(--g1); }
.bubble[data-kind="think"] .bubble-spark { animation: blink 1.2s ease-in-out infinite; }
.bubble[data-kind="hint"] { border-left-color: var(--g3); }
.bubble[data-kind="hint"] .bubble-spark { color: var(--g3); }
.bubble[data-kind="reply"] { border-left-color: var(--ok); }
.bubble[data-kind="error"] { border-left-color: var(--err); }
.bubble[data-kind="error"] .bubble-spark { color: var(--err); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* HUD chips */
.hud { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hud-chip {
    font-size: 12px;
    color: var(--ink-dim);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 11px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    white-space: nowrap;
}
.hud-chip b { color: var(--ink-faint); font-weight: 600; margin-right: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.hud-chip.muted { color: var(--ink-faint); }
.link-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); margin-right: 5px; vertical-align: middle; }
.link-ok .link-dot { background: var(--ok); }
.link-linking .link-dot { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
.link-error .link-dot { background: var(--err); }
body[data-turn="you"] #hud-turn { color: var(--ink); }
body[data-turn="you"] #hud-turn b { color: var(--g2); }

/* The pill */
.pill {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 9px 9px 18px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    transition: border-color 0.2s ease;
}
/* Gradient focus ring */
.pill::before {
    content: "";
    position: absolute;
    inset: -1.5px;
    border-radius: inherit;
    padding: 1.5px;
    background: var(--grad);
    background-size: 200% 200%;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.25s ease;
    animation: sheen 5s ease infinite;
    pointer-events: none;
}
.pill:focus-within::before { opacity: 1; }

.pill-spark {
    flex: none;
    font-size: 18px;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.pill-input {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--ink);
    font: inherit;
    font-size: 15.5px;
    padding: 8px 4px;
}
.pill-input::placeholder { color: var(--ink-faint); }
.pill-input:disabled { color: var(--ink-faint); }

.icon-btn {
    flex: none;
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink-dim);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

.hint-btn:hover { color: var(--g3); }
.send-btn {
    color: #0b0e16;
    background: var(--grad);
    background-size: 160% 160%;
    box-shadow: 0 6px 18px rgba(120, 90, 255, 0.4);
}
.send-btn:hover { color: #0b0e16; filter: brightness(1.08); background: var(--grad); }

/* Mic listening state */
.mic-btn.active {
    color: #fff;
    background: var(--err);
    box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.6);
    animation: mic-pulse 1.3s ease-out infinite;
}
@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.55); }
    100% { box-shadow: 0 0 0 16px rgba(251, 113, 133, 0); }
}

/* Footer */
.dock-footer {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; width: 100%;
    padding: 0 8px;
}
.mute-btn {
    border: 0; background: transparent; cursor: pointer;
    font: inherit; font-size: 12px; color: var(--ink-faint);
    padding: 2px 4px;
}
.mute-btn:hover { color: var(--ink-dim); }
.mute-btn .mute-off { display: none; }
.mute-btn.muted .mute-on { display: none; }
.mute-btn.muted .mute-off { display: inline; }
.credit { font-size: 11px; color: var(--ink-faint); }
.credit code {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 10.5px;
    color: var(--ink-dim);
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 5px;
    border-radius: 6px;
}

/* Busy: dim the spark, hint at activity */
body[data-busy="on"] .pill-spark { animation: blink 1s ease-in-out infinite; }

@media (max-width: 520px) {
    .dock { bottom: 14px; gap: 9px; }
    .brand-text h1 { font-size: 25px; }
    .icon-btn { width: 38px; height: 38px; }
}
