/*
 * BaseTheme: An essential Jekyll remote theme, crafted as a lean foundation for static sites on GitHub Pages.
 *
 * Table of Contents:
 * 1. Custom Properties (CSS Variables)
 *    - Colors
 *    - Typography
 *    - Layout & Spacing
 * 2. Reset & Base Styles
 * 3. Typography
 *    - Base Typography
 *    - Links
 *    - Headers
 * 4. Layout & Structure
 * 5. Components
 *    - Header
 *    - Navigation
 *    - Content Lists
 *    - Posts
 *    - Footer
 * 6. Utilities & Helpers
 * 7. Media Queries
 *    - Responsive Typography
 *    - Dark Mode
 *    - Print Styles
 *    - Accessibility
 *    - Responsive Adjustments
 */

/* -----------------------------
 * 1. Custom Properties
 * Core design tokens for consistent theming
 * ----------------------------- */
 :root {
  /* Colors */
  --text-color: #333;
  --text-color-muted: rgba(51, 51, 51, 0.8);
  --bg-color: #fff;
  --link-color: #007acc;
  --header-bg: #f8f9fa;
  --footer-bg: #f8f9fa;
  --border-color: #e1e4e8;
  --nav-active-bg: #e9ecef;
  --nav-active-border: #007acc;
  --code-bg: #f6f8fa;

  /* Typography */
  --font-family-base: system-ui, -apple-system, sans-serif;
  --line-height-base: 1.6;
  --font-size-base: 1.1rem;
  --font-size-small: 0.875rem;
  --font-size-large: 1.25rem;
  --font-size-h1: 2rem;
  --font-size-h2: 1.75rem;
  --font-size-h3: 1.5rem;

  /* Layout & Spacing */
  --content-width: 65ch;
  --wide-width: 85ch;
  --border-radius: 4px;
  --section-spacing: 2rem;
  --content-spacing: 1.5rem;
  --content-padding: 1rem;
  --item-spacing: 1rem;
  --nav-item-spacing: 0.75rem;
  --focus-outline: 3px solid var(--link-color);
}

/* -----------------------------
* 2. Reset & Base Styles
* Core styling foundation
* ----------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-base);
  line-height: var(--line-height-base);
  color: var(--text-color);
  background: var(--bg-color);
  font-size: var(--font-size-base);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -----------------------------
* 3. Typography
* Text styles and vertical rhythm
* ----------------------------- */
/* Headers */
h1, h2, h3 {
  margin: var(--section-spacing) 0 var(--content-spacing);
  line-height: 1.3;
}

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

/* Links */
a {
  color: var(--link-color);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

/* Block Elements */
p, ul, ol {
  margin-bottom: var(--content-spacing);
}

/* Code Blocks */
pre {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--content-padding);
  margin: var(--section-spacing) 0;
  overflow-x: auto;
  font-size: var(--font-size-small);
  line-height: 1.6;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

/* Post Date */
.post-date {
  display: block;
  color: var(--text-color-muted);
  font-size: var(--font-size-small);
  margin-bottom: var(--content-spacing);
}

/* -----------------------------
* 4. Layout & Structure
* Core layout containers and grid
* ----------------------------- */
main {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--section-spacing) var(--content-padding);
}

/* Feature List Component (Homepage) */
main > ul:not(.post-list):not(.page-list) {
  list-style: none;
  padding-left: 2.5rem;
  margin: var(--item-spacing) 0;
}

main > ul:not(.post-list):not(.page-list) li {
  position: relative;
  margin-bottom: 1rem;
}

main > ul:not(.post-list):not(.page-list) li::before {
  content: "•";
  position: absolute;
  left: -2rem;
  font-size: 2rem;
  line-height: 1;
  top: -0.25rem;
  color: var(--text-color-muted);
}

/* -----------------------------
* 5. Components
* Individual UI components
* ----------------------------- */

/* Header Component */
.site-header {
  background: var(--header-bg);
  padding: var(--content-padding);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--section-spacing);
}

.site-header h1 {
  margin: 0;
  font-size: var(--font-size-h1);
}

.site-header a {
  text-decoration: none;
  color: var(--text-color);
}

/* Navigation Component */
nav {
  margin-top: var(--item-spacing);
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: var(--nav-item-spacing);
}

nav a {
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  transition: background-color 0.2s ease, border-left-color 0.2s ease;
}

nav a:hover {
  background: var(--nav-active-bg);
  opacity: 1;
}

nav a.active {
  background: var(--nav-active-bg);
  border-left: 3px solid var(--nav-active-border);
  font-weight: 500;
}

/* Content Lists Component */
.list-container {
  padding: var(--content-padding);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin: var(--section-spacing) 0;
}

.page-list,
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list-item {
  margin-bottom: var(--section-spacing);
}

.post-list-item h2 {
  margin-top: 0;
  margin-bottom: var(--content-spacing);
}

.post-list-item h2 a {
  color: var(--text-color);
  text-decoration: none;
}

.post-list-item hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: var(--section-spacing) 0;
}

.post-list-item:last-child hr {
  display: none;
}

.page-list-item {
  margin-bottom: var(--item-spacing);
}

.page-title {
  display: inline;
  color: var(--link-color);
}

.page-description {
  display: inline;
  margin-left: 0.5em;
  color: var(--text-color-muted);
}

.read-more {
  display: inline-block;
  margin-top: var(--content-spacing);
  font-size: var(--font-size-small);
}

/* Footer Component */
.site-footer {
  background: var(--footer-bg);
  padding: var(--content-padding);
  margin-top: var(--section-spacing);
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: var(--font-size-small);
}

/* -----------------------------
* 6. Utilities & Helpers
* Helper classes and utilities
* ----------------------------- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--link-color);
  color: white;
  padding: 8px;
  z-index: 100;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: var(--focus-outline);
  outline-offset: -2px;
}

/* -----------------------------
* 7. Media Queries
* Responsive and context-based styles
* ----------------------------- */

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --text-color: rgba(255, 255, 255, 0.92);
    --text-color-muted: rgba(255, 255, 255, 0.75);
    --bg-color: #1a1a1a;
    --header-bg: #252525;
    --footer-bg: #252525;
    --border-color: #404040;
    --nav-active-bg: #2a2a2a;
    --code-bg: #252525;
    --focus-outline: 3px solid var(--link-color);
  }
}

/* Responsive Typography */
@media (min-width: 768px) {
  pre {
    position: relative;
    padding: var(--content-spacing);
  }
}

/* Mobile Navigation */
@media (max-width: 600px) {
  nav ul {
    flex-direction: column;
    gap: 0;
  }

  nav a {
    display: block;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
  }
}

/* Print Styles */
@media print {
  body {
    color: black;
    background: white;
    font-size: 12pt;
    line-height: 1.5;
  }

  .site-header,
  .site-footer,
  nav,
  .skip-link {
    display: none;
  }

  main {
    max-width: none;
    margin: 0;
    padding: 0.5cm;
  }

  pre {
    border: 1px solid #ddd;
    padding: 1em;
    margin: 1em 0;
    overflow: visible;
    page-break-inside: avoid;
    box-shadow: none;
  }

  a {
    color: black;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 90%;
    font-style: italic;
  }

  a[href^="/"]:after,
  a[href^="#"]:after {
    content: "";
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Forced Colors Mode */
@media (forced-colors: active) {
  :root {
    --focus-outline: 3px solid CanvasText;
  }
}