/* ===== India Jobs Atlas — dashboard styles ===== */

:root,
[data-theme='light'] {
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', 'Helvetica Neue', system-ui, sans-serif;

  --ink: #1c1b19;
  --ink-soft: #3a3833;
  --muted: #6f6d66;
  --faint: #a9a7a0;
  --line: #e3e0da;
  --line-soft: #ecebe6;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --accent: #e26a2c;        /* India saffron */
  --accent-deep: #b04e1c;
  --accent-soft: #fbe7d8;

  /* AI exposure sequential scale stops (low -> high) */
  --ai-0: #2b6a78;   /* deep teal */
  --ai-2: #4d9aa6;
  --ai-4: #8fb89a;
  --ai-6: #e3b341;   /* amber */
  --ai-8: #e07a2e;   /* saffron */
  --ai-10:#b3261e;   /* crimson */

  --radius: 10px;
  --shadow: 0 1px 2px rgba(28,27,25,.04), 0 6px 18px rgba(28,27,25,.05);
}

[data-theme='dark'] {
  --ink: #ecebe7;
  --ink-soft: #cfcdc6;
  --muted: #8b8980;
  --faint: #5e5d57;
  --line: #2c2b28;
  --line-soft: #242321;
  --bg: #131210;
  --surface: #1b1a18;
  --surface-2: #211f1c;
  --accent: #f0823f;
  --accent-deep: #c95f23;
  --accent-soft: #3a2a1f;

  --ai-0: #3a8896;
  --ai-2: #5fb0bd;
  --ai-4: #9fc9a3;
  --ai-6: #ecc557;
  --ai-8: #ef8a3e;
  --ai-10:#d83a30;

  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
}
h1,h2,h3 { line-height: 1.15; font-family: var(--font-display); text-wrap: balance; }
a { color: var(--accent-deep); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
button { cursor: pointer; font: inherit; background: none; border: none; color: inherit; }
::selection { background: var(--accent-soft); }

/* ===== Layout ===== */
.dashboard {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 64px 1fr;
  min-height: 100dvh;
}
.header {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; flex: none; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 10px; }
.source-pill { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; background: var(--surface); }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-soft); border: 1px solid var(--line); }
.icon-btn:hover { background: var(--surface-2); color: var(--accent); }

.sidebar {
  grid-row: 2; grid-column: 1;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 28px;
  display: flex; flex-direction: column; gap: 22px;
}
.kpi-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi-num { display: block; font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; color: var(--ink); letter-spacing: -.02em; }
.kpi-lbl { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.3; margin-top: 4px; text-transform: uppercase; letter-spacing: .03em; }

