/* Reset and base styles */

/* 1. Use a more-intuitive box-sizing model */
*, *::before, *::after {
  box-sizing: border-box;
}

/* 2. Remove default margin */
* {
  margin: 0;
}

/* 3. Enable keyword animations */
@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  /* 4. Add accessible line-height */
  line-height: 1.5;
  /* 5. Improve text rendering */
  -webkit-font-smoothing: antialiased;
}

/* 6. Improve media defaults */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

/* 7. Inherit fonts for form controls */
input, button, textarea, select {
  font: inherit;
}

/* 8. Avoid text overflows */
p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

/* 9. Improve line wrapping */
p {
  text-wrap: pretty;
}
h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
}

/*
  10. Create a root stacking context
*/
#root, #__next {
  isolation: isolate;
}


:root {
  /* Light mode colors (default) */
  --bg-color: #ffffff;
  --text-color: #1a1a1a;
  --link-color: #0066cc;
  --link-hover: #004499;
  --border-color: #e0e0e0;
  --card-bg: #f9f9f9;
  --header-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
}

/* Optional: Respect system preference as default */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1a1a1a;
    --text-color: #e8e8e8;
    --link-color: #66b3ff;
    --link-hover: #99ccff;
    --border-color: #333333;
    --card-bg: #242424;
    --header-bg: #1f1f1f;
    --shadow: rgba(0, 0, 0, 0.3);
  }
}

/* Dark mode via :has() - triggers when checkbox is checked */
:root:has(#theme-checkbox:checked) {
  --bg-color: #1a1a1a;
  --text-color: #e8e8e8;
  --link-color: #66b3ff;
  --link-hover: #99ccff;
  --border-color: #333333;
  --card-bg: #242424;
  --header-bg: #1f1f1f;
  --shadow: rgba(0, 0, 0, 0.3);
}

/* Light mode via :has() - triggers when checkbox is unchecked (overrides system preference) */
:root:has(#theme-checkbox:not(:checked)) {
  --bg-color: #ffffff;
  --text-color: #1a1a1a;
  --link-color: #0066cc;
  --link-hover: #004499;
  --border-color: #e0e0e0;
  --card-bg: #f9f9f9;
  --header-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
header {
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

nav {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-color);
}

#theme-checkbox {
  display: none;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-color);
  transition: all 0.2s ease;
}

#theme-toggle:hover {
  background-color: var(--card-bg);
}

#theme-toggle:focus {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

/* Main content */
main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: calc(100vh - 10rem);
}

/* Articles list */
.articles-list h1 {
  margin-bottom: 2rem;
  font-size: 2rem;
}

.articles {
  list-style: none;
  display: grid;
  gap: 1.5rem;
}

.article-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.article-card:hover {
  box-shadow: 0 4px 6px var(--shadow);
  transform: translateY(-2px);
}

.article-card h2 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.article-card h2 a {
  color: var(--text-color);
  text-decoration: none;
}

.article-card h2 a:hover {
  color: var(--link-color);
}

.article-card time {
  display: block;
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.article-card p {
  color: var(--text-color);
  opacity: 0.9;
}

/* Article full view */
.article-full {
  max-width: 45rem;
  margin: 0 auto;
}

.article-header {
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 1rem;
}

.article-header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.article-header time {
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.875rem;
}

.article-content {
  margin-bottom: 3rem;
}

.article-content h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.75rem;
}

.article-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

.article-content p {
  margin-bottom: 1rem;
}

.article-content a {
  color: var(--link-color);
  text-decoration: underline;
}

.article-content a:hover {
  color: var(--link-hover);
}

.article-content ul,
.article-content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-content code {
  background-color: var(--card-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: "Courier New", monospace;
  font-size: 0.875em;
}

.article-content pre {
  background-color: var(--card-bg);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.article-content pre code {
  padding: 0;
  background: none;
}

.article-footer {
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.article-footer a {
  color: var(--link-color);
  text-decoration: none;
}

.article-footer a:hover {
  text-decoration: underline;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-color);
  opacity: 0.7;
}

/* Responsive */
@media (max-width: 768px) {
  .article-header h1 {
    font-size: 2rem;
  }

  .articles-list h1 {
    font-size: 1.75rem;
  }

  .article-card h2 {
    font-size: 1.25rem;
  }
}
