/* ===================================================================
   Optional base layer — reset, typography, scrollbars, the RTL/LTR rules.

   Separate from tokens.css so a product can take the tokens without having its
   own reset overwritten. DinaCode loads this through Tailwind's @layer base;
   DinaChat and دینا لبز import it directly.

     @import '@dinalabs/ui/base.css';
   =================================================================== */

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper-0);
  color: var(--l-fg);
  font-family: var(--ui);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Estedad's stylistic set 01 — the Persian letterforms the brand uses. */
  font-feature-settings: 'ss01';
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
}

/* Keyboard users get the accent ring. Never remove this without a replacement. */
:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

::selection {
  background: color-mix(in oklch, var(--acc-1) 30%, white);
}

/* ── Code is ALWAYS an LTR island ──────────────────────────────────────────────
   Editors, consoles, <code>, model ids, API keys, endpoints. Per DESIGN.md §2.
   A Persian UI element INSIDE such a panel flips back with dir="rtl". */
code,
pre,
kbd,
samp,
.ltr {
  direction: ltr;
}

/* ── Scrollbars ──────────────────────────────────────────────────────────────
   Transparent track, slim accent-gradient thumb. The floating look comes from a
   transparent border with background-clip: padding-box. A more specific rule
   (e.g. a tab strip setting scrollbar-width: none) still wins. */
* {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: color-mix(in srgb, var(--acc-1) 45%, transparent) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--acc-1) 55%, transparent),
    color-mix(in srgb, var(--acc-2) 55%, transparent)
  );
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: var(--r-pill);
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--acc-1), var(--acc-2));
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ── Mobile ──────────────────────────────────────────────────────────────────
   Every form control at >=16px so iOS Safari never auto-zooms on focus. The
   `!important` deliberately beats the many per-route 0.9rem declarations that
   exist in each product. OTP digit boxes are already >=20px, so they opt out. */
@media (max-width: 768px) {
  input:not([type='checkbox']):not([type='radio']):not([type='range']):not(.dina-otp-digit),
  textarea,
  select {
    font-size: 16px !important;
  }
}

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

/* ── The one shared text helper ───────────────────────────────────────────── */
.grad-text {
  background: var(--acc-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* A centered content column at the shared max width, with a side gutter that never
   collapses — the rule that keeps every Dina page from touching the screen edge. */
.dina-wrap {
  width: min(100% - 32px, var(--wrap));
  margin-inline: auto;
}

/* ── Out of the layout, IN the accessibility tree ─────────────────────────────
   For a table caption, a chart's text alternative, a label a sighted reader gets
   from the picture next to it. NOT `display: none`, which drops it for assistive
   tech too — the whole point is that it stays readable there. */
.dina-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── A dark region inside a light page ───────────────────────────────────────
   A hero band, a footer, a dark card on a pale dashboard. Put this on the region
   and the primitives inside it stop assuming paper underneath.

   It retargets the categorical ramp at the surface it is actually drawn on, so a
   chart in a dark panel keeps the same six hues at the same separation instead of
   six near-black smudges — one token, whole ramp follows. And it swaps the few
   primitives whose INSET (not their fill) is a light-surface assumption: a
   progress track and a ring cutout painted `--paper-2` read as a bright bar on a
   near-black card, which is the opposite of what a track is for.

   It is not a theme. It does not restyle text or borders — use `dark` variants
   (`Button variant="ghost-dark"`, `Card dark`, `Eyebrow dark`) for those, which
   are explicit at the call site where the choice actually belongs. */
.dina-on-dark {
  --c-ground: var(--ink-2);
}
.dina-on-dark .dina-progress,
.dina-on-dark.dina-progress {
  background: var(--ink-3);
}
.dina-on-dark .dina-ring-cut {
  background: var(--ink-2);
}
