/* Typography Styles */

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-base);
  color: var(--colour-text);
  background-color: var(--colour-background);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--colour-text);
  margin-bottom: var(--spacing-md);
}

h1 {
  font-size: var(--font-size-h1);
  margin-bottom: var(--spacing-lg);
}

h2 {
  font-size: var(--font-size-h2);
  margin-bottom: var(--spacing-lg);
}

h3 {
  font-size: var(--font-size-h3);
}

h4 {
  font-size: var(--font-size-h4);
}

h5 {
  font-size: var(--font-size-h5);
}

h6 {
  font-size: var(--font-size-h6);
}

/* Paragraph spacing */
p {
  margin-bottom: var(--spacing-md);
  max-width: 70ch; /* Optimal reading width */
}

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

/* Lead text - larger intro paragraphs */
.lead {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
  color: var(--colour-text-light);
  margin-bottom: var(--spacing-lg);
}

/* Small text */
small,
.text-small {
  font-size: var(--font-size-sm);
}

/* Links */
a {
  color: var(--colour-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--transition-base);
}

a:hover {
  color: var(--colour-primary-dark);
  text-decoration-thickness: 2px;
}

a:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
  border-radius: var(--radius-sm);
}

/* Navigation links don't need underlines */
nav a {
  text-decoration: none;
}

nav a:hover {
  text-decoration: underline;
}

/* Lists */
ul,
ol {
  margin-bottom: var(--spacing-md);
  padding-left: var(--spacing-xl);
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

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

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

/* Nested lists */
ul ul,
ol ol,
ul ol,
ol ul {
  margin-top: var(--spacing-sm);
  margin-bottom: 0;
}

/* Definition lists */
dl {
  margin-bottom: var(--spacing-md);
}

dt {
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--spacing-xs);
}

dd {
  margin-left: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

/* Blockquotes */
blockquote {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md) var(--spacing-lg);
  border-left: 4px solid var(--colour-primary);
  background-color: var(--colour-background-alt);
  font-style: italic;
}

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

/* Strong and emphasis */
strong,
b {
  font-weight: var(--font-weight-bold);
}

em,
i {
  font-style: italic;
}

/* Code and pre-formatted text */
code,
pre {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: var(--font-size-sm);
  background-color: var(--colour-background-alt);
  border-radius: var(--radius-sm);
}

code {
  padding: 0.125rem 0.25rem;
}

pre {
  padding: var(--spacing-md);
  overflow-x: auto;
  margin-bottom: var(--spacing-md);
}

/* Horizontal rules */
hr {
  border: 0;
  height: 1px;
  background-color: var(--colour-border);
  margin: var(--spacing-2xl) 0;
}

/* Text utilities */
.text-center {
  text-align: center;
}

/* When paragraphs are centered, also center the paragraph block itself */
p.text-center,
.lead.text-center {
  margin-left: auto;
  margin-right: auto;
}

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

.text-muted {
  color: var(--colour-text-light);
}

.text-primary {
  color: var(--colour-primary);
}

.text-secondary {
  color: var(--colour-secondary);
}

.text-error {
  color: var(--colour-error);
}

.text-success {
  color: var(--colour-success);
}

.font-normal {
  font-weight: var(--font-weight-normal);
}

.font-medium {
  font-weight: var(--font-weight-medium);
}

.font-semibold {
  font-weight: var(--font-weight-semibold);
}

.font-bold {
  font-weight: var(--font-weight-bold);
}

/* Responsive font sizing for better mobile readability */
@media (max-width: 768px) {
  body {
    font-size: var(--font-size-base);
  }

  .lead {
    font-size: var(--font-size-base);
  }
}
