/* NIALL web port -- Amiga look & feel.
   Palette from the AMOS source: Palette $0,$FFF,$F00,$48
     0 = #000000 background
     1 = #FFFFFF normal text (Pen 1)
     2 = #FF0000 system messages, CO(0)
     3 = #004488 USER:/NIALL: prompts, CO(1)
   Instruction screen palette (from the unpacked IFF):
     1 #FFFFFF, 4 #990000, 5 #999900, 6 #009900, 7 #000099 */

@font-face {
  font-family: "TopazPlus";
  src: url("assets/TopazPlus_a500.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --pen0: #000000;
  --pen1: #ffffff;
  --pen2: #ff0000;
  --pen3: #004488;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #000;
  min-height: 100%;
}

body {
  font-family: "TopazPlus", "Topaz", monospace;
  color: var(--pen1);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
}

/* ---------------- The "monitor" ---------------- */

.machine {
  width: min(100vw, 960px);
  container-type: inline-size;
  cursor: text;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

/* Screen 0: banner. Original: Screen Display 0,128,40,320,28 (lores,
   so 320 pixels span the full 640-wide hires display underneath). */
.screen0 {
  width: 100%;
  aspect-ratio: 640 / 28;
  margin-bottom: 0.4%;               /* the 2-scanline gap before screen 1 */
}
/* On narrow (phone) screens the hires ratio squashes the banner flat;
   fall back to the native lores 320x28 proportions so it stays legible. */
@media (max-width: 640px) {
  .screen0 { aspect-ratio: 320 / 28; }
}
.screen0 img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  user-select: none;
  -webkit-user-select: none;
}

/* Screen 1: 640x230 hires, black. 80 columns of 8px Topaz. */
.screen1 {
  width: 100%;
  background: var(--pen0);
  border: 1px solid #111;
}

.term {
  height: min(60dvh, 480px);
  overflow-y: auto;
  padding: 0.6em 0.5em;
  font-size: clamp(11px, 2.5cqw, 16px);
  line-height: 1.25;
  scrollbar-color: #444 #000;
  scrollbar-width: thin;
  overflow-wrap: break-word;
}

.line { min-height: 1.25em; white-space: pre-wrap; }
.line.centre { text-align: center; }

.pen1   { color: var(--pen1); }
.penSys { color: var(--pen2); }   /* Pen CO(0): red   */
.penUsr { color: var(--pen3); }   /* Pen CO(1): $048  */

/* AMOS text cursor */
.cursor {
  background: var(--pen3);
  color: var(--pen0);
  animation: curs 1s steps(1) infinite;
}
@keyframes curs {
  0%, 60% { background: var(--pen3); }
  61%, 100% { background: transparent; }
}

/* ---------------- Screen 2: instructions ---------------- */

.screen2 {
  width: 100%;
  aspect-ratio: 640 / 256;
  background: url("assets/instructions_bg.png") 0 0 / 100% 100% no-repeat;
  image-rendering: pixelated;
  position: relative;
  transition: opacity 0.55s;
}
.screen2.faded { opacity: 0; }

/* Text 16,32+G*8 on a 640x256 screen, 8x8 font: replicate proportionally */
.instr {
  position: absolute;
  left: 2.5%;                  /* 16 / 640  */
  top: 15.6%;                  /* 40 / 256  */
  width: 97.5%;
  font-size: 1.25cqw;          /* 8px of a 640px screen */
  line-height: 1;
}
.iline {
  white-space: pre;
  min-height: 1em;
  text-shadow: 0.125em 0.125em 0 #000;   /* the Ink 0 drop shadow */
}
.ic1 { color: #ffffff; }
.ic4 { color: #990000; }
.ic5 { color: #999900; }
.ic6 { color: #009900; }
.ic7 { color: #000099; }

.hidden { display: none !important; }

/* ---------------- Hidden keyboard catcher ---------------- */

.kbd-form {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.kbd {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 2px;
  height: 2px;
  padding: 0;
  border: 0;
  opacity: 0.01;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}

/* ---------------- File requester (Fsel$) ---------------- */

.req-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.req {
  width: min(92vw, 420px);
  background: #0055aa;                       /* Workbench 1.x blue */
  border: 2px solid #fff;
  box-shadow: 4px 4px 0 #000;
  padding: 2px;
  color: #fff;
  font-size: clamp(12px, 2.2cqw, 15px);
}

.req-title {
  background: #fff;
  color: #0055aa;
  padding: 3px 6px;
  font-weight: bold;
}

.req-path {
  padding: 4px 6px;
  color: #ffaa00;                            /* Workbench orange */
}

.req-list {
  background: #000;
  border: 1px solid #fff;
  margin: 0 4px;
  height: 10em;
  overflow-y: auto;
}
.req-item {
  padding: 2px 6px;
  cursor: pointer;
  white-space: nowrap;
}
.req-item:hover { background: #003366; }
.req-item.sel { background: #ffaa00; color: #000; }
.req-item.req-empty { color: #888; cursor: default; }

.req-namerow { padding: 6px 4px 2px; }
.req-name {
  width: 100%;
  background: #000;
  border: 1px solid #fff;
  color: #fff;
  font-family: inherit;
  font-size: inherit;
  padding: 3px 6px;
  outline: none;
}

.req-btns {
  display: flex;
  gap: 6px;
  padding: 6px 4px;
}
.req-btn {
  flex: 1;
  font-family: inherit;
  font-size: inherit;
  background: #0055aa;
  color: #fff;
  border: 1px solid #fff;
  box-shadow: 2px 2px 0 #000;
  padding: 4px 8px;
  cursor: pointer;
}
.req-btn:active {
  background: #ffaa00;
  color: #000;
  box-shadow: none;
  transform: translate(2px, 2px);
}

/* ---------------- End screen / footer ---------------- */

.ended {
  color: #fff;
  font-family: "TopazPlus", monospace;
  text-align: center;
  margin-top: 40vh;
  cursor: pointer;
}

.pagefoot {
  flex: 0 0 auto;
  color: #555;
  font-size: 11px;
  padding: 10px 8px 12px;
  text-align: center;
}
.pagefoot a { color: #777; }

/* ---------------- Documentation pages ---------------- */

.docpage {
  background: #0055aa;                       /* Workbench blue desktop */
  display: block;
}

.doc-frame {
  max-width: 900px;
  margin: 16px auto;
  background: #fff;
  border: 2px solid #000;
  box-shadow: 6px 6px 0 #002244;
}

.doc-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #0055aa;
  color: #fff;
  padding: 5px 10px;
  border-bottom: 2px solid #000;
  font-size: 14px;
}
.doc-titlebar a.doc-close {
  color: #ffaa00;
  text-decoration: none;
  white-space: nowrap;
}
.doc-titlebar a.doc-close:hover { text-decoration: underline; }

.doc {
  color: #000;
  background: #fff;
  margin: 0;
  padding: 14px 16px 20px;
  font-family: "TopazPlus", monospace;
  font-size: clamp(11px, 1.7vw, 14px);
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-x: auto;
}

.doc-note {
  color: #333;
  background: #ffeecc;
  border-bottom: 1px solid #ccc;
  margin: 0;
  padding: 8px 16px;
  font-size: 13px;
}

@media (max-width: 640px) {
  .doc-frame { margin: 0; border-width: 0 0 2px; box-shadow: none; }
}
