/* اطلاع‌رسانی — minimal RTL blog styles. Logical properties throughout, so RTL just works. */

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #18202b;
  --text-2: #3c4656;
  --muted: #6b7584;
  --border: #e4e7ec;
  --accent: #0b7a64;
  --accent-hover: #086652;
  --accent-soft: #e5f4ef;
  --on-accent: #ffffff;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --danger: #b4321f;
  --danger-soft: #fdece9;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --radius: 16px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e1217;
    --surface: #151a21;
    --surface-2: #1d232c;
    --text: #e8ebf0;
    --text-2: #c2c8d2;
    --muted: #8e98a7;
    --border: #262d37;
    --accent: #3cc4a3;
    --accent-hover: #62d4b7;
    --accent-soft: rgba(60, 196, 163, .13);
    --on-accent: #052019;
    --warn: #f1c46c;
    --warn-soft: rgba(241, 196, 108, .12);
    --danger: #f08070;
    --danger-soft: rgba(240, 128, 112, .12);
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1; }

.wrap {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding-inline: 16px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }

.icon { flex-shrink: 0; vertical-align: -.15em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------------------------------------------------------------- header & footer */

.site-header { padding-block: 32px 8px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 60%, transparent);
}

.brand-text strong {
  display: block;
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: -.01em;
}
.brand-text small {
  display: block;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.5;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  padding-block: 40px 32px;
  color: var(--muted);
  font-size: .85rem;
}
.site-footer nav { display: flex; gap: 18px; }
.site-footer a { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.site-footer a:hover { color: var(--text); }

/* ---------------------------------------------------------------- admin bar */

.adminbar {
  background: #161c24;
  color: #dfe4ea;
  font-size: .85rem;
}
.adminbar-inner {
  display: flex;
  align-items: center;
  gap: 4px 18px;
  flex-wrap: wrap;
  min-height: 40px;
}
.adminbar a { color: #dfe4ea; display: inline-flex; align-items: center; gap: 6px; }
.adminbar a:hover { color: #fff; text-decoration: none; }
.adminbar-end { margin-inline-start: auto; }
.adminbar button {
  font: inherit;
  color: #aab3bf;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.adminbar button:hover { color: #fff; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding-inline: 6px;
  border-radius: 999px;
  background: #f5a524;
  color: #1d1300;
  font-size: .72rem;
  font-weight: 700;
}

/* ---------------------------------------------------------------- search */

.search {
  position: relative;
  margin-block: 20px 8px;
}
.search .icon {
  position: absolute;
  inset-inline-start: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search input[type="search"] {
  height: 50px;
  padding-inline: 46px 18px;
  border-radius: 999px;
}

.result-note {
  color: var(--text-2);
  font-size: .92rem;
  margin-block: 12px;
}
.result-note a { margin-inline-start: 8px; }

/* ---------------------------------------------------------------- cards & lists */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.post-list {
  display: grid;
  gap: 12px;
  margin-block: 14px;
}

.post-card { transition: border-color .15s ease, transform .15s ease; }
.post-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.post-card:active { transform: scale(.995); }
.post-card.is-pinned {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: linear-gradient(to bottom, var(--accent-soft), var(--surface) 70%);
}

.card-link {
  display: block;
  padding: 18px 20px;
  color: inherit;
  border-radius: inherit;
}
.card-link:hover { text-decoration: none; }
.card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-title {
  margin: 0 0 4px;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.65;
  color: var(--text);
}

.card-excerpt {
  margin: 0 0 10px;
  color: var(--text-2);
  font-size: .94rem;
  line-height: 1.9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  color: var(--muted);
  font-size: .84rem;
}
.meta span { display: inline-flex; align-items: center; gap: 6px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-block-end: 8px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.9;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.tag-new { background: var(--warn-soft); color: var(--warn); }
.tag-wait { background: var(--warn-soft); color: var(--warn); white-space: normal; }
.tag-muted { background: var(--surface-2); color: var(--muted); }

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 20px;
  margin-block: 20px;
  text-align: center;
  color: var(--muted);
}
.empty p { margin: 0 0 8px; }
.empty-code {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--accent);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block: 24px;
}

/* ---------------------------------------------------------------- single post */

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-block: 16px 12px;
  color: var(--muted);
  font-size: .9rem;
}
.back:hover { color: var(--text); text-decoration: none; }

.post { padding: 22px 20px; }

.post-header {
  padding-block-end: 16px;
  margin-block-end: 20px;
  border-block-end: 1px solid var(--border);
}
.post h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.6;
  letter-spacing: -.01em;
}

.post-admin {
  margin-block-start: 24px;
  padding-block-start: 16px;
  border-block-start: 1px dashed var(--border);
}

.notice {
  margin-block-end: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: .9rem;
}

@media (min-width: 640px) {
  .post { padding: 32px 36px; }
  .post h1 { font-size: 1.75rem; }
}

/* Article body */
.prose {
  font-size: 1.04rem;
  line-height: 2;
  overflow-wrap: break-word;
}
.prose > :first-child { margin-block-start: 0; }
.prose > :last-child { margin-block-end: 0; }
.prose p { margin-block: 0 1em; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  line-height: 1.6;
  margin-block: 1.6em .5em;
  font-weight: 700;
}
.prose h1, .prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.1rem; }
.prose h4 { font-size: 1rem; }
.prose ul, .prose ol { padding-inline-start: 1.4em; margin-block: 0 1em; }
.prose li { margin-block: .2em; }
.prose li::marker { color: var(--accent); }
.prose strong { font-weight: 700; color: var(--text); }
.prose a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.prose blockquote {
  margin: 1.2em 0;
  padding: .7em 1.1em;
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-2);
}
.prose blockquote p:last-child { margin-block-end: 0; }
.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.2em auto;
  border-radius: 12px;
}
.prose hr { border: 0; border-block-start: 1px solid var(--border); margin-block: 2em; }
.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin-block: 1.2em;
  font-size: .94rem;
}
.prose th, .prose td {
  padding: .5em .85em;
  border: 1px solid var(--border);
  text-align: start;
  white-space: nowrap;
}
.prose th { background: var(--surface-2); font-weight: 700; }
.prose code {
  direction: ltr;
  unicode-bidi: isolate;
  padding: .1em .4em;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
}
.prose pre {
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  padding: 1em 1.2em;
  border-radius: 12px;
  background: var(--surface-2);
  line-height: 1.6;
}
.prose pre code { padding: 0; background: none; }

