/* ============================================================================
   Base — reset, typography, layout primitives, accessibility defaults
   ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text);
  /* colour first, then the watermark tile over it — see tokens.css for why this
     is a background layer rather than a pseudo-element */
  background-color: var(--color-bg);
  background-image: var(--paper-texture);
  background-size: var(--paper-texture-size);
  min-height: 100dvh;
  /* `overflow-x: hidden` makes body a scroll container, which silently breaks
     `position: sticky` for everything inside it — the header included. `clip`
     applies the same horizontal clamp without creating that container, so the
     sticky chrome survives. `hidden` stays first as the fallback for browsers
     that do not know `clip`. */
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

/* Devanagari sits lower and needs more leading than Latin */
:lang(mr) body,
.lang-mr body,
[lang="mr"] { line-height: var(--lh-devanagari); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-regular);
  line-height: var(--lh-heading);
  color: var(--color-text);
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }
p { text-wrap: pretty; }

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-dark); }

img, svg, picture, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { list-style: none; padding: 0; }
table { border-collapse: collapse; }

/* ---- accessibility ------------------------------------------------------ */
:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 999;
  padding: var(--space-3) var(--space-4);
  background: var(--brand-primary);
  color: var(--color-on-primary);
  border-radius: var(--radius-sm);
  font-weight: var(--fw-semibold);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--space-4); color: var(--color-on-primary); }

.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;
}

[hidden] { display: none !important; }
[inert] { pointer-events: none; user-select: none; }
[aria-busy="true"] { cursor: progress; }

/* Language visibility for content authored in both scripts inside one page.
   Scoped to an explicit opt-in attribute: a bare [lang="en"] selector also matched the
   language-switch button itself, which hid the control needed to leave Marathi. */
.lang-en [data-lang-only="mr"], .lang-mr [data-lang-only="en"] { display: none; }

/* ---- layout primitives -------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--space-4);
}
.wrap--narrow { max-width: var(--wrap-narrow); }
.wrap--wide { max-width: var(--wrap-wide); }

.section { padding-block: var(--space-8); }
.section--tight { padding-block: var(--space-7); }
/* Tinted bands are opaque, so they would otherwise punch a smooth hole through
   the page's grain. They carry the tile too, slightly stronger per the brief. */
.section--tint {
  background-color: var(--color-surface-2);
  background-image: var(--paper-texture);
  background-size: var(--paper-texture-size);
}
.section--sunken { background: var(--color-surface-sunken); }

.stack > * + * { margin-top: var(--space-4); }
.grid { display: grid; gap: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

@media (min-width: 640px) {
  .wrap { padding-inline: var(--space-5); }
  .grid--sm-2 { grid-template-columns: repeat(2, 1fr); }
  .grid--sm-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .grid--md-3 { grid-template-columns: repeat(3, 1fr); }
  .grid--md-4 { grid-template-columns: repeat(4, 1fr); }
}

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

/* ---- cross-document view transitions ------------------------------------
   The site is multi-page: every bottom-nav tap is a full navigation, so the
   browser paints white, then the new document. This cross-fades the two
   instead, which removes most of the perceived stutter. Progressive — browsers
   without support simply navigate as before. It smooths the transition, it does
   not make the request faster; that is the server-rendering work. */
@view-transition { navigation: auto; }

::view-transition-old(root) { animation-duration: 140ms; }
::view-transition-new(root) { animation-duration: 200ms; }

/* the sticky chrome shouldn't cross-fade with the page body under it */
.site-header { view-transition-name: site-header; }
.bottomnav { view-transition-name: bottomnav; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}


/* The footer is the darkest surface, where the brief allows the most texture. */
.site-footer { position: relative; }
.site-footer::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: var(--paper-texture-light);
  background-size: var(--paper-texture-size);
}
.site-footer > * { position: relative; }
