/* ==========================================================================
   দেশচেনা — design tokens & components
   Single source of truth for colour, type, space, radius, motion & shadow.
   No framework, no runtime dependency, no build step.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  /* colour — light theme */
  --brand-900: #06362c;
  --brand-700: #0b6b57;
  --brand-600: #0e7f66;
  --brand-500: #159a7c;
  --brand-200: #b7e2d6;
  --brand-100: #dff2ec;
  --brand-50:  #f0f9f6;

  --gold-600: #b5791f;
  --gold-500: #d79a2b;
  --gold-200: #f6e3bd;

  --surface:        #ffffff;
  --surface-2:      #f7faf9;
  --surface-sunken: #eef4f2;
  --page:           #fbfcfb;

  --text:      #12211d;
  --text-muted:#5c7069;
  --text-soft: #6b7d76;
  --border:    #dde8e4;
  --border-strong:#c3d6d0;

  --danger: #b3341f;
  --focus:  #1477ff;

  /* map surface: water sits clearly behind the land, so the country
     silhouette stays readable and the "colour it in" idea still works */
  --map-water:  #d7e6ee;
  --map-land:   #ffffff;
  --map-border: #b3c9d4;

  /* type */
  --font: "Hind Siliguri", "Noto Sans Bengali", "Nirmala UI", "Bangla MN",
          "Kohinoor Bangla", "SolaimanLipi", system-ui, -apple-system,
          "Segoe UI", Roboto, sans-serif;
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --fs-xs:   0.75rem;   /* 12 */
  --fs-sm:   0.875rem;  /* 14 */
  --fs-base: 1rem;      /* 16 */
  --fs-lg:   1.125rem;  /* 18 */
  --fs-xl:   1.375rem;  /* 22 */
  --fs-2xl:  1.75rem;   /* 28 */
  --fs-3xl:  2.25rem;   /* 36 */
  --fs-4xl:  clamp(2.25rem, 1.4rem + 3.4vw, 3.5rem);

  --lh-tight: 1.2;
  --lh-base:  1.65;     /* Bengali needs generous leading */

  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semi:   600;
  --fw-bold:   700;

  /* space (4px base) */
  --s-1: .25rem;  --s-2: .5rem;   --s-3: .75rem;  --s-4: 1rem;
  --s-5: 1.25rem; --s-6: 1.5rem;  --s-8: 2rem;    --s-10: 2.5rem;
  --s-12: 3rem;   --s-16: 4rem;   --s-20: 5rem;

  /* radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 26px; --r-full: 999px;

  /* elevation */
  --sh-1: 0 1px 2px rgba(6, 54, 44, .06), 0 1px 3px rgba(6, 54, 44, .04);
  --sh-2: 0 2px 6px rgba(6, 54, 44, .07), 0 6px 16px rgba(6, 54, 44, .05);
  --sh-3: 0 10px 30px rgba(6, 54, 44, .10), 0 2px 8px rgba(6, 54, 44, .06);

  /* motion */
  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur-fast: 120ms;
  --dur: 220ms;
  --dur-slow: 420ms;

  --ring: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);
}

/* ---------- 2. Dark theme ------------------------------------------------ */
:root[data-theme="dark"] {
  --brand-900: #d6f2ea;
  --brand-700: #7fd8c1;
  --brand-600: #64cfb4;
  --brand-500: #4bc2a4;
  --brand-200: #1d5b4c;
  --brand-100: #143f36;
  --brand-50:  #0f2f29;

  --gold-600: #f0c274;
  --gold-500: #e0a340;
  --gold-200: #4a3a1c;

  --surface:        #121a18;
  --surface-2:      #17211f;
  --surface-sunken: #0d1413;
  --page:           #0b100f;

  --text:       #e8f0ed;
  --text-muted: #a3b6b0;
  --text-soft:  #7d918b;
  --border:     #24322f;
  --border-strong:#33443f;

  --danger: #ff8f78;
  --focus:  #6fb2ff;

  --map-water:  #08161c;
  --map-land:   #2b3834;
  --map-border: #0b1c22;

  --sh-1: 0 1px 2px rgba(0,0,0,.5);
  --sh-2: 0 2px 8px rgba(0,0,0,.45);
  --sh-3: 0 12px 32px rgba(0,0,0,.55);
}

/* ---------- 3. Reset ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

img, svg, video { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--brand-600); text-underline-offset: 3px; }
ul { list-style: none; padding: 0; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

.sr-only {
  position: absolute; 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(--s-4); top: -100px; z-index: 100;
  padding: var(--s-3) var(--s-5); background: var(--brand-700); color: #fff;
  border-radius: var(--r-full); font-weight: var(--fw-semi); text-decoration: none;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--s-4); }

/* ---------- 4. Layout --------------------------------------------------- */
.wrap { width: min(100% - var(--s-8), 1240px); margin-inline: auto; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: saturate(1.6) blur(12px);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex; align-items: center; gap: var(--s-4);
  min-height: 60px;
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-weight: var(--fw-bold); font-size: var(--fs-lg);
  color: var(--text); text-decoration: none; letter-spacing: -.01em;
}
.brand__mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px; background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
  color: #fff; font-size: 15px;
  box-shadow: var(--sh-1);
}
.site-header__spacer { margin-inline-start: auto; }
.header-actions { display: flex; align-items: center; gap: var(--s-2); }

