/* مدآپیس: stylesheet. RTL, mobile first. */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #1e2b22;
  --muted: #5d6a60;
  --paper: #f6f7f1;
  --surface: #ffffff;
  --line: #dadfd2;
  --honey: #e8a410;
  --honey-deep: #8a5a00;
  --honey-soft: #fbedc2;
  --moss: #35633f;
  --danger: #a12a1f;
  --radius: 6px;
  --wrap: 960px;
  --prose: 40rem;
}

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

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

body {
  margin: 0;
  font-family: "Vazirmatn", "Vazir", Tahoma, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.9;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--moss); text-underline-offset: 3px; }
a:hover { color: var(--honey-deep); }

:focus-visible { outline: 3px solid var(--honey); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.5; margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 1rem; }
.narrow { max-width: var(--prose); margin-inline: auto; padding-block: 1.5rem; }

.skip {
  position: absolute; inset-inline-start: 1rem; top: -4rem;
  background: var(--ink); color: #fff; padding: .4rem .8rem; border-radius: var(--radius);
}
.skip:focus { top: .5rem; z-index: 10; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "brand account" "nav nav";
  align-items: center;
  gap: .25rem 1rem;
  padding-block: .6rem;
}
.brand {
  grid-area: brand; display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 800; font-size: 1.25rem; color: var(--ink); text-decoration: none;
}
.nav { grid-area: nav; display: flex; gap: 1.1rem; overflow-x: auto; white-space: nowrap; padding-block: .25rem; }
.nav a { color: var(--ink); text-decoration: none; padding-block: .2rem; border-bottom: 2px solid transparent; }
.nav a:hover { border-bottom-color: var(--honey); color: var(--ink); }
.account { grid-area: account; display: flex; align-items: center; justify-content: flex-end; gap: .75rem; }
.me { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink); text-decoration: none; }
.me-name { max-width: 7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 820px) {
  .bar {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand nav account";
  }
  .nav { justify-content: center; }
}

/* Hexagon: avatars and brand mark */
.hex {
  display: inline-grid; place-items: center; flex: none;
  background: var(--honey-soft); color: var(--honey-deep); font-weight: 700;
  clip-path: polygon(50% 0, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%);
  overflow: hidden;
}
.hex img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hex-xs { width: 28px; height: 28px; font-size: .8rem; }
.hex-sm { width: 42px; height: 42px; font-size: 1rem; }
.hex-md { width: 60px; height: 60px; font-size: 1.3rem; }
.hex-lg { width: 120px; height: 120px; font-size: 2.4rem; }
.hex-brand { width: 28px; height: 28px; background: var(--honey); }

/* Buttons and forms */
.btn {
  display: inline-block; font: inherit; line-height: 1.5; cursor: pointer;
  padding: .55rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--ink); background: var(--surface); color: var(--ink);
  text-decoration: none; text-align: center;
}
.btn:hover { background: var(--honey-soft); color: var(--ink); }
.btn-primary { background: var(--honey); border-color: var(--honey); color: var(--ink); font-weight: 700; }
.btn-primary:hover { background: #f2b52e; border-color: #f2b52e; }
.btn-ghost { border-color: var(--line); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-small { padding: .25rem .8rem; font-size: .92rem; }

.link-button {
  font: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--moss); text-decoration: underline; text-underline-offset: 3px;
}
.link-button:hover { color: var(--honey-deep); }
form.inline { display: inline; margin: 0; }

.form { margin-block: 1rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid #b9c1ae; border-radius: var(--radius); padding: .5rem .7rem;
}
input[type="file"] { max-width: 100%; }
textarea { line-height: 1.8; resize: vertical; }
.hint { color: var(--muted); font-size: .88rem; margin-top: .25rem; }
.hint ul { margin: .25rem 0 0; padding-inline-start: 1.2rem; }
.error { color: var(--danger); margin: .25rem 0 0; font-size: .92rem; }
.note, .aside { color: var(--muted); }

/* Messages */
.messages { list-style: none; margin: 1rem 0 0; padding: 0; }
.msg {
  padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--moss);
}
.msg-error, .msg-warning { border-inline-start-color: var(--danger); }

