/* EDU-BRANCH · Git Branching Playground — same visual language as the EDU-*
   siblings: a tribute to Olivetti's desktop machines (Programma 101): warm
   putty chassis, engraved labels, mechanical keycaps, and dark phosphor-green
   display insets for everything the machine "shows". */

:root {
  --chassis: #e3ddcd;
  --chassis-deep: #d3ccb8;
  --panel: #f1ede1;
  --panel-edge: #c4bca6;
  --ink: #34322b;
  --ink-soft: #7c7663;
  --olivetti: #c8442c;
  --olivetti-dark: #a83620;
  --screen: #20251e;
  --screen-edge: #14170f;
  --phosphor: #93e8bb;
  --phosphor-dim: #5d8f74;
  --phosphor-soft: #b9f0d3;
  --amber: #e4b04a;
  --pass: #3d7a4f;
  --fail: #b23a2c;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  /* graph accents */
  --copy: #e4b04a;   /* replayed commits (rebase / cherry-pick) */
  --detach: #e88a7a; /* detached HEAD */
  --tagc: #7ad4e8;   /* tags */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 30% -10%, #efeadb 0%, var(--chassis) 55%, var(--chassis-deep) 100%);
  display: flex;
  flex-direction: column;
}

button { font: inherit; cursor: pointer; }

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

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  border-bottom: 2px solid var(--panel-edge);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }

.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--panel);
  background: var(--olivetti);
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
  letter-spacing: 0.05em;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.25);
}

.brand-text h1 {
  font-family: var(--mono);
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  color: var(--ink-soft);
  font-weight: 600;
  vertical-align: 0.15em;
}

.brand-tag { font-size: 0.72rem; color: var(--ink-soft); font-style: italic; }

.top-nav { display: flex; align-items: center; gap: 0.5rem; }

.lang-switch {
  display: flex;
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  overflow: hidden;
  margin-left: 0.4rem;
}

.lang-switch button {
  border: 0;
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.55rem;
}

.lang-switch button.active { background: var(--ink); color: var(--panel); }

/* ---------- keycap buttons ---------- */

.btn {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: linear-gradient(#faf7ee, #eae5d5);
  border: 1px solid var(--panel-edge);
  border-radius: 7px;
  padding: 0.42rem 0.85rem;
  box-shadow: 0 2px 0 var(--panel-edge), 0 3px 4px rgb(0 0 0 / 0.08);
  transition: transform 60ms, box-shadow 60ms;
  text-decoration: none;
  display: inline-block;
}

.btn:hover { filter: brightness(1.03); }

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--panel-edge);
}

.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.btn-primary {
  color: #fff;
  background: linear-gradient(#d9563c, var(--olivetti));
  border-color: var(--olivetti-dark);
  box-shadow: 0 2px 0 var(--olivetti-dark), 0 3px 4px rgb(0 0 0 / 0.15);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  color: var(--ink-soft);
}

.btn-ghost:active { transform: none; }

:focus-visible { outline: 2px solid var(--olivetti); outline-offset: 2px; }

/* ---------- cards & engraved labels ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  box-shadow: 0 1px 0 #fff inset, 0 4px 10px rgb(60 50 20 / 0.08);
  padding: 0.7rem 0.8rem 0.8rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.card-title, .lesson-eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.7);
}

.chip {
  border-radius: 4px;
  padding: 0.08rem 0.45rem;
  white-space: nowrap;
}

.chip-rule {
  font-family: var(--mono);
  font-size: 0.68rem;
  background: var(--chassis-deep);
  border: 1px solid var(--panel-edge);
  color: var(--ink);
}

/* ---------- lesson panel ---------- */

.lesson { display: flex; flex-direction: column; gap: 0.7rem; }

.lesson-eyebrow { display: flex; align-items: center; gap: 0.5rem; }

.lesson-title { font-size: 1.25rem; line-height: 1.2; }

.lesson-text { font-size: 0.86rem; line-height: 1.55; }

.lesson-text p + p { margin-top: 0.5rem; }

.lesson-text code, .goal code, .hint code, .help-body code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgb(60 50 20 / 0.08);
  border-radius: 4px;
  padding: 0.05em 0.3em;
}

