/* Coducators Code — styles */
:root {
  --blue: #3586c7;
  --blue-dark: #25689e;
  --green: #7dbd42;
  --green-dark: #5e9a2e;
  --red: #d8212b;
  --red-dark: #a3131f;
  --bg: #eef0f4;
  --ink: #1e2a35;
  --line: #d4dae2;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); }

/* ================= menu bar ================= */
#menubar {
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 12px;
  background: linear-gradient(180deg, var(--blue), #2f79b5);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  position: relative; z-index: 30;
}
#menu-logo img { height: 30px; display: block; background: #fff; border-radius: 8px; padding: 3px 8px; }
#menu-app {
  color: #fff; font-weight: 700; font-size: 15px;
  background: rgba(255,255,255,0.18); padding: 3px 10px; border-radius: 12px;
}
#project-name {
  border: none; border-radius: 6px; padding: 6px 10px; font-size: 14px; font-weight: 600;
  width: 200px; background: rgba(255,255,255,0.92); color: var(--ink);
}
.menu-btn {
  border: none; background: rgba(255,255,255,0.16); color: #fff;
  padding: 7px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.menu-btn:hover { background: rgba(255,255,255,0.3); }
.menu-spacer { flex: 1; }

/* ================= tabs ================= */
#tabs-row { background: #e3e7ee; border-bottom: 1px solid var(--line); padding: 6px 10px 0; }
#tabs { display: flex; gap: 4px; }
.tab {
  padding: 8px 18px; border-radius: 10px 10px 0 0; cursor: pointer;
  font-size: 13px; font-weight: 700; color: #5b6b7a;
  background: #d7dce4; border: 1px solid var(--line); border-bottom: none;
  user-select: none;
}
.tab.active { background: #fff; color: var(--blue); }

/* ================= layout ================= */
#editor-main {
  display: flex; height: calc(100vh - 52px - 39px); min-height: 420px;
}
#left-pane { flex: 1; min-width: 0; display: flex; background: #fff; }
.tab-panel { display: flex; flex: 1; min-width: 0; }

#right-pane {
  width: 500px; min-width: 380px; display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: var(--bg);
}

