:root {
  --background: #090b0d;
  --foreground: #dddfe7;
  --muted: #adb2c0;
  --border: #363b45;
  --ascii-field: 29, 32, 36;
  --ascii-ink: 220, 224, 237;
  --ascii-ink-variation: 0.2;
  --ascii-ripple: 147, 227, 213;
  color-scheme: dark;
  background: var(--background);
  color: var(--foreground);
  font-family: monospace;
}

:root[data-theme="light"] {
  --background: #f6f5f1;
  --foreground: #252a32;
  --contact: #404650;
  --muted: #555c67;
  --border: #bfc3c6;
  --ascii-field: 223, 225, 223;
  --ascii-ink: 23, 27, 34;
  --ascii-ink-variation: 0.04;
  --ascii-ripple: 40, 112, 103;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; }

main {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
}

h1 {
  margin: 0;
  font-size: clamp(1rem, 7vw, 8rem);
  font-weight: 700;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.word-caption {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 11px;
  background: var(--foreground);
  color: var(--background);
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.word-caption[hidden] { display: none; }

.contact {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 12px;
  color: var(--contact, var(--muted));
  background: var(--background);
  font-size: 12px;
  line-height: 20px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  text-decoration: none;
}

.contact:hover { color: var(--foreground); }
.contact:focus-visible,
.projects a:focus-visible,
.theme-switch button:focus-visible {
  outline: 1px solid var(--foreground);
  outline-offset: 3px;
}

.projects {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  background: var(--background);
}

.projects h2 {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
  line-height: 12px;
  letter-spacing: 0.12em;
}

.projects ul {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.projects a {
  display: block;
  padding: 4px 0;
  color: var(--foreground);
  font-size: 12px;
  line-height: 20px;
  text-decoration: none;
}

.projects a span { color: var(--muted); }
.projects a:hover { text-decoration: underline; text-underline-offset: 4px; }

.theme-switch {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  display: flex;
  padding: 2px;
  border: 1px solid var(--border);
  background: var(--background);
}

.theme-switch[hidden] { display: none; }

.theme-switch button {
  min-width: 38px;
  min-height: 30px;
  padding: 6px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: lowercase;
  cursor: pointer;
}

.theme-switch button:hover { color: var(--foreground); }
.theme-switch button[aria-pressed="true"] {
  background: var(--foreground);
  color: var(--background);
}

/* Keep a real heading for assistive technology and a no-JavaScript fallback. */
.rendered h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
