/* Crime Israel — Compare / Neighborhood (mobile-first). */

.compare-panel__title,
.compare-panel__subtitle,
.compare-panel__note,
.compare-stat__lbl,
.compare-chart__title,
.compare-chart__legend,
.compare-chart__label,
.compare__summary,
.compare-year__label {
  direction: rtl;
  unicode-bidi: embed;
}

/* ----- Hero: dual compare search ----- */
.hero__search-block--compare {
  width: 100%;
}

/* Mobile: stacked full-width fields; exit X sits inside top field (Figma) */
.compare-search-fields {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  direction: ltr;
  align-items: stretch;
}

.compare-search-fields .search-wrap {
  width: 100%;
  min-width: 0;
}

.compare-search-fields__addon {
  display: none;
}

.compare-exit-btn {
  position: absolute;
  /* Figma Plus Icon inside top Input Field: 24×24 at left 16 / top 18 */
  left: 16px;
  top: 18px;
  /* Above .search-wrap:focus-within z-index:45 (covers sibling exit at 40) */
  z-index: 60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  line-height: 0;
}

.compare-exit-btn img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.search-bar--compare {
  width: 100%;
}

/* Room for in-field exit on slot A (mobile) */
.search-bar--no-submit,
.search-bar--filled-a {
  padding: 8px 16px 8px 48px;
  justify-content: flex-end;
}

.search-bar--filled {
  justify-content: space-between;
}

.search-bar--filled-b {
  padding: 8px 16px 8px 8px;
}

.search-bar--filled .search-bar__field {
  cursor: text;
}

