/* =====================================================================
   git-sandbox.css — interactive git sandbox for Quarto lessons.
   Colors, type and spacing come from the Posit brand tokens.
   Everything is scoped to .gs / .gs-* so it will not fight a host theme.
   ===================================================================== */

.gs {
  --gs-blue:        #447099;
  --gs-blue-vibrant:#3276B5;
  --gs-blue-50:     #D0DBE5;
  --gs-blue-100:    #A1B7CB;
  --gs-blue-500:    #22384C;
  --gs-blue-600:    #111C26;
  --gs-gray:        #404041;
  --gs-gray-body:   #717171;
  --gs-off-white:   #F3F6F8;
  --gs-orange:      #EE6331;
  --gs-teal:        #419599;
  --gs-green:       #72994E;

  /* terminal palette: all AA-or-better on the #111C26 surface */
  --gs-t-fg:     #E8EEF4;
  --gs-t-dim:    #A1B7CB;
  --gs-t-green:  #B8CCA6;
  --gs-t-red:    #F9A395;
  --gs-t-yellow: #EFDEB9;
  --gs-t-blue:   #A1B7CB;

  --gs-font: "Open Sans", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --gs-mono: "Source Code Pro", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  font-family: var(--gs-font);
  display: block;
  margin: 32px 0;
  border: 1px solid var(--gs-blue-50);
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: 0 2px 16px rgba(33, 61, 79, 0.08);
  overflow: hidden;
}

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

.gs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--gs-off-white);
  border-bottom: 1px solid var(--gs-blue-50);
}

.gs-eyebrow {
  font-family: var(--gs-mono);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gs-blue-500);
}

/* Repo/remote status pills. margin-right: auto keeps them beside the title
   while the Reset button stays pinned to the right edge. */