/* Hero */
.hero {
  display: grid; gap: 2rem; align-items: center;
  padding-block: 2.5rem 2rem; border-bottom: 1px solid var(--line);
}
.hero h1 { font-size: 1.9rem; max-width: 22ch; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 34rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.2rem 0 0; }

.comb {
  --w: clamp(88px, 24vw, 124px);
  display: flex; padding-bottom: calc(var(--w) * 0.45); justify-content: center;
}
.cell {
  width: var(--w); aspect-ratio: 1 / 0.866; flex: none;
  margin-inline-start: calc(var(--w) * -0.25 + 4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--honey-soft); color: var(--ink); text-decoration: none;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  font-size: .85rem; line-height: 1.4;
}
.cell:first-child { margin-inline-start: 0; }
.cell:nth-child(even) { transform: translateY(calc(var(--w) * 0.433 + 2px)); }
.cell:hover { background: var(--honey); color: var(--ink); }
.cell-n { font-size: 1.35rem; font-weight: 800; }

@media (min-width: 820px) {
  .hero { grid-template-columns: 1fr auto; }
  .hero h1 { font-size: 2.3rem; }
  .comb { --w: 124px; }
}

/* Content blocks and rows */
.block { padding-block: 1.8rem 0.5rem; }
.block-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  border-bottom: 2px solid var(--ink); margin-bottom: .25rem; padding-bottom: .35rem;
}
.block-head h1, .block-head h2 { margin: 0; }

.row { display: flex; gap: .9rem; padding-block: 1rem; border-bottom: 1px solid var(--line); }
.row-avatar { flex: none; }
.row-body { min-width: 0; flex: 1; }
.row h3 { margin-bottom: .2rem; }
.row h3 a { color: var(--ink); text-decoration: none; }
.row h3 a:hover { color: var(--honey-deep); text-decoration: underline; }
.row-summary { color: var(--muted); margin-bottom: .3rem; max-width: var(--prose); }

.meta { display: flex; flex-wrap: wrap; gap: 0 1rem; color: var(--muted); font-size: .88rem; margin: 0; }
.meta a { color: var(--muted); }

.answers-count {
  flex: none; width: 3.8rem; text-align: center; line-height: 1.3; padding-top: .2rem;
  color: var(--muted); font-size: .85rem;
}
.answers-count strong { display: block; font-size: 1.3rem; color: var(--ink); }
.answers-count.is-solved { color: var(--moss); }
.answers-count.is-solved strong { color: var(--moss); }

.badge {
  display: inline-block; padding: 0 .5rem; border-radius: 99px;
  background: var(--honey-soft); color: var(--honey-deep); font-size: .8rem;
}
.badge-ok { background: #dcebdd; color: var(--moss); }

.empty { color: var(--muted); padding-block: 1rem; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; padding-block: .8rem; }
.filters input[type="search"] { flex: 1 1 14rem; width: auto; }
.filters select { flex: 0 1 12rem; width: auto; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 1.2rem; }

/* Post and question pages */
.kind { margin-bottom: .2rem; font-size: .92rem; }
.byline { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.2rem; }
.cover { width: 100%; height: auto; border-radius: var(--radius); margin-bottom: 1.2rem; }
.prose { max-width: var(--prose); }
.prose p { margin-bottom: 1.1rem; }
.manage { display: flex; gap: .5rem; margin-top: 1.5rem; }

.comments { margin-top: 2.5rem; border-top: 2px solid var(--ink); padding-top: 1rem; }
.comment { display: flex; gap: .75rem; padding-block: .9rem; border-bottom: 1px solid var(--line); }
.comment > div { min-width: 0; flex: 1; }
.comment .prose p:last-child { margin-bottom: .3rem; }
.comment.is-accepted { background: #eef5ee; margin-inline: -.75rem; padding-inline: .75rem; border-radius: var(--radius); }

/* Profile */
.profile-head { display: flex; gap: 1.2rem; align-items: center; padding-block: 2rem 1rem; }
.profile-head h1 { margin-bottom: .2rem; }
.bio { max-width: var(--prose); margin-top: .6rem; }

/* Footer */
.site-footer { margin-top: 3rem; border-top: 1px solid var(--line); padding-block: 1.5rem; color: var(--muted); font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
