/* blog.amirw.ir — Design system matches amirw.ir */

:root {
  --bg: #15181a;
  --fg: #e7e7e3;
  --muted: #9ba1a0;
  --faint: #6b7170;
  --accent: #6fa79b;
  --accent-strong: #8bc0b5;
  --accent-soft: rgba(111, 167, 155, 0.12);
  --border: #2a2e30;
  --border-strong: #3a3f42;
  --surface: #1b1f22;
  --surface-hover: #202529;
  --font-sans: ui-sans-serif, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --max: 860px;
  --line-width: 680px;
  --code-bg: #161b22;
  --tag-bg: #1b1f22;
  --tag-text: #9ba1a0;
  --blockquote-border: #2a2e30;
  --table-stripe: #1b1f22;
}

:root[data-theme="light"] {
  --bg: #f6f6f4;
  --fg: #1b1d1e;
  --muted: #5b6062;
  --faint: #8b8f8d;
  --accent: #3e6b63;
  --accent-strong: #2e5750;
  --accent-soft: rgba(62, 107, 99, 0.1);
  --border: #dededa;
  --border-strong: #c6c6c0;
  --surface: #efefeb;
  --surface-hover: #e8e8e3;
  --code-bg: #efefeb;
  --tag-bg: #efefeb;
  --tag-text: #5b6062;
  --blockquote-border: #dededa;
  --table-stripe: #efefeb;
}

*, *::before, *::after { box-sizing: border-box; }
*::selection { background: var(--accent); color: var(--bg); }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s ease, color 0.15s ease;
}

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

/* ---------- Layout (same as amirw.ir) ---------- */
.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 4rem;
}

@media (max-width: 600px) {
  .wrap { padding: 1rem 1.25rem 3rem; }
}

/* ---------- Top bar (same as amirw.ir) ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
}

@media (max-width: 600px) {
  .topbar { padding: 0.9rem 1.25rem; flex-wrap: wrap; }
}

.brand { font-weight: 650; letter-spacing: -0.01em; color: var(--fg); font-size: 1.05rem; }
.brand:hover { color: var(--accent); }
.brand .dot { color: var(--accent); }

.topbar-links { display: flex; gap: 1.4rem; align-items: center; font-size: 0.95rem; }
.topbar-links a { color: var(--muted); font-weight: 500; }
.topbar-links a:hover { color: var(--fg); }
.topbar-links a.active { color: var(--fg); border-bottom: 1px solid var(--accent); padding-bottom: 1px; }

@media (max-width: 600px) {
  .topbar-links { gap: 1rem; order: 3; width: 100%; justify-content: space-between; }
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .moon { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }

/* ---------- Page header ---------- */
.page-head { padding: 3rem 0 1.5rem; }
.page-head h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 0.4rem; }
.page-head p { color: var(--muted); max-width: 56ch; margin: 0; }

/* ---------- Post list (ysamm.com style) ---------- */
.post-list { padding-bottom: 2rem; }
.post-item {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.post-item:first-child { padding-top: 0; }
.post-date {
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--faint);
  white-space: nowrap;
  min-width: 7.5rem;
  font-variant-numeric: tabular-nums;
}
.post-title {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  line-height: 1.4;
}
.post-title a { color: var(--fg); }
.post-title a:hover { color: var(--accent); }

@media (max-width: 600px) {
  .post-item { flex-direction: column; gap: 0.2rem; }
  .post-date { min-width: auto; font-size: 0.78rem; }
  .post-title { font-size: 0.95rem; }
}

/* ---------- Writeup list ---------- */
.writeup-list { padding-bottom: 2rem; }
.writeup-card { padding: 1.5rem 0; border-bottom: 1px solid var(--border); }
.writeup-card:first-child { padding-top: 0; }
.writeup-card-body { max-width: var(--line-width); }

.writeup-meta {
  font-size: 0.82rem; color: var(--faint);
  margin-bottom: 0.3rem; display: flex; align-items: center; gap: 0.4rem;
}
.meta-sep { color: var(--faint); }

