/* Nepal GLOF Explorer — static site.
   Mirrors the Streamlit app's appearance: Source Sans 3, a left sidebar of grouped
   navigation on #F1EFE8, borderless metrics with green values, and Streamlit's alert
   colours. The theme values come from .streamlit/config.toml, with #157A5C in place of
   #1D9E75 for text on white (5.29:1 vs 3.39:1). */

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/vendor/fonts/source-sans-3-400.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/vendor/fonts/source-sans-3-600.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/vendor/fonts/source-sans-3-700.woff2") format("woff2");
}

:root {
  --brand: #157A5C;
  --brand-bright: #1D9E75;
  --ink: #2C2C2A;
  --ink-soft: #626259;
  --paper: #FFFFFF;
  --sand: #F1EFE8;
  --sand-active: #E3DFD2;
  --line: #DDD9CE;
  --line-soft: #E9E5DA;

  /* Streamlit's alert tints */
  --info-bg: rgba(28, 131, 225, .10);
  --info-line: #1C83E1;
  --warn-bg: rgba(255, 227, 18, .16);
  --warn-line: #D9AB00;
  --error-bg: rgba(255, 43, 43, .09);
  --error-line: #FF2B2B;
  --success-bg: rgba(33, 195, 84, .10);
  --success-line: #21C354;

  --risk-veryhigh: #7B1FA2;
  --risk-high: #C1121F;
  --risk-moderate: #B26A00;
  --risk-low: #157A5C;

  --sidebar-w: 20rem;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont,
          "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: .6rem 1rem;
}
.skip:focus { left: 0; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar (mirrors st.navigation) ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sand);
  padding: 3.25rem 1.5rem 2rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}
.sidebar nav { display: block; }
.sidebar .group-label {
  font-size: .875rem;
  color: var(--ink-soft);
  margin: 1.4rem 0 .35rem .5rem;
  font-weight: 400;
}
.sidebar a.nav-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .35rem .6rem;
  margin: .1rem 0;
  border-radius: .5rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.5;
}
.sidebar a.nav-item:hover { background: rgba(255, 255, 255, .55); }
.sidebar a.nav-item[aria-current="page"] { background: var(--sand-active); font-weight: 600; }
.sidebar a.nav-item .icon { flex: 0 0 1.25rem; text-align: center; font-size: 1rem; }
.sidebar hr { border: none; border-top: 1px solid var(--line); margin: 1.75rem 0 1rem; }
.sidebar .caption { font-size: .875rem; color: var(--ink-soft); margin: 0 0 .9rem; }
.sidebar .badge {
  display: inline-flex; align-items: center; font-size: .75rem;
  border-radius: 4px; overflow: hidden; text-decoration: none; line-height: 1.9;
}
.sidebar .badge .left { background: #181717; color: #fff; padding: 0 .45rem; }
.sidebar .badge .right { background: #555; color: #fff; padding: 0 .45rem; }
.sidebar .warn {
  font-size: .8rem; color: #7A4B00; background: var(--warn-bg);
  border-radius: .5rem; padding: .5rem .65rem; margin: 0 0 1rem;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none; position: fixed; top: .75rem; left: .75rem; z-index: 60;
  background: var(--paper); border: 1px solid var(--line); border-radius: .5rem;
  padding: .4rem .6rem; font: inherit; font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

/* ── Main column ───────────────────────────────────────────────────────── */
main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 3.25rem 3.5rem 6rem;
}

h1.page-title {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.005em;
  margin: 0 0 1rem;
}
h2 { font-size: 1.65rem; font-weight: 600; margin: 2.2rem 0 .6rem; line-height: 1.3; }
h3 { font-size: 1.25rem; font-weight: 600; margin: 1.6rem 0 .4rem; }
p { margin: .75rem 0; }
a { color: var(--brand); }
hr { border: none; border-top: 1px solid var(--line-soft); margin: 2rem 0; }
.lede { max-width: none; }
.muted { color: var(--ink-soft); font-size: .875rem; }
.note { color: var(--ink-soft); font-size: .875rem; margin: .35rem 0 1.25rem; }

/* ── Alerts (st.info / st.warning / st.error) ──────────────────────────── */
.callout {
  background: var(--warn-bg);
  border-radius: .5rem;
  padding: 1rem 1.1rem;
  margin: 1.1rem 0;
  font-size: 1rem;
}
.callout.info { background: var(--info-bg); }
.callout.alert { background: var(--error-bg); }
.callout.success { background: var(--success-bg); }
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

/* ── Metrics (st.metric — borderless) ──────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem 1.5rem;
  margin: 1.25rem 0 .5rem;
}
.metric .label { font-size: .875rem; color: var(--ink); margin-bottom: .1rem; }
.metric .value {
  font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1.25;
}
.metric .value.sm { font-size: 1.35rem; }

/* ── Controls ──────────────────────────────────────────────────────────── */
.controls {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem; margin: 1.25rem 0 1.5rem;
}
.control label, .control .legend-label {
  display: block; font-size: .875rem; color: var(--ink); margin-bottom: .3rem;
}
.control select {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: .5rem; background: var(--paper); color: var(--ink);
  font: inherit; font-size: .95rem;
}
.control select:focus, .control input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand-bright); outline-offset: 2px;
}
.control input[type="range"] { width: 100%; accent-color: var(--brand-bright); }
.checks { display: flex; flex-wrap: wrap; gap: .1rem 1rem; }
.checks label {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .95rem; margin: 0; cursor: pointer;
}
.checks input { accent-color: var(--brand-bright); }
output { font-variant-numeric: tabular-nums; font-weight: 600; }
button.reset {
  font: inherit; font-size: .9rem; padding: .35rem .85rem; margin-top: .6rem;
  cursor: pointer; background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: .5rem;
}
button.reset:hover { border-color: var(--brand); color: var(--brand); }

