/* core.css: base for the SMB demo kit. System fonts only, no images, no animation.
   Colour tokens are all hex so tools/contrast.py can check every pair in light and dark.
   SKIN CONTRACT: load a skin after this file. A skin sets --accent, --accent-contrast, --accent-soft and
   --accent-soft-text in :root and again inside @media (prefers-color-scheme: dark), plus --heading-weight,
   and then must pass tools/contrast.py. Setting a token only in :root would override the dark value here.
   HTML NOTES: a placeholder is never the only label (use a visible <label>). Lists with list-style: none
   (.nav-list, .lang-switch, checklist lists) need role="list" so VoiceOver keeps the list semantics.
   Scrolling tables: <div class="table-wrap" role="region" aria-labelledby="cap-id" tabindex="0">, where
   cap-id is the id of an element that names the table (a heading or the caption), or the same div with
   aria-label="..." in place of aria-labelledby. Either way the region needs an accessible name. The docs
   pages use both: aria-labelledby pointing at a heading id on some pages, aria-label on others.
   <main> carries tabindex="-1" (skip link target).
   A link used as a disabled control must have its href removed. Language switch markup and the
   bilingual page contract: see core/lang-toggle.js. */
:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --heading-weight: 700;
  --header-h: 4.5rem;
  --bg: #ffffff;
  --surface: #f3f5f4;
  --text: #17201c;
  --muted: #4a5753;
  --border: #c9d0cc;
  --border-strong: #6f7873;
  --focus: #0b4fb3;
  --error: #b3261e;
  --warn-bg: #fff1c9;
  --warn-text: #5c3d00;
  --mock-bg: #e6eae8;
  --mock-text: #17201c;
  --accent: #2b4a8c;
  --accent-contrast: #ffffff;
  --accent-soft: #dfe7f7;
  --accent-soft-text: #1b2f5c;
  --link: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1c2220;
    --text: #eef2f0;
    --muted: #b4beb9;
    --border: #3a4440;
    --border-strong: #8a9792;
    --focus: #8ab4ff;
    --error: #ff9d94;
    --warn-bg: #3a2d08;
    --warn-text: #ffd98a;
    --mock-bg: #2a3330;
    --mock-text: #eef2f0;
    --accent: #8fb0f0;
    --accent-contrast: #0c1220;
    --accent-soft: #1e2c4d;
    --accent-soft-text: #d6e2ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--header-h) + 1rem); scroll-padding-bottom: 1rem; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.125rem/1.5 var(--font);
  overflow-wrap: break-word;
}
.wrap { width: min(100% - 2rem, 72rem); margin-inline: auto; }
main { display: block; padding-block: 1.5rem 3rem; }
p, li, dd, blockquote, .measure { max-width: 65ch; }
p, ul, ol, dl, blockquote, pre, table, form { margin-block: 0 1em; }
ul, ol { padding-inline-start: 1.5em; }
li + li { margin-block-start: .35em; }
h1, h2, h3, h4 { font-weight: var(--heading-weight); line-height: 1.25; margin-block: 1.5em .5em; text-wrap: balance; }
h1 { font-size: 2rem; margin-block-start: 0; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
small, .small { font-size: .9375rem; }
.muted { color: var(--muted); }
img, svg, video { max-width: 100%; height: auto; }
code, pre, kbd { font-family: var(--mono); font-size: .95em; }
pre { overflow-x: auto; padding: 1rem; background: var(--surface); border: 1px solid var(--border); white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--border-strong); margin-block: 2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Span mode without JavaScript: both languages show, so separate each pair (lang-toggle.js adds lang-js to html) */
html:not(.lang-js) span[data-lang="es"]::before { content: " / "; }

/* Links: always underlined, never colour alone */
a { color: var(--link); text-decoration: underline; text-decoration-thickness: max(1px, .08em); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: .2em; }

/* Focus ring: 3px outline (survives forced colours), offset so it sits on the page, never removed */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Skip link */
.skip-link {
  position: absolute; inset-inline-start: .5rem; inset-block-start: .5rem; z-index: 100;
  padding: .75rem 1rem; min-height: 44px; background: var(--text); color: var(--bg); font-weight: 700;
  transform: translateY(-300%);
}
.skip-link:focus { transform: none; }

/* Header and footer; the header is static, so zoom and reflow never hide focus behind it */
.site-header { background: var(--bg); border-block-end: 1px solid var(--border-strong); padding-block: .75rem; }
.site-footer { border-block-start: 1px solid var(--border-strong); padding-block: 1.5rem; background: var(--surface); }
.site-header .wrap, .site-footer .wrap { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between; }
.nav-list { display: flex; flex-wrap: wrap; gap: .25rem 1rem; list-style: none; margin: 0; padding: 0; }
.nav-list li + li { margin: 0; }
.nav-list a { display: inline-block; padding-block: .5rem; }

/* Layout helpers */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: .5rem; padding: 1rem 1.25rem; }
.card > :first-child { margin-block-start: 0; }
.card > :last-child { margin-block-end: 0; }

