/* ==========================================================================
   base.css — reset, tipografika, layout primitivlari, a11y (D0)
   Faqat element-darajali va yordamchi (utility) qoidalar. Komponentlar —
   `components.css` da. Ranglar/o'lchamlar faqat `tokens.css` tokenlaridan.
   ========================================================================== */

/* --- Reset --------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-app);
  color: var(--text-default);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-6) 0;
}

/* --- Tipografika --------------------------------------------------------- */
h1, h2, h3, h4 {
  color: var(--text-strong);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-wrap: balance;
}

h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-sm); }

p {
  text-wrap: pretty;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

small {
  font-size: var(--text-2xs);
}

code, kbd, pre, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

code {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}

/* Raqam/pul ustunlari — bir xil kenglikdagi raqamlar (jadval tekis turadi). */
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* --- Matn yordamchilari --------------------------------------------------- */
.text-2xs { font-size: var(--text-2xs); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

.strong { color: var(--text-strong); }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.accent { color: var(--accent-text); }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger-text); }

.fw-medium { font-weight: var(--weight-medium); }
.fw-semibold { font-weight: var(--weight-semibold); }
.fw-bold { font-weight: var(--weight-bold); }

.uppercase {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prose { max-width: var(--prose-max); }

/* --- Oraliq yordamchilari (kam ishlatiladi — asosiysi .stack/.cluster) ------ */
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* --- Alpine: JS yuklangunicha element ko'rinmasin (miltillashning oldini oladi) - */
[x-cloak] {
  display: none !important;
}

/* --- Layout primitivlari -------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

/* Vertikal ustun — bolalar orasida bir xil oraliq. */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-2 { gap: var(--space-2); }
.stack-3 { gap: var(--space-3); }
.stack-6 { gap: var(--space-6); }
.stack-8 { gap: var(--space-8); }

/* Gorizontal guruh — joy yetmasa o'raladi. */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.cluster-2 { gap: var(--space-2); }
.cluster-4 { gap: var(--space-4); }
.cluster-between { justify-content: space-between; }
.cluster-end { justify-content: flex-end; }
.cluster-nowrap { flex-wrap: nowrap; }

/* Avtomatik moslashuvchi panjara — media query siz. */
.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(var(--grid-min, 240px), 1fr));
}
.grid-sm { --grid-min: 180px; }
.grid-lg { --grid-min: 320px; }

.spacer { flex: 1 1 auto; }

/* --- Ikonkalar (lokal Lucide sprite) -------------------------------------- */
.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  stroke: currentColor;
  fill: none;
  vertical-align: -0.25em;
}
.icon-sm { width: 1em; height: 1em; }
.icon-lg { width: 1.5em; height: 1.5em; }

/* --- Fokus (klaviatura) --------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Sichqoncha bilan bosilganda halqa ko'rsatilmaydi (faqat klaviatura). */
:focus:not(:focus-visible) {
  outline: none;
}

/* --- A11y yordamchilari ---------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-surface);
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  transform: translateY(-200%);
}
.skip-link:focus-visible {
  transform: translateY(0);
}

/* --- Harakatni kamaytirish (tizim sozlamasi hurmat qilinadi) --------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Chop etish (chek/hisobot) --------------------------------------------- */
@media print {
  body {
    background: #fff;
  }
  .no-print {
    display: none !important;
  }
}
