/* The Atlas of Mexican federal law (issue #245). The site's own colours
   (website/style.scss): ink #1f1e1b, muted #52514e / #898781, rules #e1e0d9,
   link #1c5cab, panels #f9f8f4. Controls use system-ui; prose keeps the
   site's serif. */

.atlas {
  --atlas-ink: #1f1e1b;
  --atlas-muted: #52514e;
  --atlas-faint: #898781;
  --atlas-rule: #e1e0d9;
  --atlas-link: #1c5cab;
  --atlas-panel: #f9f8f4;
  --atlas-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--atlas-ink);
  font-family: var(--atlas-sans);
  font-size: 15px;
  line-height: 1.45;
  margin: 1.2rem 0 2.4rem;
  min-height: 70vh;
}

.atlas [hidden] {
  display: none !important;
}

.atlas p {
  text-align: left;
  hyphens: none;
}

.atlas button {
  font: inherit;
  color: inherit;
}

/* -- toolbar ---------------------------------------------------------------- */

.atlas-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem 2rem;
  margin-bottom: 0.9rem;
}

.atlas-search {
  position: relative;
  flex: 1 1 360px;
  max-width: 620px;
}

.atlas-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.8rem;
  border: 1px solid #c9c7be;
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 16px;
  color: var(--atlas-ink);
}

.atlas-search-input:focus {
  outline: 2px solid var(--atlas-link);
  outline-offset: 1px;
  border-color: var(--atlas-link);
}

.atlas-suggestions {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--atlas-rule);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(31, 30, 27, 0.12);
  max-height: 22rem;
  overflow-y: auto;
}

.atlas-suggestion {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

.atlas-suggestion[aria-selected="true"],
.atlas-suggestion:hover {
  background: var(--atlas-panel);
}

.atlas-suggestion-name {
  flex: 1 1 auto;
  min-width: 0;
}

.atlas-suggestion-collection {
  flex: 0 0 auto;
  font-size: 0.8em;
  color: var(--atlas-faint);
}

.atlas-no-match {
  padding: 0.4rem 0.8rem;
  color: var(--atlas-muted);
}

.atlas-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.62em;
  height: 0.62em;
  border-radius: 50%;
}

/* The controls sit together on the toolbar's right: the neighbourhood size and,
   when the mount lists models, the embedding model, side by side while they
   fit and stacked when they do not. */
.atlas-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.8rem 2rem;
  min-width: 0;
}

.atlas-neighbourhood {
  flex: 0 1 360px;
  min-width: 0;
}

.atlas-model {
  flex: 0 1 220px;
  min-width: 0;
}

.atlas-model-status:not([hidden]) {
  color: var(--atlas-ink);
  font-weight: 600;
}

.atlas-control-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--atlas-muted);
  margin-bottom: 0.3rem;
}

.atlas-segmented {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.atlas-end {
  font-size: 0.8em;
  font-style: italic;
  color: var(--atlas-faint);
}

.atlas-segment {
  min-width: 2.7rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid #c9c7be;
  background: #fff;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.atlas-segment + .atlas-segment {
  margin-left: -0.4rem;
  border-left: none;
}

.atlas-end + .atlas-segment {
  border-radius: 999px 0 0 999px;
}

.atlas-segment:has(+ .atlas-end) {
  border-radius: 0 999px 999px 0;
}

/* A control without end labels rounds its own first and last segment. */
.atlas-segmented-plain .atlas-segment:first-child {
  border-radius: 999px 0 0 999px;
}

.atlas-segmented-plain .atlas-segment:last-child {
  border-radius: 0 999px 999px 0;
}

.atlas-segment[aria-checked="true"] {
  background: var(--atlas-ink);
  border-color: var(--atlas-ink);
  color: #fff;
}

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

.atlas-caption {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--atlas-muted);
}

/* -- map and panel ---------------------------------------------------------- */

.atlas-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1.2rem;
  align-items: start;
}

/* Quarto places `aside`, `div.aside` and `.column-margin` in the page margin
   with `grid-column: body-end/page-end`; no child of this grid may inherit that. */
.atlas-main > * {
  grid-column: auto;
}

.atlas-map-column {
  min-width: 0;
}

.atlas-map-wrap {
  position: relative;
  border: 1px solid var(--atlas-rule);
  background: #fff;
  overflow: hidden;
}

.atlas-map {
  display: block;
  width: 100%;
  cursor: grab;
  touch-action: none;
}

.atlas-map:active {
  cursor: grabbing;
}

.atlas-background {
  fill: #fff;
}

.atlas-point {
  stroke: #fff;
  stroke-width: 0.6;
  cursor: pointer;
  transition: opacity 0.2s;
}

.atlas-point.atlas-hover {
  stroke: var(--atlas-ink);
  stroke-width: 1.5;
  filter: brightness(1.12);
}

.atlas-link {
  stroke: var(--atlas-ink);
  stroke-width: 1.3;
  stroke-opacity: 0.75;
  pointer-events: none;
}

.atlas-ring {
  fill: none;
  stroke: var(--atlas-ink);
  stroke-width: 3;
  pointer-events: none;
}