/* Buttons: min size, never fixed width, never all caps */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; min-width: 44px; padding: .5rem 1.25rem;
  font: inherit; font-weight: 700; text-transform: none; text-decoration: none; text-align: center;
  background: var(--accent); color: var(--accent-contrast);
  border: 2px solid var(--accent); border-radius: .375rem; cursor: pointer;
}
.btn-secondary { background: var(--bg); color: var(--link); border-color: var(--border-strong); }
button[disabled], .btn[aria-disabled="true"] {
  background: var(--surface); color: var(--muted); border: 2px dashed var(--border-strong); cursor: not-allowed;
}

/* Language switch: two links or two buttons; the current one has a text-visible state (check mark and bold).
   The container carries both .lang-switch (this CSS) and data-lang-switch (lang-toggle.js). */
.lang-switch, [data-lang-switch] { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; padding: 0; list-style: none; }
.lang-switch a, .lang-switch button {
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: .5rem 1rem;
  font: inherit; text-transform: none; background: var(--bg); color: var(--link);
  border: 2px solid var(--border-strong); border-radius: .375rem; text-decoration: underline;
}
.lang-switch [aria-current]:not([aria-current="false"]), .lang-switch [aria-pressed="true"] {
  background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 700; text-decoration: none;
}
.lang-switch [aria-current]:not([aria-current="false"])::before, .lang-switch [aria-pressed="true"]::before {
  content: "\2713\00a0"; content: "\2713\00a0" / "";
}

/* Badges: always carry visible text, never colour alone */
.badge-invented, .badge-mock, .badge-draft-es {
  display: inline-block; padding: .125rem .625rem; border: 2px solid currentColor; border-radius: .25rem;
  font-size: .9375rem; font-weight: 700; line-height: 1.4; text-transform: none; vertical-align: baseline;
}
.badge-invented { background: var(--accent-soft); color: var(--accent-soft-text); }
.badge-mock { background: var(--mock-bg); color: var(--mock-text); }
.badge-draft-es { background: var(--warn-bg); color: var(--warn-text); }

/* Forms: visible labels, hint and error text, required marked in words */
form { max-width: 40rem; }
.field { margin-block: 0 1.5rem; }
label, legend { display: block; font-weight: 700; margin-block-end: .25rem; padding: 0; }
fieldset { border: 1px solid var(--border-strong); border-radius: .375rem; margin: 0 0 1.5rem; padding: 1rem; }
.req, .opt { font-weight: 400; color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: .9375rem; margin-block-end: .25rem; }
input, select, textarea {
  display: block; width: 100%; max-width: 100%; min-height: 44px; padding: .5rem .75rem;
  font: inherit; color: var(--text); background: var(--bg);
  border: 2px solid var(--border-strong); border-radius: .375rem;
}
textarea { min-height: 8rem; }
::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: max(24px, 1.5rem); height: max(24px, 1.5rem); min-height: 0; margin-inline-end: .5rem; vertical-align: middle; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error); border-width: 3px; }
.error {
  display: block; margin-block: .25rem 0; padding-inline-start: .75rem;
  border-inline-start: 4px solid var(--error); color: var(--error); font-weight: 700;
}
.error-prefix { font-weight: 700; }

/* Tables: caption on top, header cells scoped, cells wrap at any width */
table { border-collapse: collapse; width: 100%; }
caption { caption-side: top; text-align: start; font-weight: 700; padding-block: .5rem; }
th, td { border: 1px solid var(--border-strong); padding: .5rem .75rem; text-align: start; vertical-align: top; overflow-wrap: break-word; }
thead th { background: var(--surface); }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }

/* Motion: none by default; also switched off for anyone who asks */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Print: black on white, link addresses shown, no backgrounds */
@media print {
  body { font-size: 12pt; line-height: 1.4; }
  *, *::before, *::after { background: transparent !important; color: #000 !important; box-shadow: none !important; }
  a { text-decoration: underline; }
  a[href]:not([href^="#"]):not(.skip-link)::after { content: " (" attr(href) ")"; font-size: .85em; word-break: break-all; }
  .skip-link, .lang-switch, .no-print, button { display: none !important; }
  .site-header { position: static; }
  h1, h2, h3 { break-after: avoid; }
  tr, img, .card { break-inside: avoid; }
  thead { display: table-header-group; }
  .badge-invented, .badge-mock, .badge-draft-es, .card, th, td, input, select, textarea { border: 1px solid #000; }
}
