/* ------------------------------------
 * Typecho Default Theme — overreacted.io style
 * --------------------------------- */

/* --- CSS Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { line-height: 1.15; -webkit-text-size-adjust: 100%; }
body { margin: 0; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; }
ol, ul { list-style: none; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }

/* --- Custom Properties --- */
:root {
  --bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --title: #1a1a2e;
  --link: #d23669;
  --code-bg: #282c35;
  --code-text: #e6e6e6;
  --border: #eaeaea;
  --blockquote-border: #d23669;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #282c35;
    --text: #ffffff;
    --text-secondary: #9ca3af;
    --title: #ffffff;
    --link: #ffa7c4;
    --code-bg: #1e2028;
    --code-text: #e6e6e6;
    --border: #3e4452;
    --blockquote-border: #ffa7c4;
  }
}

/* --- Base --- */
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  transition: background-color 0.3s, color 0.3s;
}

/* --- Layout --- */
.wrapper-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}
.layout {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 48px;
  align-items: start;
}

/* --- Header --- */
.site-header {
  padding: 48px 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.header-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.site-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--link);
}
.site-title a { color: inherit; }
.site-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.site-nav {
  display: flex;
  gap: 0;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}
.site-nav a {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.site-nav a:hover,
.site-nav a.current {
  color: var(--link);
  border-bottom-color: var(--link);
}

/* --- Main Content --- */
main {
  padding: 48px 0;
}

/* --- Post List (index) --- */
.post-item {
  margin-bottom: 48px;
}
.post-item-title {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.3;
  color: var(--title);
}
.post-item-title a {
  color: var(--link);
}
.post-item-title a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.post-item-date {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 8px;
}
.post-item-excerpt {
  color: var(--text);
  line-height: 1.75;
}

/* --- Single Post --- */
.post-header {
  margin-bottom: 32px;
}
.post-title {
  font-size: 40px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--title);
}
.post-date {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* --- Post Content --- */
.post-content {
  line-height: 1.85;
  word-wrap: break-word;
}
.post-content p {
  margin-bottom: 24px;
}
.post-content h2 {
  font-size: 1.6em;
  font-weight: 900;
  margin: 48px 0 16px;
  color: var(--title);
}
.post-content h3 {
  font-size: 1.3em;
  font-weight: 700;
  margin: 40px 0 12px;
  color: var(--title);
}
.post-content h4 {
  font-size: 1.1em;
  font-weight: 700;
  margin: 32px 0 8px;
  color: var(--title);
}
.post-content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.post-content a:hover {
  text-decoration: none;
}
.post-content img,
.post-content video {
  max-width: 100%;
  border-radius: 4px;
}
.post-content blockquote {
  margin: 24px 0;
  padding: 0 0 0 20px;
  border-left: 3px solid var(--blockquote-border);
  color: var(--text-secondary);
  font-style: italic;
}
.post-content ul,
.post-content ol {
  margin: 16px 0;
  padding-left: 28px;
}
.post-content ul { list-style: disc; }
.post-content ol { list-style: decimal; }
.post-content li {
  margin-bottom: 8px;
}
.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px auto;
  width: 100px;
}
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
}
.post-content th,
.post-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.post-content th {
  background: var(--code-bg);
  color: var(--code-text);
}

/* --- Code --- */
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 3px;
}
pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 20px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 24px 0;
  line-height: 1.5;
}
pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.875em;
}

/* --- Post Navigation --- */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  font-size: 15px;
}
.post-nav a {
  color: var(--link);
}
.post-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.post-nav .prev,
.post-nav .next {
  max-width: 45%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.post-nav .prev { margin-right: auto; }
.post-nav .next { margin-left: auto; text-align: right; }

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  padding: 32px 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
}
.pagination li {
  display: inline-block;
}
.pagination li a,
.pagination li span {
  display: inline-block;
  padding: 4px 10px;
  font-size: 15px;
  color: var(--link);
  border-radius: 4px;
}
.pagination li.current a,
.pagination li.current span {
  color: var(--text);
  background: var(--border);
}
.pagination li a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* --- Footer --- */
.site-footer {
  padding: 32px 0 48px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Sidebar --- */
.sidebar {
  padding-top: 48px;
  position: sticky;
  top: 24px;
}
.widget {
  margin-bottom: 32px;
}
.widget-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.widget-list {
  list-style: none;
  padding: 0;
}
.widget-list li {
  margin-bottom: 8px;
}
.widget-list li a {
  font-size: 14px;
  color: var(--text);
  transition: color 0.2s;
}
.widget-list li a:hover {
  color: var(--link);
}

/* --- 404 --- */
.error-page {
  text-align: center;
  padding: 80px 0;
}
.error-page h2 {
  font-size: 48px;
  font-weight: 900;
  color: var(--title);
  margin-bottom: 16px;
}
.error-page p {
  color: var(--text-secondary);
  font-size: 18px;
}
.error-page a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* --- Archive Title --- */
.archive-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* --- Password Protected --- */
.protected .text {
  width: 100%;
  max-width: 300px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .sidebar {
    padding-top: 32px;
    border-top: 1px solid var(--border);
    position: static;
  }
  .post-item-title { font-size: 22px; }
  .post-title { font-size: 30px; }
  main { padding: 32px 0; }
  .site-header { padding-top: 32px; }
  .post-item { margin-bottom: 36px; }
  .post-nav { flex-direction: column; gap: 12px; }
  .post-nav .next { text-align: left; }
  .site-nav { flex-wrap: wrap; }
}

/* --- Accessibility --- */
.sr-only {
  border: 0;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}
