/* Legacy variable names, mapped onto the design tokens in tokens.css.
   Both themes resolve through the tokens, so there is no dark override here. */
:root {
  --page-bg: var(--bg);
  --page-text: var(--ink);
  --muted-text: var(--ink-muted);
  --content-bg: var(--bg);
  --surface-bg: var(--surface);
  --surface-subtle: var(--surface-raised);
  --primary-color: var(--accent-text);
  --primary-soft: var(--surface-raised);
  --link-color: var(--ink);
  --header-text-color: var(--ink);
  --flash-bg: var(--sun-soft);
  --flash-border: var(--ink);
  --flash-text: var(--ink);
  --input-bg: var(--surface);
  --input-text: var(--ink);
  --input-border: var(--ink);
  --button-bg: transparent;
  --button-text: var(--ink);
  --button-primary-bg: var(--ink);
  --button-primary-hover: var(--ink);
  --button-primary-text: var(--bg);
  --submit-bg: var(--action);
  --submit-text: var(--on-action);
  --danger-text: var(--signal);
  --enabled-text: var(--success);
  --disabled-text: var(--ink-muted);
  --app-img-bg: var(--screen);
  --app-img-border: var(--ink);
  --select-bg: var(--bg);
  --select-text: var(--ink);
  --select-border: var(--line-strong);
  --border-color: var(--ink);
  --post-about-text: var(--ink-muted);
  --shadow-color: transparent;
  --shadow-strong: transparent;
  --radius-sm: var(--radius-0);
  --radius-md: var(--radius-0);
  --radius-lg: var(--radius-0);
}

/* Element reset (what the pages used to get from W3.CSS). */
html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

button,
input,
select,
textarea,
optgroup {
  font: inherit;
  margin: 0;
}

img {
  border-style: none;
  vertical-align: middle;
}

small {
  font-size: 80%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 10px 0;
}

hr {
  margin: 20px 0;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

[hidden] {
  display: none !important;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/24px var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-sans);
  font-weight: 800;
  color: var(--header-text-color);
  text-wrap: balance;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.125rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h4 {
  font-size: 1rem;
  line-height: 1.3;
}

h5,
h6 {
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--header-text-color);
}

a {
  color: var(--link-color);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--accent-text);
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

hr {
  border: none;
  border-top: var(--border-hair) solid var(--line-strong);
}

code,
pre,
kbd {
  font-family: var(--font-mono);
}

.flash {
  margin: 0 0 var(--space-2);
  padding: 12px var(--space-2);
  background: var(--flash-bg);
  border: var(--border-pixel) solid var(--flash-border);
  border-radius: var(--radius-0);
  box-shadow: var(--shadow-pixel-sm);
  color: var(--flash-text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.post > header {
  display: flex;
  align-items: flex-end;
  font-size: 0.85em;
}

.post > header > div:first-of-type {
  flex: auto;
}

.post .about {
  color: var(--muted-text);
  font-style: italic;
}

.post .body {
  white-space: pre-line;
}

.content form {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.content label {
  font-weight: 700;
  margin-bottom: 0.4em;
  color: var(--page-text);
}

.content input,
.content button,
.content textarea,
.content select {
  background: var(--input-bg);
  color: var(--input-text);
  border: var(--border-pixel) solid var(--input-border);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.content input:hover,
.content textarea:hover,
.content select:hover {
  border-color: var(--ink);
}

.content input:focus,
.content textarea:focus,
.content select:focus,
.content button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--ink);
  box-shadow: none;
}

.content input:disabled,
.content textarea:disabled,
.content select:disabled {
  background: var(--surface-raised);
  color: var(--ink-muted);
  border-color: var(--line);
}

.content textarea {
  min-height: 10em;
  resize: vertical;
}

.content input[type="checkbox"],
.content input[type="radio"] {
  width: auto;
  margin: 0;
  padding: 0;
  background: initial;
  border: initial;
  appearance: auto;
  -webkit-appearance: auto;
  accent-color: var(--action);
  box-shadow: none;
}

.content input[type="range"] {
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--action);
}

.text-enabled {
  color: var(--enabled-text);
}

.text-disabled {
  color: var(--disabled-text);
}

/* LED previews: pixel art behind screen glass in a chunky ink frame. */
.app-img {
  position: relative;
  background: var(--app-img-bg);
  overflow: hidden;
  border: var(--border-bold) solid var(--app-img-border);
  border-radius: var(--radius-0);
}

.app-img img {
  aspect-ratio: 2 / 1;
  background: var(--app-img-bg);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  -webkit-mask-image: url('/dots');
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-image: url('/dots');
  mask-repeat: no-repeat;
  mask-size: contain;
  width: 100%;
  height: 100%;
}

.app-img.is-2x img {
  -webkit-mask-image: url('/dots?w=128&h=64&r=0.4');
  mask-image: url('/dots?w=128&h=64&r=0.4');
}

/* Square (64x64) panels. Without this the image is squashed into the 2:1 box
   the classic panels use. */
.app-img.is-square {
  aspect-ratio: 1 / 1;
}

.app-img.is-square img {
  aspect-ratio: 1 / 1;
  -webkit-mask-image: url('/dots?w=64&h=64');
  mask-image: url('/dots?w=64&h=64');
}

.skeleton-loader {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 15%, rgba(255, 255, 255, 0.18) 50%, transparent 85%);
  background-size: 200% 100%;
  animation: loading 1.4s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.app-img img.loaded + .skeleton-loader {
  display: none;
}

.theme-toggle-container {
  display: inline-block;
  list-style-type: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 0.2rem 0.3rem;
}

.theme-toggle label {
  margin-right: 6px;
  font: 500 12px/16px var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-text);
}

.theme-toggle select {
  height: var(--control-height-sm);
  padding: 0 0.6rem;
  border-radius: var(--radius-2);
  border: var(--border-pixel) solid var(--select-border);
  background-color: var(--select-bg);
  font: 500 12px/16px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--select-text);
  cursor: pointer;
}

.theme-toggle select:hover {
  border-color: var(--ink);
}

.theme-toggle select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
