:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --fg: #1f2328;
  --muted: #656d76;
  --border: #d8dee4;
  --code-bg: #f6f8fa;
  --accent: #0969da;
  --accent-fg: #ffffff;
  --accent-hover: #0757b3;
  --error: #cf222e;
  --error-bg: #ffebe9;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(31 35 40 / 6%), 0 4px 12px rgb(31 35 40 / 5%);
  --glow-a: #8250df;
  --glow-b: #0969da;
  --glow-c: #1a7f64;
  --glow-opacity: .22;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151b23;
    --fg: #e6edf3;
    --muted: #8d96a0;
    --border: #30363d;
    --code-bg: #0d1117;
    --accent: #4493f8;
    --accent-fg: #0d1117;
    --accent-hover: #6cb0ff;
    --error: #f85149;
    --error-bg: #2d1416;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --glow-a: #a371f7;
    --glow-b: #4493f8;
    --glow-c: #3fb9a0;
    --glow-opacity: .28;
  }
}

* { box-sizing: border-box; }

body {
  position: relative;
  margin: 0 auto;
  max-width: 72rem;
  padding: 0 1rem 3rem;
  background: var(--bg);
  color: var(--fg);
}

/* Aurora: three blurred colour blobs drifting behind the page. Decorative only. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40rem 28rem at 15% 10%, var(--glow-a), transparent 70%),
    radial-gradient(36rem 26rem at 85% 20%, var(--glow-b), transparent 70%),
    radial-gradient(34rem 26rem at 50% 95%, var(--glow-c), transparent 70%);
  opacity: var(--glow-opacity);
  filter: blur(40px);
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

header {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.brand {
  background: linear-gradient(90deg, var(--fg), var(--glow-a), var(--glow-b), var(--fg)) 0 / 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.01em;
  text-decoration: none;
}

.brand:hover { background-position: 100% 0; }

h1 {
  margin: 0 0 .75rem;
  font-size: 1.5rem;
  letter-spacing: -.01em;
  background: linear-gradient(90deg, var(--fg), var(--glow-a));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

label { display: block; margin-bottom: .5rem; font-weight: 600; }
.hint { color: var(--muted); font-size: .9em; font-weight: 400; }

textarea, .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .875rem;
  line-height: 1.55;
}

textarea {
  width: 100%;
  min-height: 24rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  box-shadow: var(--shadow);
  resize: vertical;
}

textarea:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 0;
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  margin-top: 1rem;
}

.options label { margin: 0; }
select, button, .link { font: inherit; padding: .5rem .75rem; }
.options select { display: block; margin-top: .25rem; }

select, .link {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
}

button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
  cursor: pointer;
}

button { transition: transform .15s ease, border-color .15s ease, background-color .15s ease, box-shadow .15s ease; }
button:hover { border-color: var(--accent); transform: translateY(-1px); }
button:active { transform: translateY(0) scale(.98); }

button[type="submit"] {
  padding: .5rem 1.5rem;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
}

button[type="submit"] {
  background-image: linear-gradient(120deg, var(--accent), var(--glow-a));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

button[type="submit"]:hover {
  border-color: var(--accent-hover);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 50%, transparent);
}

/* Honeypot field: off screen rather than display:none, which some bots detect. */
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.error {
  margin: 0 0 1rem;
  padding: .6rem .9rem;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error);
  font-weight: 600;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
}

.meta > span:first-child {
  padding: .1rem .55rem;
  border-radius: 999px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: .85em;
  font-weight: 600;
}

.link { flex: 1; min-width: 16rem; background: var(--code-bg); }

.code {
  margin: 0;
  padding: .75rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--fg);
  box-shadow: var(--shadow);
  counter-reset: line;
}

/* Token colours come from /static/highlight.css, generated from chroma's styles and
   loaded before this file so the background and text colour above win. */

/* Line numbers come from CSS, so selecting and copying the code leaves them out. */
.line { counter-increment: line; padding-right: .75rem; }
.line:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.line::before {
  content: counter(line);
  display: inline-block;
  width: 3.5rem;
  margin-right: 1rem;
  padding-right: .5rem;
  text-align: right;
  color: var(--muted);
  border-right: 1px solid var(--border);
  user-select: none;
}

/* Spotlight: fx.js moves --mx/--my; without it the gradient stays out of sight. */
.fx-card, .code {
  --mx: -100px;
  --my: -100px;
  background-image: radial-gradient(18rem circle at var(--mx) var(--my),
    color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.fx-card:hover, .code:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

/* Entrance: the page fades in and the code lines cascade in (first 24 only). */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes drift {
  to { transform: translate3d(2%, 3%, 0) scale(1.08); }
}

main > * { animation: rise .45s ease-out both; }
main > :nth-child(2) { animation-delay: .06s; }
main > :nth-child(3) { animation-delay: .12s; }
.line { animation: rise .35s ease-out both; }
.line:nth-child(n+2) { animation-delay: .02s; }
.line:nth-child(n+4) { animation-delay: .04s; }
.line:nth-child(n+8) { animation-delay: .08s; }
.line:nth-child(n+16) { animation-delay: .12s; }
.line:nth-child(n+24) { animation-delay: .16s; }
body::before { animation: drift 18s ease-in-out infinite alternate; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  button:hover, button:active { transform: none; }
}

@media (max-width: 40rem) {
  .options > label, .options select { width: 100%; }
  button[type="submit"] { width: 100%; }
}
