@charset "UTF-8";
/* ===========================================================================
   دیکشنری فارسی — web edition
   ---------------------------------------------------------------------------
   Carries the app's identity to the browser: the same brand green (#197b30),
   the same card-on-tinted-page structure, the same DayNight behaviour.

   Two rules are inherited verbatim from the app's values-night/colors.xml,
   because they were arrived at by looking at real screens:

     · Greens get LIGHTER at night, not darker. #197b30 is brand ink on a white
       card; on a dark card it fails contrast badly, so the dark theme lifts the
       same hue until it reads. The top bar is the exception — it is a
       background, and white-on-green only stays legible if it stays dark.

     · White is never a surface. Every use of it is ink on the green bar or the
       green CTA, both of which stay green at night, so it needs no dark value.
   =========================================================================== */

/* --------------------------------------------------------------- typography */
/* Vazirmatn, self-hosted. No CDN: an external font is a render-blocking request
   to a third party, a privacy leak, and something the CSP would have to open a
   hole for. woff2 only — every browser that matters has supported it for years. */
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------- tokens */
:root {
  --green:        #197b30;
  --green-deep:   #125C24;
  --green-tint:   #E8F3EA;
  --bullet:       #50BD00;

  --page:         #F2F4F3;
  --card:         #FFFFFF;
  --stroke:       #E0E3E1;
  --stroke-soft:  #EDF0EE;

  --ink:          #212121;
  --ink-2:        #5B6360;
  --ink-3:        #8A918E;
  --ink-en:       #1F4E79;   /* English example ink — distinct without shouting */
  --ink-ipa:      #37474F;

  --bar:          #197b30;   /* top bar stays dark in both themes */
  --bar-ink:      #FFFFFF;

  --shadow:       0 1px 2px rgba(16, 24, 20, .05), 0 4px 16px rgba(16, 24, 20, .05);
  --shadow-lift:  0 2px 6px rgba(16, 24, 20, .07), 0 12px 32px rgba(16, 24, 20, .09);

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;
  --r-pill: 999px;

  --wrap: 56rem;
  --fa: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --en: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* The dark half. Applied by prefers-color-scheme, and overridden in both
   directions by the toggle's data-theme attribute so the manual choice always
   wins over the system one. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) { color-scheme: dark; }
  :root:not([data-theme='light']) {
    --green:       #5FD07B;
    --green-deep:  #8BE3A0;
    --green-tint:  #17301E;
    --bullet:      #7CE04B;

    --page:        #12140F;
    --card:        #1B1E19;
    --stroke:      #2C312A;
    --stroke-soft: #23271F;

    --ink:         #E8EBE6;
    --ink-2:       #A9B1A6;
    --ink-3:       #7D857B;
    --ink-en:      #8FC0EA;
    --ink-ipa:     #AFBAB6;

    --bar:         #125C24;
    --shadow:      0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .28);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .4);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --green:       #5FD07B;
  --green-deep:  #8BE3A0;
  --green-tint:  #17301E;
  --bullet:      #7CE04B;
  --page:        #12140F;
  --card:        #1B1E19;
  --stroke:      #2C312A;
  --stroke-soft: #23271F;
  --ink:         #E8EBE6;
  --ink-2:       #A9B1A6;
  --ink-3:       #7D857B;
  --ink-en:      #8FC0EA;
  --ink-ipa:     #AFBAB6;
  --bar:         #125C24;
  --shadow:      0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .28);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .4);
}
:root[data-theme='light'] { color-scheme: light; }

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

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--fa);
  font-size: 1rem;
  line-height: 1.75;
  /* Persian numerals throughout; the corpus and the UI copy both use them. */
  font-variant-numeric: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2.5px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { width: min(var(--wrap), 100% - 2rem); margin-inline: auto; }

