/* Crispygoat DeskMate — CGA 16, 80x25 cells, keyboard bar. */
@font-face {
  font-family: "DeskMate";
  src: url("../fonts/Silkscreen-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --cell: 8px;
  --c0: #000000;
  --c1: #0000aa;
  --c2: #00aa00;
  --c3: #00aaaa;
  --c4: #aa0000;
  --c5: #aa00aa;
  --c6: #aa5500;
  --c7: #aaaaaa;
  --c8: #555555;
  --c9: #5555ff;
  --c10: #55ff55;
  --c11: #55ffff;
  --c12: #ff5555;
  --c13: #ff55ff;
  --c14: #ffff55;
  --c15: #ffffff;
}

* { box-sizing: border-box; }

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

button, input, textarea {
  font: inherit;
  color: inherit;
  border-radius: 0;
}

button { cursor: pointer; }

[hidden] { display: none !important; }

#letterbox {
  position: fixed;
  inset: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
}

#screen {
  position: relative;
  width: calc(var(--cell) * 80);
  height: calc(var(--cell) * 25);
  flex: none;
  margin: 10px;
  background: var(--c1);
  color: var(--c15);
  font-family: "DeskMate", ui-monospace, monospace;
  font-size: var(--cell);
  line-height: 1;
  font-smooth: never;
  -webkit-font-smoothing: none;
  text-rendering: optimizeSpeed;
  image-rendering: pixelated;
  user-select: none;
  box-shadow:
    0 0 0 3px #111,
    0 0 0 6px #3a3a3a,
    0 0 0 7px #000;
}

#screen svg, #screen canvas { image-rendering: pixelated; shape-rendering: crispEdges; }

#os {
  height: 100%;
  display: grid;
  grid-template-rows: var(--cell) minmax(0, 1fr) var(--cell) calc(var(--cell) * 2);
  position: relative;
}

#titlebar, #status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 0 0.55em;
  background: var(--c3);
  color: var(--c0);
  overflow: hidden;
  white-space: nowrap;
}

#status { border-top: 1px solid var(--c0); }

#title-name, #title-clock, #status { min-width: 0; }

#title-clock { flex: none; }

#stage {
  min-height: 0;
  overflow: hidden;
  background: var(--c1);
  position: relative;
  display: flex;
  flex-direction: column;
}

#stage > * { flex: 1; min-height: 0; }

#stage > .ask { flex: none; }

#fkeys {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 1px;
  padding: 1px;
  background: var(--c0);
  min-height: 0;
}

#fkeys button, #touchkeys button {
  appearance: none;
  margin: 0;
  border: 0;
  background: var(--c7);
  color: var(--c0);
  box-shadow: inset 1px 1px 0 var(--c15), inset -1px -1px 0 var(--c0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  line-height: 1;
}

#fkeys button { font-size: 0.85em; }

#fkeys kbd, #touchkeys kbd {
  font: inherit;
  color: var(--c1);
}

#fkeys span {
  display: block;
  min-height: 1em;
  max-width: 100%;
  overflow: hidden;
}

#fkeys button:disabled {
  background: #7a7a7a;
  color: var(--c8);
  box-shadow: inset 1px 1px 0 #bbb, inset -1px -1px 0 #333;
}

#fkeys button:disabled kbd { color: #333; }

#fkeys button:not(:disabled):hover,
#fkeys button:not(:disabled):focus-visible,
#fkeys button:not(:disabled):active,
#touchkeys button:not(:disabled):hover,
#touchkeys button:not(:disabled):active {
  background: var(--c14);
}

#scan {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.28) 0 1px,
    transparent 1px 3px
  );
}

#screen.scanlines #scan { display: block; }

#boot {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  background: var(--c1);
  color: var(--c14);
  text-align: center;
}

.boot-name { color: var(--c15); }

.boot-gap { height: 0.6em; }

.goat svg { width: 8em; height: auto; display: block; }

.blink { animation: blink 1.1s steps(1) infinite; }

html.reduce-motion .blink { animation: none; }

@keyframes blink { 50% { visibility: hidden; } }