.atlas-badge circle {
  fill: #fff;
  stroke: var(--atlas-ink);
  stroke-width: 1.2;
}

.atlas-badge text {
  font-size: 10.5px;
  font-weight: 700;
  text-anchor: middle;
  fill: var(--atlas-ink);
}

.atlas-badge,
.atlas-name {
  pointer-events: none;
}

.atlas-name {
  font-size: 13px;
  font-weight: 600;
  fill: var(--atlas-ink);
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.atlas-label {
  position: absolute;
  z-index: 10;
  max-width: 280px;
  padding: 0.25rem 0.5rem;
  background: rgba(31, 30, 27, 0.92);
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.3;
  border-radius: 4px;
  pointer-events: none;
}

.atlas-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1.4rem;
  margin-top: 0.6rem;
}

.atlas-collections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.atlas-collection {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--atlas-rule);
  border-radius: 999px;
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}

.atlas-collection[aria-pressed="true"] {
  border-color: var(--atlas-ink);
  box-shadow: inset 0 0 0 1px var(--atlas-ink);
}

.atlas-collection.atlas-muted {
  color: var(--atlas-faint);
}

.atlas-collection.atlas-muted .atlas-dot {
  opacity: 0.3;
}

.atlas-sizes {
  max-width: 100%;
  font-size: 12px;
}

.atlas-sizes text {
  fill: var(--atlas-muted);
}

.atlas-size {
  fill: none;
  stroke: var(--atlas-muted);
  stroke-width: 1;
}

.atlas-size-caption {
  font-style: italic;
}

.atlas-panel {
  box-sizing: border-box;
  border: 1px solid var(--atlas-rule);
  border-top: 3px solid var(--atlas-link);
  background: var(--atlas-panel);
  padding: 1rem 1.1rem 1.2rem;
  max-height: 80vh;
  overflow-y: auto;
}

.atlas-empty {
  margin: 0;
  color: var(--atlas-muted);
  font-family: "Palatino Linotype", Palatino, "URW Palladio L", Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.5;
}

.atlas-badge-label {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 3px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Quarto's theme gives an h2 a bottom rule and padding, and an h3 its own
   serif font; the panel's headings are designed without either. */
.atlas-panel h2,
.atlas-panel h3 {
  border-bottom: 0;
  padding-bottom: 0;
}

.atlas-panel-title {
  margin: 0.45rem 0 0.35rem;
  font-family: "Palatino Linotype", Palatino, "URW Palladio L", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.atlas-facts {
  margin: 0 0 0.9rem;
  color: var(--atlas-muted);
}

.atlas-facts strong {
  color: var(--atlas-ink);
  font-weight: 600;
}

.atlas-panel-heading {
  margin: 1rem 0 0.1rem;
  font-family: var(--atlas-sans);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--atlas-link);
}

.atlas-note {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--atlas-muted);
}

.atlas-targets {
  margin: 0;
  padding-left: 1.4rem;
  overflow: visible;
}

.atlas-target {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  grid-template-areas:
    "weight bar"
    "name name";
  gap: 0.1rem 0.5rem;
  align-items: center;
  margin: 0 0 0.55rem;
  font-variant-numeric: tabular-nums;
}

.atlas-target::marker {
  color: var(--atlas-faint);
  font-weight: 600;
}

.atlas-weight {
  grid-area: weight;
  font-weight: 600;
}

.atlas-bar {
  grid-area: bar;
  display: block;
  height: 6px;
  background: var(--atlas-rule);
  border-radius: 3px;
  overflow: hidden;
}

.atlas-bar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
}

.atlas-target-label {
  grid-area: name;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.atlas-target-name {
  padding: 0;
  border: none;
  background: none;
  text-align: left;
  color: var(--atlas-link) !important;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.atlas-target-name:hover,
.atlas-target-name:focus-visible {
  text-decoration: underline;
}

/* A weight under "Closest instruments" opens its explanation (issue #250):
   a button that looks exactly like the number it replaced, so the panel does
   not move. */
.atlas-why {
  justify-self: start;
  padding: 0;
  border: none;
  background: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: left;
  color: var(--atlas-ink) !important;
  cursor: pointer;
  text-decoration: underline dotted var(--atlas-faint);
  text-underline-offset: 3px;
}

.atlas-why:hover,
.atlas-why:focus-visible {
  text-decoration: underline solid var(--atlas-ink);
}

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

/* -- the explanation dialog ------------------------------------------------ */

.atlas-explain {
  box-sizing: border-box;
  width: min(1100px, calc(100vw - 2rem));
  max-width: 1100px;
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--atlas-rule);
  border-top: 3px solid var(--atlas-link);
  border-radius: 6px;
  background: #fff;
  color: var(--atlas-ink);
  overflow: auto;
  overscroll-behavior: contain;
}

.atlas-explain::backdrop {
  background: rgba(31, 30, 27, 0.45);
}

.atlas-explain-close {
  position: sticky;
  top: 0.6rem;
  float: right;
  z-index: 1;
  width: 2.1rem;
  height: 2.1rem;
  margin: 0.6rem 0.6rem 0 0;
  padding: 0;
  border: 1px solid var(--atlas-rule);
  border-radius: 50%;
  background: #fff;
  font-size: 1.35rem !important;
  line-height: 1;
  cursor: pointer;
}

.atlas-explain-close:hover,
.atlas-explain-close:focus-visible {
  border-color: var(--atlas-ink);
}

.atlas-explain-body {
  padding: 1.1rem 1.4rem 1.4rem;
}

/* Quarto's theme gives an h2 a bottom rule and padding: not here. */
.atlas-explain h2 {
  border-bottom: 0;
  padding-bottom: 0;
}

.atlas-explain-title {
  margin: 0 2.6rem 0.6rem 0;
  font-family: "Palatino Linotype", Palatino, "URW Palladio L", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.atlas-explain-title em,
.atlas-explain-lead em {
  font-style: italic;
}

.atlas-explain-lead {
  margin: 0 0 0.8rem;
  color: var(--atlas-muted);
}

.atlas-explain-status,
.atlas-explain-count {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--atlas-muted);
}

.atlas-explain-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.9rem;
}

