/* vscode.css -- the VS Code Dark+ chrome, ported from the sibling C++ repo's
   terminal.css (hammadshakeelai.github.io/Doomsday).

   Two things had to change on the way across:

     1. That file leans on variables defined in its own style.css
        (--text-dim, --text-faint, --mono, --arch-soft) and sizes its window
        off a .wrap.wide class that does not exist here. Everything it needs
        is declared below instead, so this file stands alone.
     2. There the window was a 1400px card on a marketing page. Here it fills
        the viewport, because the emulator canvas is the product and every
        pixel not given to it is a pixel wasted.
*/

:root {
  /* VS Code on Arch renders "monospace" as DejaVu Sans Mono; the rest are the
     closest faces likely to exist on machines without it. */
  --vsc-mono: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Liberation Mono',
              'Noto Sans Mono', ui-monospace, Consolas, 'Courier New', monospace;

  --vsc-bg:      #1e1e1e;   /* editor background */
  --vsc-chrome:  #252526;   /* tab strip         */
  --vsc-title:   #3c3c3c;   /* title bar         */
  --vsc-act:     #333333;   /* activity bar      */
  --vsc-edge:    #2a2a2a;
  --vsc-text:    #d4d4d4;
  --vsc-dim:     #858585;
  --vsc-faint:   #6e7681;
  --vsc-accent:  #0078d4;   /* active tab underline */
  --vsc-link:    #4daafc;

  --ok:    #4ec9b0;
  --warn:  #d7ba7d;
  --err:   #f14c4c;

  /* Height of the debug panel. Deliberately a fixed px value and not a
     percentage: js-dos letterboxes a 4:3 canvas inside its container, so every
     pixel of panel height comes straight out of the emulator's rendered size. */
  --panel-h: 148px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--vsc-bg);
  color: var(--vsc-text);
  font-family: var(--vsc-mono);
  font-size: 13px;
  height: 100dvh;               /* plain vh assumes a collapsed URL bar on iOS */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------------------------------------------------------- title bar */

