/* =============================================================
   detail.css
   Detail card for one hexagon, floating at the top right of the
   map. Opened by clicking a hex or a row in "Where to act first".
   ============================================================= */

.detail-card {
  top: 8px;
  right: 9px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 280px;
  max-height: calc(100% - 200px); /* leave room for the tools below */
  overflow-y: auto;
  padding: var(--card-padding) 12px 12px;
  border-radius: var(--radius-tile);
  box-shadow: 0 4px 12px rgba(40, 42, 46, 0.12);
}

.detail-card[hidden] {
  display: none;
}

.detail-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.detail-card__title {
  font-size: 14px;
  line-height: 20px;
  font-weight: var(--weight-semibold);
  color: var(--display-02);
}

.detail-card__hex {
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  color: var(--grey-700);
  word-break: break-all;
}

.detail-card__close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--grey-50);
  font-size: 16px;
  line-height: 1;
  color: var(--grey-800);
}

.detail-card__close:hover {
  background: var(--grey-100);
}

/* Big score + priority label. */
.detail-card__score {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: var(--radius-row);
  /* --score-bg: the hex's colour on the map, set in ui/detail.js */
  background: var(--score-bg, var(--grey-50));
}

.detail-card__number {
  font-size: 24px;
  line-height: 30px;
  font-weight: var(--weight-semibold);
  color: var(--grey-900);
}

.detail-card__label {
  font-weight: var(--weight-medium);
  color: var(--grey-900);
}

.detail-card__note {
  font-size: var(--body-sm-size);
  line-height: var(--body-sm-line);
  color: var(--grey-700);
}

/* Small 0–100 scale in the map's 5 colours, with a marker at this
   area's score. A white edge keeps it visible on any background. */
.score-scale {
  position: relative;
  display: block;
  margin: 6px 0 4px;
}

.score-scale__bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.score-scale__bar > span {
  flex: 1;
}

.score-scale__marker {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--grey-900);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
}

/* On the score colours the light grey note is too faint: use the
   main text colour, slightly softened. */
.detail-card__score .detail-card__note,
.detail-card__score .detail-card__reports {
  color: rgba(31, 31, 31, 0.78);
}

.detail-card__score .detail-card__reports {
  border-top-color: rgba(31, 31, 31, 0.15);
}

/* Dark score colours (60–100): white text. */
.detail-card__score--dark .detail-card__number,
.detail-card__score--dark .detail-card__label {
  color: #ffffff;
}

.detail-card__score--dark .detail-card__note,
.detail-card__score--dark .detail-card__reports {
  color: rgba(255, 255, 255, 0.85);
}

.detail-card__score--dark .detail-card__reports {
  border-top-color: rgba(255, 255, 255, 0.3);
}

/* Residents' heat reports: a small line under the note, set apart
   by a thin rule because it is not part of the score. */
.detail-card__reports {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--grey-100);
  font-size: var(--body-sm-size);
  line-height: var(--body-sm-line);
  color: var(--grey-700);
}

.detail-card__reports[hidden] {
  display: none;
}

/* "What made up the score" */
.detail-card__factors {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.factor-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.factor {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.factor__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-weight: var(--weight-medium);
  color: var(--display-body);
}

.factor__weight {
  font-size: var(--caption-3-size);
  font-weight: var(--weight-regular);
  color: var(--grey-600);
}

.factor__bar {
  width: 100%;
}

.factor__raw {
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  color: var(--grey-700);
}

/* Extra grey line, e.g. railway / main road / water share. */
.factor__raw--note {
  color: var(--grey-600);
}

/* Small screens: card spans the map width. */
@media (max-width: 768px) {
  .detail-card {
    left: 9px;
    width: auto;
    top: 50px; /* below the search bar */
  }
}

/* Data source note at the bottom of the card. */
.detail-card__source {
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  color: var(--grey-700);
}

/* "More about the data": the sources line, closed by default. */
.detail-card__more summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  list-style: none;
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  font-weight: var(--weight-medium);
  color: var(--green-600);
}

.detail-card__more summary::-webkit-details-marker {
  display: none;
}

/* Small arrow that turns when open. */
.detail-card__more summary::after {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms;
}

.detail-card__more[open] summary::after {
  transform: rotate(225deg) translateY(-1px);
}

.detail-card__more .detail-card__source {
  margin-top: 4px;
}
