/**
 * AI Skunkworks — reset, body, typography, atmosphere
 */

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

html {
  position: relative;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.6s var(--ease-out), color 0.6s var(--ease-out);
}

/* Fixed blueprint grid (60×60, accent @ var(--grid-alpha)) + red glow in dark theme */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-grid);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 60% 50% at 70% 40%, var(--glow), transparent 70%),
    linear-gradient(rgba(var(--accent-rgb), var(--grid-alpha)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), var(--grid-alpha)) 1px, transparent 1px);
  background-size: auto, 60px 60px, 60px 60px;
  background-position: 0 0, 0 0, 0 0;
  mask-image: radial-gradient(ellipse 85% 70% at 50% 45%, black 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 85% 70% at 50% 45%, black 0%, transparent 72%);
}

/* Fixed SVG noise (overlay blend) + scanlines on <html> */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-noise);
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-scan);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(0, 0, 0, 0.04) 3px,
    rgba(0, 0, 0, 0.04) 4px
  );
}

:root[data-theme="dark"]::after {
  opacity: 1;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 var(--space-sm);
}

h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

h4 {
  font-size: var(--text-md);
}

p {
  margin: 0 0 var(--space-sm);
}

a {
  color: var(--accent);
  text-decoration-color: var(--accent-dim);
  text-underline-offset: 0.2em;
  transition: color var(--duration-fast) var(--ease-out),
    text-decoration-color var(--duration-fast) var(--ease-out);
}

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

a:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background-color: var(--signal);
  color: var(--signal-ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Scrollbars (Firefox + WebKit) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) var(--paper-2);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--paper-2);
  border-left: 1px solid var(--line);
}

*::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border: 2px solid var(--paper-2);
  border-radius: var(--radius-sm);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

*::-webkit-scrollbar-corner {
  background: var(--paper-2);
}

/* Terminal-style UI keeps a monospace face */
code,
kbd,
pre,
samp,
.intake-terminal__log,
.intake-terminal__field,
.intake-terminal__msg-label,
.intake-terminal__progress-wrap {
  font-family: var(--code);
}
