/* SavePort — base.css
 * Generic/minimum styles only. Feature styling lives in extension
 * stylesheets (mod-*.css).
 *
 * Design direction (v0.12.0 styling pass): SavePort is a byte-level
 * save-file inspection and editing tool for retro handheld
 * cartridges. The visual language is that of a precision diagnostic
 * instrument, not a consumer app: a calm workbench ground, ink-dark
 * text, one disciplined phosphor-teal accent (a nod to terminal and
 * oscilloscope readouts), an amber status colour for warnings, and
 * monospace treated as a first-class face because the data — IDs,
 * offsets, checksums, counts — IS the content and must read as
 * exact. Cards are labelled panels; the validation report is a
 * status rail. Boldness is spent there and nowhere else.
 *
 * Constraints honoured: no web fonts (zero external requests), no
 * build step, system stacks only. Structure and accessibility
 * (visible focus, reduced motion, screen-reader text) are unchanged
 * from the placeholder grade — only values and a few panel details
 * were added.
 */

:root {
  /* Workbench palette (4 core + status). */
  --sp-bg: #e8eae5;           /* desk: faintly warm cool-grey */
  --sp-surface: #fbfcfa;      /* panel face: cool paper white */
  --sp-surface-2: #f0f2ee;    /* recessed surface (log, inputs) */
  --sp-ink: #16211f;          /* near-black with a green undertone */
  --sp-ink-soft: #5a655f;     /* secondary text */
  --sp-line: #ccd2cb;         /* hairlines */
  --sp-line-strong: #aab3aa;  /* emphasised hairlines */
  --sp-accent: #0f6d63;       /* phosphor teal, deepened from placeholder */
  --sp-accent-ink: #0a4f47;   /* accent text on light */
  --sp-accent-wash: #e2efec;  /* accent tint for hovers/fills */
  --sp-warn: #9a6a00;         /* status amber */
  --sp-warn-wash: #f6edd6;
  --sp-danger: #9c2f2c;       /* status red */
  --sp-ok: #1f6d3a;           /* status green */

  --sp-radius: 5px;
  --sp-gap: 1.1rem;
  --sp-max: 54rem;

  /* Type: system display/body stack + a real monospace data face. */
  --sp-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sp-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", "Consolas", "Liberation Mono", monospace;

  font-size: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--sp-bg);
  color: var(--sp-ink);
  font-family: var(--sp-sans);
  line-height: 1.55;
  /* faint engineering grid on the desk, well below the panels */
  background-image:
    linear-gradient(var(--sp-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--sp-line) 1px, transparent 1px);
  background-size: 28px 28px, 28px 28px;
  background-position: -1px -1px, -1px -1px;
}

#app {
  max-width: var(--sp-max);
  margin: 0 auto;
  padding: calc(var(--sp-gap) * 1.4) var(--sp-gap);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: var(--sp-gap);
}

a { color: var(--sp-accent-ink); text-underline-offset: 2px; }
a:hover { color: var(--sp-accent); }

h1, h2, h3 {
  line-height: 1.15;
  margin: 0 0 .5em;
  letter-spacing: -0.011em;
}
h1 { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; }
h2 { font-size: 1.18rem; font-weight: 620; }
h3 { font-size: 1rem; font-weight: 620; color: var(--sp-ink); }
p  { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }

/* ---------- controls ---------- */

button {
  font: inherit;
  font-weight: 550;
  padding: .5em 1.05em;
  border: 1px solid var(--sp-line-strong);
  border-radius: var(--sp-radius);
  background: var(--sp-surface);
  color: var(--sp-ink);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
button:hover { background: var(--sp-surface-2); border-color: var(--sp-ink-soft); }
button.primary {
  background: var(--sp-accent);
  border-color: var(--sp-accent);
  color: #fff;
}
button.primary:hover { background: var(--sp-accent-ink); border-color: var(--sp-accent-ink); }
button:disabled { opacity: .5; cursor: not-allowed; }

input[type="text"],
input[type="number"] {
  font: inherit;
  padding: .38em .55em;
  border: 1px solid var(--sp-line-strong);
  border-radius: var(--sp-radius);
  background: var(--sp-surface-2);
  color: var(--sp-ink);
}
/* Numeric and text edit fields carry data: set them in the data face
 * so values read as exact, and align numbers on their digits. */
input[type="number"] { font-family: var(--sp-mono); font-variant-numeric: tabular-nums; }
input[type="text"]   { font-family: var(--sp-mono); }
input:focus { background: var(--sp-surface); }

:focus-visible {
  outline: 3px solid var(--sp-accent);
  outline-offset: 2px;
}

/* ---------- header / footer ---------- */

header.sp-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-gap);
  border-bottom: 2px solid var(--sp-ink);
  padding-bottom: .6rem;
  flex-wrap: wrap;
}
.sp-brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--sp-ink);
  display: inline-flex;
  align-items: baseline;
  gap: .5ch;
}
/* Wordmark tell: a small square echoing the tool's status readouts. */
.sp-brand::before {
  content: "\25A0"; /* square */
  color: var(--sp-accent);
  font-size: .7em;
  transform: translateY(-0.15em);
}
.sp-nav { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .95rem; }