.skip {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  z-index: 50;
  background: var(--card);
  color: var(--green);
  padding: .7rem 1.1rem;
  border-radius: 0 0 var(--r-sm) 0;
}
.skip:focus { inset-inline-start: 0; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  background: var(--bar);
  color: var(--bar-ink);
  /* Sits above the page without a hard edge — the app's toolbar has none. */
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--bar-ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.06rem;
  padding: .35rem;
  margin-inline-start: -.35rem;
  border-radius: var(--r-sm);
}
.brand-mark { width: 1.5rem; height: 1.5rem; flex: none; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.4rem; height: 2.4rem;
  background: transparent;
  border: 0;
  border-radius: var(--r-pill);
  color: var(--bar-ink);
  cursor: pointer;
  /* A black ripple over the green bar is invisible — the app hit exactly this.
     A white wash at low alpha is what actually reads on this background. */
  transition: background-color .18s ease;
}
.theme-toggle:hover  { background: rgba(255, 255, 255, .14); }
.theme-toggle:active { background: rgba(255, 255, 255, .22); }
.theme-toggle svg { width: 1.3rem; height: 1.3rem; }
/* Show the icon of the theme you would switch TO. */
.theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle .i-sun  { display: none; }
  :root:not([data-theme='light']) .theme-toggle .i-moon { display: block; }
}
:root[data-theme='dark']  .theme-toggle .i-sun  { display: none; }
:root[data-theme='dark']  .theme-toggle .i-moon { display: block; }
:root[data-theme='light'] .theme-toggle .i-sun  { display: block; }
:root[data-theme='light'] .theme-toggle .i-moon { display: none; }

/* ------------------------------------------------------------------- search */
/* The hero is the green bar bleeding down behind the search field, so the field
   reads as part of the chrome — the same relationship the app's search box has
   to its toolbar. */
.hero {
  background: var(--bar);
  padding-block: .25rem 2.6rem;
  margin-bottom: -1.8rem;
}
.hero-title {
  color: var(--bar-ink);
  text-align: center;
  font-size: clamp(1.35rem, 4.4vw, 1.85rem);
  font-weight: 700;
  margin: .4rem 0 1.1rem;
  letter-spacing: -.01em;
}
.hero-sub {
  color: rgba(255, 255, 255, .82);
  text-align: center;
  margin: -.7rem 0 1.3rem;
  font-size: .98rem;
}

.searchbar { position: relative; display: block; }
.searchbar input {
  width: 100%;
  font: inherit;
  font-size: 1.06rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 1rem 3.3rem 1rem 1.3rem;
  box-shadow: var(--shadow-lift);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.searchbar input::placeholder { color: var(--ink-3); }
.searchbar input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: var(--shadow-lift), 0 0 0 4px color-mix(in srgb, var(--green) 22%, transparent);
}
.searchbar .s-icon {
  position: absolute;
  inset-inline-start: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.3rem; height: 1.3rem;
  color: var(--green);
  pointer-events: none;
}
/* The submit button is for keyboards and screen readers; the icon is decorative. */
.searchbar button {
  position: absolute;
  inset-inline-end: .4rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  padding: .5rem .8rem;
  border-radius: var(--r-pill);
  cursor: pointer;
}
.searchbar button:hover { color: var(--green); }

/* Suggestion strip under the hero search. */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.chip {
  display: inline-block;
  background: var(--green-tint);
  color: var(--green-deep);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: .34rem .9rem;
  font-size: .94rem;
  text-decoration: none;
  transition: background-color .15s ease, transform .15s ease;
}
.chip:hover { background: color-mix(in srgb, var(--green) 18%, var(--card)); transform: translateY(-1px); }

/* --------------------------------------------------------------------- card */
.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  margin-block: 1rem;
}
.card-label {
  color: var(--green);
  font-size: .84rem;
  font-weight: 700;
  letter-spacing: .01em;
  margin: 0 0 .5rem;
}

section { margin-block: 1.6rem; }

.section-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink-2);
  margin: 0 0 .7rem;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.section-title::before {
  content: '';
  width: .3rem; height: 1.05em;
  background: var(--green);
  border-radius: var(--r-pill);
  flex: none;
}

/* ---------------------------------------------------------------- word page */
.word-head { padding-top: 1.6rem; }

