/* Vulnerability page v2. Every rule is scoped under .atlas-v2 (or a v2-only
   class): Dash loads every file in assets/ on every page, so unscoped rules
   would leak into the v1 pages. Layout lives in pages/vulnerability_v2.py.
   Type and brand green follow the AGRA brand guide: Poppins, H1 40/700,
   H3 20/700, body 16/400; Dark Green #07743F (PANTONE 357 C). */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

.atlas-v2 {
  --stock: #F7F5EE;
  --stock-2: #EFEBDF;
  --stock-3: #E6E1D2;
  --ink: #14201A;
  --ink-2: #44514A;
  --ink-3: #5F6B64;
  --hair: #B7BDAF;
  --hair-2: #CFD4C7;
  --agra: #07743F;
  --agra-tint: #E3EFE7;
  --font: 'Poppins', sans-serif;

  /* Dash 4 dropdown theming hooks (Dash 3, pinned in requirements.txt, is styled below) */
  --Dash-Fill-Inverse-Strong: var(--stock);
  --Dash-Fill-Interactive-Weak: var(--stock-2);
  --Dash-Fill-Interactive-Strong: var(--agra);
  --Dash-Fill-Primary-Hover: var(--stock-2);
  --Dash-Fill-Primary-Active: var(--agra-tint);
  --Dash-Stroke-Strong: var(--ink);
  --Dash-Stroke-Weak: var(--hair);
  --Dash-Text-Primary: var(--ink);
  --Dash-Text-Strong: var(--ink);
  --Dash-Text-Weak: var(--ink-3);
  --Dash-Shading-Strong: transparent;
  --Dash-Shading-Weak: transparent;

  background: var(--stock);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  padding: 0 !important;
  min-height: 100vh;
}

.atlas-v2 *,
.atlas-v2 *::before,
.atlas-v2 *::after { border-radius: 0 !important; }

.atlas-v2 :focus-visible { outline: 2px solid var(--agra); outline-offset: 2px; }

/* ---------- type scale ---------- */
.atlas-v2 .v2-h1 {
  font-family: var(--font);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
}
.atlas-v2 .v2-h3 {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  margin: 0 0 10px;
}
.atlas-v2 .v2-body-text {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0 0 12px;
  max-width: 60ch;
}
.atlas-v2 .v2-body-text:last-child { margin-bottom: 0; }
.atlas-v2 .v2-body-text b,
.atlas-v2 .v2-key-list b { color: var(--ink); font-weight: 600; }
.atlas-v2 .v2-caption {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
  margin: 6px 0 0;
}
.atlas-v2 .v2-caveat {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-3);
  border-left: 2px solid var(--hair);
  padding-left: 10px;
  margin: 0;
  max-width: 60ch;
}

/* ---------- shared header, restyled for this page ---------- */
.atlas-v2 .header.surface {
  background: var(--stock);
  border: 0;
  border-bottom: 1px solid var(--hair);
  box-shadow: none;
  backdrop-filter: none;
  margin: 0;
  padding: 10px 28px 0;
  transition: none;
}
.atlas-v2 .header.surface:hover { box-shadow: none; border-color: var(--hair); }
.atlas-v2 .header img { height: 44px !important; }
.atlas-v2 .header-actions { display: none; } /* no theme toggle or help button on v2 */
.atlas-v2 .page-title {
  font-family: var(--font);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 4px !important;
}
.atlas-v2 .page-tabs.nav-v2 .nav-link { color: var(--ink-2); font-family: var(--font); font-size: 15px; font-weight: 500; }
.atlas-v2 .page-tabs.nav-v2 .nav-link.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--agra); }
.atlas-v2 .page-tabs.nav-v2 .nav-link:hover { color: var(--ink); border-bottom-color: var(--hair); }

/* ---------- shell: sticky filter sidebar + main ---------- */
.atlas-v2 .v2-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: start;
}

.atlas-v2 .v2-sidebar {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 22px 20px 24px 28px;
  border-right: 1px solid var(--hair);
  background: var(--stock-2);
  display: grid;
  gap: 14px;
  align-content: start;
}
.atlas-v2 .v2-sidebar > .v2-h3 { margin-bottom: 0; }