/* ================= palette ================= */
#cat-list {
  width: 84px; background: #fff; border-right: 1px solid var(--line);
  overflow-y: auto; padding: 6px 0; flex-shrink: 0;
}
.cat-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px; cursor: pointer; font-size: 11px; font-weight: 600; color: #5b6b7a;
  border-radius: 8px; margin: 2px 4px; text-align: center;
}
.cat-item:hover { background: var(--bg); }
.cat-item.active { background: #e4eefb; color: var(--ink); }
.cat-dot { width: 18px; height: 18px; border-radius: 50%; }

#palette-pane {
  width: 250px; flex-shrink: 0; background: #f7f8fa; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
#palette { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 60px; }
.pal-header {
  font-size: 13px; font-weight: 800; margin: 14px 0 8px; color: var(--ink);
  display: flex; align-items: center; gap: 6px;
}
.pal-header:first-child { margin-top: 0; }
.pal-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.pal-block { margin: 0 0 8px; }
.pal-note { font-size: 12px; color: #7a8794; margin-bottom: 10px; }
.pal-btn {
  display: block; width: 100%; margin: 2px 0 10px; padding: 8px;
  background: var(--blue); border: none; border-radius: 8px; color: #fff;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.pal-btn:hover { background: var(--blue-dark); }
#palette .block { cursor: grab; }
#palette .block input, #palette .block select { pointer-events: none; }

/* ================= workspace ================= */
#workspace-holder {
  flex: 1; min-width: 0; overflow: auto; position: relative;
  background: #fff;
  background-image: radial-gradient(#dfe4ea 1.2px, transparent 1.2px);
  background-size: 24px 24px;
}
.ws { position: relative; width: 2400px; height: 1600px; display: none; }
.ws.active { display: block; }
.script { position: absolute; display: flex; flex-direction: column; align-items: flex-start; }

#drag-layer {
  position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none;
}
#drag-layer .script.dragging {
  position: absolute; left: 0; top: 0;
  filter: drop-shadow(3px 5px 6px rgba(0,0,0,0.3));
}

.snap-indicator {
  position: absolute; width: 140px; height: 5px; background: #9db4c9;
  border-radius: 3px; z-index: 5; pointer-events: none;
}
.slot.snap-slot { outline: 3px solid #fff; outline-offset: 1px; border-radius: 12px; }

/* ================= blocks ================= */
.block {
  position: relative;
  font-size: 12.5px; font-weight: 600; color: #fff;
  width: max-content; max-width: 460px;
  user-select: none; touch-action: none;
  cursor: grab;
}
.block:active { cursor: grabbing; }
.brow {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; min-height: 32px;
  border-radius: 6px;
  position: relative;
}
.block .lbl { white-space: nowrap; }

/* category colors */
.cat-motion    .brow, .cat-motion.k-rep .brow    { background: #3586c7; border: 1px solid #2b6da3; }
.cat-looks     .brow                              { background: #9966ff; border: 1px solid #7a4fd6; }
.cat-sound     .brow                              { background: #cf63cf; border: 1px solid #a94fa9; }
.cat-events    .brow                              { background: #d8212b; border: 1px solid #ad1a22; }
.cat-control   .brow                              { background: #f2a20c; border: 1px solid #c9860a; }
.cat-sensing   .brow                              { background: #2ca8c2; border: 1px solid #22869b; }
.cat-operators .brow                              { background: #7dbd42; border: 1px solid #649735; }
.cat-variables .brow                              { background: #f07030; border: 1px solid #c55a24; }

.cat-control .bfoot, .cat-control .belse { background: #f2a20c; border: 1px solid #c9860a; }

/* hat blocks */
.k-hat .brow { border-radius: 18px 18px 6px 6px; padding-top: 8px; }

/* reporters & booleans */
.k-rep .brow { border-radius: 16px; min-height: 26px; padding: 2px 8px; }
.k-bool .brow { border-radius: 4px; min-height: 26px; padding: 2px 10px;
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 9px 100%, 0 50%); border: none; }
.k-rep, .k-bool { width: max-content; }

/* c-blocks */
.k-c .brow, .k-ce .brow, .k-ccap .brow { border-bottom-left-radius: 0; }
.bsub {
  margin-left: 14px; min-height: 22px; min-width: 90px;
  padding: 3px 0 3px 0;
  border-left: 14px solid transparent; margin-left: 0;
  display: flex; flex-direction: column; align-items: flex-start;
  position: relative;
}
.cat-control .bsub { border-left-color: #f2a20c; }
.belse {
  padding: 4px 10px; font-weight: 700; border-radius: 0; min-height: 24px;
  display: flex; align-items: center; width: 100%;
}
.bfoot { height: 12px; border-radius: 0 0 6px 6px; min-width: 90px; width: 100%; }
.k-ccap .bfoot { border-radius: 0 0 6px 6px; }

/* slots */
.slot { display: inline-flex; align-items: center; min-height: 22px; }
.slot input {
  border: none; border-radius: 20px; padding: 3px 8px; font-size: 12px; font-weight: 600;
  color: var(--ink); text-align: center; outline: none; min-width: 24px;
  font-family: var(--font);
}
.s-num input { border-radius: 20px; }
.s-text input, .s-any input { border-radius: 8px; }
.slot select {
  border: none; border-radius: 14px; padding: 3px 6px; font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,0.25); color: #fff; outline: none; cursor: pointer;
  font-family: var(--font); max-width: 150px;
}
.slot select option { color: var(--ink); background: #fff; }
.s-bool {
  min-width: 34px; height: 20px; background: rgba(0,0,0,0.25);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
  border-radius: 3px;
}
.slot.filled { background: transparent !important; clip-path: none; }
.slot .block { margin: 1px 0; }

/* context menu */
.ctx-menu {
  position: fixed; z-index: 2000; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,0.18); overflow: hidden; min-width: 140px;
}
.ctx-item { padding: 9px 14px; font-size: 13px; cursor: pointer; }
.ctx-item:hover { background: var(--bg); }

/* ================= stage ================= */
#stage-header {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: #fff; border-bottom: 1px solid var(--line);
}
#btn-flag, #btn-stop {
  border: none; border-radius: 8px; font-size: 17px; width: 40px; height: 34px; cursor: pointer;
}
#btn-flag { background: #e7f3dc; color: var(--green-dark); }
#btn-flag:hover, #btn-flag.running { background: var(--green); color: #fff; }
#btn-stop { background: #fbe3e4; color: var(--red); }
#btn-stop:hover, #btn-stop.active { background: var(--red); color: #fff; }

#stage-wrap {
  position: relative; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; justify-content: center; padding: 8px;
}
#stage {
  width: 100%; max-width: 480px; aspect-ratio: 4 / 3; height: auto;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  touch-action: none;
}
#watchers {
  position: absolute; left: 16px; top: 14px; display: flex; flex-direction: column; gap: 4px;
  pointer-events: none;
}
.watcher {
  display: flex; align-items: center; gap: 6px; background: rgba(238,240,244,0.92);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font-size: 11px;
}
.w-name { font-weight: 700; color: #444; }
.w-val {
  background: var(--blue); color: #fff; border-radius: 4px; padding: 1px 7px;
  font-weight: 700; min-width: 24px; text-align: center;
}
#ask-bar {
  position: absolute; left: 16px; right: 16px; bottom: 14px;
  display: flex; gap: 6px; background: #fff; border: 2px solid var(--blue);
  border-radius: 10px; padding: 6px;
}
#ask-input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 13px; outline: none; }
#ask-submit {
  border: none; background: var(--blue); color: #fff; border-radius: 50%;
  width: 32px; height: 32px; font-size: 15px; cursor: pointer;
}

/* ================= sprite panel ================= */
#sprite-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#sprite-info {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
  background: #fff; padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: 12px; color: #5b6b7a; font-weight: 600;
}
#sprite-info label { display: flex; align-items: center; gap: 5px; }
#sprite-info input {
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12px;
  width: 56px; outline: none;
}
#si-name { width: 90px !important; }
.si-toggle {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  width: 30px; height: 26px; cursor: pointer; font-size: 13px;
}
.si-toggle.on { background: var(--blue); border-color: var(--blue); color: #fff; }

#sprite-panel-body { flex: 1; display: flex; min-height: 0; padding: 8px; gap: 8px; }
#sprite-list-wrap { flex: 1; position: relative; overflow-y: auto; }
#sprite-list { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding-bottom: 60px; }
.sprite-card {
  width: 74px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
  display: flex; flex-direction: column; align-items: center; padding: 6px 4px 4px;
  cursor: pointer; position: relative; gap: 3px;
}
.sprite-card img { width: 46px; height: 46px; object-fit: contain; }
.sprite-card .sc-name {
  font-size: 11px; font-weight: 700; max-width: 66px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.sprite-card.selected { border-color: var(--blue); background: #e4eefb; }
.sc-del {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px;
  border-radius: 50%; border: none; background: var(--red); color: #fff;
  font-size: 10px; cursor: pointer; display: none;
}
.sprite-card:hover .sc-del { display: block; }
.stage-card { width: 84px; }
#btn-add-sprite {
  position: sticky; bottom: 8px; left: 100%;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: var(--green); color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25); display: block; margin-left: auto;
}
#btn-add-sprite:hover { background: var(--green-dark); }

/* ================= costumes / sounds tabs ================= */
.asset-pane { flex: 1; padding: 18px; overflow-y: auto; }
.asset-pane h3 { margin: 0 0 12px; }
.asset-note { font-size: 13px; color: #6b7987; }
#costume-list { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.costume-card {
  width: 110px; border: 2px solid var(--line); border-radius: 12px; background: #fff;
  display: flex; flex-direction: column; align-items: center; padding: 8px; gap: 4px;
  cursor: pointer; position: relative;
}
.costume-card img { width: 84px; height: 66px; object-fit: contain; }
.costume-card.selected { border-color: var(--blue); background: #e4eefb; }
.cc-num { position: absolute; top: 4px; left: 8px; font-size: 11px; font-weight: 800; color: #8593a2; }
.cc-name { font-size: 12px; font-weight: 700; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-del {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
  border-radius: 50%; border: none; background: var(--red); color: #fff; cursor: pointer; display: none;
}
.costume-card:hover .cc-del { display: block; }
.asset-actions { display: flex; gap: 8px; }

#sound-list { display: flex; flex-wrap: wrap; gap: 12px; }
.sound-card {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 16px;
  font-weight: 700; font-size: 14px;
}
.snd-play {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--blue); color: #fff; font-size: 14px; cursor: pointer;
}
.snd-play:hover { background: var(--blue-dark); }

/* ================= buttons / modal ================= */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }

#modal-back {
  position: fixed; inset: 0; background: rgba(30,42,53,0.5); z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
#modal {
  background: #fff; border-radius: 14px; width: min(680px, 92vw); max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 16px 50px rgba(0,0,0,0.3);
}
#modal-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--blue); color: #fff; padding: 12px 16px; font-weight: 800; font-size: 15px;
}
#modal-close { border: none; background: transparent; color: #fff; font-size: 16px; cursor: pointer; }
#modal-body { padding: 16px; overflow-y: auto; }
.gallery-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.gal-card {
  width: 120px; border: 2px solid var(--line); border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer;
  font-size: 13px; font-weight: 700; background: #fff;
}
.gal-card:hover { border-color: var(--blue); background: #e4eefb; }
.gal-card img { width: 84px; height: 84px; object-fit: contain; }
.gal-card.wide { width: 170px; }
.gal-card.wide img { width: 146px; height: 100px; }
.gal-icon {
  width: 84px; height: 84px; display: flex; align-items: center; justify-content: center;
  font-size: 34px; background: var(--bg); border-radius: 10px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* paint editor */
.paint-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.pt-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; }
.pt-btn.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.pt-swatch {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line);
  cursor: pointer; margin: 0 2px; vertical-align: middle;
}
.pt-swatch.on { border-color: var(--ink); transform: scale(1.15); }
#pt-canvas {
  border: 1px solid var(--line); border-radius: 8px; touch-action: none;
  background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%),
                    linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
  max-width: 100%;
}

