/* -----------------------------------------------------------
   1. VARIABLES
   ----------------------------------------------------------- */
:root {
  --color-bg: #f9f9f7;
  --color-text: #2c2c2c;
  --color-accent: #555;
  --color-primary: #2d4239;
  /* Muted Dark Green */
  --color-primary-light: #4b6257;
  /* Lighter Muted Green */

  /* New Variable for the button hover state */
  --color-btn-hover: #e6e6e2;

  /* Typography Updates */
  --font-serif: 'Source Serif 4', serif;
  --font-serif-weight: 380;
  --font-meta: 'Geist Mono', monospace;
  --font-header: 'Inter', sans-serif;
  /* Updated to Geist Mono */
  --line-height: 1.6;
  --font-size: 1.125rem;
  /* Our base for vertical rhythm */
  --spacing-unit: calc(var(--line-height) * var(--font-size));

  --measure-width: 65ch;
  --sidenote-width: 15ch;
  --gutter-width: 3ch;
  --article-total-width: calc(var(--sidenote-width) + var(--gutter-width) + var(--measure-width) + var(--gutter-width) + var(--sidenote-width));
}

/* -----------------------------------------------------------
   2. RESET & GLOBAL
   ----------------------------------------------------------- */
*,
*:before,
*:after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-serif);
  font-weight: var(--font-serif-weight);
  line-height: var(--line-height);
  font-size: var(--font-size);
}

a {
  color: var(--color-primary-light);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:visited {
  color: var(--color-primary-light);
}

a:hover {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
ul,
ol,
dl,
pre {
  margin-top: 0;
}

/* -----------------------------------------------------------
   3. HEADER & NAVIGATION
   ----------------------------------------------------------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Using spacing-unit for padding */
  padding: var(--spacing-unit) calc(var(--spacing-unit) * 2);
  background-color: #f1f3f2;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

  /* Apply Work Sans to the whole header */
  font-family: var(--font-meta);
}

.site-title {
  font-size: var(--font-size);
  letter-spacing: 0.05em;
  color: var(--color-primary-light);
}

/* Navigation Links Styling */
nav a {
  text-decoration: none;
  color: var(--color-primary-light);
  font-size: var(--font-size);
  text-transform: lowercase;

  /* Button Mechanics */
  padding: 0.5rem 1rem;
  /* Adds "clickable area" around text */
  margin-left: 0.5rem;
  /* Spacing between buttons */
  border-radius: 6px;
  /* Smooth corners */
  transition: all 0.2s ease;
  /* Smooths the color change */
}

/* The Hover Effect */
nav a:hover {
  background-color: var(--color-primary-light);
  color: #fff;
  text-decoration: none;
}

/* -----------------------------------------------------------
   4. MAIN ARTICLE
   ----------------------------------------------------------- */
main {
  width: 100%;
  max-width: var(--article-total-width);
  margin-inline: auto;
  /* Major vertical spacing based on our unit */
  padding-top: calc(var(--spacing-unit) * 5 / 4);
  padding-bottom: calc(var(--spacing-unit) * 5 / 4);
}

h1 {
  font-family: var(--font-header);
  font-weight: 380;
  font-size: calc(var(--font-size) * 1.3);
  line-height: 1.2;
  margin-bottom: calc(var(--spacing-unit) * 3 / 4);
  color: #111;
}

h2 {
  font-family: var(--font-header);
  font-size: var(--font-size);
  line-height: var(--line-height);
  margin-bottom: calc(var(--spacing-unit) * 3 / 4);
  color: #111;
  font-weight: normal;
}

.meta {
  font-family: var(--font-meta);
  color: var(--color-primary-light);
  font-size: calc(var(--font-size));
  margin-bottom: calc(var(--spacing-unit) * 3 / 4);
  display: block;
}

p {
  /* Paragraphs are separated by one line height */
  margin-bottom: calc(var(--spacing-unit) * 3 / 4);
}

blockquote {
  border-left: 2px solid var(--color-primary-light);
  /* Vertical margin is handled by bottom margin to match paragraphs */
  margin-bottom: calc(var(--spacing-unit) * 3 / 4);
  /* Indentation is one line height */
  padding-left: calc(var(--spacing-unit) * 3 / 4);
  font-style: italic;
  color: var(--color-text);
}

/* Make the article a grid container */
article {
  display: grid;
  grid-template-columns:
    [left-sidenote] var(--sidenote-width) [left-gutter] var(--gutter-width) [content] var(--measure-width) [right-gutter] var(--gutter-width) [right-sidenote] var(--sidenote-width);
}

/* Place all direct children of the article in the main column by default */
article>* {
  grid-column: content;
  /* A good practice to prevent grid blow-out with long words or images */
  min-width: 0;
}

/* Specifically place h3 in the first column and style it */
h3 {
  grid-column: left-sidenote;
  /* Override the default */
  text-align: right;
  font-family: var(--font-serif);
  font-weight: 380;
  /* Slightly heavier than body (360) to compensate for smaller size */
  font-size: 0.85rem;
  color: var(--color-text);
  font-variation-settings: 'opsz' 8;
}