.atlas-v2 .v2-filter { display: grid; gap: 5px; }
.atlas-v2 .v2-filter-label { display: flex; align-items: center; gap: 6px; }
.atlas-v2 .v2-filter-key {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
}
.atlas-v2 .v2-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--ink-3);
  border-radius: 50% !important;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  color: var(--ink-3);
  cursor: help;
  user-select: none;
}
.atlas-v2 .v2-help:hover,
.atlas-v2 .v2-help:focus-visible { border-color: var(--agra); color: #fff; background: var(--agra); }

/* Filter tooltips render at <body> level, outside .atlas-v2; the class only
   exists on this page, so this cannot affect other pages. */
.v2-tooltip .tooltip-inner {
  max-width: 280px;
  background: #14201A;
  color: #F7F5EE;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  padding: 8px 11px;
  border-radius: 0;
}
.v2-tooltip .tooltip-arrow::before { border-right-color: #14201A; border-left-color: #14201A; }

/* Dropdowns - Dash 3 (react-select), the version pinned in requirements.txt.
   styles.css forces its own rounded, bordered look with !important on
   .Select-control and .dash-dropdown, so these overrides need it too. */
.atlas-v2 .v2-filter .dash-dropdown { background: transparent !important; border: 0 !important; }
.atlas-v2 .v2-filter .Select-control {
  background: var(--stock) !important;
  border: 1px solid var(--ink) !important;
  box-shadow: none !important;
  height: 38px;
  cursor: pointer;
}
.atlas-v2 .v2-filter .Select-control:hover { background: #fff !important; border-color: var(--ink) !important; box-shadow: none !important; }
.atlas-v2 .v2-filter .is-focused:not(.is-open) > .Select-control { border-color: var(--agra) !important; box-shadow: 0 0 0 1px var(--agra) !important; }
.atlas-v2 .v2-filter .is-open > .Select-control { border-color: var(--ink) !important; background: #fff !important; }
.atlas-v2 .v2-filter .Select-value-label,
.atlas-v2 .v2-filter .Select-placeholder,
.atlas-v2 .v2-filter .Select-input > input {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink) !important;
}
.atlas-v2 .v2-filter .Select-value,
.atlas-v2 .v2-filter .Select-placeholder { line-height: 36px; padding-left: 11px; }
/* The search input is near zero-width until you type; the page-wide focus
   outline drew it as two vertical green lines at the start of the value. */
.atlas-v2 .v2-filter .Select-input > input:focus,
.atlas-v2 .v2-filter .Select-input > input:focus-visible { outline: none; box-shadow: none; }
.atlas-v2 .v2-filter .Select-arrow { border-top-color: var(--ink-3); }
.atlas-v2 .v2-filter .Select-menu-outer {
  background: #fff;
  border: 1px solid var(--ink);
  box-shadow: none;
  margin-top: -1px;
  z-index: 20;
}
.atlas-v2 .v2-filter .Select-option {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  padding: 7px 11px;
}
/* Long options (hazard names) wrap; keep each one inside its fixed row height
   (the dropdowns set optionHeight to fit three lines). */
.atlas-v2 .v2-filter .VirtualizedSelectOption {
  display: flex !important;
  align-items: center !important;
  font-size: 14px !important;
  line-height: 1.3 !important;
  padding: 4px 11px !important;
  overflow: hidden;
}
.atlas-v2 .v2-filter .Select-option.is-focused { background: var(--agra-tint); }
.atlas-v2 .v2-filter .Select-option.is-selected { background: var(--agra); color: #fff; font-weight: 600; }

/* Dropdowns - Dash 4 */
.atlas-v2 .v2-filter .dash-dropdown { font-family: var(--font); font-size: 15px; font-weight: 500; }
.atlas-v2 .v2-filter .dash-dropdown-trigger { background: var(--stock); border: 1px solid var(--ink); box-shadow: none; min-height: 38px; }
.atlas-v2 .v2-filter .dash-dropdown-focus-target:focus-visible { outline: none; }

/* ---------- title block, downloads on the right ---------- */
.atlas-v2 .v2-main { min-width: 0; }
.atlas-v2 .v2-titleblock {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 28px;
  padding: 22px 28px 14px;
}
.atlas-v2 .v2-subtitle { font-size: 15px; color: var(--ink-2); margin: 6px 0 0; }
.atlas-v2 .v2-downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.atlas-v2 .v2-btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 14px;
  border: 1px solid var(--ink);
  background: var(--stock);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.atlas-v2 .v2-btn-primary { background: var(--agra); border-color: var(--agra); color: #fff; }
.atlas-v2 .v2-btn:hover { background: var(--ink); border-color: var(--ink); color: #fff; }

.atlas-v2 .v2-double-rule {
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  height: 4px;
  margin: 0 28px;
}

/* ---------- body: stage (map + story) | inspector ---------- */
.atlas-v2 .v2-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px 32px;
  padding: 22px 28px 36px;
  align-items: start;
}

.atlas-v2 .v2-stage {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr);
  gap: 24px 36px;
  align-items: start;
  min-width: 0;
}

.atlas-v2 .v2-map-col { display: grid; gap: 14px; min-width: 0; justify-items: stretch; }

/* No frame around the map. Height leaves room for the distribution beneath it
   on a laptop screen; width follows the selection's shape (set per update). */
.atlas-v2 .v2-map-panel {
  height: clamp(340px, calc(100vh - 360px), 720px);
  max-width: 100%;
  justify-self: start;
  background: transparent;
  overflow: hidden;
}
.atlas-v2 .v2-map-panel .modebar-container { top: 2px; right: 2px; }
.atlas-v2 .v2-map-panel .modebar { background: transparent !important; }
.atlas-v2 .v2-map-panel .modebar-btn path { fill: var(--ink-2) !important; }
.atlas-v2 .v2-map-panel .modebar-btn:hover path { fill: var(--agra) !important; }

/* ---------- story column ---------- */
.atlas-v2 .v2-story-inner { display: grid; gap: 30px; }
.atlas-v2 .v2-story-section { display: grid; }
.atlas-v2 .v2-formula {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--stock-2);
  border-left: 3px solid var(--agra);
  padding: 10px 14px;
  margin: 4px 0 0;
  max-width: 60ch;
}
.atlas-v2 .v2-formula b { color: var(--ink); font-weight: 600; }
.atlas-v2 .v2-key-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.atlas-v2 .v2-key-list li {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: start;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-2);
}
.atlas-v2 .v2-key-list .v2-swatch { margin-top: 5px; }
.atlas-v2 .v2-callout {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink);
  margin: 4px 0 0;
  max-width: 60ch;
}

/* ---------- inspector ---------- */
.atlas-v2 .v2-inspector-inner { display: grid; gap: 32px; align-content: start; }
.atlas-v2 .v2-block { display: grid; }

/* layer cards: the map switcher */
.atlas-v2 .v2-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.atlas-v2 .v2-card {
  border: 1px solid var(--hair);
  background: var(--stock);
  cursor: pointer;
  display: grid;
  grid-template-rows: auto 92px auto;
}
.atlas-v2 .v2-card:hover { border-color: var(--ink); }
.atlas-v2 .v2-card:hover .v2-card-action { color: var(--ink); text-decoration: underline; }
.atlas-v2 .v2-card.is-active { border: 2px solid var(--agra); background: var(--agra-tint); cursor: default; }
.atlas-v2 .v2-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  padding: 7px 9px 2px;
}
.atlas-v2 .v2-card-label { font-size: 13px; font-weight: 600; }
.atlas-v2 .v2-card-value { font-size: 15px; font-weight: 700; }
.atlas-v2 .v2-card-map { height: 92px; pointer-events: none; }
.atlas-v2 .v2-card-action {
  font-size: 12px;
  font-weight: 600;
  color: var(--agra);
  border-top: 1px solid var(--hair-2);
  padding: 6px 9px;
}
.atlas-v2 .v2-card.is-active .v2-card-action { background: var(--agra); color: #fff; border-top-color: var(--agra); }

/* score */
.atlas-v2 .v2-score-row { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.atlas-v2 .v2-score-value { font-size: 44px; font-weight: 700; line-height: 1; }
.atlas-v2 .v2-score-status {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.atlas-v2 .v2-ramp-caption {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 3px;
}
.atlas-v2 .v2-ramp { position: relative; display: flex; height: 14px; border: 1px solid rgba(20, 32, 26, .38); }
.atlas-v2 .v2-ramp-seg { flex: 1 1 0; }
.atlas-v2 .v2-ramp-marker {
  position: absolute;
  top: -5px;
  width: 3px;
  height: 24px;
  background: var(--ink);
  transform: translateX(-1.5px);
  transition: left 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* legend */
.atlas-v2 .v2-legend-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 82px 56px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--hair-2);
  font-size: 14px;
}
.atlas-v2 .v2-legend-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--ink);
}
.atlas-v2 .v2-legend-head span:last-child { text-align: right; }
.atlas-v2 .v2-legend-code { font-weight: 600; color: var(--ink-3); }
.atlas-v2 .v2-legend-name { display: flex; align-items: center; min-width: 0; }
.atlas-v2 .v2-legend-range { color: var(--ink-3); font-size: 13px; }
.atlas-v2 .v2-legend-pct { text-align: right; font-weight: 600; }
.atlas-v2 .v2-legend-nodata { border-top: 1.5px solid var(--ink); border-bottom: 0; }
.atlas-v2 .v2-swatch {
  display: inline-block;
  flex: none;
  width: 17px;
  height: 12px;
  border: 1px solid rgba(20, 32, 26, .38);
  margin-right: 8px;
}
.atlas-v2 .v2-swatch-nodata {
  background: repeating-linear-gradient(45deg, #EDEDE3 0 3px, var(--hair) 3px 4px);
  border-style: dashed;
}

/* ---------- distribution: short, wide, gapless ---------- */
.atlas-v2 .v2-dist { display: grid; }
.atlas-v2 .v2-dist-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.atlas-v2 .v2-inline-h3 { margin: 0; font-size: 16px; }
.atlas-v2 .v2-bars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0;
  height: 64px;
  border-bottom: 1px solid var(--ink);
}
.atlas-v2 .v2-bar {
  flex: 1 1 0;
  min-width: 0;
  transform-origin: bottom;
  animation: v2-rise 720ms cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: height 520ms cubic-bezier(0.16, 1, 0.3, 1), background-color 300ms ease;
}
@keyframes v2-rise {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
.atlas-v2 .v2-dist-mean {
  position: absolute;
  top: -4px;
  bottom: 0;
  width: 0;
  border-left: 2px solid var(--ink);
  transition: left 520ms cubic-bezier(0.16, 1, 0.3, 1);
}
.atlas-v2 .v2-ticks { position: relative; height: 20px; }
.atlas-v2 .v2-tick {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--ink-3);
}
.atlas-v2 .v2-tick:first-child { transform: none; }
.atlas-v2 .v2-tick:last-child { transform: translateX(-100%); }

@media (prefers-reduced-motion: reduce) {
  .atlas-v2 .v2-bar { animation: none; transition: none; }
  .atlas-v2 .v2-dist-mean,
  .atlas-v2 .v2-ramp-marker { transition: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1500px) {
  .atlas-v2 .v2-stage { grid-template-columns: minmax(0, 1fr); }
  .atlas-v2 .v2-map-panel { justify-self: center; }
}
@media (max-width: 1180px) {
  .atlas-v2 .v2-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .atlas-v2 .v2-shell { grid-template-columns: minmax(0, 1fr); }
  .atlas-v2 .v2-sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--hair);
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    padding: 16px;
  }
  .atlas-v2 .v2-sidebar > .v2-h3 { grid-column: 1 / -1; }
  .atlas-v2 .v2-titleblock,
  .atlas-v2 .v2-body { padding-left: 16px; padding-right: 16px; }
  .atlas-v2 .v2-double-rule { margin: 0 16px; }
  .atlas-v2 .v2-h1 { font-size: 32px; }
  .atlas-v2 .v2-map-panel { height: auto; width: 100%; }
}