/* ================= landing page ================= */
body.home-page { min-height: 100vh; }
#home-hero {
  background: linear-gradient(160deg, var(--blue) 0%, #2f79b5 60%, #25689e 100%);
  color: #fff; padding: 40px 24px 56px; text-align: center;
}
#home-hero .logo-card {
  display: inline-block; background: #fff; border-radius: 16px; padding: 10px 26px; margin-bottom: 18px;
}
#home-hero .logo-card img { height: 52px; display: block; }
#home-hero h1 { margin: 6px 0 10px; font-size: 34px; }
#home-hero p { margin: 0 auto 26px; max-width: 560px; font-size: 16px; opacity: 0.95; }
.cta {
  display: inline-block; background: var(--green); color: #fff; text-decoration: none;
  font-size: 18px; font-weight: 800; padding: 14px 34px; border-radius: 30px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25); border: none; cursor: pointer;
}
.cta:hover { background: var(--green-dark); }
#home-main { max-width: 1000px; margin: 0 auto; padding: 30px 20px 60px; }
#home-main h2 { font-size: 20px; }
#project-grid { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; }
.proj-card {
  width: 220px; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; cursor: pointer; transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
}
.proj-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.12); }
.proj-thumb {
  height: 130px; background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.proj-thumb img { max-width: 80%; max-height: 110px; object-fit: contain; }
.proj-meta { padding: 10px 12px; }
.proj-name { font-weight: 800; font-size: 14px; }
.proj-date { font-size: 12px; color: #7a8794; margin-top: 2px; }
.proj-del {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  border: none; background: rgba(216,33,43,0.9); color: #fff; cursor: pointer; display: none;
}
.proj-card:hover .proj-del { display: block; }
.empty-note { color: #7a8794; font-size: 14px; }
#features { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 40px; }
.feat {
  flex: 1 1 220px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px;
}
.feat .fi { font-size: 28px; }
.feat h3 { margin: 8px 0 6px; font-size: 15px; }
.feat p { margin: 0; font-size: 13px; color: #5b6b7a; }
#home-footer { text-align: center; padding: 24px; color: #8593a2; font-size: 13px; }

/* narrow screens */
@media (max-width: 900px) {
  #editor-main { flex-direction: column; height: auto; }
  #right-pane { width: 100%; min-width: 0; border-left: none; border-top: 1px solid var(--line); }
  #tab-code { min-height: 60vh; }
  #palette-pane { width: 200px; }
}
