/* Base: the two typefaces, the reset, and the app shell (topbar / scroll / tabbar). */

/* Shabnam — the reading face. Persian text sits noticeably better in it than in a
   Latin-first family, and it ships with the app so a poor network never leaves the
   layout reflowing halfway through a screen. */
@font-face {
  font-family: Shabnam;
  src: url("/static/fonts/Shabnam.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Shabnam;
  src: url("/static/fonts/Shabnam-Medium.woff2") format("woff2");
  font-weight: 500 600;
  font-display: swap;
}
@font-face {
  font-family: Shabnam;
  src: url("/static/fonts/Shabnam-Bold.woff2") format("woff2");
  font-weight: 700 800;
  font-display: swap;
}

/* Lalezar — display only: counters, «روز با هم», the few hand-lettered headlines.
   Two subsets, because the Persian digits live in the Arabic range and the Latin
   one is only there so an ASCII number never falls back mid-word. */
@font-face {
  font-family: Lalezar;
  src: url("/static/fonts/Lalezar-arabic.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: Lalezar;
  src: url("/static/fonts/Lalezar-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2212;
}

/* Vazirmatn stays as the fallback face: it is already committed, and it covers the
   glyphs Shabnam misses without pulling anything over the network. */
@font-face {
  font-family: Vazirmatn;
  src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500 600;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700 800;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }
body {
  min-height: var(--vh);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: 1.75;
  text-align: start;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}

button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
::-webkit-scrollbar { display: none; }

h1 { font-size: var(--fs-title); font-weight: 700; line-height: 1.5; }
h2 { font-size: var(--fs-h2); font-weight: 600; }

/* --- shell -------------------------------------------------------------------
 * The page itself scrolls (the window, not an inner box): Telegram's WebView
 * fights an inner scroller over keyboard insets and swipe-to-close, and the
 * pull-to-refresh gesture reads window.scrollY. The topbar is sticky rather than
 * fixed so it participates in that same scroll.
 */

#topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--topbar-h);
  padding: var(--s2) var(--s3);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-block-end: 1px solid var(--line);
}
#topbar.hidden { display: none !important; }
#topbar .tb-slot {
  flex: none;
  inline-size: 34px;
  block-size: 34px;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  border-radius: var(--r-xs);
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--dur-micro), color var(--dur-micro);
}
#topbar .tb-slot:active { background: var(--bg-3); color: var(--ink); }
#topbar .tb-titles { flex: 1; min-width: 0; }
#topbar .tb-title {
  font-size: var(--fs-h2);
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#topbar .tb-sub {
  font-size: var(--fs-small);
  color: var(--ink-3);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app {
  padding: var(--s4) var(--s4)
    calc(var(--tabbar-h) + var(--s5) + env(safe-area-inset-bottom));
  max-width: 560px;
  margin-inline: auto;
  min-height: calc(var(--vh) - var(--topbar-h) - var(--tabbar-h));
}
/* Screens that run their own full-bleed layout (the «ما» keepsake, the reveal) ask
   for the gutter back per-section instead of fighting the page padding. */
#app.bleed { padding-inline: 0; }
#app.bleed > .gutter { padding-inline: var(--s4); }

/* --- utilities ---------------------------------------------------------------- */
.muted { color: var(--ink-3); }
.dim { color: var(--ink-2); }
.small { font-size: var(--fs-meta); }
.tiny { font-size: var(--fs-small); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: var(--s2); }
.row-top { display: flex; align-items: flex-start; gap: var(--s2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.col { display: flex; flex-direction: column; gap: var(--s3); }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.mt1 { margin-block-start: var(--s1); } .mt2 { margin-block-start: var(--s2); }
.mt3 { margin-block-start: var(--s3); } .mt4 { margin-block-start: var(--s4); }
.mt5 { margin-block-start: var(--s5); }
.mb1 { margin-block-end: var(--s1); } .mb2 { margin-block-end: var(--s2); }
.mb3 { margin-block-end: var(--s3); } .mb4 { margin-block-end: var(--s4); }
.num { font-family: var(--font-display); font-size: var(--fs-num); line-height: 1.15; font-weight: 400; }
.display { font-family: var(--font-display); font-size: var(--fs-display); line-height: 1.45; font-weight: 400; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Two lines, then ellipsis. For content that is genuinely long — a real place name
   is often «کافه عظیمیه، جهان با من برقص، پارک ایران زمین» — where one clipped line
   throws away the part that identifies it. */
.clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.prewrap { white-space: pre-wrap; word-break: break-word; }
.pretty { text-wrap: pretty; }
.hidden { display: none !important; }
.flip-x { transform: scaleX(-1); }

/* Icon defaults — every sprite symbol inherits currentColor. */
.icon { display: inline-block; vertical-align: -0.22em; flex: none; }
