/* gPromptOS 1.0 */

:root {
  /* Colors are set by the `color` command; these are the defaults (the original gPromptOS look). */
  --bg: #000;
  --fg: #c0c0c0;
  --hi: #00ee11;
  --dim: color-mix(in srgb, var(--fg) 55%, var(--bg));
  --rule: color-mix(in srgb, var(--fg) 22%, var(--bg));
  --glow: color-mix(in srgb, var(--fg) 40%, transparent);

  --font: "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --fs: clamp(14px, 0.55vw + 11px, 18px);
  --lh: 1.35;
  --pad: clamp(0.75rem, 2vw, 1.5rem);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg); scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--fs) / var(--lh) var(--font);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--hi); text-underline-offset: 0.2em; }
a:hover { background: var(--fg); color: var(--bg); text-decoration: none; }
:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: var(--pad); top: -3rem; z-index: 10;
  padding: 0.25rem 0.5rem; background: var(--fg); color: var(--bg);
}
.skip:focus { top: var(--pad); }

/* ---------- Terminal ---------- */

.term {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  text-shadow: 0 0 0.3em var(--glow);
}

/* CRT: scanlines and a soft vignette. `crt` toggles it. */
.term::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgb(0 0 0 / 0.16) 2px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 0.35));
}
.crt-off .term { text-shadow: none; }
.crt-off .term::after { display: none; }

.screen {
  flex: 1;
  overflow-y: auto;
  padding: var(--pad);
  cursor: text;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}

.out > div,
.line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: calc(var(--lh) * 1em);
}

/* ASCII art: shrink to fit narrow screens instead of wrapping. --cols is set per block by the script. */
.out pre.art {
  margin: 0;
  font: inherit;
  white-space: pre;
  overflow-x: auto;
  font-size: min(1em, calc((100vw - 2 * var(--pad) - 1rem) / (var(--cols, 80) * 0.6)));
  line-height: 1.2;
}

.out .dim { color: var(--dim); }
.out .err { color: var(--fg); }

/* Clickable things inside output: directories, programs, commands. */
.out button,
.chips button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  text-shadow: inherit;
}
.out button.dir { color: var(--hi); font-weight: bold; }
.out button.exe,
.out button.txt,
.out button.cmd { text-decoration: underline dotted var(--dim); text-underline-offset: 0.2em; }
.out button:hover,
.out button:focus-visible { background: var(--fg); color: var(--bg); text-decoration: none; text-shadow: none; outline: none; }

/* The input line: a real <input> sits invisibly on top so phones get a keyboard, and a mirror shows a DOS cursor. */
.line { position: relative; margin: 0; white-space: normal; } /* ignore the markup's own whitespace... */
.prompt, .echo { white-space: pre-wrap; } /* ...but keep spaces you type */
.prompt { cursor: text; }
#cmd {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px; /* stops iOS zooming in on focus */
  color: transparent;
  background: transparent;
  caret-color: transparent;
}
.caret { position: relative; }
.caret::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.1em;
  height: 0.18em;
  background: var(--fg);
  opacity: 0.35;
}
.line.focused .caret::after { opacity: 1; animation: blink 1.06s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .line.focused .caret::after { animation: none; } }

/* Tappable command bar under the screen. */
.chips {
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  padding: 0.6rem var(--pad) calc(0.6rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  font-size: 0.85em;
  position: relative;
  z-index: 1;
}
.chips-list { display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1; }
.chips button {
  border: 1px solid var(--dim);
  padding: 0.3rem 0.65rem;
  min-height: 2.25rem;
}
.chips button .dim { color: var(--dim); }
.chips button:hover,
.chips button:focus-visible { background: var(--fg); color: var(--bg); text-shadow: none; outline: none; }
.chips button:hover .dim,
.chips button:focus-visible .dim { color: inherit; }
.chips-plain { color: var(--dim); white-space: nowrap; }

/* On phones, one row of chips that scrolls sideways rather than eating the screen. */
@media (max-width: 40rem) {
  .chips { flex-wrap: nowrap; padding-right: 0; }
  .chips-list {
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    padding-right: var(--pad);
    mask-image: linear-gradient(to right, #000 85%, transparent);
  }
  .chips-list::-webkit-scrollbar { display: none; }
  .chips button { flex: none; white-space: nowrap; }
  .chips-plain { display: none; }
}

/* ---------- Plain version ---------- */

.plain {
  max-width: 54rem;
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) var(--pad) 3rem;
}
.plain-head h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6em;
  color: var(--hi);
  letter-spacing: 0.02em;
}
.plain-head p { margin: 0; color: var(--dim); }
.plain-head a { margin-left: 0.5em; }

.fs, .fs ul { list-style: none; margin: 0; padding: 0; }
.fs h2, .fs h3 {
  margin: 2.25rem 0 0.5rem;
  font-size: 1em;
  font-weight: bold;
  color: var(--hi);
}
.fs li[data-exe] {
  display: grid;
  grid-template-columns: minmax(10rem, 17rem) 1fr;
  gap: 0.15rem 1.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--rule);
}
.fs li[data-exe] .name { font-weight: bold; }

@media (max-width: 40rem) {
  .fs li[data-exe] { grid-template-columns: 1fr; }
}

.plain-foot {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--dim);
  font-size: 0.85em;
}

/* ---------- 404 ---------- */

.notfound {
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--pad);
  overflow-wrap: anywhere;
  text-shadow: 0 0 0.3em var(--glow);
}
.notfound p { margin: 0 0 calc(var(--lh) * 1em); white-space: pre-wrap; }
.notfound .blink { animation: blink 1.06s steps(1) infinite; }
@media (prefers-reduced-motion: reduce) { .notfound .blink { animation: none; } }