.panel { display: flex; flex-direction: column; gap: 8px; }
.panel-title { font-family: var(--font-body); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.metric-toggle { display: flex; flex-direction: column; gap: 5px; }
.metric { text-align: left; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 500; color: var(--ink-soft); transition: all .15s; }
.metric:hover { border-color: var(--accent); color: var(--accent-deep); }
.metric.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.metric.active:hover { color: #fff; }

.legend { display: flex; flex-direction: column; gap: 4px; }
.legend-bar { height: 10px; border-radius: 999px; margin: 2px 0 6px; }
.legend-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend-cats { display: flex; flex-direction: column; gap: 5px; }
.legend-cat { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.panel-note { font-size: 11px; color: var(--muted); line-height: 1.4; }

.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; }
.check input { accent-color: var(--accent); }
.search { margin-top: 4px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--ink); }
.search:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.howto { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.howto li { font-size: 12px; color: var(--muted); padding-left: 14px; position: relative; }
.howto li::before { content: ""; position: absolute; left: 0; top: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.howto b { color: var(--ink-soft); font-weight: 600; }

.main {
  grid-row: 2; grid-column: 2;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 26px 0;
}
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; }
.chart-title { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.chart-sub { font-size: 13.5px; color: var(--muted); max-width: 72ch; margin-top: 6px; }
.chart-sub b { color: var(--ink-soft); }
.legend-mini { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.legend-mini .g { width: 14px; height: 14px; border-radius: 4px; }

.treemap-wrap { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
#treemap { display: block; width: 100%; height: 640px; }
.tooltip {
  position: absolute; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--ink); color: #fff; padding: 9px 12px; border-radius: 8px;
  font-size: 12px; line-height: 1.4; max-width: 240px; box-shadow: var(--shadow); z-index: 30;
}
.tooltip b { color: #fff; font-weight: 600; }
.tooltip .tt-sub { color: rgba(255,255,255,.7); font-size: 11px; }

/* Treemap tiles */
.tile rect { stroke: var(--surface); stroke-width: 1.5; transition: opacity .15s; }
.tile text { fill: var(--ink); font-family: var(--font-body); pointer-events: none; }
.tile-label { font-weight: 600; font-size: 11px; }
.tile-val { font-size: 10px; font-weight: 600; opacity: .8; }
.group-cell rect { stroke: var(--bg); stroke-width: 1; }
.div-cell rect { fill: none; stroke: var(--line); stroke-width: 1; }
.div-label { font-family: var(--font-display); font-weight: 600; font-size: 10px; fill: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Context cards */
.context { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--line); }
.sec-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 14px; }
.context-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.ctx-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.ctx-stat { font-family: var(--font-display); font-weight: 700; font-size: 30px; color: var(--accent-deep); letter-spacing: -.02em; display: block; }
.ctx-text { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

/* Methodology */
.methodology { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--line); }
.meth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.meth-col h3 { font-family: var(--font-body); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-deep); margin-bottom: 8px; }
.meth-col p { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; line-height: 1.6; }
.meth-col p b { color: var(--ink); }
.caveat { background: var(--accent-soft); border: 1px solid color-mix(in oklab, var(--accent) 30%, transparent); border-radius: 10px; padding: 12px 14px; }
[data-theme='dark'] .caveat { background: var(--accent-soft); }
.src-title { font-family: var(--font-body); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 8px; }
.sources { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.sources li { font-size: 12.5px; color: var(--ink-soft); }
.footer { margin-top: 30px; padding: 20px 0 24px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--faint); }

/* Drawer */
.drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: 420px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0,0,0,.12); transform: translateX(105%); transition: transform .28s cubic-bezier(.16,1,.3,1);
  z-index: 40; overflow-y: auto; padding: 22px 24px 28px;
}
.drawer.open { transform: translateX(0); }
.scrim { position: fixed; inset: 0; background: rgba(20,19,17,.32); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 35; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer-close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.drawer-close:hover { background: var(--surface-2); color: var(--ink); }
.drawer-content h2 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 4px; padding-right: 30px; }
.d-code { font-size: 11px; color: var(--accent-deep); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.d-breadcrumb { font-size: 12px; color: var(--muted); margin: 2px 0 18px; }
.d-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.d-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.d-stat-num { font-family: var(--font-display); font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.d-stat-lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 3px; }
.d-exposure { margin-bottom: 18px; }
.d-exp-bar { height: 10px; border-radius: 999px; background: var(--line-soft); margin: 8px 0; overflow: hidden; }
.d-exp-fill { height: 100%; border-radius: 999px; transition: width .4s; }
.d-section { margin-bottom: 16px; }
.d-section h4 { font-family: var(--font-body); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.d-section p { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.d-sources { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.d-sources li { font-size: 12px; }

@media (max-width: 960px) {

  .dashboard {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    min-height: 100dvh;
  }

  /* Header */
  .header {
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: 0;
    min-height: 64px;
    padding: 10px 18px;
  }

  /* Sidebar becomes a normal section above the dashboard */
  .sidebar {
    grid-column: 1;
    grid-row: 2;

    border-right: none;
    border-bottom: 1px solid var(--line);

    overflow: visible;
    padding: 16px 18px 20px;

    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  /* Main MUST move to its own grid row */
  .main {
    grid-column: 1;
    grid-row: 3;

    overflow: visible;
    padding: 22px 20px 0;
  }

  /* KPI cards */
  .kpi-stack {
    grid-template-columns: repeat(4, 1fr);
  }

  .kpi {
    padding: 12px;
  }

  /* Metric buttons become a horizontal scrollable row */
  .metric-toggle {
    flex-direction: row;
    gap: 6px;

    overflow-x: auto;
    padding-bottom: 4px;

    scrollbar-width: thin;
  }

  .metric {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* Layout sections */
  .context-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .meth-grid {
    grid-template-columns: 1fr;
  }

  .sources {
    grid-template-columns: 1fr;
  }

  #treemap {
    height: 520px;
  }
}


/* ===== Tablet / Large Phone ===== */

@media (max-width: 720px) {

  .header {
    padding: 10px 14px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-title {
    font-size: 16px;
  }

  .brand-sub {
    font-size: 10px;
  }

  .source-pill {
    display: none;
  }

  .sidebar {
    padding: 14px;
    gap: 16px;
  }

  .kpi-stack {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-num {
    font-size: 21px;
  }

  .main {
    padding: 20px 14px 0;
  }

  .chart-head {
    display: block;
    margin-bottom: 14px;
  }

  .chart-title {
    font-size: 23px;
  }

  .chart-sub {
    font-size: 13px;
    max-width: none;
  }

  .legend-mini {
    margin-top: 12px;
  }

  #treemap {
    height: 480px;
  }

  .context-grid {
    grid-template-columns: 1fr;
  }

  .ctx-card {
    padding: 15px 16px;
  }

  .meth-col p {
    font-size: 12.5px;
  }

  .drawer {
    width: 100%;
    max-width: 100%;
    border-left: none;
  }
}


/* ===== Mobile ===== */

@media (max-width: 560px) {

  body {
    font-size: 14px;
  }

  .header {
    min-height: 58px;
    padding: 8px 12px;
  }

  .brand {
    min-width: 0;
  }

  .brand-text {
    min-width: 0;
  }

  .brand-title {
    font-size: 15px;
    white-space: nowrap;
  }

  .brand-sub {
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    flex: none;
  }

  /* Sidebar */
  .sidebar {
    padding: 14px 12px 18px;
  }

  .kpi-stack {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .kpi {
    padding: 10px;
  }

  .kpi-num {
    font-size: 20px;
  }

  .kpi-lbl {
    font-size: 9.5px;
  }

  /* Metric selector */
  .metric-toggle {
    margin-right: -12px;
    padding-right: 12px;
  }

  .metric {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Main */
  .main {
    padding: 18px 12px 0;
  }

  .chart-title {
    font-size: 21px;
    line-height: 1.15;
  }

  .chart-sub {
    font-size: 12.5px;
    line-height: 1.5;
  }

  /* Treemap */
  .treemap-wrap {
    border-radius: 10px;
  }

  #treemap {
    height: 440px;
  }

  /* Context */
  .context,
  .methodology {
    margin-top: 24px;
    padding-top: 20px;
  }

  .sec-title {
    font-size: 19px;
  }

  /* Methodology */
  .meth-grid {
    gap: 14px;
  }

  .meth-col p {
    font-size: 12px;
    line-height: 1.55;
  }

  .sources {
    gap: 8px;
  }

  .sources li {
    font-size: 11.5px;
  }

  /* Footer */
  .footer {
    margin-top: 24px;
    padding: 18px 0 20px;
    font-size: 10.5px;
  }

  /* Detail drawer */
  .drawer {
    padding: 18px 16px 24px;
  }

  .drawer-content h2 {
    font-size: 20px;
  }

  .d-stats {
    gap: 8px;
  }

  .d-stat {
    padding: 10px;
  }
}