:root {
  --bg: #f3f3f1;
  --fg: #111214;
  --muted: #6d7076;
  --faint: #d6d6d2;
  --rule: #e2e2de;
  --tick: rgba(0,0,0,0.45);
  --dot: 0,0,0;
  --grain: 0.06;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter Tight", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0a0a0b;
  --fg: #ececec;
  --muted: #7a7d83;
  --faint: #1f2024;
  --rule: #16171a;
  --tick: rgba(255,255,255,0.35);
  --dot: 255,255,255;
  --grain: 0.045;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
  transition: background-color 600ms ease, color 600ms ease;
}
body.dragging { cursor: grabbing; user-select: none; }

/* Theme swap: circular reveal from the toggle (View Transitions), colour fade as fallback */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

canvas.field { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

.grain {
  position: fixed; inset: -50%; width: 200%; height: 200%; z-index: 3; pointer-events: none; opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0); } 20% { transform: translate(-3%,2%); } 40% { transform: translate(2%,-4%); }
  60% { transform: translate(-4%,-1%); } 80% { transform: translate(3%,3%); } 100% { transform: translate(0,0); }
}

.tick {
  position: fixed; width: 12px; height: 12px; border: 1px solid var(--tick); pointer-events: none; z-index: 2;
  transition: width 600ms cubic-bezier(.2,.8,.2,1), height 600ms cubic-bezier(.2,.8,.2,1), border-color 600ms ease;
}
body.near-edge .tick { width: 20px; height: 20px; }
.t-tl { top: 24px; left: 24px; border-right: 0; border-bottom: 0; }
.t-tr { top: 24px; right: 24px; border-left: 0; border-bottom: 0; }
.t-bl { bottom: 24px; left: 24px; border-right: 0; border-top: 0; }
.t-br { bottom: 24px; right: 24px; border-left: 0; border-top: 0; }

.page {
  position: relative; z-index: 1; min-height: 100vh;
  display: grid; grid-template-rows: auto 1fr auto;
  padding-block: 28px; padding-inline: 40px; gap: 32px;
}

header {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
header .mark { color: var(--fg); font-family: var(--sans); font-weight: 400; letter-spacing: -0.005em; font-size: 14px; }

.theme {
  appearance: none; background: none; border: 0; padding: 6px; margin: -6px; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px; font: inherit; letter-spacing: inherit;
  transition: color 200ms ease;
}
.theme:hover, .theme:focus-visible { color: var(--fg); outline: none; }
.theme:focus-visible svg { outline: 1px solid var(--fg); outline-offset: 4px; border-radius: 50%; }
.theme svg { width: 14px; height: 14px; display: block; transition: transform 700ms cubic-bezier(.2,.8,.2,1); }
:root[data-theme="dark"] .theme svg { transform: rotate(180deg); }
.theme .lbl::after { content: "dark"; }
:root[data-theme="dark"] .theme .lbl::after { content: "light"; }

main { display: grid; align-content: center; justify-items: center; text-align: center; gap: 28px; width: 100%; }

.wordmark {
  margin: 0; font-family: var(--sans); font-weight: 300; font-size: clamp(56px, 11vw, 132px);
  line-height: 1; letter-spacing: -0.03em; color: var(--fg);
}
.wordmark span {
  display: inline-block; opacity: 0; transform: translateY(0.35em); filter: blur(6px);
  animation: settle 1.1s cubic-bezier(.2,.8,.2,1) forwards; animation-delay: calc(var(--i) * 45ms + 200ms);
}
.wordmark span.gap { width: 0.22em; }
@keyframes settle { to { opacity: 1; transform: none; filter: blur(0); } }

.lede {
  margin: 0; font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--muted); letter-spacing: 0.01em;
  opacity: 0; animation: fade 1s ease 900ms forwards;
}
@keyframes fade { to { opacity: 1; } }

.contact {
  margin-top: 4px; font-family: var(--mono); font-size: 13px; color: var(--fg); text-decoration: none;
  border-bottom: 1px solid var(--faint); padding-bottom: 3px; font-variant-ligatures: none;
  transition: border-color 160ms ease; opacity: 0; animation: fade 1s ease 1100ms forwards;
}
.contact:hover, .contact:focus-visible { border-bottom-color: var(--fg); outline: none; }

footer {
  display: flex; justify-content: space-between; align-items: end; gap: 24px;
  font-family: var(--mono); font-size: 11px; line-height: 1.6; color: var(--muted);
  border-top: 1px solid var(--rule); padding-top: 18px; font-variant-numeric: tabular-nums;
  transition: border-color 600ms ease;
}
footer .copy { text-align: right; }
footer .live { color: var(--fg); }
footer .live::after {
  content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--fg);
  margin-left: 8px; vertical-align: middle; animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

@media (max-width: 720px) {
  .page { padding-inline: 22px; padding-block: 22px; gap: 24px; }
  .tick { width: 10px; height: 10px; }
  footer { flex-direction: column; align-items: flex-start; }
  footer .copy { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark span { animation: none; opacity: 1; transform: none; filter: none; }
  .lede, .contact { animation: none; opacity: 1; }
  .grain { animation: none; }
  footer .live::after { animation: none; }
}
