/* ==========================================================================
   main.css — Core styles, layout, typography, and global resets
   ========================================================================== */

/* --- Custom Properties --- */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --text-primary: rgba(255, 255, 255, 0.87);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --accent-primary: #818CF8;
  --accent-highlight: #00D9FF;
  --accent-warning: #FF6B6B;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --max-prose-width: 68ch;
  --max-code-width: 80ch;
  --line-height-prose: 1.7;
  --line-height-code: 1.5;
  --sidebar-width: 260px;
  --progress-height: 3px;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-prose);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

ul,
ol {
  list-style: none;
}

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

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

a:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- Main Content Layout --- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem 2.5rem 4rem;
  max-width: calc(100% - var(--sidebar-width));
  overflow-x: hidden;
}

/* --- Progress Bar --- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: var(--progress-height);
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-highlight));
  z-index: 1000;
  width: 0%;
  transition: width 120ms linear;
  pointer-events: none;
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

h1 {
  font-size: 2.25rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.625rem;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

p {
  max-width: var(--max-prose-width);
  margin-bottom: 1em;
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

em {
  font-style: italic;
}

blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  max-width: var(--max-prose-width);
}

/* --- Inline Code & Code Blocks --- */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-secondary);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  max-width: var(--max-code-width);
  overflow-x: auto;
  line-height: var(--line-height-code);
  margin: 1.25rem 0;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

/* --- Lists --- */
.prose ul,
.prose ol {
  max-width: var(--max-prose-width);
  padding-left: 1.5rem;
  margin-bottom: 1em;
}

.prose ul {
  list-style: disc;
}

.prose ol {
  list-style: decimal;
}

.prose li {
  margin-bottom: 0.35em;
}

.prose li + li {
  margin-top: 0.25em;
}

/* --- Selection --- */
::selection {
  background: rgba(129, 140, 248, 0.35);
  color: #fff;
}

::-moz-selection {
  background: rgba(129, 140, 248, 0.35);
  color: #fff;
}

/* --- Scrollbar (Webkit) --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) var(--bg-primary);
}

/* --- Skip to Content (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.5rem 1rem;
  background: var(--accent-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  z-index: 2000;
  font-size: 0.875rem;
}

.skip-link:focus {
  top: 0.5rem;
}

/* --- Utilities --- */
.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;
}

/* ==========================================================================
   Responsive: Tablet / Single Column
   ========================================================================== */
@media (max-width: 1024px) {
  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 1.5rem 1.25rem 3rem;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  .sidebar,
  .progress-bar,
  .viz-controls,
  .hamburger-btn,
  .continue-toast,
  .copy-btn {
    display: none !important;
  }

  .site-wrapper {
    display: block;
  }

  body {
    background: #fff;
    color: #111;
    font-size: 12pt;
  }

  a {
    color: #111;
    text-decoration: underline;
  }

  h1, h2, h3 {
    color: #000;
    page-break-after: avoid;
  }

  pre, blockquote {
    page-break-inside: avoid;
  }

  canvas {
    display: none;
  }

  .canvas-fallback {
    display: block !important;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .progress-bar {
    transition: none;
  }
}