.atlas-explain-table th,
.atlas-explain-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--atlas-rule);
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

.atlas-explain-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--atlas-muted);
  border-bottom-color: var(--atlas-ink);
}

.atlas-explain-table .atlas-explain-n {
  width: 2.4rem;
}

.atlas-explain-table .atlas-explain-similarity {
  width: 6.4rem;
}

.atlas-explain-table .atlas-explain-weight {
  width: 8.5rem;
}

.atlas-explain-table td.atlas-explain-n,
.atlas-explain-table td.atlas-explain-similarity,
.atlas-explain-table td.atlas-explain-weight,
.atlas-explain-table th.atlas-explain-n,
.atlas-explain-table th.atlas-explain-similarity,
.atlas-explain-table th.atlas-explain-weight {
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
}

.atlas-explain-n,
.atlas-explain-similarity,
.atlas-explain-fraction {
  white-space: nowrap;
}

.atlas-explain-fraction {
  display: block;
  font-weight: 600;
}

.atlas-explain-label {
  display: block;
  font-weight: 600;
}

.atlas-explain-path,
.atlas-explain-share,
.atlas-explain-also {
  display: block;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--atlas-faint);
}

.atlas-explain-also {
  margin-top: 0.3rem;
  font-style: italic;
}

.atlas-explain-text {
  margin: 0.35rem 0 0;
  font-family: "Palatino Linotype", Palatino, "URW Palladio L", Georgia, serif;
  font-size: 0.95rem;
  line-height: 1.45;
}

.atlas-explain-more {
  margin-top: 0.9rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid #c9c7be;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.atlas-explain-more:hover,
.atlas-explain-more:focus-visible {
  border-color: var(--atlas-ink);
}

/* On a phone the dialog is the screen, and each row stacks its cells, each
   named by its column. */
@media (max-width: 640px) {
  .atlas-explain {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .atlas-explain-body {
    padding: 0.9rem 1rem 1.2rem;
  }

  .atlas-explain-table,
  .atlas-explain-table tbody,
  .atlas-explain-table tr,
  .atlas-explain-table td {
    display: block;
    width: auto !important;
  }

  .atlas-explain-table thead {
    display: none;
  }

  .atlas-explain-table tr {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--atlas-rule);
  }

  .atlas-explain-table td,
  .atlas-explain-table td.atlas-explain-n,
  .atlas-explain-table td.atlas-explain-similarity,
  .atlas-explain-table td.atlas-explain-weight {
    padding: 0.25rem 0;
    border: 0;
    text-align: left;
  }

  .atlas-explain-table td::before {
    content: attr(data-column);
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--atlas-muted);
  }
}

.atlas-error {
  padding: 1rem;
  border: 1px solid var(--atlas-rule);
  background: var(--atlas-panel);
}

/* The two columns stack on narrow screens: the map first, the panel under
   it. */
@media (max-width: 900px) {
  .atlas-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .atlas-panel {
    max-height: none;
  }

  .atlas-controls {
    flex: 1 1 100%;
  }

  .atlas-neighbourhood {
    flex: 1 1 260px;
  }

  .atlas-model {
    flex: 1 1 160px;
  }
}

/* -- the explanatory section below the application ------------------------ */

.atlas-prose {
  margin: 0 0 3rem;
}

.atlas-prose .atlas-lead p {
  font-size: 1.12em;
  line-height: 1.55;
  text-align: left;
  hyphens: none;
}

.atlas-prose .atlas-data {
  border: 1px solid #e1e0d9;
  border-left: 3px solid #1c5cab;
  background: #f9f8f4;
  padding: 0.9rem 1.2rem;
  margin: 1.6rem 0;
  font-size: 0.9em;
}

.atlas-prose .atlas-data p,
.atlas-prose .atlas-data ul {
  text-align: left;
  hyphens: none;
}

.atlas-prose .atlas-data ul {
  margin-bottom: 0.4rem;
}

/* The evaluation tables are wider than a phone: they scroll inside the page
   instead of widening it (issue #275). */
.atlas-prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
