/* Binary translator. The top part is the shared paper-and-ink look of the other sections (copied from
   ../morse-code/styles.css: header, intro, tabs, buttons, article, footer); the translator and the ASCII table are at the bottom. */
:root {
  --paper: #faf8f2;
  --ink: #292d28;
  --muted: #697064;
  --line: #dfdfd3;
  --accent: #bd5f3e;
  --teal: #24878b;
  --pad: #fffdf8;
  --dot: #d5d3c4;
  --ink-mark: #bd5f3e;
  --display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1d1a; --ink: #ecebe3; --muted: #a3a898; --line: #3a3d36;
    --accent: #e27f5a; --teal: #58b9bd; --pad: #232621; --dot: #3d4138; --ink-mark: #e27f5a;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1d1a; --ink: #ecebe3; --muted: #a3a898; --line: #3a3d36;
  --accent: #e27f5a; --teal: #58b9bd; --pad: #232621; --dot: #3d4138; --ink-mark: #e27f5a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }
.wrap { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 0; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.crumbs { flex: 1; color: var(--muted); font-size: 15px; min-width: 0; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 8px; color: var(--line); }
.crumbs [aria-current] { color: var(--ink); }
.theme-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; display: grid; place-items: center; cursor: pointer;
}
.theme-btn:hover { border-color: var(--ink); }
.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.langs { display: flex; gap: 2px; }
.langs a { padding: 5px 8px; border-radius: 999px; font-size: 13px; font-weight: 700; letter-spacing: .03em; color: var(--muted); text-decoration: none; }
.langs a:hover { color: var(--ink); }
.langs a[aria-current] { color: var(--ink); background: var(--line); }

/* ---------- intro ---------- */
.intro { padding: 34px 0 22px; }
.intro h1 {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: clamp(40px, 6.4vw, 68px); line-height: 1.02; letter-spacing: -0.02em;
}
.lede { margin: 12px 0 0; font-size: 18px; color: var(--muted); max-width: 58ch; }

.durations { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.durations a {
  padding: 7px 16px; border: 1.5px solid var(--line); border-radius: 999px;
  text-decoration: none; font-size: 15px; color: var(--muted);
}
.durations a:hover { border-color: var(--ink); color: var(--ink); }
.durations a[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 600; }

.mode-switch { display: inline-flex; margin: 0 0 18px; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.mode-switch button { border: 0; background: transparent; padding: 8px 18px; cursor: pointer; font-weight: 600; }
.mode-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.stop-row { margin: 14px 0 0; min-height: 0; }
.stop-row:has([hidden]) { margin: 0; }

.challenge {
  margin: 0 0 20px; padding: 12px 16px; border-left: 4px solid var(--accent);
  background: var(--pad); font-weight: 600;
}

.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; }
.btn {
  padding: 11px 22px; border-radius: 999px; border: 1.5px solid var(--ink);
  background: transparent; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
/* ---------- article ---------- */
.prose { max-width: 70ch; margin: 56px 0 0; font-size: 17px; line-height: 1.7; }
.prose h2 { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1.2; margin: 44px 0 10px; letter-spacing: -0.01em; }
.prose h3 { font-size: 19px; margin: 26px 0 6px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent); }
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; margin: 0 0 16px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 9px 12px 9px 0; text-align: left; vertical-align: top; }
.prose th { border-bottom: 2px solid var(--ink); font-weight: 700; }
.prose td:first-child { font-weight: 700; white-space: nowrap; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq-answer { padding: 8px 0 0; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { margin-top: 64px; padding: 22px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.site-footer a { text-decoration: none; color: var(--ink); }
.site-footer a:hover { color: var(--accent); }
.site-footer a[aria-current] { color: var(--muted); }
.site-footer .footer-site { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.site-footer p { margin: 10px 0 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0 0; }
.toolbar .label { color: var(--muted); font-size: 15px; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }


/* ---------- small screens (shared) ---------- */
@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }
  .site-header { gap: 12px; padding: 14px 0; }
  .crumbs { display: none; }
  .brand { flex: 1; }
  .intro { padding: 24px 0 16px; }
  .lede { font-size: 16px; }
  .durations { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; }
  .durations::-webkit-scrollbar { display: none; }
  .durations a { white-space: nowrap; flex: none; }
  .prose { font-size: 16px; margin-top: 40px; }
  .prose h2 { font-size: 23px; }
  .prose table { display: block; overflow-x: auto; }
}


/* ---------- translator ---------- */
.bt-tool { margin: 6px 0 0; }
.bt-formats { display: inline-flex; flex-wrap: wrap; gap: 0; margin: 0 0 16px; padding: 3px; border: 1.5px solid var(--line); border-radius: 999px; }
.bt-formats legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bt-formats label { position: relative; cursor: pointer; }
.bt-formats input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.bt-formats span { display: block; padding: 7px 16px; border-radius: 999px; font-size: 15px; color: var(--muted); }
.bt-formats input:checked + span { background: var(--ink); color: var(--paper); font-weight: 600; }
.bt-formats input:focus-visible + span { outline: 3px solid var(--teal); outline-offset: 1px; }
.bt-panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.bt-pane-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.bt-pane-head label { flex: 1; font-weight: 700; }
.bt-mini { border: 1.5px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 12px; font-size: 14px; cursor: pointer; color: var(--ink); }
.bt-mini:hover { border-color: var(--ink); }
.bt-pane textarea {
  display: block; width: 100%; min-height: 170px; resize: vertical; padding: 14px 16px;
  border: 2px solid var(--ink); border-radius: 16px; background: var(--pad); color: var(--ink);
  font: 18px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.bt-pane textarea:focus { outline: 3px solid var(--teal); outline-offset: 2px; }
.bt-pane textarea.bt-code-box { font: 600 17px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.bt-check { display: inline-flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: 15px; cursor: pointer; }
.bt-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.bt-check:has(input:disabled) { color: var(--muted); cursor: default; }
.bt-note { min-height: 1.5em; margin: 6px 0 0; color: var(--accent); font-size: 15px; }
.bt-breakdown { margin: 14px 0 0; padding: 18px; border: 1.5px solid var(--line); border-radius: 20px; }
.bt-breakdown h2 { margin: 0 0 12px; font: 800 20px/1.2 var(--display); }
.bt-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.bt-chips li { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--pad); min-width: 0; }
.bt-chips b { font: 800 24px/1.1 var(--display); overflow-wrap: anywhere; }
.bt-chips li.is-named b { font-size: 15px; line-height: 1.6; color: var(--muted); }
.bt-chips code { font: 600 15px/1.35 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .04em; }
.bt-chips small { font-size: 13px; color: var(--muted); }
.bt-chips:empty::before { content: "Type something to see each character's code."; color: var(--muted); font-size: 15px; }
.bt-more { margin: 10px 0 0; color: var(--muted); font-size: 15px; }

/* ---------- ASCII table ---------- */
.bt-table-top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.bt-find { display: flex; align-items: center; gap: 10px; flex: 1 1 260px; max-width: 420px; font-weight: 700; }
.bt-find input {
  flex: 1; min-width: 0; padding: 10px 14px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--pad); color: var(--ink); font: 16px/1.3 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.bt-find input:focus { outline: 3px solid var(--teal); outline-offset: 2px; }
.bt-ascii { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; align-items: start; margin: 6px 0 0; }
.bt-ascii.is-filtered { grid-template-columns: repeat(auto-fill, minmax(230px, 340px)); }
.bt-table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.bt-table[hidden] { display: none; }
.bt-table th { padding: 6px 6px; border-bottom: 2px solid var(--ink); text-align: left; font-size: 13px; color: var(--muted); }
.bt-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.bt-table td code { font: 500 14px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.bt-table td:last-child { font-weight: 700; font-size: 16px; }
.bt-table tr.is-ctrl td { background: color-mix(in srgb, var(--line) 45%, transparent); }
.bt-table tr.is-ctrl td:last-child { font: 600 12px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); }
.bt-legend { display: flex; gap: 10px; align-items: baseline; margin: 14px 0 0; color: var(--muted); font-size: 15px; }
.bt-print-key { display: none; }
.bt-swatch { flex: none; width: 14px; height: 14px; border-radius: 3px; background: color-mix(in srgb, var(--line) 80%, transparent); transform: translateY(2px); }

@media (max-width: 760px) {
  .bt-panes { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .bt-pane textarea { min-height: 120px; }
  .bt-breakdown { padding: 14px; }
  .bt-chips { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
  .bt-chips li { padding: 8px 9px; }
  .bt-chips b { font-size: 21px; }
  .bt-chips code { font-size: 13.5px; letter-spacing: 0; }
  .bt-chips small { font-size: 12px; }
  .bt-formats span { padding: 7px 12px; }
}

/* The printed ASCII table: the four columns on one page. */
@page { margin: 10mm; }
@media print {
  body[data-tool="table"] .site-header, body[data-tool="table"] .intro, body[data-tool="table"] .durations,
  body[data-tool="table"] .bt-table-top, body[data-tool="table"] .bt-note, body[data-tool="table"] .prose,
  body[data-tool="table"] .site-footer { display: none !important; }
  body[data-tool="table"] { background: #fff; color: #000; }
  .wrap { width: auto; }
  .bt-ascii { grid-template-columns: repeat(4, 1fr); gap: 4mm; }
  .bt-ascii::before { content: "ASCII table \00B7  pastimearcade.com/binary-translator/ascii-table/"; grid-column: 1 / -1; font: 700 13px/1.2 system-ui, sans-serif; }
  .bt-table { font-size: 9.5px; }
  .bt-table th { font-size: 8.5px; padding: 2px 3px; color: #000; border-bottom-color: #000; }
  .bt-table td { padding: 1.6px 3px; border-bottom-color: #bbb; }
  .bt-table td code { font-size: 9px; }
  .bt-table td:last-child { font-size: 10.5px; }
  .bt-table tr.is-ctrl td { background: #eee; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bt-table tr.is-ctrl td:last-child { font-size: 8px; color: #333; }
  .bt-legend { display: none; }
  .bt-print-key { display: block; columns: 3; column-gap: 6mm; margin: 4mm 0 0; padding: 3mm 0 0; border-top: 1px solid #000; list-style: none; font-size: 8.5px; line-height: 1.55; }
  .bt-print-key::before { content: "Control characters (shaded)"; display: block; font: 700 10px/1.4 system-ui, sans-serif; column-span: all; margin-bottom: 1mm; }
  .bt-print-key b { display: inline-block; width: 3.4em; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
}
