/* ============================================================
 *  css/scratch.css  —— Scratch GUI 外壳样式（原版风格，无 MD3）
 *  配色取自 scratch-blocks core/colours.js 与 Scratch GUI
 * ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --gui-blue: #4C97FF;          /* Scratch 菜单栏 */
    --gui-blue-dark: #3373CC;
    --gui-text: #575E75;
    --gui-text-light: #FFFFFF;
    --gui-border: rgba(0, 0, 0, 0.15);
    --gui-panel: #FFFFFF;
    --gui-bg: #F9F9F9;
    --gui-hover: rgba(0, 0, 0, 0.08);
    --gui-font: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    --gui-mono: "SF Mono", Menlo, Consolas, monospace;
    --code-font-size: 13px;
}

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}
body {
    display: flex;
    flex-direction: column;
    font-family: var(--gui-font);
    font-size: 13px;
    color: var(--gui-text);
    background: var(--gui-bg);
    -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
button.icon-only { display: inline-flex; align-items: center; justify-content: center; padding: 0; }

/* ---------- 顶部菜单栏（Scratch 的蓝底白字）---------- */
.menu-bar {
    flex-shrink: 0;
    height: 48px;
    background: var(--gui-blue);
    color: var(--gui-text-light);
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 2px;
    z-index: 100;
    position: relative;
}
.menu-bar-item {
    height: 38px;
    padding: 0 14px;
    border-radius: 4px;
    color: var(--gui-text-light);
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background-color 0.12s;
}
.menu-bar-item:hover { background: rgba(255, 255, 255, 0.18); }
.menu-bar-item:active { background: rgba(255, 255, 255, 0.28); }
.menu-bar-logo { padding: 0 10px; }
.menu-bar .spacer { flex: 1; }

.project-name {
    margin-left: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 13px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.project-name:hover { background: rgba(255, 255, 255, 0.3); }
.project-name.dirty::after { content: ' ●'; font-size: 10px; opacity: 0.9; }

.run-btn {
    height: 36px;
    padding: 0 18px;
    margin-left: 6px;
    border-radius: 4px;
    background: #FFBF00;
    color: #7a5a00;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.run-btn:hover { filter: brightness(1.06); }
.run-btn:active { transform: translateY(1px); }
.stop-btn {
    height: 36px; width: 40px; margin-left: 6px; border-radius: 4px;
    background: #EC5A5A; color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}
.stop-btn[hidden] { display: none; }

/* ---------- 下拉菜单 ---------- */
.menu-dropdown {
    position: fixed;
    top: 52px;
    background: var(--gui-panel);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22), 0 0 0 1px var(--gui-border);
    padding: 6px;
    min-width: 220px;
    z-index: 900;
    display: none;
}
.menu-dropdown.open { display: block; }
.tools-dropdown { left: 8px; }
.menu-item {
    height: 38px;
    padding: 0 14px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13.5px;
    color: var(--gui-text);
    cursor: pointer;
    white-space: nowrap;
}
.menu-item:hover { background: var(--gui-hover); }
.menu-item .mi-shortcut { margin-left: auto; font-size: 11px; opacity: 0.55; }
.menu-item.danger { color: #d1242f; }
.menu-divider { height: 1px; background: var(--gui-border); margin: 6px 8px; }
.menu-info { padding: 8px 14px; font-size: 11.5px; color: var(--gui-text); line-height: 1.7; opacity: 0.85; }
.menu-info b { color: #222; }

/* ---------- 主体布局 ---------- */
.main { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.workspace-wrap { flex: 1; min-width: 0; position: relative; display: flex; }
#blocklyDiv { position: absolute; inset: 0; }
.workspace-empty {
    position: absolute;
    left: 50%; top: 44%;
    transform: translate(-50%, -50%);
    color: #b0b8bf;
    font-size: 14px;
    pointer-events: none;
    user-select: none;
}

/* 撤销 / 重做 */
.history-fab {
    position: absolute;
    right: 16px; bottom: 16px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 20;
    pointer-events: none;
}
.history-btn {
    pointer-events: auto;
    width: 44px; height: 44px;
    border-radius: 8px;
    background: var(--gui-panel);
    color: var(--gui-text);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    display: flex; align-items: center; justify-content: center;
}
.history-btn:hover:not(:disabled) { background: #f2f2f2; }
.history-btn:active:not(:disabled) { transform: translateY(1px); }
.history-btn:disabled { opacity: 0.4; cursor: default; }

/* 分隔条 */
.v-resizer { width: 6px; flex-shrink: 0; cursor: col-resize; background: var(--gui-border); }
.v-resizer:hover { background: var(--gui-blue); }

/* ---------- Toast（Scratch 风格）---------- */
.toast {
    position: fixed;
    left: 50%; bottom: 28px;
    transform: translateX(-50%) translateY(12px);
    background: #575E75;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s, transform 0.22s;
    z-index: 1200;
    max-width: 90vw;
    text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
 *  官方工具箱微调
 *  本编辑器有 34 个分类 + 精选 = 35 项，官方默认样式（每项约 30px、
 *  容器不滚动）在手机上会溢出到屏幕外，所以这里：
 *    · 把 float 布局改成 flex 列，并让容器可滚动；
 *    · 缩小每一项，让更多分类能一屏看到；
 *    · 悬停时在旁边浮出分类名（Scratch 的 hover 标签）。
 * ============================================================ */
.blocklyToolboxDiv {
    background: #FFFFFF;
    border-right: 1px solid rgba(0, 0, 0, 0.12);
    padding: 4px 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}
.blocklyToolboxDiv::-webkit-scrollbar { width: 5px; }
.blocklyToolboxDiv::-webkit-scrollbar-thumb { background: #CECDCE; border-radius: 3px; }

.scratchCategoryMenu {
    width: 62px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.scratchCategoryMenuRow {
    float: none;                 /* 官方是 float，改 flex 后要清掉 */
    margin: 1px 0;
    width: 100%;
}
.scratchCategoryMenuItem {
    position: relative;
    padding: 5px 0;
}
.scratchCategoryItemBubble {
    width: 20px;
    height: 20px;
    margin: 0 auto 1px;
}
.scratchCategoryMenuItemLabel {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 6px;
    padding: 5px 12px;
    background: #FFFFFF;
    color: var(--gui-text);
    font-family: var(--gui-font);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    z-index: 60;
    transition: opacity 0.1s;
}
.scratchCategoryMenuItem:hover .scratchCategoryMenuItemLabel { opacity: 1; }

@media (max-width: 820px) {
    .menu-bar-item { padding: 0 10px; font-size: 13px; }
    .project-name { max-width: 110px; font-size: 12px; }
    .run-btn { padding: 0 12px; font-size: 13px; }
}