.vsc-titlebar {
  flex: 0 0 35px;
  background: var(--vsc-title);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--vsc-edge);
  user-select: none;
}
.vsc-titlebar .title {
  flex: 1;
  min-width: 0;
  text-align: center;
  color: #cccccc;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vsc-titlebar a.home {
  color: #cccccc;
  text-decoration: none;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
}
.vsc-titlebar a.home:hover { background: #4a4a4a; color: #fff; }

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

.btn {
  font: inherit;
  font-size: 12px;
  background: #313131;
  color: #e8e8e8;
  border: 1px solid #454545;
  border-radius: 4px;
  padding: 3px 12px;
  cursor: pointer;
  white-space: nowrap;
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; color: #e8e8e8; }
.btn:hover:not(:disabled) { background: #3c3c3c; border-color: #5a5a5a; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary {
  background: var(--vsc-accent);
  border-color: var(--vsc-accent);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: #1a86e0; border-color: #1a86e0; }

/* A visible focus ring everywhere. The browser default vanishes against
   #1e1e1e, which makes the page unusable by keyboard. */
:focus-visible { outline: 2px solid var(--vsc-link); outline-offset: 1px; }

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

.vsc-main { flex: 1; display: flex; min-height: 0; }

.vsc-activity {
  flex: 0 0 48px;
  background: var(--vsc-act);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 0;
  border-right: 1px solid var(--vsc-edge);
  user-select: none;
}
.vsc-activity .ico {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--vsc-dim);
  position: relative;
}
.vsc-activity .ico.active { color: #fff; }
.vsc-activity .ico.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: #fff;
}
.vsc-activity .ico svg { width: 24px; height: 24px; fill: currentColor; }
.vsc-activity .spacer { flex: 1; }

/* ------------------------------------------------------------ editor (left) */

/* 30%, not the sibling site's 38%. Assembly lines are short -- almost none in
   this program reach 40 columns -- so width spent here buys nothing, and the
   emulator wants every pixel it can get. */
.vsc-editor {
  flex: 0 0 30%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--vsc-bg);
  border-right: 1px solid var(--vsc-edge);
}

.vsc-tabs {
  flex: 0 0 35px;
  display: flex;
  align-items: center;
  background: var(--vsc-chrome);
  user-select: none;
}
.vsc-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 35px;
  background: var(--vsc-bg);
  color: #e8e8e8;
  font-size: 13px;
  position: relative;
}
.vsc-tab::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--vsc-accent);
}
.vsc-tab .ticon { color: #519aba; font-size: 11px; font-weight: 700; letter-spacing: -.5px; }
.vsc-tab .ro {
  color: var(--vsc-faint);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.vsc-code {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 8px 0 14px 8px;
  font-size: 13.6px;
  line-height: 19px;
  color: var(--vsc-text);
  scrollbar-width: thin;
  scrollbar-color: #4f4f4f transparent;
}
.vsc-code::-webkit-scrollbar { width: 10px; height: 10px; }
.vsc-code::-webkit-scrollbar-thumb { background: #4f4f4f; border: 3px solid var(--vsc-bg); border-radius: 6px; }
.vsc-code::-webkit-scrollbar-track { background: transparent; }

.vsc-code .ln { display: flex; width: max-content; min-width: 100%; }
.vsc-code .ln .no {
  width: 46px;
  flex: 0 0 46px;
  text-align: right;
  padding-right: 22px;
  color: var(--vsc-faint);
  position: sticky;
  left: 0;
  background: var(--vsc-bg);
  z-index: 1;
  user-select: none;
}
.vsc-code .ln .src { white-space: pre; padding-right: 18px; }

/* Gutter markers, driven by nasm-errors.js. The whole row tints, not just the
   number, so a bad line is findable while scrolling. */
.vsc-code .ln.mark-error   { background: rgba(241, 76, 76, .13); }
.vsc-code .ln.mark-warning { background: rgba(215, 186, 125, .12); }
.vsc-code .ln.mark-error   .no { color: var(--err);  background: #2a1e1e; font-weight: 700; }
.vsc-code .ln.mark-warning .no { color: var(--warn); background: #2a271e; font-weight: 700; }

/* NASM syntax colours, Dark+ palette */
.vsc-code .cm  { color: #6a9955; }   /* comment       */
.vsc-code .str { color: #ce9178; }   /* quoted text   */
.vsc-code .num { color: #b5cea8; }   /* 0x21, 100h    */
.vsc-code .kw  { color: #569cd6; }   /* mov, jmp, int */
.vsc-code .pp  { color: #c586c0; }   /* org, db, dw   */
.vsc-code .reg { color: #9cdcfe; }   /* ax, bl, dx    */
.vsc-code .lbl { color: #dcdcaa; }   /* a label       */

/* --------------------------------------------------------- run side (right) */

.vsc-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--vsc-bg);
}
.vsc-side .vsc-tabs { gap: 8px; padding-right: 10px; }
.vsc-side .vsc-tabs .sp { flex: 1; }

#status { color: var(--vsc-dim); font-size: 12px; min-width: 13ch; }
#status.running { color: var(--ok); }
#status.error   { color: var(--err); }

/* The emulator host. Black, because black is what DOS is between frames and a
   grey box flashing to black on every run reads as a fault. */
.vsc-dos {
  flex: 1;
  min-height: 0;
  background: #000;
  position: relative;
}
.vsc-dos iframe { width: 100%; height: 100%; border: 0; display: block; background: #000; }

/* Overlays sit on top of the emulator: the idle prompt, the paused-tab notice,
   and the no-WebAssembly message. */
.dos-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  background: rgba(0, 0, 0, .8);
  color: var(--vsc-text);
  z-index: 2;
}
.dos-overlay.show { display: flex; }
.dos-overlay p { margin: 0; max-width: 46ch; line-height: 1.6; color: #bfbfbf; }
.dos-overlay .big { font-size: 15px; color: #e8e8e8; }

/* -------------------------------------------------------------- debug panel */

.vsc-panel {
  flex: 0 0 var(--panel-h);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--vsc-bg);
  border-top: 1px solid #2b2b2b;
}
body.panel-collapsed .vsc-panel { flex-basis: 35px; }
body.panel-collapsed .vsc-terminal { display: none; }

.vsc-panel-tabs {
  flex: 0 0 35px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  user-select: none;
}
.vsc-panel-tabs .ptab {
  color: var(--vsc-dim);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0 10px;
  height: 35px;
  display: flex;
  align-items: center;
  position: relative;
}
.vsc-panel-tabs .ptab.active { color: #e8e8e8; }
.vsc-panel-tabs .ptab.active::after {
  content: '';
  position: absolute;
  left: 8px; right: 8px; bottom: 0;
  height: 1px;
  background: #e8e8e8;
}
.vsc-panel-actions { margin-left: auto; display: flex; gap: 6px; }
.vsc-panel-actions .act {
  background: none;
  border: 0;
  color: var(--vsc-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
}
.vsc-panel-actions .act:hover { color: #fff; background: #2a2d32; }

.vsc-terminal {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 14px 12px 20px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  scrollbar-width: thin;
  scrollbar-color: #4f4f4f transparent;
}
.vsc-terminal::-webkit-scrollbar { width: 14px; }
.vsc-terminal::-webkit-scrollbar-thumb { background: #4f4f4f; border: 4px solid var(--vsc-bg); border-radius: 8px; }
.vsc-terminal::-webkit-scrollbar-track { background: transparent; }

.c-dim  { color: var(--vsc-faint); }
.c-err  { color: var(--err); }
.c-warn { color: var(--warn); }
.c-ok   { color: var(--ok); }

/* ---------------------------------------------------------------- status bar */

.vsc-status {
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 10px;
  background: #007acc;
  color: #fff;
  font-size: 11.5px;
  user-select: none;
}
.vsc-status .sp { flex: 1; }
.vsc-status .seg { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.vsc-status a { color: #fff; text-decoration: none; }
.vsc-status a:hover { text-decoration: underline; }

/* -------------------------------------------------------- on-screen keydeck */

/* The program reads with int 21h AH=01h, so the page is useless on a phone
   without a way to send keys. Hidden where a real keyboard exists. */
.keydeck { display: none; }
.keydeck .keyrow { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.key {
  min-width: 38px;
  height: 40px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid #2a2f3a;
  background: linear-gradient(180deg, #2b2f37, #20242b);
  box-shadow: 0 3px 0 #0c0e12;
  color: var(--vsc-text);
  font: 600 15px var(--vsc-mono);
  cursor: pointer;
}
.key.wide { min-width: 72px; }
.key:active, .key.pressed { transform: translateY(3px); box-shadow: 0 0 0 #0c0e12; }

/* The CODE/RUN toggle exists only below the breakpoint. Declared here, before
   the media query, so the query can turn it on -- the reverse order silently
   wins on equal specificity and kills the toggle. */
#viewtabs { display: none; gap: 6px; }

/* -------------------------------------------------- phones and small tablets */

/* DESIGN.md: the sibling site deletes its editor pane below 760px because that
   editor was decorative. Here the source is half the point, so the panes become
   tabs instead -- both stay reachable, each gets the full height. */
@media (max-width: 760px) {
  :root { --panel-h: 116px; }
  .vsc-activity { display: none; }
  .vsc-main { position: relative; }
  .vsc-editor, .vsc-side { position: absolute; inset: 0; flex: 1 1 auto; }
  body[data-view="code"] .vsc-side   { display: none; }
  body[data-view="code"] .vsc-editor { display: flex; }
  body[data-view="run"]  .vsc-editor { display: none; }
  body[data-view="run"]  .vsc-side   { display: flex; }

  #viewtabs { display: flex; }
  .vsc-titlebar .title { display: none; }
  .vsc-titlebar { gap: 6px; padding: 0 8px; }

  /* The run strip has to fit 375px without scrolling sideways. Drop the file
     chip and the IDE link -- the IDE is one tap away from the title bar and the
     landing page -- and let the status text shrink instead of pushing. */
  .vsc-side .vsc-tabs > .vsc-tab { display: none; }
  .vsc-side .vsc-tabs > a.btn { display: none; }
  .vsc-side .vsc-tabs { padding: 0 8px; gap: 6px; }
  #status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn { padding: 3px 10px; }

  /* The status bar is one line and must not scroll sideways. The two segments
     on the right are reference, not state -- the counts and the pause notice
     are what change, so they are what stays. */
  .vsc-status { gap: 10px; padding: 0 8px; font-size: 11px; }
  .vsc-status .seg:nth-last-child(-n+2) { display: none; }
  .keydeck {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 6px 5px;
    background: #17191d;
    border-top: 1px solid var(--vsc-edge);
  }
  .keydeck .keyrow { gap: 4px; }
  .key { min-width: 30px; height: 34px; padding: 0 6px; font-size: 14px; border-radius: 6px; }
  .key.wide { min-width: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