/* Uploaded attachments (PDF, Word, …) render as file chips */
.prose a[href^="/uploads/"]:not(:has(img)) {
  display: inline-flex;
  align-items: center;
  gap: .45em;
  max-width: 100%;
  margin-block: .25em;
  padding: .3em .95em;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .92rem;
  text-decoration: none;
}
.prose a[href^="/uploads/"]:not(:has(img))::before {
  content: "";
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6M12 18v-6M9 15l3 3 3-3'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6M12 18v-6M9 15l3 3 3-3'/%3E%3C/svg%3E") center / contain no-repeat;
}
.prose a[href^="/uploads/"]:not(:has(img)):hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------------------------------------------------------------- comments */

.comments { margin-block: 32px 8px; }
.comments h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 1.15rem;
}
.count {
  padding-inline: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
}

.comment-list { padding-inline: 20px; margin-block-end: 16px; }

.comment { padding-block: 16px; }
.comment + .comment { border-block-start: 1px solid var(--border); }
.comment.is-pending { opacity: .75; }

.comment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .92rem;
}
.comment-head time {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: .8rem;
  white-space: nowrap;
}

.avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 700;
  font-size: .95rem;
}
.comment.is-admin .avatar { background: var(--accent); color: var(--on-accent); }
.verified { display: inline-flex; color: var(--accent); }
.ip {
  direction: ltr;
  unicode-bidi: isolate;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .72rem;
  line-height: 1.8;
}

.comment-body {
  margin-block-start: 4px;
  padding-inline-start: 44px;
  color: var(--text-2);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.comment-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-block-start: 10px;
  padding-inline-start: 44px;
}

.comment-form { padding: 20px; }
.comment-form h3 { margin: 0 0 12px; font-size: 1rem; }

.form-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Honeypot: invisible to people, tempting to bots */
.hp {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- forms & buttons */

.field { display: block; margin-block-end: 14px; }
.label {
  display: block;
  margin-block-end: 6px;
  font-size: .9rem;
  font-weight: 600;
}
.label .muted { font-weight: 400; }

input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.9; }

input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding-inline: 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 32px; padding-inline: 14px; font-size: .84rem; }

.flash {
  margin-block: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .93rem;
}
.flash-error { background: var(--danger-soft); color: var(--danger); }
.comment-form .flash { margin-block: 0 12px; }

/* ---------------------------------------------------------------- admin */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-block: 20px 14px;
}
.page-head h1 { margin: 0; font-size: 1.3rem; }

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.rows { overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
}
.row + .row { border-block-start: 1px solid var(--border); }
.row-main { flex: 1; min-width: 0; }
.row-title {
  display: block;
  color: var(--text);
  font-weight: 600;
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .meta { margin-block-start: 2px; }
.row .tags { margin: 0 0 4px; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.mod-item { padding: 16px 18px; }
.mod-item + .mod-item { border-block-start: 1px solid var(--border); }
.mod-item .comment-body { padding-inline-start: 0; margin-block: 6px 10px; }
.mod-item .row-actions { flex-wrap: wrap; }
.mod-item .row-actions form { display: inline; }
.mod-post { font-size: .84rem; color: var(--muted); }
.mod-post a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

.login {
  max-width: 380px;
  margin: 40px auto;
  padding: 28px 24px;
}
.login h1 { margin: 0 0 18px; font-size: 1.2rem; }
.login .btn { width: 100%; }

/* Editor */
.editor { padding: 20px; margin-block-end: 20px; }
.editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-block-end: 8px;
}
.tools { display: flex; flex-wrap: wrap; gap: 4px; }
.tool {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding-inline: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
}
.tool:hover { background: var(--surface-2); color: var(--text); }
.editor textarea[name="body"] { min-height: 340px; }
.editor-preview {
  min-height: 340px;
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}
.editor-help { margin-block: 8px 0; }
.upload-status { min-height: 1.5em; font-size: .85rem; color: var(--accent); }
.upload-status.is-error { color: var(--danger); }
.is-dragging { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-soft); }

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-block: 16px 20px;
}
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions .btn-danger { margin-inline-start: auto; }

[hidden] { display: none !important; }
