@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  /* Peachy classroom palette */
  --bg:        #f5d4ba;         /* warm peach wash */
  --bg-2:      #f0c5a4;
  --panel:     #fefaf3;         /* cream paper */
  --panel-2:   #f7eee0;         /* slightly darker cream */
  --text:      #3d3838;         /* warm dark brown */
  --muted:     #8a7a76;
  --border:    #e8d9c7;

  --accent:     #9fb9a2;        /* sage green */
  --accent-ink: #2d4a30;
  --red:        #e5897c;        /* soft salmon */
  --yellow:     #f0cc73;        /* mustard */
  --green:      #a8c4a2;
  --dark-green: #7fa17b;
  --blue:       #9fbbcc;        /* dusty blue */
  --pink:       #efb0b6;
  --purple:     #c4a9d4;
  --orange:     #efa983;
  --cyan:       #a8d1c7;
  --white:      #ffffff;

  --radius: 18px;
  --sidebar-w: 230px;
  --shadow: 0 2px 0 rgba(0,0,0,.04), 0 10px 20px -8px rgba(109, 70, 48, .18);
  --shadow-lg: 0 2px 0 rgba(0,0,0,.04), 0 24px 30px -14px rgba(109, 70, 48, .22);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  color: var(--text);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  font-weight: 600;
  overscroll-behavior: none;
  position: relative;
  background:
    /* lined paper: faint horizontal lines */
    repeating-linear-gradient(to bottom, transparent 0 27px, rgba(130,170,195,.28) 27px 28px),
    /* left margin red line */
    linear-gradient(to right, transparent 0 56px, rgba(220,120,110,.28) 56px 57px, transparent 57px 100%),
    /* paper tone */
    var(--bg);
  background-attachment: fixed;
}
/* Scattered doodle layer behind the content */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: url('../images/doodles.svg') repeat;
  background-size: 1200px 900px;
  opacity: .07;
}
.app { position: relative; z-index: 1; }

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--panel);
  border-right: 2px dashed var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 100vh;
  position: relative;
}
.sidebar::before {
  /* notebook-ring strip down the right edge */
  content: ''; position: absolute; top: 0; right: -2px; width: 10px; height: 100%;
  background-image: radial-gradient(circle at 50% 10px, var(--bg) 3px, transparent 4px);
  background-size: 10px 22px; background-repeat: repeat-y;
}
.sidebar .brand {
  font-family: 'Caveat', cursive;
  font-weight: 700; font-size: 28px;
  padding: 4px 8px 14px; color: var(--accent-ink);
  display: flex; align-items: center; gap: 8px;
}
.sidebar .brand .logo {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--yellow);
  display: inline-grid; place-items: center;
  color: #5a4b1f; font-size: 18px;
  box-shadow: var(--shadow);
}
.navlink {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 14px;
  color: var(--text); text-decoration: none;
  font-weight: 700; font-size: 15px;
  transition: background .15s, transform .1s;
}
.navlink:hover { background: var(--panel-2); }
.navlink.active {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow);
}
.navlink .ico { width: 22px; text-align: center; font-size: 17px; }
.sidebar .foot {
  margin-top: auto; padding: 10px 12px; color: var(--muted);
  font-size: 12px; font-family: 'Caveat', cursive; font-size: 16px;
}

/* Mobile drawer */
.topbar { display: none; }
.scrim  { display: none; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .content { padding-top: 0; }
  .topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 20;
    background: var(--panel); border-bottom: 2px dashed var(--border);
    padding: 10px 14px; margin: 0 -20px 14px;
  }
  .topbar .menuBtn {
    width: 40px; height: 40px; display: inline-grid; place-items: center;
    background: var(--panel-2); border-radius: 12px; cursor: pointer;
    font-size: 20px; color: var(--text);
  }
  .topbar .ttl { font-family: 'Caveat', cursive; font-weight: 700; font-size: 22px; color: var(--accent-ink); }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 260px;
    transform: translateX(-100%); transition: transform .22s ease;
    z-index: 30; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; background: rgba(60, 40, 30, .4); z-index: 25;
  }
}

.content { padding: 20px 24px 32px; max-width: 1200px; width: 100%; }

h1 {
  font-family: 'Caveat', cursive; font-weight: 700;
  font-size: 42px; margin: 2px 0 14px; color: var(--accent-ink);
  letter-spacing: .5px;
}
h2 {
  font-family: 'Caveat', cursive; font-weight: 700;
  font-size: 22px; margin: 12px 0 8px; color: var(--text);
  letter-spacing: .5px;
}

/* Cards look like paper */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card.flex { display: flex; align-items: center; gap: 14px; }

/* Two-column layout for wide screens */
.cols { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 820px) {
  .cols { grid-template-columns: 1fr 1fr; align-items: start; }
  .cols.hero-wide { grid-template-columns: minmax(260px, 1fr) 1.3fr; }
}

/* Status + log */
.status {
  background: var(--panel); padding: 10px 14px; border-radius: var(--radius);
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  font-size: 15px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); flex: 0 0 auto; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 4px rgba(159,185,162,.3); }

/* Buttons */
button {
  font: inherit; color: inherit; border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--panel-2); color: var(--text);
  font-weight: 700; font-size: 15px; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .1s;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(1px); box-shadow: none; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.danger  { background: var(--red);    color: #fff; }
button.ghost   { background: transparent; box-shadow: none; border: 2px dashed var(--border); }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.row.tight { gap: 6px; margin-bottom: 8px; }

/* Details / disclosure */
details {
  background: var(--panel); border-radius: var(--radius);
  padding: 8px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
summary {
  cursor: pointer; font-weight: 700;
  font-family: 'Caveat', cursive; font-size: 20px; color: var(--accent-ink);
  padding: 2px 0;
}
details p, details li { color: var(--muted); font-size: 14px; line-height: 1.6; }
details ol, details ul { padding-left: 22px; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; color: var(--text); }
.warn { color: #8a5a2a; font-size: 14px; margin-top: 8px; font-weight: 700; }
.hint { color: var(--muted); font-size: 14px; }

.log {
  background: var(--panel-2); color: var(--text);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px; padding: 10px; border-radius: 12px;
  height: 120px; overflow-y: auto; white-space: pre-wrap;
  border: 1px solid var(--border);
}

/* Landing tiles — notebook-card feel */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile {
  background: var(--panel); border-radius: var(--radius);
  padding: 18px 16px; display: flex; flex-direction: column; gap: 8px;
  text-decoration: none; color: var(--text);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  transition: transform .15s, box-shadow .15s;
}
.tile::before {
  /* little tape strip at the top */
  content: ''; position: absolute; top: -8px; left: 20px; width: 60px; height: 16px;
  background: rgba(240, 204, 115, .55);
  border-radius: 2px; transform: rotate(-3deg);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tile.tile-off { opacity: .4; filter: grayscale(.4); }
.tile.tile-off::after {
  content: 'off for students'; position: absolute; top: 8px; right: 8px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--panel-2); padding: 2px 8px; border-radius: 999px;
  border: 1px dashed var(--border);
}
/* In student/preview mode never fade — just hide. */
body.student-mode .tile.tile-off { display: none !important; }
body.student-mode .tile.tile-off::after { content: '' !important; }
.tile .big { font-size: 36px; }
.tile .ttl { font-family: 'Caveat', cursive; font-weight: 700; font-size: 24px; color: var(--accent-ink); }
.tile .desc { color: var(--muted); font-size: 14px; }

/* Blocks — paper-sticker look */
.blocks {
  display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap;
  background: var(--panel); padding: 14px; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.block {
  min-width: 72px; height: 72px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  position: relative; flex: 0 0 auto; color: #fff; font-size: 28px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  user-select: none; font-weight: 800;
}
.block.play   { background: var(--yellow); color: #5a4b1f;
  border-radius: 999px 14px 14px 999px; min-width: 84px; }
.block.sound  { background: var(--red); }
.block.motor  { background: var(--green); color: #35502f; }
.block.light  { background: var(--blue); color: #30465a; }
.block.wait   { background: var(--purple); color: #4a3a5e; }
.block.repeat { background: var(--orange); color: #5a3a1f; }
.block.sensor { background: var(--cyan); color: #2d4a40; }
.block .num {
  position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%);
  background: var(--panel); color: var(--accent-ink);
  font-size: 12px; font-weight: 800;
  padding: 2px 10px; border-radius: 10px;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}
.block .num input {
  width: 32px; border: 0; background: transparent; color: var(--accent-ink);
  font-weight: 800; text-align: center; font-size: 12px; font-family: inherit;
}
.block.active { transform: translateY(-5px); box-shadow: var(--shadow-lg); outline: 3px solid var(--accent-ink); outline-offset: 2px; }
.block .x {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
  background: var(--text); color: var(--panel); border-radius: 50%;
  font-size: 14px; line-height: 22px; text-align: center;
  cursor: pointer; display: none; font-weight: 800;
  box-shadow: var(--shadow);
}
.block:hover .x { display: block; }

/* Bricks */
.brick-frame img { max-height: 34vh; }
@media (max-width: 820px) { .brick-frame img { max-height: 28vh; } }

/* ---- Shared build-page stepper (used by milo.html, motion-build.html, tilt-build.html, collab-build.html) ---- */
.worksheet-card h2, .worksheet-card h3 {
  font-family: 'Caveat', cursive; color: var(--accent-ink);
  text-transform: none; letter-spacing: 0;
}
.worksheet-card h3 { font-size: 22px; margin: 8px 0 2px; }
.li-sc { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 6px; }
@media (min-width: 820px) { .li-sc { grid-template-columns: 1fr 1fr; gap: 20px; } }
.li-sc ul { margin: 4px 0 0; padding-left: 20px; }
.li-sc li { margin: 4px 0; line-height: 1.5; }
.single-li { margin: 4px 0 0; line-height: 1.5; font-size: 16px; }

.stepper {
  background: var(--panel); border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow); border: 1px solid var(--border);
  position: relative;
}
.step2-header {
  padding: 6px 10px 12px;
  border-bottom: 2px dashed var(--border);
  margin-bottom: 10px;
}
.step2-header h2 {
  font-family: 'Caveat', cursive; font-weight: 700;
  font-size: 24px; margin: 0 0 4px; color: var(--accent-ink);
  text-transform: none; letter-spacing: 0;
}
.step2-header p { margin: 0; line-height: 1.5; color: var(--text); }
.step2-header a { color: var(--accent-ink); }
.stage {
  aspect-ratio: 4 / 3;
  background: #fff; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  border: 2px dashed var(--border);
}
.stage img, .stage video {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  user-select: none; -webkit-user-drag: none;
}
.stage video { background: #000; border-radius: 14px; }
.stepper .arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--panel); color: var(--accent-ink);
  font-size: 26px; font-weight: 800; display: grid; place-items: center;
  cursor: pointer; z-index: 2; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stepper .arrow.left  { left: 14px; }
.stepper .arrow.right { right: 14px; }
.stepper .arrow:hover { transform: translateY(-50%) scale(1.05); }
.stepper .arrow:disabled { opacity: .35; cursor: not-allowed; }
.stepper .badge {
  position: absolute; top: 14px; left: 14px;
  background: var(--accent); color: var(--accent-ink);
  font-family: 'Caveat', cursive; font-weight: 700; font-size: 26px;
  padding: 2px 14px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 2;
}
.stepper .controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.stepper .progress-wrap { flex: 1; min-width: 160px; }
.stepper .progress-bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.stepper .progress-bar > div { height: 100%; background: var(--accent); transition: width .2s; }
.stepper .counter {
  font-family: 'Caveat', cursive; font-weight: 700; font-size: 22px;
  color: var(--accent-ink); white-space: nowrap;
}
.stepper .jump { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.stepper .jump input {
  width: 60px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--panel); color: var(--text);
  font: inherit; font-weight: 700; text-align: center;
}
.stepper .finished-note {
  margin-top: 10px; padding: 10px 14px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius); text-align: center;
  font-family: 'Caveat', cursive; font-size: 22px; font-weight: 700;
  display: none;
}
.stepper .finished-note.show { display: block; }
.stepper .finished-note a { color: var(--accent-ink); text-decoration: underline; }

/* ---- Secret teacher-notes brick (top-right corner) ---- */
.secret-brick {
  position: fixed; top: 14px; right: 16px; z-index: 50;
  width: 56px; height: 56px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  cursor: pointer; user-select: none;
  transition: transform .15s;
}
.secret-brick:hover { transform: translateY(-2px); }
.secret-brick.bump  { transform: scale(.92); }

/* The S preview chip sits beside the T, slightly offset */
.student-brick { right: 82px; }
@media (max-width: 760px) { .student-brick { right: 72px; } }

/* S brick visible when teacher-mode OR previewing (so the teacher can leave) */
.teacher-or-preview { display: none !important; }
body.teacher-mode .teacher-or-preview { display: grid !important; }
body.preview-mode  .teacher-or-preview { display: grid !important; }

/* While previewing, give S a different tint so the teacher can see "I'm in preview" */
body.preview-mode .student-brick svg rect,
body.preview-mode .student-brick svg ellipse { fill: #f0cc73; stroke: #a67a1a; }
body.preview-mode .student-brick svg text { fill: #5a4b1f; }

/* Full-width preview banner across the top of the viewport */
.preview-banner { display: none; }
body.preview-mode .preview-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  position: fixed; top: 0; left: 0; right: 0; z-index: 45;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 16px; font-weight: 700; font-size: 14px;
  cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
body.preview-mode .preview-banner .eye { font-size: 18px; }
body.preview-mode { padding-top: 36px; }
/* Nudge the floating bricks below the banner */
body.preview-mode .secret-brick { top: 50px; }
@media (max-width: 760px) {
  body.preview-mode .secret-brick { top: 46px; }
}

/* Mobile top-bar already has its own layer — nudge the brick down a touch */
@media (max-width: 760px) {
  .secret-brick { top: 10px; right: 12px; width: 48px; height: 48px; }
  .secret-brick svg { width: 40px; height: 32px; }
}

/* Toast confirmation when teacher mode toggles */
.wedo-toast {
  position: fixed; top: 20px; left: 50%; transform: translate(-50%, -10px);
  background: var(--accent-ink); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-weight: 700; z-index: 60;
  opacity: 0; transition: opacity .2s, transform .2s;
  box-shadow: var(--shadow-lg);
}
.wedo-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Debug log hidden by default; shown when body.debug-mode is set */
.debug-wrap { display: none; }
body.debug-mode .debug-wrap { display: block; }

/* Teacher-only elements (no yellow background) — just hidden until teacher-mode is on */
.teacher-only { display: none !important; }
body.teacher-mode .teacher-only { display: revert !important; }

/* Hide teacher-only chrome when previewing as student */
body.student-mode .teacher-only { display: none !important; }

/* Student-only elements */
.student-only { display: none !important; }
body.student-mode .student-only { display: revert !important; }

/* Hide from students; visible to everyone else */
body.student-mode .not-for-students { display: none !important; }

/* Nav links that are turned off by teacher settings:
   • In teacher / default mode: faded but still clickable (so teacher can inspect)
   • In student mode: hidden entirely */
.navlink.nav-hidden { opacity: .35; }
.navlink.nav-hidden::after {
  content: '·off'; font-size: 11px; color: var(--muted); margin-left: 6px; font-weight: 600;
}
body.student-mode .navlink.skip,
body.student-mode .navlink.nav-hidden {
  display: none !important;
  opacity: 1 !important;
}
body.student-mode .navlink.nav-hidden::after { content: '' !important; }

/* Hero landing overlay — used by build pages before "Let's go" is clicked */
.lets-go-overlay {
  position: relative; width: 100%;
  background: var(--panel); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 14px;
  display: flex; flex-direction: column; align-items: center;
}
.lets-go-overlay .hero {
  width: 100%; max-height: 50vh; object-fit: contain; display: block;
  background: #fff;
}
.lets-go-overlay .go-btn {
  margin: 16px 20px 20px; padding: 16px 28px; font-size: 22px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-family: 'Caveat', cursive; font-weight: 700; border: 0;
  box-shadow: var(--shadow-lg); cursor: pointer;
}
.lets-go-overlay .go-btn:hover { transform: translateY(-2px); }
.lets-go-overlay .go-btn:active { transform: translateY(1px); }
.lets-go-overlay .caption {
  font-family: 'Caveat', cursive; color: var(--accent-ink); font-size: 28px;
  padding: 10px 20px 0; text-align: center;
}
/* When the page is "started", we add .started to the content; hide the overlay. */
.content.started .lets-go-overlay { display: none; }
.content:not(.started) .page-body { display: none; }

/* Teacher hero view (toggle inside build pages, teacher-mode only) */
.teacher-hero {
  display: none;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
body.teacher-mode .content.teacher-hero-view .teacher-hero { display: block; }
body.teacher-mode .content.teacher-hero-view .page-body    { display: none; }
body.teacher-mode .content.teacher-hero-view .lets-go-overlay { display: none; }
.teacher-hero video { width: 100%; max-height: 50vh; border-radius: 12px; background: #000; }
.teacher-hero .mission {
  font-family: 'Caveat', cursive; font-size: 32px; color: var(--accent-ink);
  text-align: center; margin: 12px 0 6px;
}
.teacher-hero .big-text { font-size: 18px; line-height: 1.6; }
.teacher-hero h3 { font-family: 'Caveat', cursive; font-size: 26px; margin: 10px 0 4px; color: var(--accent-ink); text-transform:none; letter-spacing:0; }

.view-switch {
  display: inline-flex; gap: 4px; background: var(--panel-2); padding: 4px;
  border-radius: 999px; border: 1px solid var(--border); margin-bottom: 10px;
}
.view-switch button {
  background: transparent; box-shadow: none; padding: 6px 14px; font-size: 14px;
  border-radius: 999px;
}
.view-switch button.on { background: var(--accent); color: var(--accent-ink); }

/* Larger body text for Grade-2 readability */
.worksheet-card p, .worksheet-card li { font-size: 17px; line-height: 1.6; }
.single-li { font-size: 18px !important; }
details p, details li { font-size: 15px; }
.content h1 { font-size: 36px; }
.content > p.hint { font-size: 16px; }
@media (max-width: 820px) { .content h1 { font-size: 30px; } }

/* Teacher notes are hidden by default; shown when body.teacher-mode is set.
   In student/preview mode they stay hidden even if teacher-mode class lingers. */
.teacher-notes { display: none; }
body.student-mode .teacher-notes { display: none !important; }
body.teacher-mode .teacher-notes {
  display: block;
  background: #fff8d6;
  border: 2px dashed #c7a94a;
  color: #5a4b1f;
  border-radius: var(--radius);
  padding: 12px 16px; margin: 10px 0;
  box-shadow: var(--shadow);
}
body.teacher-mode .teacher-notes::before {
  content: '📝 Teacher notes';
  display: block; font-family: 'Caveat', cursive; font-weight: 700;
  font-size: 20px; color: #7a5e1a; margin-bottom: 4px;
}
body.teacher-mode .teacher-notes p { margin: 4px 0; line-height: 1.5; font-weight: 600; }
body.teacher-mode .teacher-notes ul { margin: 4px 0 0; padding-left: 22px; }
body.teacher-mode .teacher-notes li { margin: 2px 0; }
