/* India Toll — public-interest incident data.
   Paper ground, ink type, one reserved red. The red means deaths and nothing
   else: injuries, serious injuries and incident counts all stay in ink, so the
   colour carries meaning instead of decoration. */

:root {
  /* Three accents, each with one job, so colour always means something:
     blue is the platform, red is the toll, amber is harm short of death.
     Every figure keeps its written label -- the accents sit at similar
     lightness, so colour reinforces meaning and never carries it alone. */
  --paper: #F5F7FA;
  --surface: #FFFFFF;
  --ink: #16191D;
  --muted: #5B6470;
  --line: #DDE2E9;
  --line-strong: #C4CCD6;

  --toll: #C0271E;          /* lives lost */
  --toll-soft: #F3DAD8;
  --toll-deep: #8E211C;
  --harm: #A85A08;          /* injuries, serious injuries */
  --harm-soft: #F6E6D2;
  --link: #1A5FB4;          /* anything you can click */
  --link-soft: #E4EDF9;
  --link-deep: #164E94;

  /* Noto carries the Devanagari: about half of all source titles are in
     Hindi, and the previous stack had no face that covered them. */
  --sans: "Noto Sans", "Noto Sans Devanagari", -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Archivo", "Noto Sans", -apple-system, sans-serif;

  --radius: 6px;
  --gap: 1.5rem;
  --section-gap: 3.5rem;
  --measure: 70ch;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* Bootstrap ships code in magenta, which fights the palette. */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.05em 0.3em;
}

/* Blue and underlined: the one affordance every reader already knows. */
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* ---------------------------------------------------------------- masthead */

.masthead {
  border-bottom: 1px solid var(--line-strong);
  padding: 2.25rem 0 1.25rem;
}

.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  font-family: var(--display);
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
  text-decoration: none;
  color: var(--ink);
}

.tagline {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
  max-width: 52ch;
}

.nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.nav a { text-decoration: none; color: var(--muted); padding-bottom: 3px; font-weight: 500; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 2px solid var(--link);
}

/* ------------------------------------------------------------------- notice
   A standing caveat, said once at the top rather than buried in the footer:
   absence of a record is not absence of an incident. */

.notice {
  background: var(--link-soft);
  border-bottom: 1px solid var(--line);
}

.notice p {
  margin: 0;
  padding: 0.85rem 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink);
  max-width: var(--measure);
}

/* ------------------------------------------------------------------ filters */

.filters {
  border-bottom: 1px solid var(--line-strong);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 20;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}

/* Selects size to their widest option, so a long incident type used to push
   the row onto a second line. Let the fields share the row and shrink instead. */
.field { display: flex; flex-direction: column; gap: 0.3rem; flex: 1 1 8.5rem; min-width: 0; }

.field > span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.field select,
.field input {
  font-family: var(--sans);
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  width: 100%;
  min-width: 0;
}

.field select:hover, .field input:hover { border-color: var(--link); }

.filter-clear {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--link);
  background: var(--link-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  margin-left: auto;
}
.filter-clear:hover { border-color: var(--link); }
.filter-clear[hidden] { display: none; }

/* --------------------------------------------------------------------- toll */

.toll {
  padding: var(--section-gap) 0 3rem;
  border-bottom: 1px solid var(--line);
}

.toll-label {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--toll);
  margin: 0 0 0.35rem;
}

.toll-figure {
  font-family: var(--display);
  font-size: clamp(4rem, 11vw, 8rem);
  font-weight: 700;
  line-height: 0.86;
  letter-spacing: -0.045em;
  color: var(--toll);
  margin: 0 0 1rem;
}

/* Injuries and serious injuries carry the amber; the incident count is not a
   casualty figure and stays in ink. */
.toll-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.25rem;
}