.writeup-title {
  font-size: 1.25rem; font-weight: 650;
  line-height: 1.4; margin-bottom: 0.4rem; letter-spacing: -0.01em;
}
.writeup-title a { color: var(--fg); }
.writeup-title a:hover { color: var(--accent); }

.writeup-desc {
  font-size: 0.93rem; color: var(--muted);
  line-height: 1.55; margin-bottom: 0.7rem;
}

.writeup-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ---------- Tags ---------- */
.tag {
  display: inline-block; padding: 0.15rem 0.55rem;
  font-size: 0.72rem; font-weight: 500; font-family: var(--font-mono);
  color: var(--tag-text); background: var(--tag-bg);
  border: 1px solid var(--border); border-radius: 4px;
}
.tag:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; padding: 2rem 0 3rem;
}
.page-link {
  color: var(--accent); font-size: 0.95rem; font-weight: 500;
  padding: 0.5rem 1rem; border: 1px solid var(--border);
  border-radius: 7px; transition: all 0.15s;
}
.page-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.page-info { font-size: 0.88rem; color: var(--faint); }

/* ---------- Article ---------- */
.writeup-main { padding-bottom: 3rem; }
.writeup-article { padding: 2rem 0; }
.article-header { margin-bottom: 2rem; max-width: var(--line-width); }

.article-meta {
  font-size: 0.82rem; color: var(--faint);
  margin-bottom: 0.6rem; display: flex; align-items: center; gap: 0.4rem;
}

.article-title {
  font-size: 2rem; font-weight: 700;
  letter-spacing: -0.025em; line-height: 1.25; margin-bottom: 0.7rem;
}

.article-desc {
  font-size: 1.08rem; color: var(--muted);
  line-height: 1.55; margin-bottom: 1rem;
}

.article-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ---------- TOC ---------- */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 1.2rem 1.4rem;
  margin-bottom: 2rem; max-width: var(--line-width);
}
.toc-title {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 0.7rem;
}
.toc-list { list-style: none; padding: 0; }
.toc-item { margin-bottom: 0.25rem; }
.toc-item a { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.toc-item a:hover { color: var(--accent); }
.toc-level-2 { padding-left: 0; }
.toc-level-3 { padding-left: 1rem; }
.toc-level-4 { padding-left: 2rem; }

/* ---------- Article body typography ---------- */
.article-body { max-width: var(--line-width); font-size: 1.05rem; line-height: 1.75; }

.article-body h2 {
  font-size: 1.55rem; font-weight: 650;
  margin-top: 2.2em; margin-bottom: 0.6em;
  letter-spacing: -0.015em; line-height: 1.3;
  padding-bottom: 0.3em; border-bottom: 1px solid var(--border);
}

.article-body h3 {
  font-size: 1.3rem; font-weight: 600;
  margin-top: 1.8em; margin-bottom: 0.5em;
  letter-spacing: -0.01em; line-height: 1.35;
}

.article-body h4 {
  font-size: 1.1rem; font-weight: 600;
  margin-top: 1.5em; margin-bottom: 0.5em;
  color: var(--fg);
}

.article-body h5, .article-body h6 {
  font-size: 1rem; font-weight: 600;
  margin-top: 1.5em; margin-bottom: 0.5em;
  color: var(--muted);
}

.article-body p { margin-bottom: 1.2em; }

.article-body a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.article-body a:hover { border-bottom-color: var(--accent); }

.article-body strong { font-weight: 600; }
.article-body em { font-style: italic; }

.article-body ul, .article-body ol { margin-bottom: 1.2em; padding-left: 1.5em; }
.article-body li { margin-bottom: 0.4em; }

/* Code */
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.87em; background: var(--code-bg);
  color: var(--fg); padding: 0.1rem 0.35rem; border-radius: 4px;
}

.article-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem 1.25rem;
  overflow-x: auto; margin-bottom: 1.4em;
  font-size: 0.88rem; line-height: 1.55;
}

.article-body pre code {
  background: none; padding: 0; font-size: inherit; border-radius: 0;
}

/* Blockquote */
.article-body blockquote {
  border-left: 3px solid var(--blockquote-border);
  padding: 0.4rem 1rem; margin: 1.2em 0;
  background: var(--surface);
  border-radius: 0 4px 4px 0; color: var(--muted);
}
.article-body blockquote p:last-child { margin-bottom: 0; }