#intro {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: 0;
  bottom: calc(var(--cell) * 2);
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(0, 0, 170, 0.94);
  padding: 0.4em;
}

.panel {
  width: min(52em, 100%);
  background: var(--c3);
  color: var(--c0);
  border: 2px solid var(--c14);
  box-shadow: 4px 4px 0 var(--c0);
  padding: 0.45em 0.7em 0.55em;
}

.panel h2, .doc h2 {
  margin: 0 0 0.35em;
  font-size: 1em;
  font-weight: 400;
}

.panel h2 { color: var(--c1); }

.panel p, .doc p { margin: 0 0 0.35em; }

.panel button, .term button, .calc-keys button, .tools button, .key, .step, .day {
  border: 2px solid var(--c0);
}

.panel button {
  background: var(--c1);
  color: var(--c14);
  padding: 0.15em 0.8em;
}

.desk {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  padding: 0.4em 0.8em;
}

.icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
  background: transparent;
  color: var(--c15);
  border: 0;
  min-width: 0;
}

.icon .art {
  width: 4em;
  height: 4em;
  display: grid;
  place-items: center;
}

.icon .art svg { width: 4em; height: 4em; }

.icon .name { padding: 0.12em 0.3em; text-align: center; }

.icon.selected .art { outline: 1px solid var(--c14); outline-offset: 1px; }

.icon.selected .name { background: var(--c14); color: var(--c0); }

.doc {
  height: 100%;
  overflow: auto;
  padding: 0.45em 0.7em;
  color: var(--c15);
  white-space: pre-wrap;
}

.doc h2, .joke { color: var(--c14); }

.about { text-align: left; }

.about-goat svg { width: 6em; height: auto; }

.text-app { height: 100%; background: var(--c1); padding: 0.35em; }

.text-app textarea, input, .ask input {
  user-select: text;
}

textarea[data-editor] {
  display: block;
  width: 100%;
  height: 100%;
  resize: none;
  border: 2px solid var(--c15);
  background: var(--c15);
  color: var(--c0);
  padding: 0.25em 0.35em;
  outline: none;
  white-space: pre;
  overflow: auto;
}

.ask {
  background: var(--c3);
  color: var(--c0);
  padding: 0.1em 0.4em;
}

.ask input, .term input {
  background: var(--c0);
  color: var(--c14);
  border: 0;
  padding: 0 0.2em;
  width: 14em;
  outline: none;
}

.sheet { height: 100%; display: flex; flex-direction: column; background: var(--c1); color: var(--c15); }

.formula {
  display: flex;
  gap: 0.6em;
  background: var(--c0);
  color: var(--c14);
  padding: 0.15em 0.4em;
  min-height: 1.3em;
}

.formula [data-addr] { color: var(--c11); flex: none; }

.block {
  display: inline-block;
  width: 0.55em;
  height: 0.9em;
  background: var(--c14);
  vertical-align: -0.05em;
}

.gridwrap { flex: 1; min-height: 0; overflow: auto; }

.sheet table { width: 100%; border-collapse: collapse; table-layout: fixed; }

.sheet th, .sheet td {
  border: 1px solid var(--c8);
  height: 1.45em;
  padding: 0 0.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

.sheet th { background: var(--c3); color: var(--c0); text-align: center; }

.sheet td { background: var(--c15); color: var(--c0); text-align: left; }

.sheet td.num { text-align: right; }

.sheet td.on, .sheet th.on { background: var(--c14); color: var(--c0); }

.sheet td.err { background: var(--c0); color: var(--c12); }

.list, .filer { height: 100%; display: flex; flex-direction: column; color: var(--c15); }

.list-head, .filer-head { color: var(--c11); padding: 0.2em 0.45em; }

.filer-head, .filer .row {
  display: grid;
  grid-template-columns: 1.5fr 0.7fr 0.6fr;
  gap: 0.4em;
}

.list-rows { overflow: auto; min-height: 0; }

.list .row, .filer .row, .step {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--c15);
  border: 0;
  padding: 0.05em 0.45em;
}

