/* Teacher builder styles: topbar + three panes (palette, flow, inspector) */

html, body { height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.75rem;
  /* The toolbar has to wrap, otherwise its buttons set a minimum width for
     the whole page and a phone gets a sideways scrollbar. */
  flex-wrap: wrap;
  padding: 0.6rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.topbar .brand {
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.topbar input.simtitle {
  max-width: 340px;
  font-weight: 600;
}
.topbar select.mode { width: auto; }
.topbar .spacer { flex: 1; }
.topbar .autosave { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

.panes {
  display: grid;
  grid-template-columns: 210px 1fr 360px;
  flex: 1 1 auto;
  min-height: 0;
}

.pane {
  overflow-y: auto;
  padding: 1rem;
  min-height: 0;
}
.pane.palette { border-right: 1px solid var(--border); background: var(--card); }
.pane.inspector { border-left: 1px solid var(--border); background: var(--card); }

.palette h3, .inspector h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.palette-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.5rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.palette-btn:hover { border-color: var(--accent); background: #f7f9ff; }
.palette-btn .dot { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }
.palette-hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.75rem; }

/* flow pane */
.flow-col { max-width: 780px; margin: 0 auto; }
.flow-arrow {
  text-align: center;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.4;
  user-select: none;
}
.flow-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-left: 6px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  position: relative;
}
.flow-card:hover { border-color: var(--accent); }
.flow-card.selected { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.flow-card.type-event { border-left-color: var(--c-event); }
.flow-card.type-information { border-left-color: var(--c-information); }
.flow-card.type-decision { border-left-color: var(--c-decision); }
.flow-card.type-consequence { border-left-color: var(--c-consequence); }
.flow-card.type-result { border-left-color: var(--c-result); }
.flow-card .head { display: flex; align-items: center; gap: 0.5rem; }
.flow-card .head .start-tag {
  font-size: 0.68rem; font-weight: 800; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 5px; padding: 0 0.35rem;
}
.flow-card .head .del {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1rem; padding: 0 0.2rem;
}
.flow-card .head .del:hover { color: var(--danger); }
.flow-card .body { font-size: 0.92rem; margin-top: 0.3rem; color: var(--text); }
.flow-card .body.empty { color: var(--muted); font-style: italic; }

.flow-choice {
  display: flex; align-items: baseline; gap: 0.5rem;
  font-size: 0.88rem;
  margin-top: 0.35rem;
  padding-left: 0.25rem;
}
.flow-choice .letter {
  flex: 0 0 auto;
  width: 1.35rem; height: 1.35rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-decision); color: #fff;
  border-radius: 6px; font-size: 0.75rem; font-weight: 700;
}
.flow-choice .target { color: var(--muted); }
.flow-choice .fx { color: var(--c-consequence); font-size: 0.8rem; }

/* A decision is a real branch, not three consequences in a vertical queue.
   The column count is set per decision in builder.js, so 2, 3 and 4 options
   all sit side by side and anything wider wraps instead of squeezing. */
.decision-tree {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.branch-hint {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

/* effects written out, and kept visually distinct from each other */
.fx-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: baseline;
  margin-top: 0.3rem;
  min-height: 1.35rem;
}
.fx-caption {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.fx-chip {
  font-size: 0.76rem;
  font-weight: 650;
  border-radius: 5px;
  padding: 0.05rem 0.35rem;
  white-space: nowrap;
}
.fx-choice .fx-chip { background: #f3ecfe; color: #6d28d9; }
.fx-consequence .fx-chip { background: #e4f6ee; color: #047857; }
.fx-chip.down { opacity: 0.95; }
.fx-none { font-size: 0.74rem; color: var(--muted); font-style: italic; }

/* where the branches come back together */
.branch-merge {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}
.branch-merge .merge-arrow { color: var(--accent); font-weight: 700; }
.branch-merge.split { color: #8a6116; }
.branch-merge.split .merge-arrow { color: #b45309; }
.merge-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}
.merge-link:hover { text-decoration: underline; }
.decision-branch {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.branch-choice {
  margin: 0;
  padding: 0;
  align-items: center;
  min-height: 2.75rem;
}
.branch-label {
  min-width: 0;
  flex: 1;
  font-weight: 650;
  line-height: 1.25;
}
.branch-choice .fx { white-space: nowrap; }
.branch-connector {
  text-align: center;
  color: var(--c-consequence);
  font-size: 1rem;
  line-height: 1.4;
}
.branch-target {
  position: relative;
  min-height: 7.6rem;
  padding: 0.65rem;
  border: 1.5px solid #b8e4d3;
  border-left: 5px solid var(--c-consequence);
  border-radius: 9px;
  background: #f5fcf9;
  cursor: pointer;
}
.branch-target:hover { border-color: var(--c-consequence); }
.branch-target.selected { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.branch-target-head { display: flex; align-items: center; gap: 0.35rem; }
.branch-target-title { margin-top: 0.45rem; font-size: 0.9rem; font-weight: 700; line-height: 1.25; }
.branch-target .fx { margin-top: 0.3rem; color: var(--c-consequence); font-size: 0.78rem; }
.branch-next { margin-top: 0.45rem; color: var(--muted); font-size: 0.76rem; line-height: 1.25; }
.branch-del {
  margin-left: auto;
  padding: 0 0.15rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.branch-del:hover { color: var(--danger); }
.branch-target-generic { border-left-color: var(--muted); background: #f8fafc; }

/* On a narrow screen the branches stack, so nothing is ever cut off the
   side. The inline grid-template-columns set per decision is overridden
   here on purpose. */
@media (max-width: 1150px) {
  .decision-tree { grid-template-columns: 1fr !important; }
  .branch-target { min-height: 0; }
}

/* drag re-ordering */
.flow-card.dragging { opacity: 0.4; }
.flow-card.drop-hint { outline: 2.5px dashed var(--accent); outline-offset: 2px; }
.flow-endzone {
  margin-top: 0.9rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
.flow-endzone.drop-hint { border-color: var(--accent); color: var(--accent); }

.correct-row {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.88rem; font-weight: 600; color: var(--text);
  margin: 0.5rem 0 0.1rem; cursor: pointer;
}
.correct-row input { width: auto; }

.flow-section-title {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 1.5rem 0 0.5rem;
}
.flow-empty { color: var(--muted); text-align: center; margin-top: 3rem; }

/* inspector */
.inspector .field { margin-bottom: 0.35rem; }
.inspector hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

.choice-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.7rem;
  background: #fafbfd;
}
.choice-box .choice-head { display: flex; align-items: center; gap: 0.5rem; }
.choice-box .choice-head .letter {
  flex: 0 0 auto;
  width: 1.5rem; height: 1.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-decision); color: #fff; border-radius: 6px;
  font-size: 0.8rem; font-weight: 700;
}
.choice-box .choice-head input { flex: 1; }
.choice-box .choice-head .del {
  background: none; border: none; cursor: pointer; color: var(--muted);
}
.choice-box .choice-head .del:hover { color: var(--danger); }

.fx-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px 26px;
  gap: 0.35rem;
  margin-top: 0.4rem;
  align-items: center;
}
.fx-row select, .fx-row input { padding: 0.3rem 0.4rem; font-size: 0.88rem; }
.fx-row .del {
  background: none; border: none; cursor: pointer; color: var(--muted);
}
.fx-row .del:hover { color: var(--danger); }

.addlink {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 0.88rem; font-weight: 600;
  padding: 0.25rem 0;
}
.addlink:hover { text-decoration: underline; }

.metric-row {
  display: grid;
  grid-template-columns: 1fr 90px 110px 26px;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
  align-items: center;
}
.metric-row input, .metric-row select { padding: 0.3rem 0.4rem; font-size: 0.88rem; }
.metric-row .del { background: none; border: none; cursor: pointer; color: var(--muted); }
.metric-row .del:hover { color: var(--danger); }

.issues { margin-top: 0.75rem; }
.issue {
  font-size: 0.85rem;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.35rem;
  cursor: pointer;
}
.issue.error { background: #fbe9e7; color: var(--bad); }
.issue.warning { background: #fff7e6; color: #8a6116; }

.inspector .danger-zone { margin-top: 1rem; }

/* publish modal */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(15, 26, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(10, 20, 40, 0.25);
  max-width: 520px;
  width: calc(100% - 2rem);
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
}
.modal h2 { font-size: 1.25rem; }
.linkbox {
  display: flex; gap: 0.5rem; align-items: center;
  margin: 0.5rem 0 1rem;
}
.linkbox input { font-size: 0.9rem; color: var(--muted); }
.modal .closer { margin-top: 0.5rem; text-align: right; }
.qr-center { display: flex; justify-content: center; margin: 0.5rem 0 0.25rem; }
.qr-center svg { border-radius: 8px; }
.joincode-big {
  font-size: 2rem; font-weight: 800; letter-spacing: 0.25em;
  text-align: center; margin: 0.5rem 0;
  color: var(--accent);
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .panes { grid-template-columns: 1fr; }
  .pane.palette { border-right: none; border-bottom: 1px solid var(--border); }
  .pane.inspector { border-left: none; border-top: 1px solid var(--border); }
  .topbar { padding: 0.55rem 0.75rem; }
  .topbar input.simtitle { max-width: none; flex: 1 1 100%; order: -1; }
  .topbar .spacer { display: none; }
  .topbar .autosave { flex: 1 1 100%; white-space: normal; }
}

/* Writing task length window: two small number boxes side by side, with the
 * plain-English consequence of them printed underneath. */
.lengthrow { margin-top: 0.4rem; }
.lengthfields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.lengthfields .field { margin: 0; }
@media (max-width: 900px) {
  .lengthfields { grid-template-columns: 1fr; }
}
