/* ═══════════════════════════════════════════════════════════════════════════
   BASE — Reset, typography, global styles

   Depends on: tokens.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  tab-size: 4;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-fg);
  background-color: var(--color-bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background-color var(--duration-slow) var(--ease-smooth),
              color var(--duration-slow) var(--ease-smooth);
}

/* ── Typography ───────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-fg);
  letter-spacing: var(--tracking-tight);
}

h1 {
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
}

h2 {
  font-size: var(--text-2xl);
  line-height: var(--leading-snug);
}

h3 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
}

h4 {
  font-size: var(--text-lg);
  line-height: var(--leading-normal);
}

p {
  margin-bottom: var(--space-6);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-smooth);
}

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

strong, b {
  font-weight: 700;
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--text-sm);
}

blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: var(--space-6);
  margin: var(--space-8) 0;
  font-family: var(--font-sans);
  font-style: italic;
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-fg-muted);
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-12) 0;
}

/* ── Code ──────────────────────────────────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg-inset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.35em;
}

pre {
  background: var(--color-bg-inset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  overflow-x: auto;
  margin: var(--space-8) 0;
  line-height: 1.5;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
}

/* ── Images ────────────────────────────────────────────────────────────────── */

img {
  max-width: 100%;
  height: auto;
  display: block;
}

figure {
  margin: var(--space-8) 0;
}

figcaption {
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
  margin-top: var(--space-3);
  text-align: center;
}

/* ── Lists ─────────────────────────────────────────────────────────────────── */

ul, ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-6);
}

li {
  margin-bottom: var(--space-2);
}

li::marker {
  color: var(--color-fg-faint);
}

/* ── Tables ────────────────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-8) 0;
  font-size: var(--text-sm);
}

th, td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 700;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-fg-muted);
}

/* ── Selection ─────────────────────────────────────────────────────────────── */

::selection {
  background: var(--color-accent);
  color: var(--color-bg);
}

/* ── Focus ──────────────────────────────────────────────────────────────────── */

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

/* ── Scrollbar (subtle, matches theme) ─────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-bold);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-fg-faint);
}

/* ── Utility classes ───────────────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.container--narrow {
  max-width: var(--container-narrow);
}

.container--wide {
  max-width: var(--container-wide);
}

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

/* ── Section spacing ───────────────────────────────────────────────────────── */

.section {
  padding-top: var(--space-12);
  padding-bottom: var(--space-12);
}

.section--lg {
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}

/* ── Page wrapper ──────────────────────────────────────────────────────────── */

.site-wrapper {
  position: relative;
  z-index: var(--z-base);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-content {
  flex: 1;
}

/* ── Matrix rain canvas ────────────────────────────────────────────────────── */

#matrix-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.25;
}

/* Barely-there texture on non-homepage pages */
body:not(.home-template) #matrix-canvas {
  opacity: 0.06;
}

/* ── Gradient word (SOHub-style accent gradient on first word) ──────────────── */

.gradient-word {
  background: linear-gradient(135deg, var(--color-accent), #ff8a65);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .gradient-word {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Error page ────────────────────────────────────────────────────────────── */

.error-page {
  text-align: center;
}

.error-page__inner {
  padding: var(--space-24) 0;
}

.error-page__code {
  font-family: var(--font-mono);
  font-size: var(--text-display);
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: var(--space-4);
}

.error-page__message {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-4);
}

.error-page__desc {
  font-size: var(--text-base);
  color: var(--color-fg-muted);
  margin-bottom: var(--space-8);
}

.error-page__actions {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
}

.error-page__btn {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-3) var(--space-8);
  border-radius: var(--radius-full);
  text-decoration: none;
  background: var(--color-accent);
  color: var(--color-bg);
  transition: background var(--duration-fast) var(--ease-smooth);
}

.error-page__btn:hover {
  background: var(--color-accent-hover);
  color: var(--color-bg);
}

.error-page__btn--secondary {
  background: transparent;
  color: var(--color-fg);
  border: 1px solid var(--color-border-bold);
}

.error-page__btn--secondary:hover {
  border-color: var(--color-fg-muted);
  background: transparent;
  color: var(--color-fg);
}