/* ---------- 5. Buttons -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 42px; padding: 0 var(--s-5);
  border-radius: var(--r-full);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm); font-weight: var(--fw-semi);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--brand-200); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--brand-700); border-color: var(--brand-700); color: #fff;
  box-shadow: var(--sh-1);
}
.btn--primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn--icon { width: 42px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--sm { min-height: 34px; padding: 0 var(--s-4); font-size: var(--fs-xs); }

/* ---------- 6. Hero ----------------------------------------------------- */
.hero { padding: var(--s-16) 0 var(--s-10); }
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-4) var(--s-1) var(--s-3);
  border-radius: var(--r-full);
  background: var(--brand-100); color: var(--brand-900);
  font-size: var(--fs-xs); font-weight: var(--fw-semi); letter-spacing: .01em;
  border: 1px solid var(--brand-200);
}
.hero__title {
  margin-top: var(--s-5);
  font-size: var(--fs-4xl); line-height: var(--lh-tight);
  font-weight: var(--fw-bold); letter-spacing: -.02em;
  max-width: 22ch;
}
.hero__title em {
  font-style: normal;
  color: var(--brand-600);
  background: linear-gradient(transparent 62%, var(--brand-100) 62%);
}
.hero__lede {
  margin-top: var(--s-4); max-width: 60ch;
  color: var(--text-muted); font-size: var(--fs-lg);
}
.hero__stats {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: var(--s-8);
  max-width: 720px;
}
.stat {
  padding: var(--s-4) var(--s-5);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.stat__num {
  display: block; font-size: var(--fs-2xl); font-weight: var(--fw-bold);
  color: var(--brand-700); line-height: 1.15; font-family: var(--font-num);
  letter-spacing: -.02em;
}
.stat__label { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- 7. Explorer grid ------------------------------------------- */
.explorer { padding-bottom: var(--s-16); }
.explorer__grid {
  display: grid; gap: var(--s-6);
  grid-template-columns: 1fr;
}
@media (min-width: 1000px) {
  .explorer__grid { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
  .panel { position: sticky; top: 76px; }
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-1); overflow: hidden;
}
.card__head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border);
}
.card__title { font-size: var(--fs-base); font-weight: var(--fw-semi); }
.card__body { padding: var(--s-5); }

/* ---------- 8. Map ----------------------------------------------------- */
.map-stage {
  position: relative; background: var(--map-water);
  padding: var(--s-2);
}
/* the map is the page's main content: let it own the full column width so the
   country silhouette fills the card instead of floating in empty water.
   The page column is capped at 1240px, so the map stays a sane height. */
.map-stage svg {
  width: 100%; height: auto;
  display: block; touch-action: none;
}
.district {
  fill: var(--map-land);
  stroke: var(--map-border);
  stroke-width: 1.1;
  cursor: pointer;
  transition: fill var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.district:hover { fill: var(--brand-200); }
.district[data-visited="true"] { fill: var(--brand-500); stroke: var(--brand-700); }
.district[data-visited="true"]:hover { fill: var(--brand-600); }
.district[data-selected="true"] {
  stroke: var(--gold-500); stroke-width: 2.6; paint-order: stroke;
}
.district[data-dim="true"] { fill: var(--map-land); opacity: .3; }
.district:focus-visible { outline: none; stroke: var(--focus); stroke-width: 3; paint-order: stroke; }

.map-toolbar {
  position: absolute; top: var(--s-3); right: var(--s-3); z-index: 5;
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px; border-radius: var(--r-full);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border); box-shadow: var(--sh-2);
  backdrop-filter: blur(8px);
}
.map-toolbar .btn { width: 40px; min-height: 40px; border-radius: var(--r-full); border-color: transparent; }
.map-toolbar .btn:hover { background: var(--brand-100); }

.map-legend {
  position: absolute; left: var(--s-3); bottom: var(--s-3); z-index: 5;
  display: flex; gap: var(--s-4); align-items: center;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-full); font-size: var(--fs-xs); color: var(--text);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border); box-shadow: var(--sh-1); backdrop-filter: blur(8px);
}
.map-legend i {
  width: 12px; height: 12px; border-radius: 3px; display: inline-block;
  margin-inline-end: 5px; vertical-align: -1px; border: 1px solid var(--map-border);
}
.map-hint {
  position: absolute; top: var(--s-3); left: var(--s-3); z-index: 5;
  padding: var(--s-1) var(--s-3); border-radius: var(--r-full);
  font-size: var(--fs-xs); color: var(--text-muted);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border); backdrop-filter: blur(8px);
}

/* ---------- 9. Panel --------------------------------------------------- */
.panel__section { padding: var(--s-5); border-bottom: 1px solid var(--border); }
.panel__section:last-child { border-bottom: 0; }
.panel__label {
  display: block; font-size: var(--fs-xs); font-weight: var(--fw-semi);
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-soft); margin-bottom: var(--s-3);
}

