/* Shared fixes for every page. Loaded after each page's own inline <style>,
   so rules here win over it; !important is only used where the React
   components set the same property as an inline style. */

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Taps fire immediately instead of waiting for a double-tap-to-zoom check */
a, button, input, select, textarea, label, [role="button"], [role="tab"] {
  touch-action: manipulation;
}

/* iOS Safari zooms the whole page when a focused field is under 16px */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}

/* Visible keyboard focus everywhere (pages set outline:none on inputs) */
:focus-visible {
  outline: 2px solid var(--accent-ink, #6a1e00) !important;
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline-offset: 0;
}

/* Mobile browser toolbars make 100vh taller than the visible screen */
@supports (min-height: 100svh) {
  body, #root { min-height: 100svh; }
}

/* Hover styles only on devices that can hover, so they don't stick after a tap */
@media (hover: hover) and (pointer: fine) {
  .hover-lift:hover { background: var(--surface-2); }
  .hover-link:hover { color: var(--fg) !important; }
  .hover-card:hover { border-color: var(--border) !important; box-shadow: var(--shadow-sm); }
}
.hover-lift:active, .hover-card:active { transform: scale(0.99); }

/* Number inputs: no spinner, values don't change on mouse wheel scroll */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Right-to-left pages: Urdu uses Nastaliq, Pashto/Sindhi/Punjabi (Shahmukhi) use Naskh.
   The Latin fonts stay first so numbers and "Rs." keep their look; letters they
   lack fall through to Noto. Overriding the variables also covers the many inline
   styles that use var(--font-*). Nastaliq needs more line height or descenders clip. */
html[lang="ur"] {
  --font-sans: 'Geist', "Noto Nastaliq Urdu", "Noto Naskh Arabic", system-ui, sans-serif;
  --font-serif: 'Instrument Serif', "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif;
  --font-mono: 'Geist Mono', "Noto Naskh Arabic", ui-monospace, monospace;
}
html[lang="ps"], html[lang="pa"], html[lang="sd"] {
  --font-sans: 'Geist', "Noto Naskh Arabic", system-ui, sans-serif;
  --font-serif: 'Instrument Serif', "Noto Naskh Arabic", serif;
  --font-mono: 'Geist Mono', "Noto Naskh Arabic", ui-monospace, monospace;
}
html[lang="ur"] body { line-height: 2; }
html[lang="ps"] body, html[lang="pa"] body, html[lang="sd"] body { line-height: 1.8; }

/* Placeholder inside #root until React renders (replaced on first render) */
.root-loading {
  width: 100%; max-width: var(--content-max, 1200px); margin: 0 auto;
  padding: 88px var(--gutter, 20px) 0; display: grid; gap: 14px;
}
.root-loading span {
  display: block; height: 18px; border-radius: 8px;
  background: var(--bg-2, #f1ebe1); animation: root-pulse 1.4s ease-in-out infinite;
}
.root-loading span:nth-child(1) { width: 40%; }
.root-loading span:nth-child(2) { width: 70%; height: 64px; }
.root-loading span:nth-child(3) { width: 55%; }
@keyframes root-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .root-loading span { animation: none; } }

/* Static pages (guides, about, …): the header nav and wide tables scroll
   sideways on small phones instead of widening the whole page */
.site-header__inner { min-width: 0; }
.site-header__nav {
  min-width: 0; overflow-x: auto; white-space: nowrap;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.site-header__nav::-webkit-scrollbar { display: none; }
main table, .static-section table {
  display: block; max-width: 100%; overflow-x: auto;
}
