/* ==========================================================================
   base.css - global element styling, typography, helpers
   ========================================================================== */

/* Archivo: the UI face (oblique cut echoes the logo). Bangla falls through to Hind Siliguri. */
@font-face {
  font-family: "Archivo"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../assets/fonts/archivo-latin-var.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Archivo"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url("../assets/fonts/archivo-latin-var-italic.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
  background: var(--bg-body);
}

body {
  font-size: var(--fs-md);
  color: var(--text-primary);
  background: var(--bg-body);
  overflow-x: clip; /* last-resort guard: the page never scrolls sideways */
  transition: background-color var(--dur-mid) var(--ease-out),
    color var(--dur-mid) var(--ease-out);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-strong);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: -0.014em;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }

a {
  color: var(--accent-text);
}
a:hover {
  text-decoration: underline;
}

small {
  font-size: var(--fs-xs);
}

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: var(--fs-2xs);
  line-height: 1;
  white-space: nowrap;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-4) 0;
}

::selection {
  background: var(--brand-200);
  color: var(--ink);
}

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
  background-clip: content-box;
}

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

/* ---- Accessibility helpers ---- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: var(--sp-3);
  z-index: var(--z-toast);
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent);
  color: var(--text-on-brand);
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus {
  transform: translateY(0);
}

/* ---- Layout utilities ---- */
.stack > * + * { margin-top: var(--stack-gap, var(--sp-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--sp-3)); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.full-width { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.005em; }
.tabular { font-variant-numeric: tabular-nums; }

.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.strong { color: var(--text-strong); font-weight: var(--fw-semibold); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-lg { font-size: var(--fs-lg); }
.text-success { color: var(--success-fg); }
.text-danger { color: var(--danger-fg); }
.text-warning { color: var(--warning-fg); }

.pos-amount {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-6);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.page-header__title h1 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.page-header__title p {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.page-header__actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.section-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
}

/* App-wide loading bar */
#app-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur-mid);
  z-index: var(--z-toast);
  opacity: 0;
}
#app-progress.is-active { opacity: 1; }

/* Boot / auth gate screens */
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
}

/* Reversed logo art swaps in on dark surfaces (the switch lives in tokens.css). */
.logo-std { display: var(--logo-std); }
.logo-rev { display: var(--logo-rev); }

/* Slanted display type is a Latin voice. Bangla has no true oblique, so it stands upright. */
html[lang="bn"] .takings__value,
html[lang="bn"] .auth__card h1, html[lang="bn"] .auth__aside h2,
html[lang="bn"] .portal-login h2, html[lang="bn"] .legal h1 { font-style: normal; }