/* ── Map + charts ──────────────────────────────────────────────────────── */
.map { height: 520px; border-radius: .5rem; margin: .75rem 0 1.5rem; z-index: 0; }
.map.tall { height: 600px; }
.chart { margin: .5rem 0 1.5rem; }
.leaflet-container { font-family: var(--sans); border-radius: .5rem; }
.leaflet-popup-content { margin: .7rem .9rem; font-size: .9rem; line-height: 1.5; }

.map-legend {
  background: rgba(255, 255, 255, .95); padding: .55rem .75rem; border-radius: .5rem;
  border: 1px solid var(--line); font-size: .85rem; line-height: 1.75; color: var(--ink);
}
.map-legend b { display: block; margin-bottom: .15rem; }
.chip {
  display: inline-block; width: 12px; height: 12px; border-radius: 2px;
  border: 1px solid #555; vertical-align: middle; margin-right: 6px;
}

/* ── Tables (st.dataframe) ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto; margin: .75rem 0 1.5rem;
  border: 1px solid var(--line-soft); border-radius: .5rem;
}
table { border-collapse: collapse; width: 100%; font-size: .9rem; background: var(--paper); }
caption { text-align: left; font-size: .875rem; color: var(--ink-soft); padding: .5rem .75rem; }
th, td { padding: .45rem .75rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
thead th {
  background: #FAFAF8; font-weight: 600; font-size: .82rem; color: var(--ink-soft);
  position: sticky; top: 0; white-space: nowrap; border-bottom: 1px solid var(--line);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAF8; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; color: #fff; white-space: nowrap;
}
.pill.veryhigh { background: var(--risk-veryhigh); }
.pill.high { background: var(--risk-high); }
.pill.moderate { background: var(--risk-moderate); }
.pill.low { background: var(--risk-low); }

/* ── Cards + downloads ─────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 1.25rem; }
.card {
  border: 1px solid var(--line-soft); border-radius: .5rem; padding: 1.1rem 1.25rem;
  background: var(--paper); display: flex; flex-direction: column;
}
.card h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.card p { font-size: .95rem; margin: .25rem 0 .6rem; }
.card .schema {
  font-family: var(--mono); font-size: .75rem; color: var(--ink-soft);
  background: #FAFAF8; padding: .5rem .6rem; border-radius: .4rem;
  margin: .25rem 0 .9rem; word-break: break-word; line-height: 1.55;
}
.dl {
  display: inline-block; margin-top: auto; align-self: flex-start;
  background: var(--brand); color: #fff; text-decoration: none;
  padding: .4rem .9rem; border-radius: .5rem; font-size: .93rem; font-weight: 600;
}
.dl:hover { background: #10634A; }
.dl .size { font-weight: 400; opacity: .85; }

pre.code {
  background: #F4F3EE; color: #2C2C2A; padding: 1rem 1.1rem; border-radius: .5rem;
  overflow-x: auto; font-family: var(--mono); font-size: .8rem; line-height: 1.6;
  border: 1px solid var(--line-soft);
}
code.inline {
  font-family: var(--mono); font-size: .84em; color: #B5305F;
  background: rgba(180, 180, 170, .18); padding: .1rem .3rem; border-radius: .3rem;
}

/* ── Formula ───────────────────────────────────────────────────────────── */
.formula {
  display: flex; align-items: center; gap: .55rem; font-size: 1.05rem;
  margin: .8rem 0; flex-wrap: wrap;
}
.frac { display: inline-flex; flex-direction: column; text-align: center; }
.frac .num { border-bottom: 1.5px solid var(--ink); padding: 0 .45rem .1rem; }
.frac .den { padding: .1rem .45rem 0; }

/* ── Footer ────────────────────────────────────────────────────────────── */
footer {
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line-soft);
  font-size: .85rem; color: var(--ink-soft);
}
footer a { color: var(--brand); }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar-toggle { display: block; }
  .sidebar {
    position: fixed; z-index: 50; top: 0; left: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: 0 0 24px rgba(0, 0, 0, .18); padding-top: 3.5rem;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40;
  }
  main { padding: 3.5rem 1.25rem 4rem; }
  h1.page-title { font-size: 2rem; }
  h2 { font-size: 1.4rem; }
  .map { height: 420px; }
  .map.tall { height: 460px; }
}

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