/* HR */
.article-body hr { border: none; height: 1px; background: var(--border); margin: 2em 0; }

/* Images */
.article-body img {
  max-width: 100%; height: auto; border-radius: 8px;
  margin: 1.4em 0; display: block; border: 1px solid var(--border);
}
.article-body img + em {
  display: block; text-align: center;
  font-size: 0.85rem; color: var(--faint);
  margin-top: -1em; margin-bottom: 1.4em;
}

/* Video */
.article-body iframe {
  max-width: 100%; border-radius: 8px;
  margin: 1.4em 0; border: 1px solid var(--border);
}

/* Tables */
.article-body table {
  width: 100%; border-collapse: collapse;
  margin: 1.4em 0; font-size: 0.93rem;
  overflow-x: auto; display: block;
}
.article-body th {
  background: var(--surface); font-weight: 600;
  text-align: left; padding: 0.6rem 0.85rem;
  border: 1px solid var(--border); font-size: 0.88rem;
}
.article-body td { padding: 0.5rem 0.85rem; border: 1px solid var(--border); }
.article-body tr:nth-child(even) td { background: var(--table-stripe); }

/* Footer note */
.article-footer-note { margin-top: 3rem; }
.footer-note-text { font-size: 0.93rem; color: var(--muted); }
.footer-note-text a { color: var(--accent); }

/* ---------- Related ---------- */
.related-section { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.related-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.8rem; color: var(--muted); }
.related-list { display: grid; gap: 0.5rem; }
.related-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.9rem; border: 1px solid var(--border);
  border-radius: 8px; transition: border-color 0.15s;
}
.related-item:hover { border-color: var(--accent); }
.related-date { font-size: 0.75rem; color: var(--faint); flex-shrink: 0; }
.related-name { font-size: 0.93rem; color: var(--fg); font-weight: 500; }
.related-item:hover .related-name { color: var(--accent); }

/* ---------- Footer ---------- */
.footer {
  margin-top: 3rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--faint); font-size: 0.85rem;
  font-family: var(--font-mono);
}
.footer a { color: var(--faint); }
.footer a:hover { color: var(--accent); }

.footer-desc {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--font-sans);
  margin-bottom: 0.6rem;
}

.footer-social {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  transition: all 0.15s;
}

.footer-social a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.footer-social svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.footer-social a.email svg {
  fill: none;
}

.footer-credit {
  font-size: 0.82rem;
  color: var(--faint);
}

/* ---------- Feed link ---------- */
.feed-link {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- About page ---------- */
.about-page { padding-top: 2rem; }
.about-page h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
.about-subtitle { color: var(--muted); font-size: 1.05rem; max-width: 56ch; margin-bottom: 2rem; }
.about-block { margin-top: 2rem; }
.about-block h3 {
  font-size: 1rem; font-weight: 600;
  color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.05em; font-family: var(--font-mono);
  margin: 0 0 0.6rem;
}
.about-block p { max-width: 62ch; margin-bottom: 0.8rem; color: var(--fg); }
.about-block a { color: var(--accent); border-bottom: 1px solid transparent; }
.about-block a:hover { border-bottom-color: var(--accent); }

/* ---------- Tag page header ---------- */
.tag-header { padding: 2.5rem 0 1rem; }
.tag-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.tag-header p { color: var(--muted); margin-top: 0.3rem; }

/* ---------- Empty ---------- */
.empty-state { text-align: center; padding: 4rem 0; color: var(--muted); }
.back-link { display: inline-block; margin-top: 0.7rem; color: var(--accent); }
.back-link:hover { text-decoration: underline; }

/* ---------- Utilities ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { body { transition: none; } }
@media (max-width: 600px) {
  .article-title { font-size: 1.55rem; }
  .writeup-title { font-size: 1.1rem; }
  .article-body { font-size: 1rem; }
  .article-body h2 { font-size: 1.3rem; }
  .article-body h3 { font-size: 1.15rem; }
  .page-head h1 { font-size: 1.5rem; }
}