.headword {
  font-family: var(--en);
  font-size: clamp(2rem, 7vw, 2.9rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}
/* A Persian headword is RTL and wants the Persian face, not the Latin one. */
.headword[lang='fa'] { font-family: var(--fa); }

.ipa-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .9rem;
  align-items: center;
  margin-top: .6rem;
}
.ipa {
  font-family: var(--mono);
  color: var(--ink-ipa);
  font-size: .98rem;
  background: var(--stroke-soft);
  border-radius: var(--r-pill);
  padding: .2rem .7rem;
  direction: ltr;
  unicode-bidi: isolate;
}
.ipa b {
  font-family: var(--fa);
  font-weight: 500;
  color: var(--ink-3);
  margin-inline-end: .35rem;
  font-size: .86em;
}
.speak {
  display: inline-grid;
  place-items: center;
  width: 2rem; height: 2rem;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--green);
  border-radius: var(--r-pill);
  cursor: pointer;
  padding: 0;
}
.speak:hover { background: var(--green-tint); }
.speak svg { width: 1.05rem; height: 1.05rem; }
/* Speech gives no progress of its own, so the button has to say it is playing —
   otherwise a slow voice reads as a dead control and gets clicked again. */
.speak.is-speaking {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.speak.is-speaking svg { animation: speak-pulse 1s ease-in-out infinite; }
@keyframes speak-pulse {
  50% { opacity: .45; }
}
@media (prefers-reduced-motion: reduce) {
  .speak.is-speaking svg { animation: none; }
}

/* The Persian gloss, the single most important thing on the page. */
.gloss-card { border-inline-start: 4px solid var(--green); }
.gloss {
  font-size: 1.22rem;
  line-height: 2;
  margin: 0;
  color: var(--ink);
}
.gloss-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; }
.gloss-chips span {
  background: var(--green-tint);
  color: var(--green-deep);
  border-radius: var(--r-pill);
  padding: .28rem .85rem;
  font-size: 1.02rem;
}

/* Rendered dictionary markup — the shapes Markup::sanitize produces. */
.entry p { margin: .5rem 0; }
.entry .sense {
  color: var(--ink);
  font-size: 1.06rem;
  font-weight: 500;
  margin-top: 1.1rem;
  padding-inline-start: .2rem;
}
.entry .sense:first-child { margin-top: 0; }
.entry .bullet { color: var(--bullet); margin-inline-end: .4rem; font-size: .8em; vertical-align: .1em; }
.entry .example-en {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  font-family: var(--en);
  color: var(--ink-en);
  margin: .35rem 0 .1rem;
  padding-inline-start: 1rem;
  border-inline-start: 2px solid var(--stroke);
}
.entry .example-fa {
  color: var(--ink-2);
  margin: 0 0 .5rem;
  padding-inline-start: 1rem;
  border-inline-start: 2px solid var(--stroke);
}
.entry b, .entry strong { font-weight: 700; color: var(--ink); }

/* WordNet senses. */
.en-senses { list-style: none; margin: 0; padding: 0; counter-reset: sense; }
.en-senses > li {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  font-family: var(--en);
  counter-increment: sense;
  padding: .55rem 0 .55rem 2rem;
  position: relative;
  border-top: 1px solid var(--stroke-soft);
}
.en-senses > li:first-child { border-top: 0; }
.en-senses > li::before {
  content: counter(sense);
  position: absolute;
  left: 0; top: .62rem;
  width: 1.45rem; height: 1.45rem;
  display: grid; place-items: center;
  background: var(--green-tint);
  color: var(--green-deep);
  border-radius: var(--r-pill);
  font-size: .78rem;
  font-weight: 700;
}
.en-senses .ex {
  display: block;
  color: var(--ink-2);
  font-style: italic;
  margin-top: .2rem;
  font-size: .95rem;
}
.pos {
  display: inline-block;
  font-family: var(--en);
  direction: ltr;
  background: var(--stroke-soft);
  color: var(--ink-2);
  border-radius: var(--r-sm);
  padding: .1rem .55rem;
  font-size: .82rem;
  margin-bottom: .4rem;
}

/* Etymology and usage. Persian labels over English content, so every block that
   holds English is isolated: without it the trailing period of "…from Latin
   'ubique'." reorders to the wrong end of the line inside an RTL paragraph. */
.usage > .card-label { margin-top: 1.3rem; }
.usage > .card-label:first-child { margin-top: 0; }
.usage > :first-child { margin-top: 0; }

.usage-def,
.usage-etym {
  font-family: var(--en);
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  margin: 0;
}
.usage-def {
  color: var(--ink);
  font-size: 1.06rem;
  line-height: 1.65;
}
.usage-etym {
  color: var(--ink-2);
  font-size: .97rem;
  line-height: 1.7;
}

