/* Paradox Lives Again — the page is a Paradox 4.5 session.
   One committed visual world: the 16-colour VGA text palette on DOS blue. */

:root {
  color-scheme: dark;
  --blue: #0000aa;
  --blue-deep: #00006e;
  --white: #ffffff;
  --grey: #aaaaaa;
  --grey-dark: #555555;
  --cyan: #00aaaa;
  --cyan-hi: #55ffff;
  --yellow: #ffff55;
  --black: #000000;
  --red: #aa0000;
  --green-hi: #55ff55;
  --red-hi: #ff5555;

  --ground: var(--blue);
  --ink: var(--white);
  --ink-soft: #d8d8f2;
  --rule: var(--cyan-hi);
  --focus: var(--yellow);

  --display: "VT323", "Lucida Console", "Courier New", monospace;
  --mono: "IBM Plex Mono", "DejaVu Sans Mono", "Consolas", "Menlo", monospace;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: clamp(2.25rem, 5vw + 1rem, 3.5rem);
  --step-4: clamp(3rem, 9vw + 1rem, 6.5rem);

  /* Hard DOS drop shadow, one character cell wide. */
  --shadow: 0.6rem 0.6rem 0 var(--black);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--mono);
  padding-inline: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan-hi); text-underline-offset: 0.2em; }
a:hover { color: var(--yellow); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

code, kbd { font-family: var(--mono); font-size: 0.95em; }
code { color: var(--yellow); }
kbd {
  display: inline-block;
  padding: 0 0.35em;
  background: var(--grey);
  color: var(--black);
  line-height: 1.35;
}

h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1; text-wrap: balance; margin: 0; }
h2 { font-size: var(--step-3); color: var(--white); }

[hidden] { display: none !important; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ */
/* Ring menu (lines 1 and 2 of the Paradox screen)                     */
/* ------------------------------------------------------------------ */

.menubar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  margin-inline: -16px;
  padding: 0.35rem 16px 0.4rem;
  background: var(--ground);
  border-bottom: 3px double var(--rule);
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 1rem;
}

.ring { display: flex; flex-wrap: wrap; gap: 0.2rem 1.4rem; }
.ring a {
  color: var(--white);
  text-decoration: none;
  padding: 0 0.3rem;
  margin-inline: -0.3rem;
}
.ring a::first-letter { color: var(--yellow); }
.ring a:hover, .ring a:focus-visible, .ring a.on { background: var(--grey); color: var(--blue); outline: none; }
.ring a:hover::first-letter, .ring a:focus-visible::first-letter, .ring a.on::first-letter { color: var(--blue); }

.mode {
  align-self: start;
  background: var(--grey);
  color: var(--blue);
  padding: 0 0.5rem;
}
.ring-help {
  grid-column: 1 / -1;
  margin: 0.1rem 0 0;
  color: var(--ink-soft);
  font-size: var(--step--1);
  min-height: 1.6em;
}

main { max-width: 72rem; margin: 0 auto; }

/* ------------------------------------------------------------------ */
/* Hero: a DOS dialog with a hard shadow, beside a PAL listing         */
/* ------------------------------------------------------------------ */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: center;
  padding-block: 3.5rem 3rem;
}

.dialog {
  background: var(--grey);
  color: var(--black);
  border: 3px double var(--black);
  outline: 0.55rem solid var(--grey);
  box-shadow: 0.55rem 0.55rem 0 0.55rem var(--black);
  margin: 0.55rem;
  padding: 1.5rem 1.75rem 1.75rem;
  position: relative;
}
.dialog-title {
  position: absolute;
  top: -0.95rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0 0.6rem;
  background: var(--grey);
  font-size: var(--step--1);
  white-space: nowrap;
}
.dialog h1 {
  font-size: var(--step-4);
  color: var(--blue);
  letter-spacing: 0.01em;
}
.lede { margin: 1.1rem 0 0; max-width: 60ch; }
.lede strong { color: var(--blue); }

.actions { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 1.5rem; }

.key {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.9rem;
  background: var(--cyan);
  color: var(--black);
  border: 0;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0.35rem 0.35rem 0 var(--black);
}
.key kbd { background: var(--black); color: var(--yellow); }
.key:hover { background: var(--cyan-hi); color: var(--black); }
.key:active { transform: translate(0.2rem, 0.2rem); box-shadow: 0.15rem 0.15rem 0 var(--black); }
.key.alt { background: var(--blue-deep); color: var(--white); outline: 1px solid var(--rule); outline-offset: -1px; }
.key.alt:hover { background: var(--black); color: var(--yellow); }
@media (prefers-reduced-motion: reduce) { .key:active { transform: none; } }

