/* واژه‌نامهٔ شعر فارسی — ظاهر فلت
   بدون سایه، بدون گرادیان؛ فقط رنگ تخت و خط جداکننده. */

@font-face {
  font-family: Vazir;
  src: url('../fonts/Vazir.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: Vazir;
  src: url('../fonts/Vazir-Medium.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: Vazir;
  src: url('../fonts/Vazir-Bold.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

:root {
  --bg: #ffffff;
  --surface: #f4f5f7;
  --border: #e2e4e9;
  --text: #16181d;
  --muted: #6b7280;
  --accent: #2f6fed;
  --accent-soft: #e8f0fe;
  --bar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --surface: #1e2128;
    --border: #2b2f38;
    --text: #e8eaed;
    --muted: #9aa1ac;
    --accent: #5b8cff;
    --accent-soft: #1d2740;
  }
}

* { box-sizing: border-box; }

/* بدون این، هر قاعدهٔ display در CSS خاصیت hidden را بی‌اثر می‌کند */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: Vazir, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
  overscroll-behavior-y: none;
}

/* ---------- نوار بالا ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--bar-h);
  padding: 0 12px;
}

.search {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
}

.search:focus-within { border-color: var(--accent); }

#q {
  flex: 1;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  padding: 9px 0;
  outline: none;
  min-width: 0;
}

#q::-webkit-search-cancel-button { display: none; }

.icon-btn {
  flex: none;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn:active { background: var(--surface); }

/* ---------- تراشه‌های فیلتر کتاب ---------- */

.chips {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 13px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

/* ---------- فهرست نتایج ---------- */

.summary {
  padding: 12px 16px 6px;
  color: var(--muted);
  font-size: 14px;
}

.results { list-style: none; margin: 0; padding: 0; }

.row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 49px;
}
.row:active { background: var(--surface); }

.row .w { font-size: 19px; font-weight: 500; }
.row .w mark { background: none; color: var(--accent); font-weight: 700; }
.row .meta { margin-inline-start: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.row .n { font-variant-numeric: tabular-nums; }

/* ---------- صفحهٔ واژه ---------- */

.detail { padding: 20px 16px 40px; }

.detail h1 {
  margin: 0 0 4px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.3;
}

.detail .sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.fact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 14px;
}
.fact b { font-weight: 700; font-variant-numeric: tabular-nums; }
.fact span { color: var(--muted); }

.detail h2 {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin: 26px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ---------- معنی ---------- */

.gloss-box { margin-bottom: 4px; }

.gloss-via {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
}
.gloss-via a { color: var(--accent); text-decoration: none; }

.gloss {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.gloss-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* برچسب منبع — تا همیشه معلوم باشد معنی از کجا آمده */
.src {
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  padding: 2px 8px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}
.src-moein { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.gloss-meta { font-size: 12px; color: var(--muted); }

.senses { margin: 0; padding-inline-start: 20px; }
.senses li { margin-bottom: 3px; }
.senses li::marker { color: var(--muted); font-size: 13px; }
ul.senses { list-style: none; padding-inline-start: 0; }

.variants { display: flex; flex-wrap: wrap; gap: 6px; }
.variant {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 11px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.variant:active { background: var(--surface); }
.variant i { color: var(--muted); font-style: normal; font-size: 12px; }

.cite {
  border-inline-start: 3px solid var(--border);
  padding: 2px 14px;
  margin-bottom: 20px;
}
.cite p {
  margin: 0;
  font-size: 18px;
  line-height: 2;
}
.cite p mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.cite a {
  display: inline-block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.cite a:hover { color: var(--accent); }

/* ---------- حالت‌ها ---------- */

.state { padding: 60px 20px; text-align: center; color: var(--muted); }

.spinner {
  width: 26px; height: 26px;
  margin: 0 auto 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

@media (min-width: 720px) {
  .bar-row, .chips, .summary, .results, .detail { max-width: 700px; margin-inline: auto; }
  .results { border-inline: 1px solid var(--border); }
}
