/* ===== Topic Dictionary — style ===== */
:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface2: #fbfbf7;
  --ink: #1e241c;
  --ink-2: #55604f;
  --ink-3: #8b968a;
  --line: #e3e6dc;
  --accent: #2e6b4f;
  --accent-2: #3d8a67;
  --accent-soft: #e8f1ea;
  --gold: #b7791f;
  --gold-soft: #fdf3e0;
  --fa-font: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  --en-font: "JetBrains Mono", ui-monospace, monospace;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(30, 36, 28, .06), 0 8px 24px rgba(30, 36, 28, .05);
  --shadow-lg: 0 4px 12px rgba(30, 36, 28, .08), 0 16px 40px rgba(30, 36, 28, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--fa-font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  min-height: 100vh;
}

.hidden { display: none !important; }

b { font-weight: 700; }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 26px;
  filter: sepia(.3) hue-rotate(60deg);
}

.brand-text h1 { font-size: 19px; font-weight: 800; line-height: 1.3; }

.brand-sub {
  display: block;
  font-size: 10.5px;
  font-family: var(--en-font);
  color: var(--ink-3);
  letter-spacing: .04em;
}

.search-wrap { position: relative; flex: 1; min-width: 260px; max-width: 520px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 9px 14px;
  transition: border-color .15s, box-shadow .15s;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-icon { font-size: 14px; opacity: .55; }

#searchInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--en-font);
  font-size: 14.5px;
  color: var(--ink);
  direction: ltr;
  text-align: left;
}

#searchInput::placeholder { color: var(--ink-3); font-family: var(--fa-font); font-size: 13px; text-align: right; }

.clear-btn {
  border: none;
  background: var(--line);
  color: var(--ink-2);
  width: 20px; height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  flex-shrink: 0;
}
.clear-btn:hover { background: var(--ink-3); color: #fff; }

.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  flex-shrink: 0;
}
.header-stats b { color: var(--accent); font-family: var(--en-font); }
.stat-sep { opacity: .35; }

/* ===== Suggestions dropdown ===== */
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 380px;
  overflow-y: auto;
  z-index: 60;
}

.sug-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--surface2);
  direction: ltr;
  text-align: left;
}
.sug-item:last-child { border-bottom: none; }
.sug-item:hover, .sug-item.active { background: var(--accent-soft); }

.sug-term { font-family: var(--en-font); font-size: 14px; font-weight: 600; }
.sug-pos {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}
.sug-gloss { font-size: 12px; color: var(--ink-2); margin-left: auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 45%; direction: rtl; }

.sug-more {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 8px;
  border-top: 1px solid var(--line);
}

/* ===== Main layout ===== */
.site-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ===== Welcome ===== */
.welcome-hero { text-align: center; margin: 24px 0 30px; }

.welcome-badge { font-size: 34px; margin-bottom: 10px; }

.welcome-hero h2 { font-size: 21px; font-weight: 800; margin-bottom: 10px; }

.welcome-text {
  max-width: 640px;
  margin: 0 auto;
  font-size: 13.5px;
  color: var(--ink-2);
}

.demo-block { margin: 26px 0 34px; text-align: center; }

.demo-label {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 10px;
  letter-spacing: .02em;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--en-font);
  font-size: 12.5px;
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all .15s;
  direction: ltr;
  unicode-bidi: isolate;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ===== Topic grid ===== */
.topics-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.topics-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.topics-title { font-size: 15px; font-weight: 700; }

.topic-filter {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 12px;
  font-family: var(--fa-font);
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
  width: 190px;
}
.topic-filter:focus { border-color: var(--accent); }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.topic-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid var(--line);
  background: var(--surface2);
  border-radius: 10px;
  padding: 11px 13px;
  cursor: pointer;
  transition: all .15s;
  text-align: right;
}
.topic-card:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }

.topic-name { font-size: 13.5px; font-weight: 600; direction: ltr; text-align: right; font-family: var(--en-font); font-size: 12px; }

.topic-count { font-size: 11px; color: var(--ink-3); }

.chip-n { font-family: var(--en-font); font-size: 10px; color: var(--ink-3); }

.subtopics { margin-bottom: 16px; }

/* ===== Results list ===== */
.results-head { margin-bottom: 14px; }
.results-title { font-size: 16px; font-weight: 800; }
.results-note { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.result-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.result-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.res-term { font-family: var(--en-font); font-size: 15.5px; font-weight: 600; direction: ltr; }

.res-pos {
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 9px;
  border-radius: 20px;
  flex-shrink: 0;
}

.res-gloss { font-size: 13px; color: var(--ink-2); margin-inline-start: auto; }

.res-path {
  width: 100%;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--en-font);
  direction: ltr;
  text-align: left;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
  margin-top: 2px;
}

/* ===== Detail ===== */
.back-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--fa-font);
  font-size: 12.5px;
  padding: 7px 16px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 18px;
  transition: all .15s;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }

.entry-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  margin-bottom: 16px;
}

.entry-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; direction: ltr; }

.entry-term { font-family: var(--en-font); font-size: 28px; font-weight: 700; }

.entry-ipa { font-family: var(--en-font); font-size: 14px; color: var(--gold); }

.entry-pos {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 11px;
  border-radius: 20px;
  font-family: var(--en-font);
}

.entry-sub { font-size: 11px; color: var(--ink-3); font-family: var(--en-font); direction: ltr; text-align: left; }

.entry-fa {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--accent);
  margin: 10px 0 4px;
  line-height: 1.9;
}

.entry-def {
  font-size: 14px;
  color: var(--ink-2);
  direction: ltr;
  text-align: left;
  border-right: none;
  border-left: 3px solid var(--accent-soft);
  padding-left: 12px;
  margin: 10px 0;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: .03em;
  margin: 20px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.pattern-box, .syn-box {
  direction: ltr;
  text-align: left;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pat-chip {
  font-family: var(--en-font);
  font-size: 12px;
  background: var(--gold-soft);
  color: var(--gold);
  padding: 3px 11px;
  border-radius: 8px;
}

.syn-chip {
  font-family: var(--en-font);
  font-size: 12.5px;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  padding: 3px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.syn-chip:hover { border-color: var(--accent); color: var(--accent); }

.notes-list { direction: ltr; text-align: left; padding-right: 0; padding-left: 0; list-style: none; }
.notes-list li {
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 7px 0 7px 0;
  border-bottom: 1px dashed var(--line);
  font-family: var(--en-font);
}
.notes-list li:last-child { border-bottom: none; }

.example-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}
.example-item:last-child { border-bottom: none; }

.ex-en { font-size: 13.5px; direction: ltr; text-align: left; color: var(--ink); font-family: var(--en-font); font-size: 12.5px; }

.ex-fa { font-size: 13px; color: var(--accent-2); padding-right: 18px; }

/* ===== Topic path / breadcrumb ===== */
.crumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  direction: ltr;
  font-family: var(--en-font);
  font-size: 11.5px;
  margin: 14px 0 4px;
}

.crumb-sep { color: var(--ink-3); }

.crumb-node { color: var(--ink-2); background: var(--surface2); border: 1px solid var(--line); padding: 1px 9px; border-radius: 20px; }

.crumb-node.leaf { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; }

.entry-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--en-font);
  direction: ltr;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

/* ===== Loading & empty ===== */
.empty-msg { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 14px; }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .header-stats { display: none; }
  .entry-term { font-size: 22px; }
  .entry-card { padding: 18px; }
  .res-gloss { max-width: 100%; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