.hero-code {
  margin: 0;
  padding: 1.25rem 1.4rem;
  background: var(--black);
  color: var(--grey);
  font-size: 0.85rem;
  line-height: 1.55;
  overflow-x: auto;
  border-left: 3px double var(--rule);
}
.hero-code .c { color: var(--grey-dark); }
.hero-code .k { color: var(--cyan-hi); }
.hero-code .s { color: var(--yellow); }

/* ------------------------------------------------------------------ */
/* Sections                                                            */
/* ------------------------------------------------------------------ */

.panel { padding-block: 3rem; border-top: 1px solid rgba(85, 255, 255, 0.25); }
.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--cyan-hi);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
}
.panel > h2 + * { margin-top: 1.2rem; }
.prose p, .prose li { max-width: 68ch; }
.note { color: var(--ink-soft); max-width: 72ch; }

.points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0.9rem; }
.points li { padding-left: 1.6rem; position: relative; }
.points li::before { content: "►"; position: absolute; left: 0; color: var(--yellow); }
.points b { color: var(--white); }

.code {
  background: var(--black);
  color: var(--white);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 100%;
}
.code .c { color: var(--grey); }

details { border-bottom: 1px solid rgba(85, 255, 255, 0.25); padding: 0.8rem 0; max-width: 72ch; }
summary { cursor: pointer; color: var(--white); font-weight: 600; list-style: none; }
summary::before { content: "▸ "; color: var(--yellow); }
details[open] summary::before { content: "▾ "; }
summary::-webkit-details-marker { display: none; }
details p { color: var(--ink-soft); margin: 0.6rem 0 0 1.3rem; }

/* ------------------------------------------------------------------ */
/* Paradox table view                                                  */
/* ------------------------------------------------------------------ */

