/* physel.com: one stylesheet for every page.
   Hand-written. No web fonts, no frameworks, nothing loaded from other sites. */

:root {
  color-scheme: light dark;

  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1b1c1e;
  --muted: #53575d;
  --line: #dcd9d1;
  --accent: #1d5a85;
  --accent-hover: #123d5c;
  --brick: #b0482f;
  --todo-bg: #fff1a8;
  --todo-ink: #3d3200;
  --focus: #1d5a85;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --text: 42rem;
  --wide: 72rem;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #191b1e;
    --ink: #ecebe7;
    --muted: #a9adb3;
    --line: #2d3035;
    --accent: #8ec5ee;
    --accent-hover: #c0e0f8;
    --brick: #d9735a;
    --todo-bg: #4a3d00;
    --todo-ink: #fff3b0;
    --focus: #8ec5ee;
    --shadow: none;
  }
}

@media (min-width: 760px) {
  :root { --gutter: 32px; }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--font);
  overflow-wrap: break-word;
}

img { display: block; max-width: 100%; height: auto; }

/* Elements styled with a display value would otherwise ignore the hidden attribute. */
[hidden] { display: none !important; }

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-hover); }
a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.25rem, 6vw, 3.5rem); margin: 0 0 0.75rem; font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); margin: 0 0 1rem; font-weight: 650; }
h3 { font-size: 1.125rem; margin: 0 0 0.4rem; font-weight: 650; }

p { margin: 0 0 1rem; }
ul { margin: 0 0 1rem; padding-left: 1.25rem; }
li + li { margin-top: 0.4rem; }

/* Skip link: hidden until it has focus */

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  color: var(--accent);
  border: 2px solid var(--focus);
  border-radius: 4px;
}
.skip:focus { left: var(--gutter); top: 0.5rem; }

/* Layout */

/* Side padding only, so a section's own top padding is not reset (sections are also .wrap). */
.wrap {
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.text {
  max-width: var(--text);
}

section {
  padding-top: 3.5rem;
}

/* Header */

.site-header { border-bottom: 1px solid var(--line); }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
}
.brand:hover { color: var(--ink); }

.mark { width: 28px; height: 28px; flex: none; }
.mark-body { fill: var(--brick); }
.mark-sheen { fill: #ffffff; fill-opacity: 0.22; }

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}
.site-nav li + li { margin-top: 0; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--ink); text-decoration: underline; }

/* Intro */

.intro { padding-top: 3rem; }

.lede {
  font-size: clamp(1.2rem, 2.6vw, 1.45rem);
  line-height: 1.45;
  margin-bottom: 1rem;
}

.intro-short { padding-top: 2rem; }
.intro-short h1 { margin-bottom: 0.5rem; }
.intro-short .lede { margin-bottom: 0.5rem; }

/* The demo's fallback picture links to its full-size file, so phones can open the detail. */
.full { display: block; border-radius: 6px; }

/* Tables */

.table-wrap {
  max-width: var(--text);
  overflow-x: auto;
  margin: 0 0 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.5;
}

caption {
  text-align: left;
  font-weight: 650;
  padding-bottom: 0.5rem;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.75rem 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
thead th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 650;
  border-bottom-width: 2px;
}
tbody th { font-weight: 650; min-width: 8rem; }
td:last-child, th:last-child { padding-right: 0; }

.nowrap { white-space: nowrap; }

/* Lists with a rule between items */

.list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
.list li {
  padding: 0.7rem 0 0.7rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.975rem;
}
.list li + li { margin-top: 0; }
.list strong { display: block; }

.note {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Buttons (links styled as buttons) */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}

.button {
  display: inline-block;
  padding: 0.6rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}
.button-main {
  background: var(--accent);
  color: var(--bg);
}
.button-main:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
}

/* Placeholders the owner fills in before going live */

mark.todo {
  background: var(--todo-bg);
  color: var(--todo-ink);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-weight: 600;
}

/* Footer */

.site-footer {
  margin-top: 4.5rem;
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer p { max-width: var(--text); margin-bottom: 0.5rem; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }

/* Plain pages (privacy, 404) */

.page { padding-top: 3rem; }
.page h2 { font-size: 1.35rem; margin-top: 2.5rem; }

/* Text for screen readers only */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The demo (index.html) */

:root {
  --f-pos: #dce8f5;
  --f-rot: #e3e0f4;
  --f-size: #dcefe4;
  --f-shape: #f6e6c9;
  --f-mat: #f3dcd4;
  --f-look: #ece9e2;
  --f-flags: #e2ecef;
  --f-state: #f9e1ef;
  --f-word: #e9e9e9;
  --flash: #ffe066;
}

@media (prefers-color-scheme: dark) {
  :root {
    --f-pos: #1f3247;
    --f-rot: #2c2846;
    --f-size: #1d3a2a;
    --f-shape: #43351a;
    --f-mat: #452a22;
    --f-look: #2c2b28;
    --f-flags: #1f3236;
    --f-state: #45233a;
    --f-word: #26272a;
    --flash: #7a6400;
  }
}

.demo { padding-top: 1.5rem; }

.scene-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.chip, .small-button {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
}
.chip {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.95rem;
}
.small-button {
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  font-size: 0.875rem;
}
.chip:hover, .small-button:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}
.chip:focus-visible, .small-button:focus-visible, .demo input:focus-visible, .demo select:focus-visible, .button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* The picture across the page, the dials under it. */
.stage {
  display: grid;
  gap: 1.25rem;
}

