/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Theme tokens ===== */
:root {
  --color-bg: #fafafa;
  --color-bg-alt: #f4f4f5;
  --color-text: #18181b;
  --color-text-secondary: #52525b;
  --color-text-muted: #a1a1aa;
  --color-border: #e4e4e7;
  --color-accent: #FF4F00;
  --color-accent-hover: #E64600;
  --color-accent-subtle: #FFF1EB;
  --color-code-bg: #f4f4f5;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --max-width: 680px;
  --header-max-width: 880px;
}

[data-theme="dark"] {
  --color-bg: #18181b;
  --color-bg-alt: #27272a;
  --color-text: #fafafa;
  --color-text-secondary: #a1a1aa;
  --color-text-muted: #71717a;
  --color-border: #3f3f46;
  --color-accent: #FF7A3D;
  --color-accent-hover: #FF935E;
  --color-accent-subtle: #2A1A10;
  --color-code-bg: #27272a;
}

/* ===== Base ===== */
html {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.post-image-link {
  display: block;
  text-align: center;
}

.post-image {
  display: block;
  margin: 2rem auto;
  max-width: 100%;
  cursor: zoom-in;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: 2rem;
}

.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

/* ===== Layout ===== */
.site-header {
  max-width: var(--header-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.site-title:hover {
  color: var(--color-text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.site-nav a {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

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

main {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
  flex: 1;
}

.site-footer {
  max-width: var(--header-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ===== Dark mode toggle ===== */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 1.1rem;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

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

/* ===== Post list ===== */
.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.post-item-title {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.3;
}

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

.post-item-title a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.post-item-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.post-item-summary {
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
}

/* ===== Tags ===== */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}

.tag-list a {
  color: var(--color-accent);
  font-size: 0.85rem;
  font-weight: 500;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.post-tags a {
  color: var(--color-accent);
  font-size: 0.8rem;
  font-weight: 500;
}

.post-tags a::before {
  content: "#";
}

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

.post-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

.post-meta span + span::before {
  content: " · ";
}

.post-cover {
  margin-bottom: 2rem;
}

/* ===== Post content (prose) ===== */
.post-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.post-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.25rem;
}

.post-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 1rem;
  color: var(--color-text-secondary);
  margin-bottom: 1.25rem;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--color-code-bg);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

.post-content a {
  text-decoration-color: var(--color-accent-subtle);
  text-underline-offset: 2px;
}

.post-content a:hover {
  text-decoration-color: var(--color-accent);
}

.post-content video,
.post-content iframe {
  max-width: 100%;
  margin-bottom: 1.25rem;
  border-radius: 4px;
}

/* ===== Tags index page ===== */
.tags-index {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tags-index a {
  font-size: 1rem;
  font-weight: 500;
}

.tags-index .tag-count {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 400;
}

/* ===== 404 ===== */
.not-found {
  text-align: center;
  padding: 4rem 0;
}

.not-found h1 {
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-accent);
}

.not-found p {
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
}

/* ===== Page title (about, tags index) ===== */
.page-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
