/*
 * Map settings.
 *
 * One list on desktop (#layersPanel) and phones (#mobileAdjustMap). Each row
 * leads with a small key of what it draws, so the panel doubles as a legend.
 * On/off choices are switches; three-way choices sit in the recessed tray
 * with an ink carriage, the same material as the map's view toggles.
 */

html body .map-settings-group {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
}

html body .map-settings-group + .map-settings-group {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(17, 16, 14, 0.08);
}

html body .map-settings-group:not(:has(.map-settings-row:not([hidden]):not(.is-mode-hidden))) {
  display: none;
}

/* Sheet headings elsewhere carry a scale-bar ornament; these stay plain. */
html body :is(#layersPanel, #mobileAdjustMap) .map-settings-group > .map-settings-heading {
  display: block;
  border: 0;
  background: none;
}

html body :is(#layersPanel, #mobileAdjustMap) .map-settings-group > .map-settings-heading::before,
html body :is(#layersPanel, #mobileAdjustMap) .map-settings-group > .map-settings-heading::after {
  content: none;
  display: none;
}

html body .map-settings-heading {
  margin: 0 0 2px;
  padding: 0;
  color: rgba(22, 20, 15, 0.56);
  font-family: var(--font-rail-label);
  font-size: 0.64rem;
  font-weight: 820;
  line-height: 1.2;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

html body .map-settings-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  margin: 0 -6px;
  padding: 3px 6px 3px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--chrome-ink, #11100e);
  cursor: default;
}

html body label.map-settings-row {
  cursor: pointer;
}

html body label.map-settings-row:hover {
  background: rgba(17, 16, 14, 0.045);
}

html body .map-settings-row[hidden],
html body .map-settings-row.is-mode-hidden {
  display: none;
}

html body .map-settings-label {
  min-width: 0;
  color: var(--chrome-ink, #11100e);
  font-family: var(--font-rail-label);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Keys: drawn in the map's own inks. */
html body .map-settings-key {
  position: relative;
  display: block;
  width: 24px;
  height: 14px;
}

html body .map-settings-key-heat {
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(90deg, #1c2f7e, #6290dc 22%, #23875b 42%, #eab92c 62%, #e5631f 80%, #a92f45);
  box-shadow: inset 0 0 0 1px rgba(17, 16, 14, 0.08);
}

html body .map-settings-key-lines::before,
html body .map-settings-key-lines::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  height: 3px;
  border-radius: 2px;
}

html body .map-settings-key-lines::before {
  top: 3px;
  background: #c9352b;
}

html body .map-settings-key-lines::after {
  bottom: 3px;
  background: #2f7f89;
}

html body .map-settings-key-stops::before,
html body .map-settings-key-stops::after {
  content: "";
  position: absolute;
  top: 3px;
  width: 8px;
  height: 8px;
  box-sizing: border-box;
  border: 2px solid var(--chrome-ink, #11100e);
  border-radius: 50%;
  background: #fffdf7;
}

html body .map-settings-key-stops::before { left: 2px; }
html body .map-settings-key-stops::after { right: 2px; }

html body .map-settings-key-outlines {
  box-sizing: border-box;
  border: 1.5px dashed rgba(103, 82, 64, 0.82);
  border-radius: 4px;
}

html body .map-settings-key-detail {
  overflow: hidden;
  box-sizing: border-box;
  border: 1px solid rgba(17, 16, 14, 0.16);
  border-radius: 3px;
  background: rgb(243, 237, 222);
}

html body .map-settings-key-detail::before {
  content: "";
  position: absolute;
  inset: 0 0 0 55%;
  background: rgb(170, 199, 210);
}

html body .map-settings-key-detail::after {
  content: "";
  position: absolute;
  inset: 0 45% 0 0;
  background:
    linear-gradient(rgba(120, 112, 96, 0.5), rgba(120, 112, 96, 0.5)) 0 4px / 100% 1px no-repeat,
    linear-gradient(rgba(120, 112, 96, 0.5), rgba(120, 112, 96, 0.5)) 6px 0 / 1px 100% no-repeat;
}

html body .map-settings-key-names {
  display: grid;
  place-items: center;
  color: rgba(84, 76, 62, 0.86);
  font-family: var(--font-rail-label);
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

/* Switch: the panel's existing ink pill. */
html body .map-settings-row input.map-settings-switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 30px;
  height: 18px;
  margin: 0;
  border: 1px solid rgba(17, 16, 14, 0.18);
  border-radius: 999px;
  background: rgba(17, 16, 14, 0.14);
  box-shadow: none;
  cursor: pointer;
  transition: background var(--motion-duration-fast, 140ms) var(--motion-ease-standard, ease);
}

html body .map-settings-row input.map-settings-switch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fffdf7;
  box-shadow: 0 1px 2px rgba(17, 16, 14, 0.3);
  transform: translateY(-50%);
  transition: transform var(--motion-duration-fast, 140ms) var(--motion-ease-standard, ease);
}

html body .map-settings-row input.map-settings-switch:checked {
  border-color: var(--chrome-ink, #11100e);
  background: var(--chrome-ink, #11100e);
}

html body .map-settings-row input.map-settings-switch:checked::before {
  transform: translateY(-50%) translateX(12px);
}

html body .map-settings-row input.map-settings-switch:focus-visible {
  outline: 2px solid rgba(201, 53, 43, 0.55);
  outline-offset: 2px;
}

/* Three-way choices: recessed tray, ink carriage. */
html body .map-settings-segments {
  display: inline-grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--relief-segment-tray, rgba(232, 224, 208, 0.4));
  box-shadow: var(--relief-inset, inset 0 1px 3px rgba(55, 45, 31, 0.095), inset 0 0 0 1px rgba(55, 45, 31, 0.065));
}

html body .map-settings-segments > button {
  min-width: 44px;
  min-height: 26px;
  margin: 0;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: rgba(17, 16, 14, 0.66);
  font-family: var(--font-rail-label);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background-color var(--motion-duration-fast, 140ms) var(--motion-ease-standard, ease),
    color var(--motion-duration-fast, 140ms) var(--motion-ease-standard, ease);
}

html body .map-settings-segments > button:hover {
  color: var(--chrome-ink, #11100e);
  background: rgba(255, 253, 247, 0.7);
}

html body .map-settings-segments > button[aria-pressed="true"] {
  background: var(--chrome-ink, #11100e);
  color: #fffdf7;
  box-shadow: 0 1px 2px rgba(17, 16, 14, 0.18);
}

html body .map-settings-segments > button:focus-visible {
  outline: 2px solid rgba(201, 53, 43, 0.55);
  outline-offset: 1px;
}

/* Older panel rules set every paragraph in tiny clamped capitals. */
html body :is(#layersPanel, #mobileAdjustMap) .map-settings-note {
  display: block;
  max-width: none;
  margin: 0 0 4px 34px;
  overflow: visible;
  color: rgba(22, 20, 15, 0.6);
  font-family: var(--font-main, var(--font-rail-label));
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  -webkit-line-clamp: unset;
  line-clamp: none;
}

/* Phones: roomier rows and a full-width tray under long labels. */
@media (max-width: 760px), (max-width: 980px) and (orientation: portrait), (max-width: 980px) and (max-height: 599px) {
  html body #mobileAdjustMap .map-settings-group {
    grid-column: 1 / -1;
  }

  html body #mobileAdjustMap .map-settings-row {
    min-height: 44px;
    margin: 0;
    padding: 4px 4px 4px 6px;
  }

  html body #mobileAdjustMap .map-settings-label {
    font-size: 0.78rem;
  }

  /* Full 44px touch targets; the tray stays one row tall. */
  html body #mobileAdjustMap .map-settings-segments > button {
    min-width: 48px;
    min-height: 44px;
    font-size: 0.66rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .map-settings-row input.map-settings-switch,
  html body .map-settings-row input.map-settings-switch::before,
  html body .map-settings-segments > button {
    transition: none;
  }
}
