/* The `smeltery new` widget (src/partials/installer.html, assets/js/installer.js).
   The terminal is dark in both themes, with its own colours from the forge palette: ember for the CLI's ember
   (prompt marks, cursor, borders), gold for its gold (answers, notes), a warm green for its ✓, warm greys for
   text and dim text. Everything outside the terminal uses the site's tokens. */
.inst {
  --t-bg: #120d0b;
  --t-bar-1: #2e2522;
  --t-bar-2: #231c19;
  --t-edge: rgba(255, 214, 170, .12);
  --t-text: #e9dfd6;
  --t-w: #fbf4ee;
  --t-dim: #93857b;
  --t-ok: #8fd694;
  --t-em: var(--ember, #ff7a1a);
  --t-gold: var(--gold, #ffd76a);
  --t-amber: var(--amber, #ffb22e);
  --t-red: var(--accent, #ff4a1c);
  --t-font: var(--font-mono, "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  position: relative;
}
.inst-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.inst-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* ------------------------------------------------------------------ the window */
.inst-term {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  border-radius: var(--radius, 10px); background: var(--t-bg); border: 1px solid var(--t-edge);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 40px 90px -40px rgba(0, 0, 0, .85), 0 0 120px -60px color-mix(in srgb, var(--t-em) 60%, transparent);
}
.inst-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; height: 38px; padding: 0 8px 0 14px;
  background: linear-gradient(180deg, var(--t-bar-1), var(--t-bar-2)); border-bottom: 1px solid #0a0706;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.inst-lights { display: inline-flex; gap: 8px; }
.inst-lights i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .35); }
.inst-lights i:nth-child(2) { background: #febc2e; }
.inst-lights i:nth-child(3) { background: #28c840; }
.inst-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 12.5px var(--font-text, system-ui, sans-serif); color: #cfc4bb; letter-spacing: .01em; }
.inst-replay {
  justify-self: end; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: #a99c92; cursor: pointer; transition: color .2s, border-color .2s, background .2s;
}
.inst-replay:hover { color: var(--t-amber); border-color: rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .04); }
.inst-replay:focus-visible { outline: 2px solid var(--t-amber); outline-offset: 1px; }
.inst-replay svg { width: 15px; height: 15px; }
.inst-replay .i-skip, .inst-replay[data-state="skip"] .i-replay { display: none; }
.inst-replay[data-state="skip"] .i-skip { display: block; }

/* ------------------------------------------------------------------ the transcript */
.inst-term-body {
  position: relative; margin: 0; padding: 14px 16px 18px; height: 540px; overflow: auto; overscroll-behavior: contain;
  font: 12.5px/1.55 var(--t-font); color: var(--t-text); background: none; border: 0; border-radius: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; font-variant-ligatures: none;
  scrollbar-width: thin; scrollbar-color: #3a2f2a transparent;
}
.inst-term-body:focus-visible { outline: 2px solid var(--t-amber); outline-offset: -2px; }
.inst-term-body .t-dim { color: var(--t-dim); }
.inst-term-body .t-w { color: var(--t-w); }
.inst-term-body .t-b { font-weight: 700; }
.inst-term-body .t-em { color: var(--t-em); }
.inst-term-body .t-gold { color: var(--t-gold); }
.inst-term-body .t-ok { color: var(--t-ok); }
.inst-term-body .t-pr { color: var(--t-amber); font-weight: 700; }
.inst-term-body .t-banner { display: inline-block; vertical-align: top; width: min(calc(100% - 2ch), calc(var(--cols) * 1ch)); height: auto; margin: 2px 0 1px; }
.inst-term-body .t-stop-a { stop-color: var(--t-em); }
.inst-term-body .t-stop-b { stop-color: var(--t-gold); }
/* The rules are text in the markup (copyable, readable without CSS) but drawn as lines: web fonts give ─ another
   width than the other glyphs, so a row of them would not match the banner's width. */
.inst-term-body .t-rule, .inst-term-body .t-div {
  display: inline-block; width: calc(var(--w, 56) * 1ch); max-width: calc(100% - 2ch); overflow: hidden; white-space: nowrap;
  vertical-align: top; color: transparent; background: linear-gradient(90deg, var(--t-em), var(--t-gold)) 0 50% / 100% 1px no-repeat;
}
.inst-term-body .t-div { background: linear-gradient(90deg, #4a3d36, #4a3d36) 0 50% / 100% 1px no-repeat; }
.inst-term-body .t-badge { font-weight: 700; border-radius: 2px; }
.inst-term-body .t-badge-done { background: #1f9d55; color: #fff; }
.inst-term-body .t-badge-info { background: var(--steel, #5f7d95); color: #fff; }
.inst-term-body .t-box {
  display: inline-block; max-width: calc(100% - 2ch); overflow-x: auto; white-space: pre; vertical-align: top;
  padding: .45em 1ch .5em; border: 1px solid var(--t-em); border-radius: 7px; scrollbar-width: thin; scrollbar-color: #3a2f2a transparent;
}
.inst-term-body .t-cursor { display: inline-block; width: .6em; height: 1.15em; margin-left: 1px; vertical-align: text-bottom; background: var(--t-text); animation: inst-blink 1.05s steps(1) infinite; }
@keyframes inst-blink { 50% { opacity: 0; } }

/* answers and choices are buttons that look like terminal text */
.inst-term-body button { all: unset; cursor: pointer; white-space: pre-wrap; border-radius: 3px; }
.inst-term-body button:focus-visible { outline: 2px solid var(--t-amber); outline-offset: 1px; }
.inst-term-body .t-q:hover, .inst-term-body .t-opt:hover { background: rgba(255, 178, 46, .1); }
.inst-term-body .t-ans, .inst-term-body .t-q-empty .t-qp { text-decoration: underline dashed color-mix(in srgb, var(--t-gold) 55%, transparent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.inst-term-body .t-yn, .inst-term-body .t-enter { padding: 0 .7ch; border: 1px solid color-mix(in srgb, var(--t-em) 55%, transparent); color: var(--t-text); }
.inst-term-body .t-yn:hover, .inst-term-body .t-enter:hover { border-color: var(--t-em); background: rgba(255, 122, 26, .12); }
.inst-term-body .t-yn.on { background: var(--t-em); border-color: var(--t-em); color: #1a0f0a; font-weight: 700; }
.inst-term-body .t-enter { color: var(--t-em); }
.inst-hint { margin: 0; padding: 7px 16px 9px; border-top: 1px solid rgba(255, 255, 255, .06); background: var(--t-bar-2); font: 11.5px var(--t-font); color: var(--t-dim); }

/* ------------------------------------------------------------------ the one-line command */
.inst-cmd {
  display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 9px 9px 14px;
  border-radius: var(--radius, 10px); border: 1px solid var(--line, rgba(255, 255, 255, .1)); background: var(--code-bg, #17110f);
}
.inst-cmd code { flex: 1; min-width: 0; font: 12.5px/1.55 var(--t-font); color: var(--text, #f3ebe4); background: none; border: 0; padding: 0; white-space: normal; overflow-wrap: anywhere; }
.inst-cmd code::before { content: "$ "; color: var(--text-3, #8f8279); }
.inst-cmd code .w { white-space: nowrap; }
.inst-copy {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-2, rgba(255, 255, 255, .16)); background: var(--bg-3, transparent); color: var(--text-2, #d8ccc2);
  font: 600 12px var(--t-font); transition: color .2s, border-color .2s;
}
.inst-copy:hover { color: var(--ember, #ff7a1a); border-color: var(--ember, #ff7a1a); }
.inst-copy:focus-visible { outline: 2px solid var(--amber, #ffb22e); outline-offset: 2px; }
.inst-copy svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ the preview */
.inst-preview {
  display: flex; flex-direction: column; min-width: 0; max-height: calc(540px + 38px + 34px + 10px + 52px); overflow: hidden;
  border-radius: var(--radius, 10px); border: 1px solid var(--line, rgba(255, 255, 255, .1)); background: var(--bg-2, #1a1310);
}
.inst-tabs { display: flex; align-items: center; gap: 4px; padding: 7px; border-bottom: 1px solid var(--line, rgba(255, 255, 255, .1)); background: var(--bg-3, #221915); }
.inst-tabs [role="tab"] { padding: 6px 12px; border-radius: 7px; border: 0; background: transparent; color: var(--text-2, #d8ccc2); font: 600 12.5px var(--t-font); cursor: pointer; }
.inst-tabs [role="tab"]:hover { color: var(--text, #f3ebe4); }
.inst-tabs [role="tab"][aria-selected="true"] { background: var(--bg-2, #1a1310); color: var(--text, #f3ebe4); box-shadow: inset 0 -2px 0 var(--ember, #ff7a1a); }
.inst-tabs [role="tab"]:focus-visible { outline: 2px solid var(--amber, #ffb22e); outline-offset: 1px; }
.inst-count { margin-left: auto; padding-right: 6px; font: 11.5px var(--t-font); color: var(--text-3, #8f8279); }
.inst-pane { flex: 1; min-height: 0; padding: 14px 14px 16px; overflow: auto; scrollbar-width: thin; }
.inst-pane:focus-visible { outline: 2px solid var(--amber, #ffb22e); outline-offset: -2px; }
.inst-pre { margin: 0; padding: 0; background: none; border: 0; font: 12px/1.6 var(--t-font); color: var(--text-2, #d8ccc2); white-space: pre-wrap; overflow-wrap: anywhere; }
.inst-pre .t-c { color: var(--text-3, #8f8279); }

/* the Files tab: the app layout as a tree whose notes wrap */
.inst-files { font: 12px/1.6 var(--t-font); color: var(--text-2, #d8ccc2); }
.inst-files .t-dir { color: var(--ember, #ff7a1a); font-weight: 600; }
.inst-files .t-file { color: var(--text, #f3ebe4); }
.inst-files .ft-root { margin-bottom: 2px; }
.inst-files .ft-list { list-style: none; margin: 0 0 0 .5ch; padding: 0; }
.inst-files .ft-list li { position: relative; display: grid; grid-template-columns: 11ch minmax(0, 1fr); column-gap: 1.5ch; padding: 1px 0 1px 2.5ch; }
.inst-files .ft-list li.wide { grid-template-columns: minmax(0, 1fr); }
.inst-files .ft-list li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 1px solid var(--line-2, rgba(255, 255, 255, .16)); }
.inst-files .ft-list li:last-child::before { bottom: auto; height: .85em; }
.inst-files .ft-list li::after { content: ""; position: absolute; left: 0; top: .85em; width: 1.8ch; border-top: 1px solid var(--line-2, rgba(255, 255, 255, .16)); }
.inst-files .ft-n { overflow-wrap: anywhere; }
.inst-files .ft-n span { white-space: nowrap; margin-right: 1ch; }
.inst-files .ft-d { color: var(--text-3, #8f8279); }
.inst-files .ft-list .ft-list { grid-column: 1 / -1; margin-top: 1px; }
.inst-pre .t-h { color: var(--accent, #ff4a1c); font-weight: 600; }
.inst-pre .t-k { color: var(--text, #f3ebe4); }
.inst-pre .t-s { color: var(--copper, #d98a4e); }

/* without JavaScript: the final state as text, no controls */
.inst:not(.is-live) .inst-replay, .inst:not(.is-live) .inst-hint, .inst:not(.is-live) .inst-copy,
.inst:not(.is-live) #inst-tab-cargo, .inst:not(.is-live) .inst-count { display: none; }

@media (max-width: 1080px) {
  .inst-grid { grid-template-columns: minmax(0, 1fr); }
  .inst-preview { max-height: 460px; }
}
@media (max-width: 620px) {
  .inst-term-body { height: 470px; padding: 12px 12px 14px; font-size: 10.5px; }
  .inst-bar { padding-left: 11px; }
  .inst-lights { gap: 6px; }
  .inst-lights i { width: 10px; height: 10px; }
  .inst-title { font-size: 11.5px; }
  .inst-cmd code { font-size: 11.5px; }
  .inst-pre, .inst-files { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .inst-term-body .t-cursor { animation: none; }
}
