/**
 * Age of Dinosaurs — Base Typography & Document Styles
 *
 * Establishes fundamental document defaults, typographic hierarchy, accessible
 * focus styles, and scientific styling conventions based on design tokens.
 *
 * @package AgeOfDinosaurs
 */

/* ==========================================================================
   1. Box Sizing & Document Normalization
   ========================================================================== */
*,
*::before,
*::after {
	box-sizing: border-box;
}

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

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

/* ==========================================================================
   2. Body & Global Typography Defaults
   ========================================================================== */
body {
	margin: 0;
	padding: 0;
	font-family: var(--font-family-body);
	font-size: var(--font-size-body);
	font-weight: var(--font-weight-regular);
	line-height: var(--line-height-body);
	color: var(--color-text-primary);
	background-color: var(--color-bg-primary);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

/* ==========================================================================
   3. Heading Typography (Fraunces Display & Editorial)
   ========================================================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
	font-family: var(--font-family-heading);
	color: var(--color-text-primary);
	margin-top: 0;
	margin-bottom: var(--space-md);
	letter-spacing: var(--letter-spacing-tight);
	text-wrap: balance;
}

h1 {
	font-size: var(--font-size-h1);
	font-weight: var(--font-weight-extrabold);
	line-height: var(--line-height-display);
}

h2 {
	font-size: var(--font-size-h2);
	font-weight: var(--font-weight-bold);
	line-height: var(--line-height-heading);
}

h3 {
	font-size: var(--font-size-h3);
	font-weight: var(--font-weight-semibold);
	line-height: var(--line-height-heading);
}

h4 {
	font-size: var(--font-size-h4);
	font-weight: var(--font-weight-semibold);
	line-height: var(--line-height-ui);
}

h5 {
	font-size: var(--font-size-body);
	font-weight: var(--font-weight-bold);
	line-height: var(--line-height-ui);
}

h6 {
	font-size: var(--font-size-small);
	font-weight: var(--font-weight-bold);
	line-height: var(--line-height-ui);
	letter-spacing: var(--letter-spacing-wide);
	text-transform: uppercase;
}

/* ==========================================================================
   4. Paragraphs, Quotes & Lists
   ========================================================================== */
p {
	margin-top: 0;
	margin-bottom: var(--space-lg);
}

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

blockquote {
	margin: 0 0 var(--space-xl) 0;
	padding: var(--space-md) var(--space-xl);
	border-left: 4px solid var(--color-fern);
	background-color: var(--color-bg-secondary);
	font-family: var(--font-family-heading);
	font-style: italic;
	color: var(--color-text-primary);
}

ul,
ol {
	margin-top: 0;
	margin-bottom: var(--space-lg);
	padding-left: var(--space-xl);
}

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

/* ==========================================================================
   5. Links & Interactive Text
   ========================================================================== */
a {
	color: var(--color-text-primary);
	text-decoration: underline;
	text-decoration-color: var(--color-border-strong);
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
	transition: color var(--motion-duration-fast) var(--motion-ease-standard),
	            text-decoration-color var(--motion-duration-fast) var(--motion-ease-standard);
}

a:hover {
	color: var(--color-fern);
	text-decoration-color: var(--color-fern);
}

/* ==========================================================================
   6. Text Formatting & Scientific Conventions
   ========================================================================== */
strong,
b {
	font-weight: var(--font-weight-bold);
}

em,
i {
	font-style: italic;
}

small,
.text-small {
	font-size: var(--font-size-small);
	line-height: var(--line-height-ui);
}

/* Scientific Nomenclature: Genus and species must always be italicized */
.scientific-name,
[data-scientific-name] {
	font-style: italic;
}

/* Data & Scientific Metrics (DM Mono) */
code,
kbd,
samp,
pre,
.data-metric,
.quick-fact-value {
	font-family: var(--font-family-data);
	font-size: 0.9em;
}

.quick-fact-label {
	font-family: var(--font-family-data);
	font-size: var(--font-size-quick-fact);
	font-weight: var(--font-weight-medium);
	letter-spacing: var(--letter-spacing-wide);
	text-transform: uppercase;
	color: var(--color-text-secondary);
}

/* ==========================================================================
   7. Media & Embeds
   ========================================================================== */
img,
svg,
video,
canvas {
	max-width: 100%;
	height: auto;
	display: block;
}

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

figcaption {
	margin-top: var(--space-xs);
	font-size: var(--font-size-small);
	color: var(--color-text-secondary);
}

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

/* ==========================================================================
   8. Accessible Focus Indicator Foundation
   WCAG 2.2 AA requirement: Visible, high-contrast focus rings.
   ========================================================================== */
:focus-visible {
	outline: var(--focus-ring-width) solid var(--focus-ring-color);
	outline-offset: var(--focus-ring-offset);
}

/* ==========================================================================
   9. Selection & Accessibility Utilities
   ========================================================================== */
::selection {
	background-color: var(--color-sand);
	color: var(--color-espresso);
}

.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal;
}

.screen-reader-text:focus {
	background-color: var(--color-chalk);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-md);
	clip: auto;
	clip-path: none;
	color: var(--color-espresso);
	display: block;
	font-size: var(--font-size-small);
	font-weight: var(--font-weight-bold);
	height: auto;
	left: 5px;
	line-height: normal;
	padding: 15px 23px 14px;
	text-decoration: none;
	top: 5px;
	width: auto;
	z-index: 100000;
}