.goal {
  font-size: 0.86rem;
  line-height: 1.5;
  background: rgb(200 68 44 / 0.07);
  border-left: 3px solid var(--olivetti);
  border-radius: 0 7px 7px 0;
  padding: 0.5rem 0.7rem;
}

.goal-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--olivetti);
  margin-bottom: 0.15rem;
}

.rule-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.hints { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }

.hint {
  font-size: 0.82rem;
  line-height: 1.5;
  background: rgb(228 176 74 / 0.14);
  border-left: 3px solid var(--amber);
  border-radius: 0 7px 7px 0;
  padding: 0.45rem 0.65rem;
}

.banner {
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font-size: 0.86rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.banner-pass { background: rgb(61 122 79 / 0.12); border: 1px solid var(--pass); color: var(--pass); }
.banner-fail { background: rgb(178 58 44 / 0.1); border: 1px solid var(--fail); color: var(--fail); }

.done-mark { color: var(--pass); font-weight: 700; }

.btn-reset-code { align-self: flex-start; font-size: 0.68rem; }
.btn-hint { font-size: 0.72rem; border: 1px dashed var(--panel-edge); }

/* ---------- modals ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgb(40 35 20 / 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
  max-width: 860px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1rem 1.2rem 1.2rem;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.modal-head h2 { font-size: 1.1rem; letter-spacing: 0.02em; }

.level-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  text-align: left;
  background: linear-gradient(#faf7ee, #eee9da);
  border: 1px solid var(--panel-edge);
  border-radius: 9px;
  padding: 0.7rem 0.8rem;
  box-shadow: 0 2px 0 var(--panel-edge);
  transition: transform 80ms;
}

.level-card:hover { transform: translateY(-2px); }

.level-card.current { border-color: var(--olivetti); box-shadow: 0 2px 0 var(--olivetti); }

.level-card .level-num {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--olivetti);
  letter-spacing: 0.1em;
}

.level-card .level-name { font-weight: 600; font-size: 0.85rem; }

.level-card .level-desc { font-size: 0.72rem; color: var(--ink-soft); }

.level-card .done-mark { position: absolute; top: 0.55rem; right: 0.7rem; }

.level-card.done { background: linear-gradient(#f2f7ee, #e4ecdc); }

.sandbox-card { border-style: dashed; }

.help-body { font-size: 0.86rem; line-height: 1.55; }

.help-body h3 {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--olivetti);
  margin: 1rem 0 0.4rem;
}

.help-body p { margin-bottom: 0.5rem; }

.help-body table { border-collapse: collapse; width: 100%; font-size: 0.8rem; }

.help-body th, .help-body td {
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgb(60 50 20 / 0.12);
}

.help-body th {
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.help-body pre {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  background: var(--screen);
  color: var(--phosphor);
  border-radius: 7px;
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  margin: 0.4rem 0;
}

.intro-foot { display: flex; justify-content: flex-end; margin-top: 1rem; }

/* ---------- workbench layout ---------- */

.workbench {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(460px, 1fr) minmax(320px, 400px);
  gap: 0.9rem;
  padding: 0.9rem 1.2rem 1.2rem;
  align-items: start;
  max-width: 1750px;
  width: 100%;
  margin: 0 auto;
}

.col-repo, .col-inspect { display: flex; flex-direction: column; gap: 0.9rem; }

.toolbar { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

.speed {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-left: 0.3rem;
}

.speed input { width: 90px; accent-color: var(--olivetti); }

/* ---------- the phosphor screen (commit graph) ---------- */

.graphscreen {
  position: relative;
  background: var(--screen);
  border: 2px solid var(--screen-edge);
  border-radius: 8px;
  box-shadow: inset 0 2px 10px rgb(0 0 0 / 0.55);
  overflow: auto;
  min-height: 220px;
  max-height: 46vh;
}

.graphscreen svg { display: block; margin: 0 auto; }

.graphscreen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(rgb(0 0 0 / 0.09) 0 1px, transparent 1px 3px);
  pointer-events: none;
  border-radius: 6px;
}

.edge {
  fill: none;
  stroke: var(--phosphor-dim);
  stroke-width: 1.6;
  stroke-opacity: 0.85;
}

.edge-dim { stroke-opacity: 0.25; }

.commit { transition: transform 450ms cubic-bezier(0.25, 0.8, 0.35, 1); }

.commit .commit-shape {
  stroke: var(--phosphor);
  stroke-width: 1.8;
  fill: rgb(147 232 187 / 0.08);
}

.commit .commit-detail {
  stroke: var(--phosphor-dim);
  stroke-width: 1.2;
  fill: none;
}

.commit .commit-id {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  fill: var(--phosphor);
  text-anchor: middle;
}

.commit.copy .commit-shape { stroke: var(--copy); stroke-dasharray: 4 2.5; }
.commit.copy .commit-id { fill: var(--copy); }

.commit.revert .commit-shape { stroke: var(--phosphor-soft); }

.commit.orphan { opacity: 0.35; }

.commit.born { animation: commit-born 420ms ease-out; }

@keyframes commit-born {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.commit.pulse .commit-shape { animation: node-pulse 550ms ease-out; }

@keyframes node-pulse {
  0% { fill: rgb(147 232 187 / 0.6); }
  100% { fill: rgb(147 232 187 / 0.08); }
}

.ref-chip { transition: transform 450ms cubic-bezier(0.25, 0.8, 0.35, 1); }

.ref-chip rect {
  fill: rgb(0 0 0 / 0.45);
  stroke-width: 1.2;
}

.ref-chip .ref-text {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  text-anchor: middle;
}

.chip-branch rect { stroke: var(--phosphor); }
.chip-branch .ref-text { fill: var(--phosphor); }

.chip-tag rect { stroke: var(--tagc); }
.chip-tag .ref-text { fill: var(--tagc); }

.chip-head rect { stroke: var(--amber); fill: rgb(228 176 74 / 0.16); }
.chip-head .ref-text { fill: var(--amber); }

.chip-detached rect { stroke: var(--detach); fill: rgb(232 138 122 / 0.18); }
.chip-detached .ref-text { fill: var(--detach); }

.ref-chip.born { animation: commit-born 420ms ease-out; }

/* ---------- editor (display inset) ---------- */

.editor-wrap {
  display: flex;
  background: var(--screen);
  border: 2px solid var(--screen-edge);
  border-radius: 8px;
  box-shadow: inset 0 2px 10px rgb(0 0 0 / 0.55);
  overflow: hidden;
  height: min(30vh, 280px);
}

.gutter {
  overflow: hidden;
  background: rgb(0 0 0 / 0.25);
  border-right: 1px solid rgb(147 232 187 / 0.15);
  padding: 0.6rem 0;
  min-width: 2.6em;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--phosphor-dim);
  text-align: right;
  user-select: none;
}

.gutter-inner div { padding: 0 0.55em; }

.gutter-inner .g-cur { color: var(--screen); background: var(--phosphor); font-weight: 700; }
.gutter-inner .g-err { color: var(--screen); background: var(--fail); font-weight: 700; }

.editor-area { position: relative; flex: 1; overflow: hidden; }

.editor-area .code {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--phosphor);
  caret-color: var(--phosphor-soft);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 0.6rem 0.8rem;
  white-space: pre;
  text-shadow: 0 0 6px rgb(147 232 187 / 0.25);
}

