/* ============================================================
   BlockForge — main.css
   Design system shared by the home page and the editor.
   Modern "visual programming studio" look: deep navy ink,
   soft blue-gray canvas, Scratch-blue primary, crisp white
   panels, rounded corners and gentle shadows.
   ============================================================ */

:root {
  /* brand / accent */
  --primary:      #4c97ff;   /* Scratch blue */
  --primary-deep: #3665d9;
  --primary-soft: #eaf3ff;
  --violet:       #4c97ff;   /* alias kept for old rules */
  --violet-soft:  #eaf3ff;
  --cyan:         #25c2e3;
  --amber:        #ffab19;
  --green:        #0fbd8c;
  --red:          #ff4d4d;
  --scratch-green: #0fbd8c;
  --scratch-red:  #ff4d4d;

  /* surfaces */
  --bg:       #f2f5fa;
  --panel:    #ffffff;
  --panel-2:  #f8fafd;
  --line:     #e4eaf2;
  --line-soft:#eef2f8;

  /* ink */
  --ink:      #182b4a;
  --ink-soft: #5e6f8a;

  /* radii */
  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* elevation */
  --shadow-sm: 0 1px 2px rgba(24, 43, 74, .06);
  --shadow:    0 2px 10px rgba(24, 43, 74, .08);
  --shadow-lg: 0 16px 44px rgba(24, 43, 74, .16);

  --tb-h: 60px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  font-size: 15px;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 { margin: .25em 0; line-height: 1.2; letter-spacing: -.01em; }
.muted { color: var(--ink-soft); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); }

/* thin scrollbars on fine pointers (ignored on iOS) */
@media (pointer: fine) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: #ccd6e4; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
  ::-webkit-scrollbar-thumb:hover { background-color: #b3c1d4; }
  ::-webkit-scrollbar-track { background: transparent; }
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .12s ease, background .12s, border-color .12s;
}
.btn:hover { box-shadow: var(--shadow); border-color: #d4deea; }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-deep));
  border-color: transparent; color: #fff;
}
.btn.primary:hover { box-shadow: 0 6px 18px rgba(76, 151, 255, .35); }
.btn.danger { background: #fff1f1; border-color: #ffd4d4; color: #d63a3a; }
.btn.small { padding: 8px 13px; min-height: 40px; font-size: 13px; }

/* ---------- Toasts ---------- */
.toast-root {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 9999;
  pointer-events: none;
  width: max-content; max-width: 92vw;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #14233f; color: #fff;
  padding: 11px 18px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease;
}
.toast::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--primary);
}
.toast.ok::before { background: var(--scratch-green); }
.toast.err::before { background: var(--scratch-red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ============================================================
   HOME PAGE
   ============================================================ */
.home-body {
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(76, 151, 255, .14), transparent 60%),
    radial-gradient(800px 500px at 105% 15%, rgba(37, 194, 227, .12), transparent 60%),
    linear-gradient(180deg, #f7faff 0%, var(--bg) 45%);
  min-height: 100%;
}
.home { max-width: 1000px; margin: 0 auto; padding: 52px 20px 64px; }

.home-hero { text-align: center; margin-bottom: 36px; }
.home-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 88px; height: 88px; border-radius: 26px;
  background: linear-gradient(145deg, #ffffff, #eef4ff);
  box-shadow: 0 14px 34px rgba(76, 151, 255, .22), inset 0 1px 0 #fff;
  margin-bottom: 4px;
}
.home-hero h1 {
  font-size: 46px; margin: 14px 0 8px; letter-spacing: -.03em;
  background: linear-gradient(90deg, #2b6fe0 0%, #4c97ff 55%, #25c2e3 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.home-tagline { color: var(--ink-soft); font-size: 17px; line-height: 1.55; margin: 0; }
.home-badge {
  display: inline-block; margin-top: 14px; padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--primary-deep);
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid #d6e6fb;
}
.home-badge + .home-badge { margin-left: 6px; }

.home-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px; margin-bottom: 36px;
}
.home-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .15s ease, border-color .12s;
  min-height: 84px;
}
.home-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #d0ddf0; }
.home-btn:active { transform: scale(.98); }
.home-btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-deep));
  border-color: transparent; color: #fff;
}
.home-btn.primary small { color: #dbe9ff; }
.home-btn.primary .home-btn-icon { background: rgba(255, 255, 255, .18); }
.home-btn-icon {
  width: 48px; height: 48px; flex: none;
  border-radius: 14px; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.home-btn strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.home-btn small { color: var(--ink-soft); font-size: 13px; line-height: 1.35; }

.home-projects h2, .home-docs h2 { font-size: 21px; margin-bottom: 14px; }
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px;
}
.project-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .15s ease;
}
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.project-card h3 { margin: 0 0 6px; font-size: 16px; overflow-wrap: anywhere; }
.project-card time { color: var(--ink-soft); font-size: 12px; }
.project-card .pc-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.home-docs {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 24px 28px; margin-bottom: 20px; box-shadow: var(--shadow);
  animation: panel-in .18s ease;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }
.docs-body { line-height: 1.7; font-size: 15px; }
.docs-body h3 { margin-top: 20px; font-size: 17px; }
.docs-body code {
  background: var(--primary-soft); border-radius: 6px; padding: 1px 7px; font-size: 13px;
  font-family: var(--mono);
}
.settings-row {
  display: flex; gap: 12px; align-items: center; padding: 8px 0; font-size: 15px;
}
.settings-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.home-foot { text-align: center; color: var(--ink-soft); font-size: 13px; margin-top: 34px; }

/* ---------- Generic modal ---------- */
.modal-root {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(16, 28, 51, .5);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--panel); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(460px, 94vw); max-height: 86vh; overflow: auto;
  padding: 26px; animation: modal-in .16s ease;
}
@keyframes modal-in { from { opacity: 0; transform: scale(.95) translateY(6px); } }
.modal h3 { margin-top: 0; font-size: 19px; }
.modal .modal-row { margin: 14px 0; }
.modal input[type="text"] {
  width: 100%; padding: 13px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.modal input[type="text"]:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }