/* R3B3L v0.1 — KØNB1T brand: black background, brand-blue accent */
:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1b1b1b;
  --line: #2a2a2a;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --blue: #2563eb;
  --blue-bright: #5b8cff;
  --blue-soft: rgba(37, 99, 235, .16);
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
p { margin: 0 0 .8em; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }

/* ---------- Ribbon ---------- */
.ribbon {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { border-radius: 50%; display: block; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 26px; font-weight: 800; letter-spacing: .06em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.ribbon-id { display: flex; gap: 16px; flex-wrap: wrap; flex: 1; min-width: 280px; }
.ribbon-field { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.ribbon-field em { font-style: normal; color: var(--blue-bright); }
.ribbon-field input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 230px;
  max-width: 70vw;
}
.ribbon-field input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.date-feedback { font-size: 13px; min-height: 1.2em; }
.date-feedback.ok { color: var(--green); }
.date-feedback.no { color: var(--amber); }
.ribbon-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
}
.btn:hover { border-color: var(--blue); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { background: transparent; }

/* ---------- Data note ---------- */
.data-note {
  background: #1c1503;
  border-bottom: 1px solid #4a3405;
  color: #fcd34d;
  font-size: 13.5px;
  padding: 8px 20px;
}
.data-note strong { color: #fde68a; }

/* ---------- Shell: ladder + canvas ---------- */
.shell {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  min-height: 0;
  align-items: stretch;
}
.ladder {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  overflow-y: auto;
  max-height: calc(100vh - 118px);
  position: sticky;
  top: 118px;
}
.ladder-head h2 { font-size: 18px; margin: 0; }
.ladder-hint { font-size: 12px; color: var(--muted); }
.level-list { list-style: none; margin: 6px 0 10px; padding: 0; }
.level-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--text);
  font-size: 14.5px;
}
.level-item:hover { background: var(--panel-2); border-color: var(--line); }
.level-item.active { background: var(--blue-soft); border-color: var(--blue); }
.level-item .level-title { flex: 1; }
.level-item .level-num {
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 7px;
  flex: none;
}
.level-item .done-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); flex: none;
}
.pin-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 15px; padding: 2px 4px; flex: none; line-height: 1;
}
.pin-btn[aria-pressed="true"] { color: var(--amber); }
.level-item.soon { opacity: .55; cursor: default; }
.level-item.soon:hover { background: transparent; border-color: transparent; }
.story-badge {
  background: #7c3aed; color: #fff; font-size: 10.5px; font-weight: 700;
  border-radius: 999px; padding: 2px 7px; letter-spacing: .04em; flex: none;
}
.soon-tag {
  font-size: 11px; color: var(--amber); font-weight: 600;
  border: 1px solid var(--amber); border-radius: 999px; padding: 1px 7px;
  vertical-align: middle;
}
.junior-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px; font-weight: 700;
  padding: 10px 12px;
  margin-top: 10px;
}
.junior-toggle .junior-sub { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; }
.junior-toggle .junior-caret { transition: transform .15s; display: inline-block; }
.junior-toggle[aria-expanded="false"] .junior-caret { transform: rotate(-90deg); }
.grade-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 4px 2px; }
.pinned-box h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); margin: 12px 4px 2px; }
.ladder-foot { font-size: 12.5px; color: var(--muted); padding: 0 4px; }

/* ---------- Canvas ---------- */
.canvas { padding: 18px 22px 30px; min-width: 0; }
.mascot-bar {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.mascot { width: 74px; height: 74px; flex: none; }
.mascot svg { width: 74px; height: 74px; display: block; }
.mascot-speech { flex: 1; min-width: 0; }
.mascot-speech strong { display: block; font-size: 13px; color: var(--blue-bright); letter-spacing: .03em; }
.mascot-speech span { font-size: 15px; }
.score-chip {
  flex: none; background: var(--blue-soft); border: 1px solid var(--blue);
  border-radius: 999px; padding: 6px 12px; font-size: 13.5px;
}
.welcome h1 { font-size: 30px; }
.welcome > p { max-width: 720px; color: #d4d4d4; }
.welcome-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.welcome-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px;
}
.welcome-card b { display: block; margin-bottom: 4px; color: var(--blue-bright); }
.welcome-card span { font-size: 14px; color: #d4d4d4; }

/* Tabs */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab-btn {
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 999px; padding: 8px 16px; font-weight: 600;
}
.tab-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.tab-panel[hidden] { display: none; }

.level-head h1 { font-size: 26px; }
.level-head .level-kicker { color: var(--blue-bright); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.explainer {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
  max-width: 760px;
}
.explainer p:last-child { margin-bottom: 0; }
.illustration {
  background: #fff; border-radius: var(--radius);
  padding: 10px; margin-bottom: 16px; max-width: 760px;
}
.illustration svg { width: 100%; height: auto; display: block; border-radius: 8px; }
.illustration .cap { color: #444; font-size: 13px; text-align: center; padding-top: 6px; }

/* Exercises */
.exercise {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px;
  max-width: 760px;
}
.exercise .q { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.exercise .q .big { font-size: 26px; color: var(--blue-bright); }
.answer-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.answer-row input[type="text"], .answer-row input[type="number"] {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; width: 150px; font-size: 17px;
}
.answer-row input:focus { outline: 2px solid var(--blue); }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice-btn {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font-weight: 600; font-size: 16px;
}
.choice-btn:hover { border-color: var(--blue); }
.choice-btn.picked-correct { background: var(--green); border-color: var(--green); color: #fff; }
.choice-btn.picked-wrong { background: var(--red); border-color: var(--red); color: #fff; }
.check-btn { background: var(--blue); border-color: var(--blue); color: #fff; }
.feedback { margin-top: 10px; font-weight: 600; min-height: 1.3em; }
.feedback.ok { color: var(--green); }
.feedback.no { color: var(--amber); }
.feedback .answer-hint { font-weight: 400; color: var(--muted); display: block; font-size: 14px; }
.comment-box { margin-top: 12px; }
.comment-box label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 4px; }
.comment-box textarea {
  width: 100%; min-height: 56px; resize: vertical;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font-size: 15px;
}
.comment-box textarea:focus { outline: 2px solid var(--blue); }
.comment-saved { font-size: 12.5px; color: var(--green); min-height: 1.2em; }

/* Word problems */
.word-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; max-width: 760px;
}
.word-card .q { font-size: 17px; margin-bottom: 10px; }
.word-note { font-size: 13.5px; color: var(--muted); }

/* Story chapters */
.chapter { max-width: 760px; }
.chapter h2 { font-size: 22px; margin-top: 4px; }
.chapter .story-text {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px;
  font-size: 17px;
}
.chapter .story-text p:last-child { margin-bottom: 0; }
.chapter .story-text em { color: var(--blue-bright); font-style: normal; font-weight: 700; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; max-width: 520px; width: 100%;
}
.modal h2 { font-size: 22px; }
.modal-warning {
  background: #1c1503; border: 1px solid #4a3405; color: #fcd34d;
  border-radius: 10px; padding: 12px 14px; font-size: 14.5px;
}
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.site-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px; background: var(--panel);
}

/* ---------- Mobile: ladder becomes a docked scroll strip ---------- */
@media (max-width: 860px) {
  .shell { display: flex; flex-direction: column; }
  .ladder {
    position: sticky;
    top: 0;
    z-index: 30;
    max-height: none;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    background: var(--panel);
  }
  .ladder-head, .ladder-foot { display: none; }
  .junior-toggle { margin-top: 0; }
  #juniorBody { max-height: 132px; overflow-y: auto; }
  .level-list {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .level-item { flex: none; width: auto; border: 1px solid var(--line); background: var(--panel-2); }
  .level-item .level-title { white-space: nowrap; }
  .grade-group h3 { margin-top: 8px; }
  .ribbon { position: static; }
  .canvas { padding: 14px 14px 26px; }
  .mascot { width: 60px; height: 60px; }
  .mascot svg { width: 60px; height: 60px; }
}

/* EN | FR language toggle (v0.1.1) */
.lang-toggle {
  display: inline-flex;
  border: 2px solid #2563eb;
  border-radius: 999px;
  overflow: hidden;
  flex: none;
}
.lang-btn {
  border: 0;
  background: #fff;
  color: #2563eb;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
  line-height: 1;
}
.lang-btn.active {
  background: #2563eb;
  color: #fff;
}
.lang-btn:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}
