/* Site chrome — warm, gender-neutral, kid-friendly, modern.
   NOTE: this styles only the app's own pages. Kid-authored pages render inside
   sandboxed iframes with their own CSS and are never touched by this file. */
:root {
  --cream: #f1f7fd;       /* page background base (soft sky) */
  --cream-2: #e4eefb;     /* page background tint */
  --card: #ffffff;        /* cards / panels */
  --primary: #3f8fd6;     /* friendly blue — buttons, brand, accents */
  --primary-dark: #2f6fb0;
  --accent: #2fb0a8;      /* teal — secondary accent */
  --sun: #f4b942;         /* warm yellow highlight */
  --ink: #27364a;         /* deep navy-slate text */
  --muted: #6d7d92;       /* hints, captions, footer */
  --border: #d9e6f4;      /* soft blue-gray border */
  --border-soft: #e8f0fa;
  --code-bg: #e9f2fc;
  --flash-bg: #fff3d6;
  --flash-border: #f3d69a;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(39, 54, 74, .05), 0 2px 6px rgba(39, 54, 74, .06);
  --shadow: 0 4px 14px rgba(39, 54, 74, .08), 0 14px 40px rgba(39, 54, 74, .07);
  --shadow-primary: 0 3px 10px rgba(63, 143, 214, .35);
  --shadow-primary-lg: 0 6px 18px rgba(63, 143, 214, .42);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must win over explicit display rules (buttons/flex). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--primary-dark); }

h1, h2, h3 { letter-spacing: -0.015em; }

/* ---- Top nav ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(255, 253, 249, .82);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
  gap: 8px;
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--code-bg);
  font-size: 1rem;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.topbar nav a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 13px;
  border-radius: var(--r-pill);
  transition: background .14s ease, color .14s ease;
}

.topbar nav a:hover { background: var(--code-bg); }

.topbar nav a.active {
  color: var(--primary-dark);
  background: var(--code-bg);
}

.topbar nav a.nav-cta {
  color: var(--primary-dark);
  border: 1.5px solid var(--border);
}
.topbar nav a.nav-cta:hover { border-color: var(--primary); background: var(--card); }

/* ---- Layout ---- */
.container {
  display: block;
  max-width: 940px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.flash {
  background: var(--flash-bg);
  border: 1px solid var(--flash-border);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-primary);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-primary-lg); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-primary); }

.btn.secondary {
  background: var(--card);
  color: var(--primary-dark);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover { background: var(--cream); border-color: var(--primary); }

.btn.danger { background: #d9534f; box-shadow: 0 3px 10px rgba(217, 83, 79, .32); }
.btn.danger:hover { background: #c23c38; }

/* ---- Forms ---- */
.visibility-select,
input[type=text], input[type=password], input[type=email], input[type=file], textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 12px;
  background: var(--card);
  color: var(--ink);
  transition: border-color .14s ease, box-shadow .14s ease;
}

.visibility-select { cursor: pointer; }

input:focus, textarea:focus, .visibility-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63, 143, 214, .18);
}

textarea.code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 440px;
  resize: vertical;
  background: #3a2f28;
  color: #f6eadc;
  border-color: #3a2f28;
}
textarea.code:focus { box-shadow: 0 0 0 3px rgba(58, 47, 40, .25); }

label {
  font-weight: 700;
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

/* ---- Editor ---- */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.preview-frame {
  width: 100%;
  height: 500px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: white;
  box-shadow: var(--shadow-sm);
}

/* ---- Lists ---- */
.post-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
  gap: 12px;
}
.post-list-item:last-child { border-bottom: 0; }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.image-grid figure {
  margin: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: 10px;
  text-align: center;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, box-shadow .14s ease;
}
.image-grid figure:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.image-grid img {
  max-width: 100%;
  max-height: 110px;
  object-fit: cover;
  border-radius: 8px;
}

