/* ============================================
   THE CONTEXT WINDOW — base.css
   Design tokens, reset, body, typography
   ============================================ */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600&family=Lora:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- Design tokens ---- */
:root {
  /* Colour */
  --color-bg: #0D1117;
  --color-text: #E8E6DF;
  --color-accent: #E8832A;
  --color-muted: #8B93A1;
  --color-border: #1F2937;
  --color-surface: #111827;

  /* Spacing scale */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: 6rem;

  /* Sticky terminal bar height — referenced by .reading-progress
     so it can stick directly below the bar instead of underneath it. */
  --terminal-bar-height: 3rem;

  /* Fonts */
  --font-head: 'Space Grotesk', sans-serif;
  --font-body: 'Lora', serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  scroll-behavior: smooth;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

ul,
ol {
  list-style: none;
}

/* ---- Body / graph paper grid ---- */
body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.7;
  min-height: 100vh;
}

/* Graph paper grid lives on a fixed pseudo-element so it can
   fade out down the viewport instead of tiling uniformly —
   strongest at the top, gone by ~130% of a viewport height. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(107, 114, 128, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(107, 114, 128, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 130vh);
  mask-image: linear-gradient(to bottom, black, transparent 130vh);
}

/* ---- Headings ---- */
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

/* ---- Metadata / mono text ---- */
.mono,
.meta {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--color-muted);
}

/* ---- Terminal bar (present on every page) ----
   Single merged bar: terminal prompt on the left,
   full site navigation on the right. Absorbs what
   used to be a separate .site-nav bar — see layout.css. */
.terminal-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  height: var(--terminal-bar-height);
  background-color: rgba(17, 24, 39, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-accent);
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.terminal-prompt {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.terminal-bar .cursor {
  display: inline-block;
  margin-left: 0.25ch;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* ---- Section divider — quiet line, amber stays
   reserved for interactive/live elements ---- */
hr.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  width: 100%;
  margin: var(--space-xl) 0;
}

/* ---- Issue number badge ---- */
.issue-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

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

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
