/* =====================================================================
   Bajrang Electricals and Engineering Works — Base & Typography
   Reset, base element styles, and the shared type scale. Requires
   tokens.css to be loaded first.
===================================================================== */

/* ---------- 1. RESET ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-base);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  /* Same --surface-* tokens every component reads from (see tokens.css
     §10) — the public site gets the dark default; a page whose body (or
     a .app-shell wrapper inside it) carries .surface-light/.app-shell
     gets the light one instead. Without this, body is transparent and
     any section that doesn't paint its own background falls through to
     nothing, leaving light-on-dark text unreadable. */
  background: var(--surface-bg);
  color: var(--surface-text-secondary);
}

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

ul,
ol {
  list-style: none;
}

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

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

button {
  border: none;
  cursor: pointer;
  background: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ---------- 2. FOCUS ----------
   Never removed, only restyled. A visible focus ring is a hard
   requirement, not a cosmetic option — this is the one visual cue every
   keyboard and switch-device user depends on. */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-electric-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- 3. TYPOGRAPHY ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: var(--leading-tight);
  text-wrap: balance;
  color: inherit;
}

h1 {
  font-size: var(--text-4xl);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-3xl);
  letter-spacing: -0.02em;
}

h3 {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h4 {
  font-size: var(--text-xl);
  font-weight: 600;
}

h5 {
  font-size: var(--text-lg);
  font-weight: 600;
}

h6 {
  font-size: var(--text-md);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Paragraphs: a line short enough to find the start of the next one, and
   no single word left alone on the last line. */
p {
  max-width: 64ch;
  text-wrap: pretty;
}

/* Devanagari carries marks above and below the line that Latin does not,
   so Hindi needs more room between lines, and tracking tuned for Latin
   capitals only pulls its conjuncts apart. */
html[lang='hi'] body {
  line-height: 1.8;
}

html[lang='hi'] :is(h1, h2, h3, h4, h5, h6) {
  line-height: 1.4;
  letter-spacing: 0;
}

small,
.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

code,
.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- 4. UTILITY TEXT ROLES ---------- */
.eyebrow {
  display: inline-block;
  /* A fixed size, not --text-xs: a tracked, all-caps label is already wide
     for its size and must stay on one line on a phone. */
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead {
  font-size: var(--text-lg);
  line-height: 1.55;
  max-width: 58ch;
}

/* ---------- 5. LAYOUT UTILITIES ---------- */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

/* Components set `display:flex` etc. on plenty of elements that are also
   sometimes toggled with the native `hidden` attribute (form field errors,
   status banners) — without this, the author rule would beat the user
   agent's default `[hidden]{display:none}` and the element would stay
   visible. */
[hidden] {
  display: none !important;
}

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

/* Revealed on keyboard focus — lets a keyboard user jump past repeated
   navigation straight to the page's main content. */
.skip-link {
  position: absolute;
  top: -3rem;
  left: var(--space-sm);
  z-index: 1000;
  background: var(--color-electric-blue);
  color: var(--color-white);
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-sm);
  transition: top var(--transition-fast);
}

.skip-link:focus-visible {
  top: var(--space-sm);
  outline-offset: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Auth gate ----------
   env-config.js adds .auth-pending to dashboard pages; the layout script
   removes it once the session is confirmed. A failed check redirects to
   login with the class still on, so nothing private is ever shown. */
html.auth-pending body > * {
  visibility: hidden;
}

html.auth-pending::after {
  content: 'Checking your session\2026';
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary, #9aa6c1);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  background: var(--color-navy-950, #080c1a);
}