main.sp-main { flex: 1; }

footer.sp-footer {
  border-top: 1px solid var(--sp-line-strong);
  padding-top: .6rem;
  font-size: .82rem;
  color: var(--sp-ink-soft);
}
footer.sp-footer nav { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .35rem; }
footer.sp-footer p:last-child { font-family: var(--sp-mono); font-size: .78rem; }

/* ---------- panels (cards) ---------- */

.sp-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-line-strong);
  border-radius: var(--sp-radius);
  padding: var(--sp-gap);
}
/* The card heading gets a hairline underscore, tying panels together
 * without heavy chrome. */
.sp-card > h2:first-child {
  padding-bottom: .5rem;
  margin-bottom: .8rem;
  border-bottom: 1px solid var(--sp-line);
}

.sp-muted { color: var(--sp-ink-soft); font-size: .9rem; }

/* ---------- drop zone (the hero action) ---------- */

.sp-dropzone {
  border: 2px dashed var(--sp-line-strong);
  border-top: 3px solid var(--sp-accent);
  border-radius: var(--sp-radius);
  padding: 3rem 1rem;
  text-align: center;
  background:
    radial-gradient(130% 110% at 50% 0%, var(--sp-surface) 38%, var(--sp-surface-2) 100%);
  transition: border-color .15s ease, background .15s ease;
}
.sp-dropzone h2 { border: 0; padding: 0; margin-bottom: .35rem; font-size: 1.3rem; }
.sp-dropzone label { display: inline-block; margin: .4rem 0 .9rem; }
.sp-dropzone.is-over {
  border-color: var(--sp-accent);
  background: var(--sp-accent-wash);
}
.sp-dropzone input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- status log (readout) ---------- */

.sp-log {
  list-style: none;
  margin: 0;
  padding: .25rem .6rem;
  background: var(--sp-surface-2);
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-radius);
  font-family: var(--sp-mono);
  font-size: .82rem;
}
.sp-log li {
  padding: .2rem 0 .2rem 1.1rem;
  border-bottom: 1px dotted var(--sp-line);
  position: relative;
}
.sp-log li:last-child { border-bottom: 0; }
/* prompt glyph, quietly */
.sp-log li::before {
  content: "\203A"; /* > */
  position: absolute;
  left: 0;
  color: var(--sp-ink-soft);
}
.sp-log li.is-error { color: var(--sp-danger); }
.sp-log li.is-error::before { content: "\2715"; color: var(--sp-danger); }
.sp-log li.is-ok    { color: var(--sp-ok); }
.sp-log li.is-ok::before { content: "\2713"; color: var(--sp-ok); }

/* ---------- data tables ---------- */

.sp-table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.sp-table th, .sp-table td {
  text-align: left;
  padding: .4rem .65rem;
  border-bottom: 1px solid var(--sp-line);
}
.sp-table thead th {
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--sp-ink-soft);
  border-bottom: 1px solid var(--sp-line-strong);
}
.sp-table tbody tr:last-child td { border-bottom: 0; }
/* Numeric/data cells align on digits in the data face. */
.sp-table td.g3-num { font-family: var(--sp-mono); font-variant-numeric: tabular-nums; }

/* ---------- fact list (spec readout) ---------- */

.sp-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .3rem 1.25rem;
  margin: 0;
}
.sp-facts dt {
  color: var(--sp-ink-soft);
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  align-self: baseline;
  padding-top: .1rem;
}
.sp-facts dd { margin: 0; font-family: var(--sp-mono); }

/* ---------- validation report (the signature: a status rail) ---------- */

.sp-checks {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: .9rem;
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-radius);
  overflow: hidden;
}
.sp-checks li {
  padding: .4rem .7rem .4rem 2.2rem;
  border-bottom: 1px solid var(--sp-line);
  position: relative;
  background: var(--sp-surface);
}
.sp-checks li:last-child { border-bottom: 0; }
/* status glyph sits in a tinted gutter, like an LED beside each line */
.sp-checks li::before {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sp-mono);
  font-weight: 700;
  border-right: 1px solid var(--sp-line);
}
.sp-checks li.is-pass::before { content: "\2713"; color: var(--sp-ok);     background: #e7f1ea; }
.sp-checks li.is-warn::before { content: "!";      color: var(--sp-warn);   background: var(--sp-warn-wash); }
.sp-checks li.is-fail::before { content: "\2715"; color: var(--sp-danger); background: #f3e1e0; }
.sp-checks li.is-warn { color: #6b4e00; background: #fdfaf2; }
.sp-checks li.is-fail { color: var(--sp-danger); background: #fbf2f1; }

/* ---------- motion / a11y ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- narrow screens ---------- */

@media (max-width: 34rem) {
  #app { padding: var(--sp-gap) .8rem; }
  .sp-facts { grid-template-columns: 1fr; gap: .15rem .5rem; }
  .sp-facts dt { padding-top: .5rem; }
  .sp-facts dt:first-of-type { padding-top: 0; }
  h1 { font-size: 1.45rem; }
}
