/* Kids Coding Playground — colorful light theme for the app chrome.
   (This styles the app itself, not the child's preview. The preview shows
   their own page with Bootstrap 5.) */

:root {
  --bg: #fff7ed;             /* warm cream background */
  --bg2: #ffe9d6;
  --ink: #2b2d42;
  --muted: #6b7280;
  --card: #ffffff;
  --brand: #ff6b35;          /* orange */
  --brand2: #4f7cff;         /* blue */
  --pink: #ff5d8f;
  --green: #2ec4b6;
  --yellow: #ffd23f;
  --purple: #9b5de5;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(43, 45, 66, 0.12);
  --font: 'Baloo 2', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  min-height: 100vh;
}

a { color: var(--brand2); }

.btn {
  font-family: var(--font);
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.04); }
.btn:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(0,0,0,0.12); }
.btn-brand { background: var(--brand); color: #fff; }
.btn-blue  { background: var(--brand2); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-pink  { background: var(--pink); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); box-shadow: 0 2px 0 rgba(0,0,0,0.08); }
.btn-sm { padding: 7px 14px; font-size: .9rem; box-shadow: 0 3px 0 rgba(0,0,0,0.12); }

/* ---------- Landing / PIN ---------- */
.center-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.pin-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  text-align: center;
}
.logo-emoji { font-size: 3.4rem; line-height: 1; }
.pin-card h1 { margin: 10px 0 2px; font-size: 1.7rem; }
.pin-card p.sub { color: var(--muted); margin: 0 0 24px; }
.pin-inputs { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; }
.pin-inputs input {
  width: 48px; height: 58px; text-align: center;
  font-size: 1.7rem; font-family: var(--font); font-weight: 700;
  border: 3px solid #ffd9c2; border-radius: 14px; background: #fff;
  color: var(--ink); outline: none;
}
.pin-inputs input:focus { border-color: var(--brand); }
.error-msg { color: #e63946; min-height: 22px; font-weight: 600; margin-bottom: 8px; }

/* ---------- Header bar (hub + editor) ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px; background: #fff; box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.topbar .brand { font-size: 1.3rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.topbar .spacer { flex: 1; }
.hello { color: var(--muted); font-weight: 600; }

/* ---------- Hub ---------- */
.hub-wrap { max-width: 1050px; margin: 0 auto; padding: 28px 22px 60px; }
.hub-wrap h2 { font-size: 1.5rem; margin: 18px 0 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }

.project-card, .new-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; cursor: pointer; border: 3px solid transparent;
  transition: transform .12s ease, border-color .12s ease;
  position: relative;
}
.project-card:hover, .new-card:hover { transform: translateY(-4px); border-color: var(--brand); }
.project-card .emoji, .new-card .emoji { font-size: 2.6rem; }
.project-card .pname { font-weight: 800; font-size: 1.15rem; margin-top: 6px; }
.project-card .pmeta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.card-actions { margin-top: 12px; display: flex; gap: 8px; }
.new-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; border: 3px dashed #ffb996; background: #fff;
  min-height: 150px;
}
.new-card .plus { font-size: 2.8rem; color: var(--brand); line-height: 1; }
.new-card .lbl { font-weight: 800; margin-top: 6px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(43,45,66,0.45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 640px; padding: 26px; max-height: 90vh; overflow: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 1.3rem; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.tpl-pick {
  border: 3px solid #eee; border-radius: 14px; padding: 14px 10px; text-align: center;
  cursor: pointer; transition: border-color .12s ease, transform .12s ease; background: #fff;
}
.tpl-pick:hover { transform: translateY(-3px); }
.tpl-pick.selected { border-color: var(--brand); background: #fff3ec; }
.tpl-pick .temoji { font-size: 2rem; }
.tpl-pick .ttitle { font-weight: 800; margin-top: 4px; font-size: .95rem; }
.tpl-pick .tdesc { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.field { margin: 16px 0; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.field input[type=text] {
  width: 100%; padding: 12px 14px; border: 3px solid #ffd9c2; border-radius: 12px;
  font-size: 1rem; font-family: var(--font); outline: none;
}
.field input[type=text]:focus { border-color: var(--brand); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- Editor layout ---------- */
.editor-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor-main { flex: 1; display: flex; min-height: 0; }
.panes { display: flex; flex: 1; min-width: 0; }
.code-side { display: flex; flex-direction: column; min-width: 0; background: #fff; }
.preview-side { min-width: 0; background: #fff; border-left: 4px solid var(--bg2); display: flex; flex-direction: column; }

.tabs { display: flex; gap: 4px; padding: 8px 8px 0; background: #fff; }
.tab {
  border: none; background: #ffe9d6; color: var(--ink); font-family: var(--font);
  font-weight: 800; padding: 8px 16px; border-radius: 12px 12px 0 0; cursor: pointer; font-size: .95rem;
}
.tab.active { background: var(--brand); color: #fff; }
.tab.hidden-pane { display: none; }

.code-area { flex: 1; position: relative; min-height: 0; }
textarea.code {
  width: 100%; height: 100%; border: none; outline: none; resize: none;
  font-family: 'Fira Code', 'Consolas', monospace; font-size: 15px; line-height: 1.5;
  padding: 14px 16px; background: #fffdf9; color: #2b2d42; tab-size: 2;
}
.code-pane { display: none; height: 100%; }
.code-pane.active { display: block; }

.preview-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: #fff; border-bottom: 2px solid var(--bg2);
}
.preview-head .plabel { font-weight: 800; color: var(--muted); }
iframe.preview { flex: 1; width: 100%; border: none; background: #fff; }

/* snippet bar */
.snippet-bar {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px;
  background: #fff; border-top: 2px solid var(--bg2);
}
.snippet-bar .lbl { font-weight: 800; color: var(--muted); align-self: center; margin-right: 4px; }
.chip {
  border: none; background: var(--purple); color: #fff; font-family: var(--font);
  font-weight: 700; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: .85rem;
  box-shadow: 0 3px 0 rgba(0,0,0,0.12);
}
.chip:hover { filter: brightness(1.06); }
.chip.c2 { background: var(--green); }
.chip.c3 { background: var(--brand2); }
.chip.c4 { background: var(--pink); }
.chip.c5 { background: var(--yellow); color: #2b2d42; }

.divider { width: 8px; cursor: col-resize; background: var(--bg2); }
.divider:hover { background: var(--brand); }

.save-state { font-weight: 700; color: var(--green); font-size: .9rem; }
.save-state.saving { color: var(--muted); }

/* Full-preview mode: hide the code side */
.editor-main.full .code-side,
.editor-main.full .divider { display: none; }

@media (max-width: 820px) {
  .panes { flex-direction: column; }
  .divider { display: none; }
  .preview-side { border-left: none; border-top: 4px solid var(--bg2); }
}