.toll-secondary > div {
  flex: 1 1 10rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

.toll-secondary > div:nth-child(1) .stat-value,
.toll-secondary > div:nth-child(2) .stat-value { color: var(--harm); }

.stat-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.stat-value {
  font-family: var(--display);
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
}

.stat-note {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

/* ----------------------------------------------------------------- sections */

.section { padding: var(--section-gap) 0 3rem; border-bottom: 1px solid var(--line); }
.section:last-of-type { border-bottom: 0; }

.section-title {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 0.4rem;
}

.section-note {
  font-family: var(--sans);
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0 0 2rem;
  max-width: var(--measure);
}

.split { display: grid; grid-template-columns: 1.05fr 1fr; gap: 3.5rem; }

/* ---------------------------------------------------------------- map slot */

.map-slot { min-height: 340px; }

.map-slot svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 430px;
  margin: 0 auto;
  overflow: visible;
}

.state {
  stroke: var(--paper);
  stroke-width: 1.1;
  cursor: pointer;
  transition: fill 120ms linear;
}

.state:hover { stroke: var(--ink); stroke-width: 1.4; }

/* The selected state keeps its colour and gains an outline; the rest step
   back but stay live, so the map is still how you move between states. */
.state.is-selected { stroke: var(--ink); stroke-width: 2.4; }
.state.is-dimmed { opacity: 0.85; }
.state.is-dimmed:hover { opacity: 1; stroke: var(--link); stroke-width: 1.6; }
.state:focus-visible { outline: none; stroke: var(--toll); stroke-width: 2.2; }

.map-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 1.25rem;
}

.legend-swatch { display: block; width: 24px; height: 11px; }
.legend-swatch--none { margin-left: 0.75rem; }

.legend-clear {
  font: inherit;
  color: var(--link);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.legend-label {
  font-size: 0.6875rem;
  color: var(--muted);
  margin: 0 0.35rem;
}

/* -------------------------------------------------------------- bar chart */

.bars { display: flex; flex-direction: column; gap: 0.55rem; }

.bar-row {
  display: grid;
  grid-template-columns: 10.5rem 1fr 3rem;
  align-items: center;
  gap: 0.85rem;
  cursor: default;
}

.bar-name { font-size: 0.875rem; font-weight: 500; }

.bar-track { display: block; height: 14px; background: var(--toll-soft); }

.bar-fill {
  /* Must be block: an inline span ignores width and height. */
  display: block;
  height: 100%;
  background: var(--toll);
  /* Rounded data-end, anchored flat to the baseline it grows from. */
  border-radius: 0 3px 3px 0;
  min-width: 2px;
}

.bar-value { font-size: 0.875rem; font-weight: 600; text-align: right; }

.bar-row:hover .bar-track { background: var(--toll-soft); }

/* --------------------------------------------------------------- timeline */

.timeline {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 190px;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 0;
}

.timeline-col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  min-width: 0;
  cursor: default;
}

.timeline-bar {
  display: block;
  width: 100%;
  /* Capped so a short series does not turn into blocks of colour. */
  max-width: 46px;
  background: var(--toll);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: background 120ms linear;
}

.timeline-col:hover .timeline-bar { background: var(--toll-deep); }

.timeline-axis {
  display: flex;
  gap: 4px;
  margin-top: 0.5rem;
}

.timeline-tick {
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.6875rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

/* --------------------------------------------------------------- incidents */

.incidents { display: flex; flex-direction: column; gap: 0.6rem; }

.incident {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 1.5rem;
  align-items: baseline;
  /* Inset horizontally so the row's content does not run into the ends of
     its own rule, and so the hover fill has a margin around the text. */
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}

.incident:hover { border-color: var(--link); }

.incident-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.incident-headline {
  color: var(--link);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.2rem;
}

.incident-where { display: block; color: var(--muted); }

.incident-place {
  font-family: var(--sans);
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0;
}

.incident-toll { text-align: right; white-space: nowrap; }

.incident-deaths {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--toll);
  line-height: 1;
}

.incident-harm {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--harm);
  line-height: 1;
}

