@font-face {
  font-family: "0xProto";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('/assets/fonts/0xProto-Regular.woff2') format('woff2');
}
@font-face {
  font-family: "0xProto";
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  src: url('/assets/fonts/0xProto-Italic.woff2') format('woff2');
}
@font-face {
  font-family: "0xProto";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('/assets/fonts/0xProto-Bold.woff2') format('woff2');
}

:root {
  --font: "0xProto", ui-monospace, monospace;
  --line: 1.5rem;
  --border: 2px;
  --stroke: 0.3px;

  --fg: #1a1a1a;
  --fg-dim: #888;
  --bg: #f6f4ee;
  --bg-alt: #e9e6dd;
  --accent: #b85c2e;

  --ok: #4a7c3a;
  --warn: #c08c1e;
  --bad: #b03030;

  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: var(--line);
  color: var(--fg);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #ebe7da;
    --fg-dim: #7a7466;
    --bg: #161412;
    --bg-alt: #221f1a;
    --accent: #e08a4e;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
* + * { margin-top: var(--line); }

html { display: flex; flex-direction: column; align-items: center; }
body {
  width: 100%;
  max-width: calc(min(80ch, round(down, 100%, 1ch)));
  padding: var(--line) 2ch;
  overflow-x: hidden;
}
@media (max-width: 480px) {
  :root { font-size: 14px; }
  body { padding: var(--line) 1ch; }
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--line);
  margin: calc(var(--line) * 2) 0 var(--line);
  -webkit-text-stroke: var(--stroke) currentColor;
}
h1 { font-size: 1.5rem; line-height: calc(var(--line) * 1.5); }
h2 { font-size: 1.15rem; }
h3, h4, h5, h6 { font-size: 1rem; }

strong, th, button, label, ol li::before, .subtitle {
  -webkit-text-stroke: var(--stroke) currentColor;
}

p { word-break: break-word; hyphens: auto; }
em, .subtitle { font-style: italic; color: var(--fg-dim); }

a, a:visited { color: var(--fg); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--fg-dim); }

hr { border: none; border-top: var(--border) solid currentColor; margin: var(--line) 0; }

img, video { display: block; width: 100%; object-fit: contain; overflow: hidden; }
img { font-style: italic; color: var(--fg-dim); }

pre { white-space: pre; overflow-x: auto; margin: var(--line) 0; }
pre, code { font-family: var(--font); }
code { background: var(--bg-alt); padding: 0 0.5ch; }
pre code { background: none; padding: 0; }

table {
  position: relative;
  top: calc(var(--line) / 2);
  width: calc(round(down, 100%, 1ch));
  border-collapse: collapse;
  margin: 0 0 calc(var(--line) * 2);
}
th, td {
  border: var(--border) solid var(--fg);
  padding:
    calc(var(--line) / 2)
    calc(1ch - var(--border) / 2)
    calc(var(--line) / 2 - var(--border));
  line-height: var(--line);
  vertical-align: top;
  text-align: left;
}
table tbody tr:first-child > * { padding-top: calc(var(--line) / 2 - var(--border)); }
.width-min { width: 0%; }
.width-auto { width: 100%; }
td time { white-space: nowrap; }

.header { table-layout: fixed; margin-bottom: calc(var(--line) * 2); }
.header h1 { margin: 0; }
.header tr:first-child td { text-align: left; }
.header-nav td {
  width: 20%;
  text-align: center;
  text-transform: uppercase;
}
.header-nav a { display: block; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-nav .active { background: var(--fg); color: var(--bg); }
.header-nav .active a { color: inherit; }
@media (max-width: 480px) {
  .header-nav td { font-size: .85rem; padding: calc(var(--line) / 2) .5ch; }
}

footer { margin-top: calc(var(--line) * 2); text-align: center; color: var(--fg-dim); }

ul, ol { margin: 0 0 var(--line); }
ul { list-style: square; padding-left: 2ch; }
ol { list-style: none; counter-reset: item; }
ol ul, ol ol, ul ol, ul ul { padding-left: 3ch; margin: 0; }
ol li::before { content: counters(item, ".") ". "; counter-increment: item; }
li { margin: 0; }
li::marker { line-height: 0; }

::-webkit-scrollbar { height: var(--line); }
::placeholder { color: var(--fg-dim); opacity: 1; }

input, button, textarea, select {
  font: inherit;
  font-weight: inherit;
  background: var(--bg);
  color: var(--fg);
  border: var(--border) solid currentColor;
  padding:
    calc(var(--line) / 2 - var(--border))
    calc(1ch - var(--border));
  height: calc(var(--line) * 2);
  line-height: normal;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}
input { width: calc(round(down, 100%, 1ch)); }
button { cursor: pointer; }
button:hover, .flow-button.active { background: var(--fg); color: var(--bg); }
button:active { transform: translate(1px, 1px); }
button:focus, input:focus, textarea:focus, select:focus {
  outline: var(--border) solid var(--fg);
  outline-offset: 0;
}
button::-moz-focus-inner { padding: 0; border: 0; }

select {
  padding-right: 2.5ch;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.4ch) 50%, calc(100% - .7ch) 50%;
  background-size: .7ch .7ch;
  background-repeat: no-repeat;
}