.gs-state { display: flex; gap: 6px; margin-right: auto; }
.gs-state-pill {
  font-family: var(--gs-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.gs-state-none  { color: var(--gs-gray-body); border: 1px dashed var(--gs-blue-100); }
.gs-state-repo  { background: var(--gs-blue-50); color: var(--gs-blue-500); }
.gs-state-remote { background: #DBE6D3; color: #394D27; }

.gs-reset, .gs-undo {
  font-family: var(--gs-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gs-blue);
  background: #FFFFFF;
  border: 1px solid var(--gs-blue-100);
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.gs-reset:hover, .gs-undo:hover:not(:disabled) { background: var(--gs-blue); color: #FFFFFF; border-color: var(--gs-blue); }
.gs-reset:focus-visible, .gs-undo:focus-visible { outline: 3px solid rgba(50, 118, 181, 0.45); outline-offset: 2px; }
/* nothing on the stack yet */
.gs-undo:disabled { opacity: 0.45; cursor: default; }

/* -------------------------------- body ------------------------------- */

.gs-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

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

.gs-term-wrap {
  background: var(--gs-blue-600);
  display: flex;
  flex-direction: column;
  height: 340px;
}

.gs-out {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 4px;
  font-family: var(--gs-mono);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--gs-t-fg);
  cursor: text;
}

.gs-line { white-space: pre-wrap; word-break: break-word; margin: 0 0 2px; }
.gs-echo { color: var(--gs-t-fg); margin-top: 8px; }
.gs-echo-prompt { color: var(--gs-t-dim); }
.gs-err { color: var(--gs-t-red); }

.gs-out .tg { color: var(--gs-t-green); }
.gs-out .tr { color: var(--gs-t-red); }
.gs-out .ty { color: var(--gs-t-yellow); }
.gs-out .tb { color: var(--gs-t-blue); }
.gs-out .tw { color: #FFFFFF; font-weight: 700; }

.gs-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px;
  border-top: 1px solid rgba(161, 183, 203, 0.18);
}

.gs-prompt {
  font-family: var(--gs-mono);
  font-size: 13.5px;
  color: var(--gs-t-dim);
  white-space: nowrap;
  cursor: text;
}

.gs-input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: #FFFFFF;
  caret-color: var(--gs-orange);
  font-family: var(--gs-mono);
  font-size: 13.5px;
  padding: 4px 2px;
}
.gs-input:focus-visible { box-shadow: 0 2px 0 0 var(--gs-orange); }
.gs-input:disabled { opacity: 0.6; }
/* The invitation to type; fades once the input is focused so the caret owns
   the line. Chrome/Safari default placeholder grey is unreadable on the dark
   terminal, hence the explicit color. */
.gs-input::placeholder { color: var(--gs-t-dim); opacity: 0.75; font-style: italic; }
.gs-input:focus::placeholder { opacity: 0.35; }

.gs-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 16px 14px;
}
.gs-hints-label {
  font-family: var(--gs-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gs-t-dim);
  margin-right: 2px;
}
.gs-hint {
  font-family: var(--gs-mono);
  font-size: 12px;
  color: #FFFFFF;
  background: rgba(161, 183, 203, 0.16);
  border: 1px solid rgba(161, 183, 203, 0.34);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
}
.gs-hint:hover { background: var(--gs-blue-vibrant); border-color: var(--gs-blue-vibrant); }
.gs-hint:focus-visible { outline: 3px solid rgba(238, 99, 49, 0.6); outline-offset: 2px; }

/* ---------------------------- visualisation --------------------------- */

.gs-viz {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--gs-blue-50);
  min-width: 0;
}

/* One panel shows at a time; the tab row replaces the stacked section
   headers. Badges keep the folded panels legible: a count means "something
   here", a green check means clean/in-sync. */
.gs-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--gs-blue-50);
}
.gs-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--gs-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gs-gray-body);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 6px 10px 7px;
  margin-bottom: -1px;
  cursor: pointer;
}
/* display:inline-flex above would defeat the UA's [hidden] rule */
.gs-tab[hidden], .gs-tab-badge[hidden] { display: none; }
.gs-tab:hover { color: var(--gs-blue-500); }
.gs-tab:focus-visible { outline: 3px solid rgba(50, 118, 181, 0.45); outline-offset: -3px; }
.gs-tab.is-active {
  color: var(--gs-blue-500);
  border-bottom-color: var(--gs-blue);
}
.gs-tab-badge {
  font-size: 10px;
  letter-spacing: 0;
  line-height: 1;
  background: var(--gs-blue-50);
  color: var(--gs-blue-500);
  border-radius: 999px;
  padding: 2px 6px;
}
.gs-tab-badge-ok { background: #DBE6D3; color: #394D27; }

.gs-panel { min-width: 0; }

/* stages */

.gs-stages {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 4px;
}
.gs-col {
  background: var(--gs-off-white);
  border: 1px solid var(--gs-blue-50);
  border-radius: 8px;
  padding: 8px;
  min-width: 0;
}
.gs-col-h {
  font-size: 12px;
  font-weight: 700;
  color: var(--gs-blue-500);
  line-height: 1.25;
}
.gs-col-n {
  font-size: 11px;
  /* Posit Gray, not the lighter body gray: at 11px on the off-white surface
     #717171 lands at 4.49:1, a hair under WCAG AA. */
  color: var(--gs-gray);
  margin-bottom: 6px;
  line-height: 1.3;
}
.gs-chips { display: flex; flex-direction: column; gap: 4px; }

.gs-chip {
  display: block;
  font-family: var(--gs-mono);
  font-size: 11px;
  border-radius: 4px;
  padding: 3px 6px;
  word-break: break-all;
  line-height: 1.3;
}
.gs-chip-k {
  display: block;
  font-size: 10px;
  opacity: 0.85;
}
.gs-chip-work  { background: #FAD8CB; color: #763218; }
.gs-chip-stage { background: #DBE6D3; color: #394D27; }
.gs-chip-repo  { background: #D0DBE5; color: #22384C; }
.gs-chip-empty { background: transparent; color: var(--gs-gray-body); font-style: italic; }
/* A tracked file with no changes: present but quiet, so modified files pop. */
.gs-chip-work.gs-chip-clean { background: var(--gs-off-white); color: var(--gs-gray-body); }

.gs-arrow {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 22px;
  line-height: 1;
  color: var(--gs-blue-vibrant);
}
.gs-arrow span {
  font-family: var(--gs-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--gs-blue-500);
  white-space: nowrap;
  background: var(--gs-blue-50);
  border-radius: 999px;
  padding: 2px 8px;
}
.gs-arrow-g {
  font-style: normal;
  line-height: 1;
  display: inline-block;
}
@media (max-width: 560px) {
  .gs-stages { grid-template-columns: 1fr; }
  .gs-arrow { flex-direction: row; gap: 8px; padding: 4px 0; font-size: 18px; }
  .gs-arrow-g { transform: rotate(90deg); }
}

/* changes (diff panel) */

/* Long diffs scroll inside the panel instead of stretching the box. */
.gs-diff { max-height: 320px; overflow-y: auto; }

.gs-diff-empty { font-size: 13px; color: var(--gs-gray-body); }
.gs-diff-empty code { font-family: var(--gs-mono); font-size: 12px; }

.gs-diff-file {
  border: 1px solid var(--gs-blue-50);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}
.gs-diff-file:last-child { margin-bottom: 0; }

.gs-diff-filehead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--gs-off-white);
  border-bottom: 1px solid var(--gs-blue-50);
}
.gs-diff-name { font-family: var(--gs-mono); font-size: 12px; color: var(--gs-blue-500); }
.gs-diff-kind {
  font-family: var(--gs-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 8px;
  border-radius: 9px;
  background: var(--gs-blue-50);
  color: var(--gs-blue-500);
}
.gs-diff-kind-new     { background: #E7EEDD; color: #4C6A2F; }
.gs-diff-kind-deleted { background: #FADFD6; color: #9C3D1B; }

.gs-diff-line {
  display: grid;
  grid-template-columns: 2.4em 2.4em 1.1em minmax(0, 1fr);
  font-family: var(--gs-mono);
  font-size: 12px;
  line-height: 1.75;
}
.gs-diff-num  { text-align: right; padding-right: 8px; color: var(--gs-gray-body); opacity: 0.7; user-select: none; }
.gs-diff-sign { user-select: none; }
.gs-diff-text { white-space: pre-wrap; word-break: break-word; padding-right: 8px; }
.gs-diff-add { background: #EFF4E7; }
.gs-diff-add .gs-diff-sign, .gs-diff-add .gs-diff-text { color: #4C6A2F; }
.gs-diff-del { background: #FBECE6; }
.gs-diff-del .gs-diff-sign, .gs-diff-del .gs-diff-text { color: #9C3D1B; }

/* graph */

/* Deep histories scroll inside the panel instead of stretching the box. */
.gs-graph-scroll { overflow-x: hidden; max-height: 360px; overflow-y: auto; }
.gs-graph { display: block; width: 100%; }
.gs-sha  { font-family: var(--gs-mono); font-size: 12px; fill: var(--gs-gray-body); }
.gs-msg  { font-family: var(--gs-font); font-size: 13px; fill: var(--gs-gray); }
.gs-ref  { font-family: var(--gs-mono); font-size: 11px; fill: var(--gs-blue-500); }
.gs-ref-head { fill: #FFFFFF; }
.gs-ref-remote { fill: var(--gs-gray-body); }

/* remote (mock origin) — its own tab, so no divider needed */

.gs-remote-sync { font-size: 12px; color: var(--gs-gray-body); margin-top: 2px; }
.gs-remote-sync code { font-family: var(--gs-mono); font-size: 11px; }
.gs-empty-text { font-family: var(--gs-font); font-size: 13px; fill: var(--gs-gray-body); }

/* ------------------------------- tasks -------------------------------- */

.gs-tasks:not(:empty) {
  border-top: 1px solid var(--gs-blue-50);
  padding: 14px 16px 16px;
  background: #FFFFFF;
}
.gs-tasks-h {
  font-family: var(--gs-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gs-blue-500);
  margin-bottom: 8px;
}
.gs-count { color: var(--gs-gray-body); margin-left: 6px; }

.gs-task-list { list-style: none; margin: 0; padding: 0; }
.gs-task {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gs-gray);
  padding: 3px 0;
}
.gs-task-mark {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  margin-top: 2px;
  border: 1.5px solid var(--gs-blue-100);
  border-radius: 4px;
  font-size: 12px;
  line-height: 15px;
  text-align: center;
  color: transparent;
}
.gs-task.is-done .gs-task-mark {
  background: #55733A;
  border-color: #55733A;
  color: #FFFFFF;
}
/* A just-completed task flashes so the tick registers while the learner's
   eye is still on the terminal above. */
.gs-task.is-just-done { animation: gs-task-flash 1.2s ease-out; }
@keyframes gs-task-flash {
  0%   { background: #DBE6D3; }
  100% { background: transparent; }
}
.gs-task.is-done .gs-task-txt { color: var(--gs-gray-body); }
.gs-task code {
  font-family: var(--gs-mono);
  font-size: 0.92em;
  background: var(--gs-off-white);
  border: 1px solid var(--gs-blue-50);
  border-radius: 3px;
  padding: 1px 4px;
}
/* An unreadable `when:` or `js:` is an authoring mistake, not a learner
   mistake — say so in place rather than leaving a task that never ticks. */
.gs-task-broken .gs-task-mark {
  background: #A62103;
  border-color: #A62103;
  color: #FFFFFF;
  font-weight: 700;
}
.gs-task-err {
  display: block;
  font-family: var(--gs-mono);
  font-size: 12px;
  line-height: 1.45;
  color: #A62103;
  margin-top: 2px;
}

.gs-done {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: #394D27;
  background: #DBE6D3;
  border-radius: 6px;
  padding: 8px 10px;
}

/* ------------------------------ loading ------------------------------- */

.gs-loading {
  padding: 24px 16px;
  font-family: var(--gs-mono);
  font-size: 13px;
  color: var(--gs-gray-body);
}

@media print {
  .gs-term-wrap, .gs-viz { break-inside: avoid; }
  .gs-input-row, .gs-hints, .gs-reset, .gs-undo, .gs-tabs { display: none; }
  /* On paper there are no tabs to click, so print every panel. */
  .gs-panel[hidden] { display: block; }
  .gs-diff, .gs-graph-scroll { max-height: none; overflow: visible; }
  .gs::after {
    content: "This exercise is interactive. Open the lesson in a browser to use it.";
    display: block;
    padding: 10px 16px;
    font-size: 13px;
    color: #717171;
  }
}