.canvas-box { position: relative; }

#view {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #c9d6e4;
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
}
#view:active { cursor: grabbing; }
@media (min-width: 760px) {
  #view { aspect-ratio: 16 / 9; }
}
#view:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.no-webgl {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.no-webgl img { margin-top: 0.75rem; border-radius: 6px; }

.viewer-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.25rem;
  margin-top: 0.85rem;
}
.tool-buttons { display: inline-flex; gap: 0.5rem; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  cursor: pointer;
}
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); margin: 0; }

.hint {
  margin: 0.6rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.status-line {
  min-height: 1.6em;
  font-size: 0.95rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.1rem 0.5rem;
}
.panel h3 { margin-bottom: 0.2rem; }
.panel-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}
.together { margin: 0 0 0.9rem; }

/* The dial groups flow down up to three columns. */
.panel-body { columns: 3 17rem; column-gap: 2.25rem; }
.panel-body > fieldset, .panel-body > .facts { break-inside: avoid; }

.panel fieldset {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 0.75rem 0 0.4rem;
  min-width: 0;
}
.panel legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 0.5rem;
  font-weight: 650;
  font-size: 0.95rem;
}
.panel legend + * { clear: both; }
.legend-note {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: 0.35rem;
}

.presets { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.dial {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 0 0.75rem;
  margin-bottom: 0.45rem;
}
.dial label { font-size: 0.92rem; }
.dial output {
  justify-self: end;
  text-align: right;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.dial input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0.15rem 0 0;
  accent-color: var(--accent);
}
.dial input.ignored { opacity: 0.45; }
.dial-select { align-items: center; }
.dial select {
  justify-self: end;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
}
.dial-inline {
  grid-template-columns: auto minmax(8rem, 14rem) auto;
  align-items: center;
  margin: 0;
}
.dial-inline input[type="range"] { grid-column: auto; margin: 0; }

.dial-help {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0 0 0.6rem;
}

.facts {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}
.facts dl { margin: 0 0 0.75rem; display: grid; gap: 0.3rem; }
.facts dl div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.5rem; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts .button { cursor: pointer; font: inherit; font-weight: 600; margin-bottom: 0.6rem; }

.record-box { margin-top: 2rem; }
.record-box h3 { font-size: 1.25rem; }

.bytes {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 3px;
  max-width: 64rem;
  margin: 0.75rem 0 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}
@media (min-width: 600px) {
  .bytes { grid-template-columns: repeat(16, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .bytes { grid-template-columns: repeat(32, minmax(0, 1fr)); font-size: 0.8rem; }
}
.byte {
  padding: 0.4rem 0;
  text-align: center;
  border-radius: 3px;
  color: var(--ink);
}
.f-pos { background: var(--f-pos); }
.f-rot { background: var(--f-rot); }
.f-size { background: var(--f-size); }
.f-shape { background: var(--f-shape); }
.f-mat { background: var(--f-mat); }
.f-look { background: var(--f-look); }
.f-flags { background: var(--f-flags); }
.f-state { background: var(--f-state); }
.f-word { background: var(--f-word); }

@media (prefers-reduced-motion: no-preference) {
  .byte.flash { animation: flash 0.9s ease-out; }
}
@keyframes flash {
  from { box-shadow: inset 0 0 0 2px var(--accent); background: var(--flash); }
}

.record-table { max-width: 64rem; }
@media (min-width: 760px) {
  .record-table td:nth-child(2) { white-space: nowrap; }
}
.swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  margin-right: 0.45rem;
  vertical-align: -0.05rem;
}

/* Fold-out sections (the demo's 32 bytes, what the demo leaves out) */

details > summary {
  cursor: pointer;
  font-weight: 650;
  width: fit-content;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
details > summary:hover { border-color: var(--accent); }
details > summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
details[open] > summary { margin-bottom: 0.9rem; }
.left-out { margin-top: 1.5rem; }

/* White papers page */


.papers {
  display: grid;
  gap: 0.75rem;
  max-width: 52rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.papers li + li { margin-top: 0; }

.paper {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.15rem 0.85rem;
}
.paper:hover { border-color: var(--accent); }
.page h1 + .papers { margin-top: 1.5rem; }
.paper h2 { font-size: 1.1rem; margin: 0 0 0.35rem; }
.paper h2 a { text-decoration: none; }
.paper h2 a:hover { text-decoration: underline; }
/* The whole card opens the paper. */
.paper h2 a::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
}
.paper h2 a:focus-visible { outline: none; }
.paper h2 a:focus-visible::before {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.paper h2 a::after {
  content: "PDF";
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  vertical-align: 0.15em;
  text-decoration: none;
}
.paper p { margin: 0 0 0.35rem; font-size: 0.975rem; }
.paper-meta { color: var(--muted); font-size: 0.85rem !important; }
.papers-licence { margin-top: 1.25rem; }
