/* =====================================================================
   DSTMS - assets/css/base.css
   Design tokens (:root), reset, typography, utilities.
   Load order in every page: base.css, components.css, then auth.css or
   app.css, then dark.css (print.css with media="print").
   Mobile first. Breakpoints: 480, 768, 1024, 1280.
   ===================================================================== */

:root {
  /* Brand */
  --primary: #1d4ed8;
  --primary-d: #1e3a8a;
  --primary-l: #dbeafe;          /* light tint for hovers and chips */
  --accent: #f59e0b;

  /* Status */
  --ok: #16a34a;     --ok-bg: #dcfce7;
  --warn: #d97706;   --warn-bg: #fef3c7;
  --bad: #dc2626;    --bad-bg: #fee2e2;
  --info: #0284c7;   --info-bg: #e0f2fe;

  /* Surfaces and text */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --overlay: rgba(17, 24, 39, .55);
  --focus: rgba(29, 78, 216, .35);

  /* Shape and depth */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --shadow: 0 4px 18px rgba(17, 24, 39, .08);
  --shadow-sm: 0 1px 3px rgba(17, 24, 39, .08);
  --shadow-lg: 0 18px 48px rgba(17, 24, 39, .22);

  /* Spacing scale */
  --s1: .25rem;  --s2: .5rem;  --s3: .75rem;  --s4: 1rem;
  --s5: 1.5rem;  --s6: 2rem;   --s7: 3rem;

  /* Type */
  --font: "Hind Siliguri", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* App frame sizes */
  --topbar-h: 56px;
  --bottomnav-h: 64px;
  --sidebar-w: 260px;
  --sidebar-w-sm: 72px;
  --content-max: 1280px;

  /* Safe areas (notched phones) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* Motion */
  --t-fast: 150ms;
  --t-med: 220ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Layers */
  --z-sticky: 20;
  --z-nav: 40;
  --z-sheet: 60;
  --z-modal: 70;
  --z-toast: 90;

  color-scheme: light;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(var(--topbar-h) + var(--safe-top) + 8px);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: clamp(15px, .94rem + .15vw, 16.5px);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: anywhere;
}

body.no-scroll { overflow: hidden; }

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }

table { border-collapse: collapse; border-spacing: 0; width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s4) 0; }

[hidden] { display: none !important; }

::selection { background: var(--primary-l); color: var(--primary-d); }

/* ---------- Links and focus ---------- */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--primary-d); text-decoration: underline; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Typography ---------- */
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.25; font-weight: 700; }
h2 { font-size: clamp(1.25rem, 1.05rem + .8vw, 1.6rem); line-height: 1.3; font-weight: 700; }
h3 { font-size: clamp(1.1rem, 1rem + .4vw, 1.3rem); line-height: 1.35; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
strong, b { font-weight: 600; }
small, .small { font-size: .85rem; }
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 6px; border: 1px solid var(--line); }

.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.text-primary { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ---------- Icons (inline SVG, stroke follows text colour) ---------- */
.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 1em; height: 1em; }
.icon-lg { width: 1.6em; height: 1.6em; }

/* ---------- Layout utilities ---------- */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1 1 0; min-width: 0; }
.grid { display: grid; }

.gap-1 { gap: var(--s1); } .gap-2 { gap: var(--s2); } .gap-3 { gap: var(--s3); }
.gap-4 { gap: var(--s4); } .gap-5 { gap: var(--s5); }

.mt-0 { margin-top: 0; }  .mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s2); } .mb-3 { margin-bottom: var(--s3); }
.mb-4 { margin-bottom: var(--s4); } .mb-5 { margin-bottom: var(--s5); }
.ml-auto { margin-left: auto; }
.p-0 { padding: 0; } .p-3 { padding: var(--s3); } .p-4 { padding: var(--s4); } .p-5 { padding: var(--s5); }

.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rounded { border-radius: var(--radius); }
.pointer { cursor: pointer; }

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

/* Content only for the printed page (print.css shows it) */
.print-only { display: none; }

.screen-full { min-height: 100vh; min-height: 100dvh; }

/* Show/hide by screen size */
.only-mobile { display: initial; }
.only-desktop { display: none !important; }
@media (min-width: 768px) {
  .only-mobile { display: none !important; }
  .only-desktop { display: initial !important; }
}

/* Responsive grid helpers: 1 column on phones, more on larger screens */
.cols { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 480px)  { .cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 768px)  { .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

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

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