/*
 * webMARS help documents.
 *
 * These pages are read inside an application pane roughly 745x350 CSS pixels,
 * not on a full page, so the scale is the application's own: dense, square and
 * information-first, the way MARS 4.5 presents its Swing panels. Structure does
 * the work that display type would do on the web -- rules, bevels and header
 * bars -- because the same sheet renders Arabic, Thai, Devanagari and CJK,
 * where uppercasing and letter-spacing either do nothing or break shaping.
 *
 * Theming follows the frame contract in 15-help-system.js: the application sets
 * data-theme="dark" on this document's root and removes it otherwise. There is
 * deliberately no prefers-color-scheme rule -- the attribute is the only
 * signal, so a light interface on a dark desktop keeps light help pages.
 */

:root {
  color-scheme: light;

  --ink: #24354b;
  --ink-strong: #111111;
  --heading: #1f2f45;
  --muted: #4e5a69;
  --faint: #7c8794;

  --surface: #ffffff;
  --surface-soft: #f2f5f9;
  --surface-sunken: #eef3f9;
  --code-bg: #f5f7fa;

  --border: #9db0c8;
  --border-soft: #b7c4d4;
  --bevel: rgba(255, 255, 255, 0.9);

  --accent: #2f6ea9;
  --accent-strong: #1f5f99;
  --accent-soft: #d1e8ff;

  --table-head: #fcf6ef;
  --table-line: #d9cfc3;

  --note-bg: #eef6ff;
  --note-line: #8fb4d9;
  --warn: #8f5a13;
  --warn-bg: #fff8dc;
  --warn-line: #d6b181;
  --good: #2f7c3d;

  --tag-bg: #d9e7f8;
  --tag-ink: #1f4d7d;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --ink: #d6dfe9;
  --ink-strong: #f2f6fa;
  --heading: #cfdae7;
  --muted: #a3b1c1;
  --faint: #7c8b9c;

  --surface: #171d24;
  --surface-soft: #1b222a;
  --surface-sunken: #1a2028;
  --code-bg: #13181f;

  --border: #3b4757;
  --border-soft: #333d4a;
  --bevel: rgba(255, 255, 255, 0.04);

  --accent: #4a8fd4;
  --accent-strong: #7fbaf0;
  --accent-soft: #1e3c58;

  --table-head: #1f272f;
  --table-line: #2b333d;

  --note-bg: #16283a;
  --note-line: #3f6d99;
  --warn: #d9a441;
  --warn-bg: #2c2415;
  --warn-line: #6d5526;
  --good: #56c46b;

  --tag-bg: #24425f;
  --tag-ink: #bcd6f5;
}

* { box-sizing: border-box; }

html {
  font: 13px/1.5 Tahoma, "Segoe UI", system-ui, sans-serif;
}

body {
  /* The pane is the frame; the page adds only reading margin. */
  max-width: 78ch;
  margin: 0;
  padding: 12px 16px 22px;
  color: var(--ink);
  background: var(--surface);
  overflow-wrap: break-word;
}

/* ---- Headings -------------------------------------------------------- */

h1, h2, h3 {
  color: var(--heading);
  line-height: 1.25;
  text-wrap: balance;
}

h1 {
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 3px double var(--border);
  font-size: 16px;
  font-weight: 700;
}

/* Section bar: an accent rule on the leading edge, the way a Swing titled
   border opens a group, instead of a large display size. */
h2 {
  margin: 20px 0 8px;
  padding: 3px 0 3px 8px;
  border-inline-start: 3px solid var(--accent);
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-soft);
  font-size: 13.5px;
  font-weight: 700;
}

h3 {
  margin: 14px 0 5px;
  font-size: 12.5px;
  font-weight: 700;
}

p { margin: 6px 0 9px; }

