/**
 * Typography Stylesheet
 *
 * This file defines the font faces, sizes, and weights for the entire site.
 * It establishes a clear visual hierarchy and ensures readability.
 *
 * Dependencies:
 * - Relies on CSS custom properties defined in style.css
 * - Should be loaded early in the cascade, before other component stylesheets.
 *
 * @package IIAR_Publishing
 */

/* --------------------------------------------------------------------
  1. Import Web Fonts
  - We use a clean sans-serif for body text and a classic serif for headings.
  - This combination is highly readable and standard for academic publishing.
-------------------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap');

/* --------------------------------------------------------------------
  2. Base Typography
-------------------------------------------------------------------- */

body {
  /* Font Families */
  font-family: var(--font-family-primary); /* Inter, defined in style.css */
  font-weight: 400;
  font-size: 1rem; /* 16px */
  line-height: 1.7;
  color: var(--text-color);

  /* Improves font rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------
  3. Headings
  - Use a serif font for a classic, academic look.
  - Maintain a consistent scale and rhythm.
-------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-secondary); /* Merriweather */
  font-weight: 700;
  line-height: 1.3;
  color: var(--heading-color);
  margin-top: 0;
  margin-bottom: 1em; /* Use a consistent margin relative to font size */
}

h1 { font-size: 2.5rem; }   /* 40px */
h2 { font-size: 2rem; }     /* 32px */
h3 { font-size: 1.75rem; }  /* 28px */
h4 { font-size: 1.5rem; }   /* 24px */
h5 { font-size: 1.25rem; }  /* 20px */
h6 { font-size: 1.125rem; } /* 18px */

/* --------------------------------------------------------------------
  4. Text Elements
-------------------------------------------------------------------- */

p {
  margin-top: 0;
  margin-bottom: 1.25em;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}

a:hover,
a:focus {
  color: var(--link-hover-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

strong, b {
  font-weight: 600;
}

em, i {
  font-style: italic;
}

/* Blockquotes for quotes */
blockquote {
  margin: 1.5em 0;
  padding: 0.5em 1.5em;
  border-left: 5px solid var(--primary-color);
  background-color: var(--secondary-color);
  color: #555;
  font-style: italic;
}

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

/* Code blocks */
code {
  font-family: var(--font-family-mono); /* Fira Code */
  background-color: #e9ecef;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  color: #d6336c;
}

pre {
  background-color: #212529;
  color: #f8f9fa;
  padding: 1em;
  border-radius: var(--border-radius-md);
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
  font-size: 1em;
}

/* Horizontal Rule */
hr {
  border: 0;
  height: 2px;
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0), var(--border-color), rgba(0, 0, 0, 0));
  margin: 3em 0;
}

/* Lists */
ul, ol {
  margin-top: 0;
  margin-bottom: 1.25em;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.5em;
}

/* Definition Lists */
dt {
  font-family: var(--font-family-secondary);
  font-weight: 600;
}

dd {
  margin-left: 1.5em;
  margin-bottom: 1.25em;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.9em;
}

th, td {
  padding: 0.75em;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

thead th {
  font-family: var(--font-family-secondary);
  font-weight: 600;
  color: var(--heading-color);
  border-bottom: 2px solid var(--border-color);
}

/* --------------------------------------------------------------------
  5. Selection & Focus Styles
-------------------------------------------------------------------- */

/* Selected text */
::selection {
  background-color: var(--primary-color);
  color: #fff;
}

/* Focused elements (for accessibility) */
:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------
  6. Responsive Typography
  - Adjust font sizes for smaller screens to improve readability.
-------------------------------------------------------------------- */

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.5rem; }
  h4 { font-size: 1.25rem; }
  h5 { font-size: 1.125rem; }
  h6 { font-size: 1rem; }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.125rem; }
  h5 { font-size: 1rem; }
  h6 { font-size: 0.875rem; }
}