/**
 * Narayanika Astro Reader - Reset & Base Typography
 */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 80px; /* Offset for sticky header */
  width: 100%;
  overflow-x: clip; /* clip allows position: sticky to function without horizontal scroll */
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-main);
  background-color: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 100%;
  overflow-x: clip;
  position: relative;
}

/* --- Word Wrap & Overflow Protection for Small Screens --- */
p, h1, h2, h3, h4, h5, h6, span, a, li, blockquote, dt, dd, label {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* --- Heading Scale --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--primary);
  line-height: 1.25;
  font-weight: 700;
}

h1 { font-size: clamp(1.85rem, 4vw, 3.2rem); margin-bottom: var(--space-md); }
h2 { font-size: clamp(1.5rem, 2.8vw, 2.4rem); margin-bottom: var(--space-md); }
h3 { font-size: clamp(1.15rem, 2vw, 1.6rem); margin-bottom: var(--space-sm); font-weight: 600; }
h4 { font-size: 1.1rem; margin-bottom: var(--space-xs); font-weight: 600; }

p {
  margin-bottom: var(--space-md);
  color: var(--text-muted);
  line-height: 1.75;
}

p:last-child { margin-bottom: 0; }

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

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

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

ul, ol { list-style: none; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  max-width: 100%;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

/* Accessible global focus ring */
:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

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

/* Skip-to-content link for keyboard users */
.skip-link {
  position: absolute;
  top: -100%;
  left: 12px;
  z-index: 9999;
  background: var(--primary);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  transition: top var(--transition-fast);
}

.skip-link:focus { top: 0; }