.incident-none {
  font-size: 0.875rem;
  color: var(--muted);
}

.cell-zero { text-align: right; font-weight: 600; color: var(--muted); white-space: nowrap; }

.incident-deaths-label,
.incident-type-label {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Provenance: a record a reader submitted, once reviewed and promoted, still
   says where it came from. */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

.badge--user { background: var(--link-soft); color: var(--link-deep); }

/* ------------------------------------------------------------------ states */

.empty {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--muted);
  padding: 2.5rem 0;
  margin: 0;
}

.loading { color: var(--muted); font-size: 0.9375rem; }

.more {
  display: inline-block;
  margin-top: 1.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--link);
  padding-bottom: 3px;
}

/* ----------------------------------------------------------------- tooltip */

.tip {
  position: fixed;
  z-index: 60;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 0.8125rem;
  line-height: 1.35;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  pointer-events: none;
  max-width: 15rem;
}
.tip[hidden] { display: none; }
.tip b { font-weight: 600; }

/* ------------------------------------------------------------------ table
   Named .records, not .table: Bootstrap ships its own .table whose
   `> :not(caption) > * > *` rule outranks a single class and was forcing
   every cell's colour back to black. */

.result-count {
  font-family: var(--sans);
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.table-wrap { overflow-x: auto; }

.records {
  width: 100%;
  /* Fixed layout: with auto layout the long location strings widened the
     table past its container and the last column was cut off. */
  table-layout: fixed;
  min-width: 46rem;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.records th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0 0.75rem 0.6rem 0;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

/* Inset the outer edges so the first and last columns do not run into the
   ends of the row rules, matching the recent-incidents list. Flush against
   the edge, the right-aligned figures also read as though they were cut off. */
.records th:first-child, .records td:first-child { padding-left: 1rem; }
.records th:last-child, .records td:last-child { padding-right: 1rem; }

/* Every column is sized except Incident, which takes the remaining width. */
.records th:nth-child(1), .records td:nth-child(1) { width: 7.75rem; }   /* date     */
.records th:nth-child(3), .records td:nth-child(3) { width: 9.5rem; }    /* location */
.records th:nth-child(4), .records td:nth-child(4) { width: 8.5rem; }    /* type     */
.records th:nth-child(5), .records td:nth-child(5) { width: 5rem; }      /* deaths   */
.records th:nth-child(6), .records td:nth-child(6) { width: 5rem; }      /* injured  */
.records th:nth-child(7), .records td:nth-child(7) { width: 5.75rem; }   /* serious  */

/* Long place names must wrap rather than force the table wider. */
.records td { overflow-wrap: anywhere; }

.records td {
  padding: 0.9rem 0.75rem 0.9rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.records tbody tr:hover { background: var(--link-soft); }

/* Sortable headers are buttons so they are reachable from the keyboard. */
.th-sort {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.th-sort:hover { color: var(--ink); }
.th-sort[aria-sort] { color: var(--ink); }
.th-sort .arrow { color: var(--link); margin-left: 0.25rem; }

.cell-date { white-space: nowrap; color: var(--muted); font-size: 0.875rem; }
.cell-headline { font-weight: 600; text-decoration: none; }
.cell-headline:hover { text-decoration: underline; }
.cell-place { font-family: var(--sans); color: var(--muted); }
.cell-num { text-align: right; font-weight: 600; white-space: nowrap; color: var(--harm); }
.cell-deaths { text-align: right; font-weight: 700; color: var(--toll); white-space: nowrap; }
.cell-unknown { color: var(--line-strong); }

.pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.75rem;
}

.pager button {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  background: none;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--link); color: var(--link); }
.pager button:disabled { color: var(--line-strong); border-color: var(--line); cursor: default; }
.pager span { font-size: 0.875rem; color: var(--muted); }

/* ----------------------------------------------------------------- detail */

.detail { padding: var(--section-gap) 0 2rem; }

.back {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2rem;
}
.back:hover { color: var(--ink); }

.detail-headline {
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0 0 0.75rem;
  max-width: 22ch;
}

.detail-toll {
  display: flex;
  flex-wrap: wrap;
  gap: 2.75rem;
  padding: 2rem 0;
  margin: 2rem 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.detail-toll .stat-value.is-toll { color: var(--toll); font-size: 3rem; font-weight: 700; }
.detail-toll > div:nth-child(2) .stat-value,
.detail-toll > div:nth-child(3) .stat-value { color: var(--harm); }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1.75rem 2.5rem;
  margin: 0 0 2.5rem;
}

.facts dt {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.facts dd { margin: 0; font-size: 1.0625rem; font-weight: 500; }

.detail-description {
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.65;
  max-width: var(--measure);
  margin: 0 0 3rem;
}

.sources { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

.source {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}

.source-title { font-size: 1rem; font-weight: 600; color: var(--link); }
.source-title:hover { text-decoration: underline; }

.source-meta {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0.2rem 0 0;
}

@media (max-width: 640px) {
  .detail-toll { gap: 1.5rem 2rem; }
  .detail-toll .stat-value.is-toll { font-size: 2.25rem; }
}

/* ------------------------------------------------------------------- form */

.form-intro {
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--muted);
  max-width: var(--measure);
  margin: 0 0 2.5rem;
}

.form { max-width: 760px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 1.75rem;
}

.form-field { display: flex; flex-direction: column; }
.form-field--wide { grid-column: 1 / -1; }

.form-field > label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.required { color: var(--toll); margin-left: 0.15rem; }

.form-field input,
.form-field select,
.form-field textarea {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  width: 100%;
}

.form-field textarea { font-family: var(--sans); line-height: 1.5; resize: vertical; min-height: 6rem; }
.form-field input:hover, .form-field select:hover, .form-field textarea:hover { border-color: var(--link); }

.form-hint {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

/* Errors state what to do, not that something is invalid. */
.form-error {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--toll);
  margin: 0.35rem 0 0;
}
.form-error:empty { display: none; }

.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea { border-color: var(--toll); }

.form-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}

.btn {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--link);
  border: 1px solid var(--link);
  border-radius: var(--radius);
  padding: 0.8rem 1.6rem;
  cursor: pointer;
}
.btn:hover { background: var(--link-deep); border-color: var(--link-deep); }
.btn:disabled { background: var(--muted); border-color: var(--muted); cursor: default; }

.form-status { font-size: 0.875rem; color: var(--toll); }
.form-status:empty { display: none; }

.confirm { max-width: var(--measure); }
.confirm-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.0625rem;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ prose */

.prose { max-width: var(--measure); }

.prose h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 3rem 0 0.85rem;
}

.prose p, .prose li {
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
}

.prose p { margin: 0 0 1.1rem; }
.prose ul { margin: 0 0 1.1rem; padding-left: 1.2rem; }
.prose li { margin-bottom: 0.5rem; }
.prose strong { font-weight: 600; }

.lede {
  font-family: var(--sans);
  font-size: 1.3125rem;
  line-height: 1.55;
  margin: 0 0 2rem;
}

/* ------------------------------------------------------------------ footer */

.footer {
  border-top: 1px solid var(--line-strong);
  margin-top: var(--section-gap);
  padding: 2rem 0 3rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
}
.footer p { margin: 0 0 0.4rem; max-width: var(--measure); }

/* --------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; gap: 3rem; }
  .toll-secondary { gap: 2rem; }
}

@media (max-width: 640px) {
  :root { --section-gap: 2.75rem; }
  .nav { gap: 1rem; }
  .field select, .field input { min-width: 7.5rem; }
  .incident { grid-template-columns: 1fr auto; }
  .incident-date { grid-column: 1 / -1; }
  .toll-secondary { gap: 1.5rem 2.5rem; }
  .stat-value { font-size: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