.editor-area .code:focus { outline: none; }

.hl-bar {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 0;
  pointer-events: none;
}

.hl-current { background: rgb(147 232 187 / 0.14); border-left: 3px solid var(--phosphor); }
.hl-error { background: rgb(178 58 44 / 0.35); border-left: 3px solid var(--fail); }

/* script errors */

.asm-errors {
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  border-left: 3px solid var(--fail);
  background: rgb(178 58 44 / 0.07);
  border-radius: 0 6px 6px 0;
  padding: 0.45rem 0.6rem;
}

.asm-errors .err-title {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fail);
  margin-bottom: 0.25rem;
}

.asm-errors .err-item { cursor: pointer; padding: 0.1rem 0; }
.asm-errors .err-item:hover { text-decoration: underline; }
.asm-errors .err-line { color: var(--fail); font-weight: 700; }

.status-line {
  font-size: 0.78rem;
  color: var(--ink-soft);
  min-height: 1.3em;
  padding-top: 0.35rem;
}

.status-line[data-kind="err"] { color: var(--fail); font-weight: 600; }
.status-line[data-kind="ok"] { color: var(--pass); font-weight: 600; }
.status-line[data-kind="run"] { color: var(--ink); }

/* ---------- refs panel: phosphor table ---------- */

.net-screenbox {
  background: var(--screen);
  border: 2px solid var(--screen-edge);
  border-radius: 7px;
  box-shadow: inset 0 2px 6px rgb(0 0 0 / 0.5);
  padding: 0.4rem 0.5rem;
  overflow-x: auto;
  min-height: 2.4em;
}

