/* === CSS Custom Properties === */
:root {
  --color-text: #222;
  --color-secondary: #666;
  --color-accent: #c60;
  --color-bg: #fff;
  --color-code-bg: #f4f4f4;
  --color-border: #ddd;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #d4d4d4;
    --color-secondary: #999;
    --color-accent: #f08030;
    --color-bg: #1a1a1a;
    --color-code-bg: #2a2a2a;
    --color-border: #444;
  }
}

/* === Reset / Base === */
*, *::before, *::after {
  box-sizing: border-box;
}

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

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

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

iframe {
  max-width: 100%;
}

/* === Layout === */
.layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 2rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

main {
  max-width: 65ch;
  min-width: 0;
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* === Header === */
header {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem 1.25rem;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

header h1 {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

header h1 a {
  color: var(--color-text);
}

header h1 a:hover {
  text-decoration: none;
  color: var(--color-accent);
}

.site-description {
  margin: 0.4rem 0 0;
  color: var(--color-secondary);
  font-size: 0.9rem;
}

/* === Footer === */
footer {
  max-width: 900px;
  margin: 2rem auto 0;
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85em;
  color: var(--color-secondary);
}

footer p {
  margin: 0.5em 0;
}

.accessibility-notice {
  font-size: 0.85em;
}

.identity-links a {
  color: var(--color-accent);
}

/* === Post Entry (index/tag listings) === */
.post-entry {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.post-entry:last-child {
  border-bottom: none;
}

.post-meta {
  color: var(--color-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.post-meta time {
  margin-right: 0.75rem;
}

.reading-time {
  color: var(--color-secondary);
}

.post-title {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}

.post-title a {
  color: var(--color-text);
}

.post-title a:hover {
  color: var(--color-accent);
}

.post-excerpt {
  margin: 0.5rem 0;
  color: var(--color-secondary);
}

.read-more {
  white-space: nowrap;
  font-size: 0.85rem;
}

/* === Tag Pills === */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  color: var(--color-secondary);
  line-height: 1.4;
}

.tag:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  text-decoration: none;
}

/* === Post Page === */
.post-header {
  margin-bottom: 2rem;
}

.post-header .post-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.post-content {
  line-height: 1.65;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.post-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.post-content p {
  margin-bottom: 1.5em;
}

.post-content blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 3px solid var(--color-accent);
  color: var(--color-secondary);
  background: var(--color-code-bg);
}

.post-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

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

.post-content th {
  background: var(--color-code-bg);
  font-weight: 600;
}

/* === Heading Anchors === */
.anchor {
  color: var(--color-border);
  text-decoration: none;
  font-weight: normal;
}

.anchor:hover {
  color: var(--color-accent);
}

/* === Code === */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-code-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

pre {
  overflow-x: auto;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  font-size: 0.85rem;
  background: var(--color-code-bg);
  padding: 1rem;
  border-radius: 4px;
  margin: 1em 0;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0;
  padding: 1rem 0;
}

.pagination a {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  min-height: 44px;
  line-height: 1.5;
}

.pagination a:hover {
  border-color: var(--color-accent);
  text-decoration: none;
}

.page-info {
  color: var(--color-secondary);
  font-size: 0.9rem;
}

/* === Post Navigation (prev/next) === */
.post-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.post-nav a {
  display: inline-block;
  padding: 0.5rem 0;
  max-width: 48%;
}

.post-nav .next {
  text-align: right;
  margin-left: auto;
}

/* === Sidebar === */
.sidebar {
  font-size: 0.9rem;
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section summary {
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0;
  font-size: 0.95rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.archive-list,
.links-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.archive-list li,
.links-list li {
  padding: 0.1rem 0;
}

.archive-list a,
.links-list a {
  display: inline-block;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .archive-list a,
  .links-list a {
    min-height: 44px;
    line-height: 2.75;
  }
}

/* On desktop, always show sidebar content regardless of open state */
@media (min-width: 769px) {
  .sidebar-section > *:not(summary) {
    display: block !important;
  }
}

/* === Archive Entries === */
.archive-entries {
  list-style: none;
  padding: 0;
}

.archive-entries li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border);
}

.archive-entries time {
  color: var(--color-secondary);
  font-size: 0.85rem;
  margin-right: 0.75rem;
  display: inline-block;
  min-width: 8em;
}

/* === Skip Link === */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* === Article Content === */
.article-content {
  line-height: 1.65;
}

.article-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2rem;
}

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

.article-content p {
  margin-bottom: 1.5em;
}

/* === Print Styles === */
@media print {
  .sidebar, header nav, .pagination, .post-nav, .skip-link {
    display: none;
  }
  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
  .layout {
    display: block;
  }
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
  pre {
    white-space: pre-wrap;
    border: 1px solid #ccc;
    overflow: visible;
  }
}