input[type=checkbox], input[type=radio] {
  display: inline-grid;
  place-content: center;
  vertical-align: top;
  width: 2ch;
  height: var(--line);
  cursor: pointer;
}
input[type=checkbox]:checked::before,
input[type=radio]:checked::before {
  content: "";
  width: 1ch;
  height: calc(var(--line) / 2);
  background: var(--fg);
}
input[type=radio], input[type=radio]::before { border-radius: 100%; }

label {
  display: block;
  width: calc(round(down, 100%, 1ch));
  line-height: var(--line);
}
label input, label select { width: 100%; }

progress {
  display: block;
  width: 100%;
  height: var(--line);
  border: var(--border) solid currentColor;
  background: var(--bg);
  appearance: none;
  -webkit-appearance: none;
}
progress::-webkit-progress-bar { background: var(--bg); }
progress::-webkit-progress-value { background: var(--fg); }
progress::-moz-progress-bar { background: var(--fg); }
progress.break-mode::-webkit-progress-value,
progress.flow-mode::-webkit-progress-value { background: var(--fg-dim); }
progress.break-mode::-moz-progress-bar,
progress.flow-mode::-moz-progress-bar { background: var(--fg-dim); }

.grid {
  --cells: 1;
  display: flex;
  gap: 1ch;
  width: calc(round(down, 100%, 1ch));
  margin-bottom: var(--line);
}
.grid > *, .grid > input {
  flex: 1 1 calc(round(down, (100% - 1ch * (var(--cells) - 1)) / var(--cells), 1ch));
  margin-top: 0;
}
.grid:has(> :nth-child(2)) { --cells: 2; }
.grid:has(> :nth-child(3)) { --cells: 3; }
.grid:has(> :nth-child(4)) { --cells: 4; }

.button-grid { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1ch; }
.button-grid > * { margin-top: 0; }

main.centered { text-align: center; }
main.centered form.grid, main.centered p { text-align: left; }

.data-table { table-layout: fixed; }
.data-table td { font-variant-numeric: tabular-nums; }

.heatmap { table-layout: fixed; }
.heatmap td {
  text-align: center;
  font-size: .8rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
  padding: calc(var(--line) / 2) 0;
}
.heatmap td[style*="transparent"] { background: var(--bg) !important; color: var(--fg); text-shadow: none; }

.clock { position: relative; width: 100%; height: calc(var(--line) * 6); margin-bottom: var(--line); }
.clock progress { width: 100%; height: 100%; }
.clock output {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  margin: 0; font-size: 2rem;
  color: var(--fg);
  -webkit-text-stroke: 4px var(--bg);
  paint-order: stroke fill;
  pointer-events: none;
}

.nback-grid {
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 1ch;
  width: min(100%, calc(var(--line) * 12));
  aspect-ratio: 1;
  margin: var(--line) auto;
}
.nback-grid > * { margin-top: 0; }
.nback-grid .cell {
  background: var(--bg-alt);
  border: var(--border) solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.nback-grid .cell.active { background: var(--fg); color: var(--bg); }

#score { display: block; }

.viewpoint { display: block; font-size: 2rem; margin: var(--line) 0; }
.viewpoint-correct { color: var(--ok); }
.viewpoint-incorrect { color: var(--bad); }

.temp-normal { color: var(--ok); }
.temp-warning { color: var(--warn); }
.temp-critical { color: var(--bad); }