.net-tbl {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--phosphor);
}

.net-tbl th {
  text-align: left;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--phosphor-dim);
  padding: 0.1rem 0.5rem 0.2rem 0;
  border-bottom: 1px solid rgb(147 232 187 / 0.2);
}

.net-tbl td {
  padding: 0.16rem 0.5rem 0.16rem 0;
  border-bottom: 1px solid rgb(147 232 187 / 0.08);
  white-space: nowrap;
}

.net-tbl tr.ref-row-head td { color: var(--amber); font-weight: 700; }
.net-tbl tr.ref-row-tag td { color: var(--tagc); }

.tbl-empty { color: var(--phosphor-dim); font-family: var(--mono); font-size: 0.75rem; }

/* ---------- event log tape ---------- */

.evt-tape {
  background: var(--screen);
  border: 2px solid var(--screen-edge);
  border-radius: 7px;
  box-shadow: inset 0 2px 6px rgb(0 0 0 / 0.5);
  height: 260px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.35rem 0.45rem;
}

.evt-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.06rem 0.15rem;
  color: var(--phosphor);
  white-space: nowrap;
  border-radius: 3px;
}

.evt-time { color: var(--phosphor-dim); flex: 0 0 3.6em; text-align: right; }

.evt-row.evt-cmd { color: var(--phosphor-soft); font-weight: 700; }
.evt-row.evt-log { color: var(--phosphor-soft); }
.evt-row.evt-dim { color: var(--phosphor-dim); }
.evt-row.evt-warn { color: #e88a7a; }
.evt-row.evt-replay { color: var(--amber); }

/* ---------- sandbox terminal ---------- */

.term-wrap {
  background: var(--screen);
  border: 2px solid var(--screen-edge);
  border-radius: 8px;
  box-shadow: inset 0 2px 10px rgb(0 0 0 / 0.55);
  padding: 0.5rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: text;
}

.term-scroll { max-height: 180px; overflow-y: auto; margin-bottom: 0.25rem; }

.term-line { color: var(--phosphor); white-space: pre-wrap; word-break: break-all; }
.term-line.term-echo { color: var(--phosphor-soft); }
.term-line.term-err { color: #e88a7a; }

.term-prompt-row { display: flex; align-items: center; gap: 0.4rem; }

.term-ps1 { color: var(--amber); font-weight: 700; white-space: nowrap; }

.term-in {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--phosphor);
  caret-color: var(--phosphor-soft);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-shadow: 0 0 6px rgb(147 232 187 / 0.25);
}

.term-in:focus { outline: none; }

/* ---------- responsive ---------- */

@media (max-width: 1240px) {
  .workbench { grid-template-columns: minmax(240px, 300px) 1fr; }
  .col-inspect { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .col-inspect .card { flex: 1 1 300px; }
}

@media (max-width: 800px) {
  .workbench { grid-template-columns: 1fr; padding: 0.7rem; }
  .col-inspect { flex-direction: column; }
  .editor-wrap { height: 34vh; }
}

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