.image-grid figcaption {
  font-size: 0.72rem;
  margin-top: 6px;
  word-break: break-all;
  color: var(--muted);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 6px;
  word-break: break-word;
  font-size: 0.88em;
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 28px;
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ---- How-to / legal ---- */
.howto ol { padding-left: 20px; line-height: 1.7; }
.howto li { margin-bottom: 12px; }

.legal { max-width: 760px; margin: 0 auto; line-height: 1.7; }
.legal h1 { color: var(--primary); }
.legal h2 { margin-top: 26px; font-size: 1.15rem; }
.legal ul { line-height: 1.7; }

/* ---- Family / circles ---- */
.kid-block {
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 16px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  box-shadow: var(--shadow-sm);
}

.circle-box {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.circle-list { list-style: none; padding: 0; margin: 8px 0; }
.circle-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}

.comment-body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; }

.bg-preview {
  width: 140px;
  height: 90px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 2px solid var(--border);
}

/* ---- Landing ---- */
.hero {
  text-align: center;
  padding: 20px 16px 8px;
}

.hero .chip {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--code-bg);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  margin-bottom: 16px;
  letter-spacing: 0.01em;
}

.hero h1 {
  font-size: 2.6rem;
  line-height: 1.1;
  margin: 0 0 12px;
}

/* Only the words get the gradient; the emoji renders normally so it stays crisp. */
.hero h1 .grad {
  background: linear-gradient(120deg, var(--primary), #2f6fb0 55%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-emoji {
  display: inline-block;
  vertical-align: middle;
}

.hero .lead {
  font-size: 1.12rem;
  color: var(--ink);
  max-width: 620px;
  margin: 0 auto;
}

.landing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  margin-top: 24px;
}

.landing-list { list-style: none; padding: 0; line-height: 1.7; }
.landing-list li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.landing-list li:last-child { border-bottom: 0; }

/* ---- Tutorial ---- */
.tut-progress {
  height: 8px;
  background: var(--code-bg);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: 14px;
}
.tut-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--r-pill);
  transition: width .25s ease;
}

.tut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  margin-top: 12px;
}

.tut-preview {
  width: 100%;
  height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.tut-nav {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.tut-finish {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.tut-code { margin-top: 14px; }
.tut-code summary { cursor: pointer; font-weight: 600; color: var(--primary-dark); }
.tut-code-block { margin-top: 10px; }
.tut-code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.tut-copy {
  background: var(--code-bg);
  border: none;
  border-radius: var(--r-pill);
  padding: 3px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-dark);
  cursor: pointer;
}
.tut-code pre {
  background: #3a2f28;
  color: #f6eadc;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-size: 0.82rem;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.tut-snippet {
  margin: 12px 0;
}
.tut-snippet pre {
  background: #3a2f28;
  color: #f6eadc;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-size: 0.82rem;
  margin: 0 0 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- Cheat sheet ---- */
.cheat-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.cheat-row:last-child { border-bottom: 0; }
.cheat-code {
  background: #3a2f28;
  color: #f6eadc;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  margin: 0;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.cheat-desc { font-size: 0.9rem; color: var(--ink); }
.cheat-copy { white-space: nowrap; padding: 8px 14px; font-size: 0.85rem; }

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.color-swatch {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--card);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}
.color-swatch:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.color-block {
  height: 52px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.06);
}
.color-name { font-size: 0.82rem; font-weight: 700; color: var(--ink); }
.color-hex { font-size: 0.75rem; color: var(--muted); font-family: 'SF Mono', Menlo, monospace; }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 8px;
}
.emoji-btn {
  font-size: 1.5rem;
  line-height: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--card);
  cursor: pointer;
}
.emoji-btn:hover { border-color: var(--primary); background: var(--cream); }

@media (max-width: 620px) {
  .cheat-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 720px) {
  .editor-grid, .landing-grid, .tut-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2.1rem; }
  .container { padding: 24px 16px 40px; }
  .topbar { padding: 10px 16px; }
}
