/* ============================================
   GLOBAL STYLES — Reset, Typography, Layout
   ============================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.75;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Canvas background */
#scene-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: var(--z-canvas);
  pointer-events: none;
}

/* Content sits above canvas */
.page-content {
  position: relative;
  z-index: var(--z-content);
}

/* ---- Typography ---- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  text-transform: var(--heading-transform);
  letter-spacing: var(--heading-letter-spacing);
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.8rem, 4vw, 3rem); }
h3 { font-size: clamp(1.3rem, 3vw, 2rem); }
h4 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }

p {
  margin-bottom: 1.25em;
  color: var(--text-secondary);
}

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

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

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

em {
  font-style: italic;
}

blockquote {
  border-left: 3px solid var(--accent-primary);
  padding: var(--space-sm) var(--space-lg);
  margin: var(--space-lg) 0;
  font-style: italic;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

ul, ol {
  margin: var(--space-md) 0;
  padding-left: var(--space-lg);
  color: var(--text-secondary);
}

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

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

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

::selection {
  background: var(--accent-primary);
  color: #fff;
}

/* ---- Layout Utilities ---- */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

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

.section {
  padding: var(--space-3xl) 0;
}

.text-center { text-align: center; }
.text-accent { color: var(--accent-primary); }
.text-glow { color: var(--accent-glow); }

/* ---- Fade-in on scroll ---- */

.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Focus styles for keyboard navigation ---- */

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

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ---- Screen reader only ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ---- Share buttons ---- */

.share-bar {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
  margin: var(--space-lg) 0;
  padding: var(--space-md) 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.share-bar__label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-right: var(--space-sm);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.share-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ---- Reading time ---- */

.reading-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* ---- Print styles ---- */

@media print {
  #scene-canvas, .nav, .float-cta, .nav__theme-toggle,
  .btn--pulse, .share-bar, .end-cta { display: none !important; }

  body { background: #fff; color: #000; }
  .page-content { position: static; }
  h1, h2, h3 { color: #000; text-transform: none; }
  p, li { color: #333; }
  a { color: #333; text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
  .post__body { max-width: 100%; padding: 0; }
  blockquote { border-left-color: #999; }
}