.lead {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.meta { color: var(--faint); font-size: 11.5px; }

strong, b { color: var(--ink-strong); font-weight: 700; }
.good { color: var(--good); font-weight: 700; }

a { color: var(--accent-strong); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:is(a, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 1px;
}

ul, ol { margin: 6px 0 10px; padding-inline-start: 20px; }
li + li { margin-top: 3px; }

/* ---- Code ------------------------------------------------------------ */

code, kbd, pre, samp {
  font-family: "Cascadia Code", Consolas, "Lucida Console", monospace;
  direction: ltr;
  unicode-bidi: embed;
}

code, kbd {
  padding: 0 3px;
  border: 1px solid var(--border-soft);
  background: var(--code-bg);
  font-size: 12px;
}

kbd {
  box-shadow: inset 0 -1px 0 var(--border-soft);
  font-weight: 700;
}

pre {
  overflow: auto;
  margin: 8px 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  box-shadow: inset 1px 1px 0 var(--bevel);
  background: var(--code-bg);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}

pre code { padding: 0; border: 0; background: none; font-size: inherit; }

/* ---- Tables ---------------------------------------------------------- */

table {
  width: 100%;
  margin: 8px 0 14px;
  border-collapse: collapse;
  font-size: 12.5px;
}

th, td {
  padding: 4px 8px;
  border: 1px solid var(--table-line);
  text-align: start;
  vertical-align: top;
}

th {
  background: var(--table-head);
  box-shadow: inset 1px 1px 0 var(--bevel);
  color: var(--heading);
  font-weight: 700;
}

tr:hover td { background: var(--surface-soft); }
.compact th, .compact td { padding: 2px 6px; }

/* ---- Panels ---------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.card, .note, .warning {
  padding: 8px 10px;
  border: 1px solid var(--border);
  box-shadow: inset 1px 1px 0 var(--bevel);
  background: var(--surface-soft);
}

.card h3 { margin-top: 0; }
.card > :last-child, .note > :last-child, .warning > :last-child { margin-bottom: 0; }

.note {
  border-inline-start: 3px solid var(--accent);
  background: var(--note-bg);
  border-color: var(--note-line);
}

.warning {
  border-inline-start: 3px solid var(--warn-line);
  border-color: var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn);
}

/* Square counters: a circled numeral is a web convention, a boxed one reads
   as a step in a manual. */
.steps { counter-reset: step; list-style: none; margin: 8px 0 12px; padding: 0; }
.steps > li { position: relative; padding: 0 0 9px 30px; }
.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 20px;
  height: 20px;
  border: 1px solid var(--accent-strong);
  box-shadow: inset 1px 1px 0 var(--bevel);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.pill {
  display: inline-block;
  margin: 1px 3px 1px 0;
  padding: 0 5px;
  border: 1px solid var(--note-line);
  background: var(--tag-bg);
  color: var(--tag-ink);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: nowrap;
}

/* ---- Legacy MARS markup ---------------------------------------------- */

/* Pages carried over from MARS 4.5 still use <font> and numbered classes. */
font { font-size: inherit !important; color: inherit; }
.style1, .style2 { font-weight: 700; color: var(--heading); }

/* The about card is a title block, not a document, so the version carries a
   little more weight than a page heading -- but nowhere near the 2.15rem the
   page used to set inline, which overflowed its own window.
   It stays a single column at every width: side-by-side panels made the
   credits and the privacy notice read as unrelated tiles. */
.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.about-grid h1 { font-size: 20px; }
.about-grid .card { background: var(--surface); }

img { max-width: 100%; height: auto; }
hr { margin: 14px 0; border: 0; border-top: 1px solid var(--border-soft); }

/* ---- Direction ------------------------------------------------------- */

/* Logical properties cover the mirrored sides; only the code blocks, which are
   pinned to LTR above, need their alignment restored. */
[dir="rtl"] pre { text-align: right; }
[dir="rtl"] pre, [dir="rtl"] code, [dir="rtl"] kbd { direction: ltr; }

/* ---- Narrow panes ---------------------------------------------------- */

@media (max-width: 520px) {
  body { padding: 10px 12px 18px; }
  .cards { grid-template-columns: 1fr; }
  h1 { font-size: 15px; }
  h2 { font-size: 13px; }
}

@media print {
  body { max-width: none; color: #000; background: #fff; }
  .card, .note, .warning, pre, th { box-shadow: none; }
}