.filer .row { display: grid; }

.row.on, .step.on, .day.on { background: var(--c14); color: var(--c0); }

.empty, .dim { color: var(--c11); padding: 0.4em; }

.cal { height: 100%; display: flex; flex-direction: column; padding: 0.25em 0.4em 0.15em; }

.cal-title { color: var(--c14); margin-bottom: 0.15em; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--c0);
}

.dow, .day {
  background: var(--c1);
  color: var(--c15);
  text-align: center;
  min-height: 1.45em;
  padding: 0;
}

.day { border: 0; }

.day.pad { background: #000088; }

.day.today { box-shadow: inset 0 0 0 1px var(--c11); }

.day i { font-style: normal; color: var(--c14); }

.day.on i { color: var(--c4); }

.cal-notes { flex: 1; min-height: 0; overflow: auto; padding-top: 0.2em; }

.calc {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0.4em;
}

.calc-box {
  width: min(22em, 100%);
  background: var(--c7);
  color: var(--c0);
  border: 2px solid var(--c15);
  box-shadow: inset -2px -2px 0 var(--c0), 3px 3px 0 var(--c0);
  padding: 0.35em;
}

.calc-display {
  background: var(--c0);
  color: var(--c10);
  text-align: right;
  padding: 0.25em 0.35em;
  min-height: 1.3em;
  margin-bottom: 0.35em;
}

.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.22em;
}

.calc-keys button {
  background: var(--c1);
  color: var(--c15);
  min-height: 1.7em;
  padding: 0;
}

.calc-keys button.op { background: var(--c3); color: var(--c0); }

.calc-keys .wide { grid-column: 1 / -1; }

.paint { height: 100%; display: flex; flex-direction: column; background: var(--c1); }

.tools, .swatches {
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 2px;
  background: var(--c0);
}

.tools button, .swatch {
  background: var(--c7);
  color: var(--c0);
  border: 1px solid var(--c15);
  min-height: 1.3em;
  padding: 0 0.35em;
}

.tools button.on, .swatch.on { outline: 1px solid var(--c14); background: var(--c14); }

.tool-name { color: var(--c11); padding-left: 0.4em; }

.swatch { width: 1.35em; padding: 0; }

.paint-stage { position: relative; flex: 1; min-height: 0; background: var(--c0); }

.paint-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.paint-stage .cursor { pointer-events: none; }

.music { height: 100%; display: flex; flex-direction: column; background: var(--c1); }

.pattern {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.hint { margin: 0; padding: 0.1em 0.4em; color: var(--c11); background: var(--c0); }

.piano { background: var(--c0); padding: 2px; }

.blacks {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  height: 1.5em;
}

.whites {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
}

.key { min-height: 2em; padding: 0; }

.key.white { background: var(--c15); color: var(--c0); }

.key.black { background: var(--c0); color: var(--c15); border-color: var(--c7); min-height: 1.4em; }

.term {
  height: 100%;
  overflow: auto;
  background: var(--c0);
  color: var(--c10);
  padding: 0.4em 0.55em;
}

.term-title, .c14 { color: var(--c14); }

.c11 { color: var(--c11); }

.term p { margin: 0 0 0.35em; }

.term button {
  background: var(--c1);
  color: var(--c15);
  margin: 0 0.25em 0.25em 0;
  padding: 0.05em 0.35em;
}

.log { margin: 0; white-space: pre-wrap; color: var(--c11); }

.led { margin: 0.4em 0 0; color: var(--c8); }

.led.on { color: var(--c12); }

#touchkeys {
  display: none;
  width: min(100%, 40rem);
  flex: none;
  position: sticky;
  bottom: 0;
  z-index: 3;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  margin: 0 auto;
  font-family: "DeskMate", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.1;
  background: #05030f;
}

#touchkeys button { min-height: 42px; touch-action: manipulation; }

#touchkeys button:disabled { opacity: 0.45; }

body.show-touch #touchkeys { display: grid; }

@media (prefers-reduced-motion: reduce) {
  .blink { animation: none; }
}