.usage-examples {
  list-style: none;
  margin: 0;
  padding: 0;
}
.usage-examples li {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  font-family: var(--en);
  color: var(--ink-en);
  font-style: italic;
  margin: .4rem 0;
  padding-inline-start: .8rem;
  border-inline-start: 2px solid var(--stroke);
  /* The button sits with the sentence rather than after it, so a line that wraps
     does not leave the control stranded on a line of its own. */
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.usage-examples .ex-text { flex: 1 1 auto; }
.usage-examples .speak-slot { flex: none; }
/* Smaller than the headword's, which should stay the obvious one on the page. */
.usage-examples .speak {
  width: 1.6rem; height: 1.6rem;
  font-style: normal;
}
.usage-examples .speak svg { width: .85rem; height: .85rem; }

/* Chips, but never the green of .gloss-chips: those carry what the word means
   and these only carry how it is used, and the page should not offer them with
   equal weight. */
.usage-collocations {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 0;
  direction: ltr;
  justify-content: flex-start;
}
.usage-collocations span {
  font-family: var(--en);
  unicode-bidi: isolate;
  background: var(--stroke-soft);
  color: var(--ink-2);
  border: 1px solid var(--stroke);
  border-radius: var(--r-pill);
  padding: .22rem .7rem;
  font-size: .9rem;
  /* The builder caps these at 40 characters, but it is the only thing standing
     between one bad row and a chip wider than the phone it is read on. */
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ results */
.results { list-style: none; margin: 0; padding: 0; }
.results li { border-top: 1px solid var(--stroke-soft); }
.results li:first-child { border-top: 0; }
.results a {
  display: flex;
  align-items: baseline;
  gap: .9rem;
  padding: .85rem .35rem;
  text-decoration: none;
  color: inherit;
  border-radius: var(--r-sm);
}
.results a:hover { background: var(--stroke-soft); }
.results .w {
  font-family: var(--en);
  font-weight: 700;
  color: var(--green);
  font-size: 1.08rem;
  flex: none;
  max-width: 45%;
  overflow-wrap: anywhere;
}
.results .w[lang='fa'] { font-family: var(--fa); }
.results .g {
  color: var(--ink-2);
  font-size: .98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count { color: var(--ink-3); font-size: .92rem; margin: .2rem 0 1rem; }

/* -------------------------------------------------------------------- empty */
.empty { text-align: center; padding: 2.5rem 1rem; }
.empty h1 { font-size: 1.3rem; margin: 0 0 .5rem; }
.empty p { color: var(--ink-2); margin: 0 auto 1.4rem; max-width: 34rem; }

.cta {
  display: inline-block;
  background: var(--green);
  color: #fff;
  border-radius: var(--r-pill);
  padding: .7rem 1.6rem;
  text-decoration: none;
  font-weight: 500;
}
:root[data-theme='dark'] .cta,
:root:not([data-theme='light']) .cta { color: #0d1710; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) .cta { color: #fff; }
}
.cta:hover { background: var(--green-deep); }

/* ------------------------------------------------------------------- footer */
.footer {
  margin-top: 3.5rem;
  border-top: 1px solid var(--stroke);
  background: var(--card);
  padding-block: 1.6rem 2.2rem;
}
.footer-inner { text-align: center; }
.footer-links { display: flex; gap: 1.4rem; justify-content: center; flex-wrap: wrap; }
.footer-links a { color: var(--ink-2); text-decoration: none; font-size: .95rem; }
.footer-links a:hover { color: var(--green); text-decoration: underline; }
.footer-note { color: var(--ink-3); font-size: .88rem; margin: .8rem 0 0; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 30rem) {
  .card { padding: 1.05rem 1rem; border-radius: var(--r-sm); }
  .results .w { max-width: 100%; }
  /* align-items has to be restated with the direction. The row rule aligns on
     the baseline, which a column flex container resolves against its *cross*
     axis — the horizontal one — and every headword ended up at a different
     indent, each one placed by how wide it happened to be. Invisible while
     .results lived only on the noindex search page; the reverse-index lists put
     it on every word page. */
  .results a { flex-direction: column; align-items: flex-start; gap: .15rem; }
  .results .g { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* Print: the word page is a reference, so make it one. */
@media print {
  .topbar, .footer, .theme-toggle, .hero, .speak { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
