/* ============================================================================
   Reset + poydevor tipografika
   ========================================================================= */

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-ui);
  font-size: var(--fs-15);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;

  /* Mini App'da sahifa "cho'zilib" ketmasligi uchun */
  overscroll-behavior-y: none;
  min-height: 100dvh;
}

/* Telegram ichida matn tanlanishi kerak emas — native his beradi.
   Maydonlar va nusxa olinadigan joylar istisno. */
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

input,
textarea,
[data-selectable] {
  -webkit-user-select: text;
  user-select: text;
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
  background: var(--sand);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

/* Fokus — faqat klaviatura bilan yurganda koʼrinadi */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ── Sarlavhalar ────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-title);
  text-wrap: balance;
}

h1 { font-size: var(--fs-28); letter-spacing: var(--ls-display); }
h2 { font-size: var(--fs-22); }
h3 { font-size: var(--fs-17); }

p { text-wrap: pretty; }

/* ── Kichik yordamchi sinflar ───────────────────────────────────────────── */

.muted   { color: var(--stone); }
.dim     { color: var(--ink-2); }
.gold    { color: var(--gold); }

.caps {
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hidden { display: none !important; }

/* Gorizontal scroll qatori — ekran kengligida, ichki chekka bilan.
   Oxirgi element chekkada "kesilgan" boʼlib turadi: yana borligi shundan bilinadi. */
.hscroll {
  display: flex;
  gap: var(--grid-gap);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding-inline: var(--gutter);
  scroll-padding-inline: var(--gutter);
}

.hscroll::-webkit-scrollbar { display: none; }

/* ── Ikonkalar ──────────────────────────────────────────────────────────── */

.icon {
  width: 24px;
  height: 24px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm { width: 18px; height: 18px; stroke-width: 1.8; }
.icon-lg { width: 32px; height: 32px; stroke-width: 1.4; }

/* ── Ekran maketi ───────────────────────────────────────────────────────── */

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;

  /* Telefon kengligida qolamiz va markazga joylashamiz. Ichidagi sticky
     elementlar (appbar, dock) ham shu ustun bilan cheklanadi. */
  max-width: var(--app-max);
  margin-inline: auto;
  width: 100%;
}

/* Ustun sigʼib, yon tomonlarda joy qolganda — fon bilan ajratamiz,
   aks holda kontent bo'shliqda osilib turgandek koʼrinadi. */
@media (min-width: 620px) {
  body {
    background: var(--sand-2);
  }

  #app {
    background: var(--paper);
    border-inline: var(--bw) solid var(--line-soft);
  }
}

.screen {
  flex: 1;
  padding-bottom: calc(var(--s-12) + var(--safe-bottom));
}

/* Pastda yopishib turgan panel (.dock yoki .tabbar) boʼlsa, u oʼzi boʼshliqni
   egallaydi — ustiga yana padding qoʼshsak, eng pastga scroll qilinganda
   tugmalar ostida bemaʼni bosh joy qoladi. */
.screen:has(.dock),
#app:has(.tabbar:not([hidden])) .screen {
  padding-bottom: 0;
}

.wrap {
  padding-inline: var(--gutter);
}

/* Kirish animatsiyasi — har ekran ochilganda */
.screen > * {
  animation: rise var(--t-base) var(--ease) backwards;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .screen > * { animation: none; }
}