.field { position: relative; }
.field__icon {
  position: absolute; inset-inline-start: var(--s-4); top: 50%; translate: 0 -50%;
  width: 17px; height: 17px; color: var(--text-soft); pointer-events: none;
}
.field input {
  width: 100%; min-height: 46px;
  padding: var(--s-2) var(--s-10) var(--s-2) var(--s-12);
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-full);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.field input::placeholder { color: var(--text-soft); }
.field input:focus-visible {
  background: var(--surface); border-color: var(--brand-500);
}
.field__clear {
  position: absolute; inset-inline-end: 5px; top: 50%; translate: 0 -50%;
  width: 38px; height: 38px; border-radius: var(--r-full);
  display: none; place-items: center; color: var(--text-muted);
}
.field__clear:hover { background: var(--surface-sunken); color: var(--text); }
.field[data-filled="true"] .field__clear { display: grid; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 var(--s-4);
  border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  font-size: var(--fs-sm); color: var(--text-muted);
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--brand-200); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--brand-700); border-color: var(--brand-700); color: #fff;
  font-weight: var(--fw-semi);
}
.chip__dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--brand-500);
}
.chip[aria-pressed="true"] .chip__dot { background: currentColor; }

/* progress */
.progress { display: flex; align-items: baseline; gap: var(--s-2); }
.progress__value {
  font-family: var(--font-num); font-size: var(--fs-2xl);
  font-weight: var(--fw-bold); color: var(--brand-700); letter-spacing: -.02em;
}
.progress__of { color: var(--text-muted); font-size: var(--fs-sm); }
.progress__pct {
  margin-inline-start: auto; font-size: var(--fs-sm); color: var(--text-muted);
  font-family: var(--font-num);
}
.bar {
  height: 8px; margin-top: var(--s-3);
  background: var(--surface-sunken); border-radius: var(--r-full); overflow: hidden;
}
.bar__fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-700));
  border-radius: inherit;
  transition: width var(--dur-slow) var(--ease);
}

/* detail card */
.detail { min-height: 96px; }
.detail__name {
  display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap;
}
.detail__bn { font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.detail__en { color: var(--text-soft); font-size: var(--fs-sm); }
.detail__meta {
  display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4);
  margin-top: var(--s-3); font-size: var(--fs-sm); color: var(--text-muted);
}
.detail__empty { color: var(--text-soft); font-size: var(--fs-sm); }
.detail__actions { margin-top: var(--s-4); display: flex; gap: var(--s-2); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px var(--s-3); border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
  background: var(--brand-100); color: var(--brand-900);
  border: 1px solid var(--brand-200);
}
.badge--gold { background: var(--gold-200); color: var(--gold-600); border-color: var(--gold-200); }
.badge--muted { background: var(--surface-sunken); color: var(--text-muted); border-color: var(--border); }

/* division breakdown */
.divlist { display: grid; gap: var(--s-3); }
.divlist__row { display: grid; grid-template-columns: 1fr auto; gap: var(--s-1) var(--s-3); align-items: center; }
.divlist__name { font-size: var(--fs-sm); }
.divlist__count { font-size: var(--fs-xs); color: var(--text-muted); font-family: var(--font-num); }
.divlist__bar {
  grid-column: 1 / -1; height: 5px; border-radius: var(--r-full);
  background: var(--surface-sunken); overflow: hidden;
}
.divlist__bar > span {
  display: block; height: 100%; width: 0; background: var(--brand-500);
  border-radius: inherit; transition: width var(--dur-slow) var(--ease);
}

.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ---------- 10. Footer ------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: var(--s-10) 0 var(--s-12); margin-top: var(--s-10);
  font-size: var(--fs-sm); color: var(--text-muted);
}
.site-footer h2 { font-size: var(--fs-sm); color: var(--text); margin-bottom: var(--s-2); }
.site-footer p + h2 { margin-top: var(--s-5); }
.site-footer ul { display: grid; gap: var(--s-1); }
.site-footer code {
  font-family: var(--font-num); font-size: .92em;
  background: var(--surface-sunken); padding: 1px 6px; border-radius: 6px;
}

/* ---------- 11. Toast -------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: var(--s-6); translate: -50% 0;
  z-index: 90;
  padding: var(--s-3) var(--s-6);
  border-radius: var(--r-full);
  background: var(--brand-900); color: var(--brand-50);
  font-size: var(--fs-sm); box-shadow: var(--sh-3);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), translate var(--dur) var(--ease);
}
:root[data-theme="dark"] .toast { background: var(--brand-100); color: var(--brand-900); }
.toast[data-show="true"] { opacity: 1; translate: -50% -6px; }

/* ---------- 12. Print -------------------------------------------------- */
@media print {
  .site-header, .map-toolbar, .map-hint, .map-legend, .panel, .hero__stats,
  .toast, .skip-link, .actions { display: none !important; }
  .explorer__grid { grid-template-columns: 1fr; }
  .card, .map-stage { border: 0; box-shadow: none; }
  body { background: #fff; }
}