.search-bar__value {
  flex: 1;
  text-align: right;
  font-size: 14px;
  line-height: 20px;
  color: var(--ci-ink);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-bar__value strong {
  font-weight: var(--moses-bold);
}

.search-bar__value-city {
  font-weight: var(--moses-regular);
}

.search-bar--filled .search-bar__value {
  font-size: 16px;
  line-height: 22px;
}

.search-bar--filled .search-bar__value strong {
  font-weight: var(--moses-bold);
}

/* ----- Compare shell ----- */
.compare {
  padding: 4px 16px 24px;
  max-width: 100%;
  overflow-x: clip;
}

.compare__shell {
  background: #f3f7fe;
  border-radius: 16px;
  box-shadow: 0 3px 4px rgba(33, 33, 33, 0.25);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 40px;
  max-width: none;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.compare__head {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.compare-year {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  direction: rtl;
}

.compare-year__label {
  font-size: 14px;
  font-weight: var(--moses-bold);
  color: #3d4453;
}

.compare-year__select {
  position: relative;
  width: 226px;
}

.compare-year__select select {
  width: 100%;
  height: 32px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-color: #fff;
  padding: 0 12px 0 28px;
  font-family: inherit;
  font-size: 14px;
  color: #3d4453;
  direction: rtl;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #3d4453 50%),
    linear-gradient(135deg, #3d4453 50%, transparent 50%);
  background-position: 12px calc(50% - 2px), 17px calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.compare__panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

/* ----- Compare panel cards ----- */
.compare-panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  padding: 0 8px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.compare-panel__head {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px 16px;
  border-bottom: 3px solid #747d92;
  border-radius: 8px 8px 0 0;
}

.compare-panel--primary .compare-panel__head {
  border-bottom-color: var(--ci-blue);
}

.compare-panel__title {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 18px;
  font-weight: var(--moses-bold);
  line-height: 18px;
  color: #000;
  text-align: center;
}

.compare-panel__city {
  font-size: 14px;
  font-weight: var(--moses-rg-neg);
}

.compare-panel__subtitle {
  margin: 0;
  font-size: 12px;
  font-weight: var(--moses-rg-neg);
  line-height: 16px;
  color: #000;
  text-align: center;
}

.compare-panel__body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.compare-panel__safety {
  width: auto;
  max-width: 100%;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  box-sizing: border-box;
}

/* Figma Status: 5×38px cubes + 4px gaps = 206px, centered in the card. */
.compare-panel__safety .results-safety {
  width: auto;
  max-width: 100%;
  align-self: center;
  padding: 0;
}

.compare-panel__safety .results-safety__bar {
  width: auto;
  max-width: 100%;
}

.compare-panel__safety .results-safety__seg {
  flex: none;
  width: 38px;
  height: 20px;
}

.compare-panel__safety .results-safety__seg--active {
  height: 28px;
}

.compare-panel__safety .results-safety--disabled .results-safety__seg,
.compare-panel__safety .results-safety--disabled .results-safety__seg--active {
  height: 20px;
}

.compare-panel__stats {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compare-stat {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 9px 8px rgba(33, 33, 33, 0.1);
  min-height: 108px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.compare-stat__lbl {
  font-size: 12px;
  font-weight: var(--moses-medium);
  line-height: 15px;
  color: #000;
}

.compare-stat__val {
  font-size: 22px;
  font-weight: var(--moses-bold);
  line-height: 1.4;
  color: #000;
  letter-spacing: -0.11px;
}

.compare-panel__note {
  margin: 0;
  font-size: 12px;
  font-weight: var(--moses-rg-neg);
  color: #000;
  text-align: center;
}

.compare-panel__note--unranked {
  font-size: 13px;
  font-weight: var(--moses-rg-neg);
}

.compare-panel__note-star {
  color: #d70026;
  font-weight: var(--moses-bold);
}

/* ----- Dual-bar charts ----- */
.compare-chart {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 20px 8px 24px;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: visible;
  box-sizing: border-box;
}

.compare-chart__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.compare-chart__title {
  margin: 0;
  font-size: 16px;
  font-weight: var(--moses-bold);
  line-height: 20px;
  text-align: center;
  color: #000;
}

.compare-chart__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 12px;
}

.compare-chart__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: var(--moses-medium);
  color: var(--ci-ink);
  direction: rtl;
}

.compare-chart__swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.compare-chart__swatch--b {
  background: linear-gradient(180deg, #293da8 40%, #101842 95%);
}

.compare-chart__swatch--a {
  background: linear-gradient(0deg, #444a58 0%, #8f9ab2 89%);
}

.compare-chart__body {
  display: flex;
  flex-direction: row;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  scrollbar-width: thin;
  /* Keep Y-axis on the left despite page RTL (QA Excel 84–85) */
  direction: ltr;
}

.compare-chart > .hscroll-hints {
  margin-bottom: 8px;
}

.compare-chart__axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 220px;
  font-size: 11px;
  line-height: 1;
  color: #666;
  flex-shrink: 0;
  width: 28px;
  text-align: left;
  padding-bottom: 0;
  box-sizing: content-box;
  /* Reserve label band under the plot so ticks align with bars. */
  margin-bottom: 44px;
}

.compare-chart__plot {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  height: 264px;
  /* Horizontal only — overflow-y:visible becomes auto when paired with overflow-x:auto */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.compare-chart__track {
  position: relative;
  min-width: max-content;
  width: max-content;
  height: 264px;
}

.compare-chart__grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 220px;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    #ebebeb 0,
    #ebebeb 1px,
    transparent 1px,
    transparent 22px
  );
}

.compare-chart__cols {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-start;
  /* Wider columns + gaps on mobile (QA Excel 86) */
  gap: 14px;
  height: 264px;
  box-sizing: border-box;
  min-width: max-content;
  width: max-content;
  margin: 0;
}

.compare-chart__cols--cats {
  gap: 10px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  justify-content: space-between;
}

.compare-chart__col {
  flex: 0 0 72px;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
  min-width: 0;
}

.compare-chart__cols--cats .compare-chart__col {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

.compare-chart__pair {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: 220px;
  /* LTR so A/B bar order matches Figma (QA Excel 85–87) */
  direction: ltr;
  overflow: visible;
}

.compare-chart__bar {
  width: 28px;
  max-width: calc(50% - 2px);
  border-radius: 6px 6px 0 0;
  position: relative;
  display: flex;
  justify-content: center;
  min-height: 4px;
  flex-shrink: 0;
}

.compare-chart__bar--wide {
  width: 32px;
}

.compare-chart__bar--b {
  background: linear-gradient(180deg, #293da8 40%, #101842 95%);
}

.compare-chart__bar--a {
  background: linear-gradient(0deg, #444a58 0%, #8f9ab2 89%);
}

.compare-chart__bar span {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: var(--moses-bold);
  color: #fff;
  white-space: nowrap;
}

.compare-chart__bar--value-above span {
  top: -14px;
  color: var(--ci-ink);
}

.compare-chart__label {
  font-size: 10px;
  font-weight: var(--moses-rg-neg);
  line-height: 1.15;
  color: var(--ci-ink);
  text-align: center;
  max-width: 100%;
  width: 100%;
  min-height: 38px;
  flex: 0 0 auto;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.compare-chart__label--quarter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1px;
  -webkit-line-clamp: unset;
  overflow: visible;
  min-height: 32px;
}

.compare-chart__q,
.compare-chart__y {
  display: block;
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
}

.compare-chart__q {
  font-weight: var(--moses-rg-neg);
}

.compare-chart__y {
  font-weight: var(--moses-bold);
}

.compare-chart__label em {
  font-style: normal;
  font-weight: var(--moses-regular);
}

.compare-chart__label b {
  font-weight: var(--moses-bold);
}

.compare__summary {
  margin: 0;
  padding: 12px 8px;
  background: #fff;
  border-radius: 8px;
  font-size: 16px;
  font-weight: var(--moses-medium);
  line-height: 20px;
  color: var(--ci-ink);
  text-align: center;
  direction: rtl;
}

.compare__summary strong {
  color: var(--ci-blue);
  font-weight: var(--moses-bold);
}

/* Desktop stat order (rate, hoods / change, crimes) */
@media (min-width: 1280px) {
  .compare-stat--pop,
  .compare-stat--hoods { order: 2; }
  .compare-stat--crimes { order: 4; }
  .compare-stat--change { order: 3; }
  .compare-stat--rate { order: 1; }

  .compare-stat__lbl {
    font-size: 14px;
  }
}

/* City compare panels — no safety bar; tighter body */
.compare-panel--city .compare-panel__body--city {
  width: 100%;
}

.compare-panel--city .compare-panel__stats {
  margin-top: 0;
}

@media (min-width: 1280px) {
  .compare-panel--city .compare-panel__stats {
    min-height: 200px;
  }
}

@media (min-width: 768px) {
  .compare__shell {
    max-width: none;
  }
}

@media (min-width: 1280px) {
  .compare {
    padding: 24px;
  }

  .compare__shell {
    max-width: var(--ci-content-w);
    padding: 24px;
    gap: 32px;
  }

  .compare__panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    direction: rtl;
  }

  .compare-panel {
    padding: 0 16px 24px;
  }

  .compare-panel__stats {
    gap: 16px;
    min-height: 247px;
  }

  .compare-stat {
    min-height: 0;
    height: 100%;
    padding: 10px;
  }

  .compare-chart {
    padding: 32px 40px;
    max-width: 100%;
    width: 100%;
    gap: 24px;
  }

  /* Keep stack safety visible inside compare (results page hides stack @1280). */
  .compare-panel__safety .results-safety--stack {
    display: flex;
  }

  .compare-chart__title {
    font-size: 17px;
  }

  .compare-chart__body {
    gap: 12px;
    overflow: visible;
  }

  .compare-chart__axis {
    height: 263px;
    margin-bottom: 36px;
    font-size: 12px;
    width: 32px;
  }

  .compare-chart__plot {
    height: 299px;
    overflow-x: visible;
  }

  .compare-chart > .hscroll-hints {
    display: none !important;
  }

  /* Stretch plot track to full shell width (was max-content → left-hugging chart). */
  .compare-chart__track {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .compare-chart__grid {
    height: 263px;
    background: repeating-linear-gradient(
      to bottom,
      #ebebeb 0,
      #ebebeb 1px,
      transparent 1px,
      transparent 26.3px
    );
  }

  .compare-chart__cols {
    height: 299px;
    gap: 12px;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .compare-chart__col {
    flex: 1 1 0;
    width: auto;
  }

  .compare-chart__pair {
    max-height: 263px;
    gap: 2px;
  }

  .compare-chart__bar {
    width: 26px;
    max-width: none;
  }

  .compare-chart__bar--wide {
    width: 45px;
  }

  .compare-chart__bar span {
    top: 8px;
    font-size: 12px;
  }

  .compare-chart__bar--value-above span {
    top: -18px;
  }

  .compare-chart__label {
    font-size: 12px;
    line-height: 1.2;
    min-height: 30px;
    -webkit-line-clamp: 2;
  }

  .compare-chart__q,
  .compare-chart__y {
    font-size: 12px;
  }

  .compare__summary {
    font-size: 18px;
    line-height: 20px;
    padding: 12px 24px;
  }

  .results-share {
    flex-direction: row;
    justify-content: center;
    padding: 10px 120px;
    gap: 20px;
    width: 100%;
  }

  .results-share__text {
    order: -1;
  }
}

@media (min-width: 1280px) {
  .compare-search-fields {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    direction: ltr;
  }

  .compare-exit-btn {
    position: static;
    left: auto;
    top: auto;
    z-index: auto;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    order: 1;
  }

  .compare-exit-btn img {
    width: 32px;
    height: 32px;
  }

  .compare-search-fields .search-wrap[data-compare-slot="b"] {
    order: 2;
  }

  .compare-search-fields .search-wrap[data-compare-slot="a"] {
    order: 3;
  }

  .compare-search-fields .search-wrap {
    /* Wider than 306 so placeholder "…שנייה" fits with submit chrome (Figma pair ~649) */
    width: 324px;
    flex: 0 0 324px;
  }

  .search-bar--no-submit,
  .search-bar--filled-a {
    padding: 8px 16px;
  }

  .search-bar--compare .search-bar__input,
  .search-bar--compare .search-bar__input::placeholder {
    font-size: 16px;
    line-height: 22px;
  }

  .search-bar--filled .search-bar__value {
    font-size: 16px;
    line-height: 22px;
  }
}