.table-scroll { overflow-x: auto; max-width: 100%; }
table.pdx { border-collapse: collapse; width: 100%; min-width: 36rem; font-size: 0.92rem; }
.pdx th, .pdx td { text-align: left; vertical-align: top; padding: 0.35rem 0.75rem; border-left: 3px double var(--rule); }
.pdx th:first-child, .pdx td:first-child { border-left: 0; }
.pdx thead th { color: var(--white); font-weight: 600; border-bottom: 3px double var(--rule); white-space: nowrap; }
.pdx thead th:first-child { color: var(--yellow); }
.pdx tbody td:first-child { color: var(--ink-soft); text-align: right; font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
.pdx tbody tr:hover td { background: rgba(170, 170, 170, 0.14); }
.pdx tbody tr:hover td:nth-child(2) { background: var(--grey); color: var(--blue); }
.pdx tbody tr:hover td:nth-child(2) code { color: var(--blue); }
.features td:nth-child(2) { white-space: nowrap; }
.compat td:first-child { text-align: left; color: var(--white); width: auto; }

.chip { display: inline-block; padding: 0 0.5rem; color: var(--black); white-space: nowrap; }
.chip.ok { background: var(--green-hi); }
.chip.part { background: var(--yellow); }
.chip.no { background: var(--red-hi); }

/* ------------------------------------------------------------------ */
/* Playground                                                          */
/* ------------------------------------------------------------------ */

.playground {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  margin-top: 1.5rem;
}

.monitor-wrap { container-type: inline-size; min-width: 0; }
.monitor {
  background: #1b1b1b;
  padding: 2.2cqw;
  border-radius: 1.2cqw;
  box-shadow: var(--shadow);
  outline-offset: 4px;
  position: relative;
  cursor: text;
}
.monitor:focus-visible { outline: 2px solid var(--focus); }
.monitor.idle::after {
  content: "Click here to use the keyboard";
  position: absolute;
  right: 3cqw;
  bottom: 3cqw;
  padding: 0 0.5em;
  background: var(--yellow);
  color: var(--black);
  font-size: max(11px, 1.6cqw);
}

/* 80 columns of a monospace face are ~48em wide: scale the font to the monitor. */
.screen {
  --cell: calc((100cqw - 4.4cqw) / 48.2);
  margin: 0;
  font: 400 var(--cell)/1.25 var(--mono);
  background: var(--blue);
  color: var(--grey);
  white-space: pre;
  overflow: hidden;
  user-select: none;
}
.screen .row { display: block; height: 1.25em; }
.screen span { display: inline; }
.screen .cur { animation: blink 1s steps(1) infinite; text-decoration: underline; text-decoration-thickness: 0.15em; text-underline-offset: 0.12em; }
.screen .blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .screen .cur, .screen .blink { animation: none; } }
.screen-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* VGA palette as foreground / background classes. */
.f0{color:#000}.f1{color:#00a}.f2{color:#0a0}.f3{color:#0aa}.f4{color:#a00}.f5{color:#a0a}.f6{color:#a50}.f7{color:#aaa}
.f8{color:#555}.f9{color:#55f}.f10{color:#5f5}.f11{color:#5ff}.f12{color:#f55}.f13{color:#f5f}.f14{color:#ff5}.f15{color:#fff}
.b0{background:#000}.b1{background:#00a}.b2{background:#0a0}.b3{background:#0aa}.b4{background:#a00}.b5{background:#a0a}.b6{background:#a50}.b7{background:#aaa}

.softkeys { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.softkeys button {
  min-width: 2.75rem;
  padding: 0.25rem 0.6rem;
  background: var(--grey);
  color: var(--black);
  border: 0;
  font: inherit;
  cursor: pointer;
  box-shadow: 0.25rem 0.25rem 0 var(--black);
}
.softkeys button:active { transform: translate(0.15rem, 0.15rem); box-shadow: 0.1rem 0.1rem 0 var(--black); }
.typein { display: inline-flex; align-items: center; gap: 0.4rem; flex: 1 1 12rem; }
.typein span { color: var(--ink-soft); font-size: var(--step--1); }
.typein input, .controls select, .controls textarea {
  background: var(--black);
  color: var(--white);
  border: 1px solid var(--cyan);
  font: inherit;
  padding: 0.25rem 0.5rem;
  min-width: 0;
  width: 100%;
}

.controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.8rem; min-width: 0; }
.controls .row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.controls .row > label { color: var(--ink-soft); font-size: var(--step--1); }
.controls select { flex: 1 1 12rem; width: auto; }
.controls textarea#editor {
  height: 17rem;
  resize: vertical;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
  color: var(--grey);
  tab-size: 3;
}
.buttons { gap: 0.9rem !important; }

.drop {
  display: grid;
  gap: 0.2rem;
  padding: 0.8rem 1rem;
  border: 2px dashed var(--cyan);
  color: var(--ink-soft);
  font-size: var(--step--1);
}
.drop strong { color: var(--white); font-size: var(--step-0); font-weight: 600; }
.drop .row { margin-top: 0.5rem; }
.disk-list a { color: var(--yellow); font-size: var(--step--1); }
.disk-list .muted { color: #8f8fd0; font-size: var(--step--1); }
.drop.over { background: rgba(85, 255, 255, 0.12); border-color: var(--yellow); }

.disk { display: grid; gap: 0.45rem; }
.disk-list:empty::after { content: "—"; color: #8f8fd0; }
.disk-title { margin: 0; font-size: var(--step--1); color: var(--ink-soft); }
.disk-title .hint { color: var(--grey-dark); color: #8f8fd0; }
.disk-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.disk-list button {
  background: var(--blue-deep);
  color: var(--cyan-hi);
  border: 1px solid var(--cyan);
  font: inherit;
  font-size: var(--step--1);
  padding: 0.05rem 0.5rem;
  cursor: pointer;
}
.disk-list button:hover { background: var(--grey); color: var(--blue); }

.log {
  margin: 0;
  min-height: 4.5rem;
  max-height: 12rem;
  overflow: auto;
  padding: 0.6rem 0.8rem;
  background: var(--black);
  color: var(--green-hi);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.log .err { color: var(--red-hi); }

.inspector { margin-top: 1.75rem; padding: 1rem 1.25rem 1.25rem; border: 3px double var(--rule); display: grid; gap: 0.9rem; }
.inspector-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.8rem; }
.inspector-head .eyebrow { margin: 0; }
.inspector-head .row { display: flex; gap: 0.8rem; }
.inspector td { white-space: nowrap; }
textarea.csv {
  width: 100%;
  height: 12rem;
  background: var(--black);
  color: var(--white);
  border: 1px solid var(--cyan);
  font: 0.8rem/1.45 var(--mono);
  padding: 0.5rem;
  white-space: pre;
}
#csv-wrap { display: grid; gap: 0.6rem; justify-items: start; }

/* ------------------------------------------------------------------ */

.footer {
  max-width: 72rem;
  margin: 2rem auto 0;
  padding-block: 1.5rem 2.5rem;
  border-top: 3px double var(--rule);
  color: var(--ink-soft);
  font-size: var(--step--1);
}
.footer strong { color: var(--white); }

@media (max-width: 60rem) {
  .hero, .playground { grid-template-columns: minmax(0, 1fr); }
  .hero { padding-block: 2.5rem 2rem; }
}
@media (max-width: 30rem) {
  .menubar { position: static; }
  .dialog { padding: 1.25rem 1.1rem 1.4rem; }
  .ring { gap: 0.2rem 0.9rem; }
}
