/* Quality of Life — city & country page polish.
   Everything is scoped under .qol-page so it cannot leak onto the many other
   indicator pages that share the same helper markup (table_indices, gauge,
   the green_small/red_small/... value labels, .reportees, etc.). */

.qol-page {
  --numbeo-blue: #1B3B6F;
  --numbeo-blue-light: #2E5090;
  --numbeo-blue-dark: #0F2444;
  --qol-text: #2a3340;
  --qol-muted: #6c7689;
  --qol-divider: #e7ecf3;
  --qol-row-hover: #f5f8fc;
  --qol-total-bg: #eef2f8;
  margin: 10px 0 6px;
  max-width: 640px;
}

/* ---------- Hero: gauge + headline score ---------- */
.qol-hero {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 30px;
  max-width: 820px;
  margin: 6px 0 2px;
  padding: 20px 28px;
  background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
  border: 1px solid var(--qol-divider);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 36, 68, 0.04),
              0 14px 34px -16px rgba(15, 36, 68, 0.20);
  overflow: hidden;
}

.qol-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--numbeo-blue) 0%, var(--numbeo-blue-light) 100%);
}

/* Put the gauge first (left), reset any shared float/margin */
.qol-hero #gauge_div {
  order: -1;
  float: none !important;
  margin: 0 !important;
  flex: none;
}

/* The shared index table becomes a clean stacked stat */
.qol-hero aside {
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 1 1 220px;
}

.qol-hero .table_indices,
.qol-hero .table_indices tbody,
.qol-hero .table_indices tr {
  display: block;
  width: 100%;
  border: 0;
  background: none;
}

/* Hide the "Index | (i)" header row */
.qol-hero .table_indices tr:first-child {
  display: none;
}

.qol-hero .table_indices td {
  display: block;
  border: 0 !important;
  padding: 0 !important;
  text-align: left !important;
  background: none !important;
}

.qol-hero .table_indices td:first-child {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--qol-muted);
  margin-bottom: 2px;
}

.qol-hero .table_indices td:last-child {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.05;
  color: var(--numbeo-blue);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ---------- Breakdown scorecard ---------- */
.qol-breakdown {
  width: 100%;
  max-width: 820px;
  border-collapse: collapse;
  margin: 18px 0 16px;
  background: #ffffff;
  border: 1px solid var(--qol-divider);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 36, 68, 0.04),
              0 12px 30px -16px rgba(15, 36, 68, 0.18);
}

.qol-breakdown td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--qol-divider);
  vertical-align: middle;
}

.qol-breakdown tr:hover td {
  background: var(--qol-row-hover);
}

/* Indicator name */
.qol-breakdown td:first-child {
  font-size: 15px;
  font-weight: 600;
  color: var(--qol-text);
}

.qol-breakdown td:first-child a.discreet_link {
  color: var(--qol-text);
  text-decoration: none;
}

.qol-breakdown td:first-child a.discreet_link:hover {
  color: var(--numbeo-blue);
  text-decoration: underline;
}

/* Value */
.qol-breakdown td:nth-child(2) {
  text-align: right !important;
  width: 1%;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
  color: var(--numbeo-blue-dark);
  font-variant-numeric: tabular-nums;
}

/* Category pill cell */
.qol-breakdown td:nth-child(3) {
  text-align: right !important;
  width: 1%;
  white-space: nowrap;
  font-weight: 400 !important;
}

/* Hide the old hairline separator row; the total row carries its own rule */
.qol-breakdown tr.qol-sep {
  display: none;
}

/* Emphasized total row */
.qol-breakdown tr.qol-total td {
  border-top: 2px solid var(--numbeo-blue);
  border-bottom: none;
  padding-top: 16px;
  padding-bottom: 16px;
  background: var(--qol-total-bg);
}

.qol-breakdown tr.qol-total:hover td {
  background: var(--qol-total-bg);
}

.qol-breakdown tr.qol-total td:first-child {
  font-size: 16px;
  font-weight: 800;
  color: var(--numbeo-blue-dark);
}

.qol-breakdown tr.qol-total td:nth-child(2) {
  font-size: 20px;
}

.qol-breakdown tr.qol-total td:first-child a.discreet_link {
  color: var(--numbeo-blue);
}

/* ---------- Category labels rendered as pills ---------- */
.qol-page .green_small,
.qol-page .green_light_small,
.qol-page .yellow_neutral_small,
.qol-page .red_light_small,
.qol-page .red_small {
  display: inline-block;
  min-width: 64px;
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

.qol-page .green_small        { background: #e3f6ea; color: #1c7a42; border-color: #c4e9d0; }
.qol-page .green_light_small  { background: #eef8f1; color: #2f8a4e; border-color: #d6ecdb; }
.qol-page .yellow_neutral_small { background: #fdf3da; color: #946800; border-color: #f3e2ad; }
.qol-page .red_light_small    { background: #fdeedd; color: #c15a25; border-color: #f6dcc2; }
.qol-page .red_small          { background: #fce9e7; color: #c0392b; border-color: #f5cec9; }

/* ---------- Data freshness meta ---------- */
.qol-page > p {
  margin: 3px 0;
}

.qol-page .reportees {
  font-size: 12.5px;
  color: var(--qol-muted);
}

/* ---------- Orchestrated entrance ---------- */
@media (prefers-reduced-motion: no-preference) {
  .qol-hero,
  .qol-breakdown {
    opacity: 0;
    transform: translateY(10px);
    animation: qolRise 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
  .qol-hero { animation-delay: 0.04s; }
  .qol-breakdown { animation-delay: 0.12s; }
}

@keyframes qolRise {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .qol-hero {
    padding: 18px 18px;
    gap: 8px 18px;
    justify-content: center;
    text-align: center;
  }
  .qol-hero aside { flex-basis: 100%; }
  .qol-hero .table_indices td { text-align: center !important; }
  .qol-breakdown td { padding: 12px 12px; }
  .qol-breakdown td:first-child { font-size: 14px; }
  .qol-page .green_small,
  .qol-page .green_light_small,
  .qol-page .yellow_neutral_small,
  .qol-page .red_light_small,
  .qol-page .red_small {
    min-width: 0;
    padding: 3px 9px;
    font-size: 11.5px;
  }
}

/* ============================================================
   Comparison pages (compare_cities / compare_countries)
   Scoped under .qol-compare so nothing leaks onto other pages.
   ============================================================ */
.qol-compare {
  --numbeo-blue: #1B3B6F;
  --numbeo-blue-light: #2E5090;
  --numbeo-blue-dark: #0F2444;
  --qol-text: #2a3340;
  --qol-muted: #6c7689;
  --qol-divider: #e7ecf3;
  --qol-row-hover: #f5f8fc;
  --qol-total-bg: #eef2f8;
  max-width: 780px;
  margin: 10px 0 8px;
}

/* ---------- Headline scoreboard (index header table_indices) ---------- */
.qol-compare .table_indices {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
  background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
  border: 1px solid var(--qol-divider);
  border-top: 4px solid var(--numbeo-blue);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 36, 68, 0.04),
              0 14px 34px -16px rgba(15, 36, 68, 0.20);
}

/* hide the row-label column ("Index" / "Quality of Life Index:") */
.qol-compare .table_indices th:first-child,
.qol-compare .table_indices td:first-child {
  display: none;
}

.qol-compare .table_indices th {
  padding: 16px 18px 4px;
  border: 0;
  text-align: center !important;
  font-size: 14px;
  font-weight: 700;
  color: var(--qol-muted);
}

.qol-compare .table_indices td {
  padding: 0 18px 18px !important;
  border: 0 !important;
  text-align: center !important;
  font-size: 40px;
  font-weight: 800;
  line-height: 1.05;
  color: var(--numbeo-blue);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* center divider between the two cities */
.qol-compare .table_indices th:nth-child(2),
.qol-compare .table_indices td:nth-child(2) {
  border-right: 1px solid var(--qol-divider);
}

/* ---------- Detailed comparison scorecard ---------- */
.qol-compare .visualizeComparison {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 14px;
  background: #ffffff;
  border: 1px solid var(--qol-divider);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 36, 68, 0.04),
              0 12px 30px -16px rgba(15, 36, 68, 0.18);
}

.qol-compare .visualizeComparison th {
  padding: 12px 16px;
  text-align: center !important;
  font-size: 14px;
  font-weight: 700;
  color: var(--numbeo-blue-dark);
  background: var(--qol-row-hover);
  border-bottom: 1px solid var(--qol-divider);
}

.qol-compare .visualizeComparison th:first-child {
  background: #ffffff;
}

.qol-compare .visualizeComparison td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--qol-divider);
  vertical-align: middle;
}

.qol-compare .visualizeComparison tr:hover td {
  background: var(--qol-row-hover);
}

/* indicator name */
.qol-compare .visualizeComparison td:first-child {
  text-align: left !important;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--qol-text);
}

/* value cells (city1 = 3rd, city2 = 5th) */
.qol-compare .visualizeComparison td:nth-child(3),
.qol-compare .visualizeComparison td:nth-child(5) {
  text-align: right !important;
  white-space: nowrap;
  width: 1%;
  font-size: 15px;
  font-weight: 700;
  color: var(--numbeo-blue-dark);
  font-variant-numeric: tabular-nums;
}

.qol-compare .visualizeComparison td:nth-child(3) a.discreet_link,
.qol-compare .visualizeComparison td:nth-child(5) a.discreet_link {
  color: var(--numbeo-blue-dark);
  text-decoration: none;
}

.qol-compare .visualizeComparison td:nth-child(3) a.discreet_link:hover,
.qol-compare .visualizeComparison td:nth-child(5) a.discreet_link:hover {
  color: var(--numbeo-blue);
  text-decoration: underline;
}

/* pill cells (city1 = 2nd, city2 = 4th) */
.qol-compare .visualizeComparison td:nth-child(2),
.qol-compare .visualizeComparison td:nth-child(4) {
  text-align: right !important;
  white-space: nowrap;
  width: 1%;
}

/* vertical divider before the city2 group */
.qol-compare .visualizeComparison th:nth-child(3),
.qol-compare .visualizeComparison td:nth-child(4) {
  border-left: 1px solid var(--qol-divider);
  padding-left: 18px;
}

/* hide the old hairline separator row */
.qol-compare .visualizeComparison tr.qol-cmp-sep {
  display: none;
}

/* emphasized total row */
.qol-compare .visualizeComparison tr.qol-cmp-total td {
  border-top: 2px solid var(--numbeo-blue);
  border-bottom: none;
  background: var(--qol-total-bg);
  padding-top: 15px;
  padding-bottom: 15px;
}

.qol-compare .visualizeComparison tr.qol-cmp-total:hover td {
  background: var(--qol-total-bg);
}

.qol-compare .visualizeComparison tr.qol-cmp-total td:first-child {
  font-size: 15px;
  font-weight: 800;
  color: var(--numbeo-blue-dark);
}

.qol-compare .visualizeComparison tr.qol-cmp-total td:nth-child(3),
.qol-compare .visualizeComparison tr.qol-cmp-total td:nth-child(5) {
  font-size: 17px;
}

/* freshness / contributor meta rows */
.qol-compare .visualizeComparison tr td.reportees {
  border-bottom: none;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--qol-muted);
}

.qol-compare .visualizeComparison tr:hover td.reportees {
  background: transparent;
}

/* category pills (reuse the single-page palette) */
.qol-compare .green_small,
.qol-compare .green_light_small,
.qol-compare .yellow_neutral_small,
.qol-compare .red_light_small,
.qol-compare .red_small {
  display: inline-block;
  min-width: 64px;
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

.qol-compare .green_small        { background: #e3f6ea; color: #1c7a42; border-color: #c4e9d0; }
.qol-compare .green_light_small  { background: #eef8f1; color: #2f8a4e; border-color: #d6ecdb; }
.qol-compare .yellow_neutral_small { background: #fdf3da; color: #946800; border-color: #f3e2ad; }
.qol-compare .red_light_small    { background: #fdeedd; color: #c15a25; border-color: #f6dcc2; }
.qol-compare .red_small          { background: #fce9e7; color: #c0392b; border-color: #f5cec9; }

/* orchestrated entrance */
@media (prefers-reduced-motion: no-preference) {
  .qol-compare .table_indices,
  .qol-compare .visualizeComparison {
    opacity: 0;
    transform: translateY(10px);
    animation: qolRise 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
  .qol-compare .table_indices { animation-delay: 0.04s; }
  .qol-compare .visualizeComparison { animation-delay: 0.12s; }
}

@media (max-width: 768px) {
  .qol-compare .table_indices th { font-size: 13px; padding-top: 14px; }
  .qol-compare .table_indices td { font-size: 30px; }
  .qol-compare .visualizeComparison td,
  .qol-compare .visualizeComparison th { padding: 10px 8px; }
  .qol-compare .visualizeComparison th:nth-child(3),
  .qol-compare .visualizeComparison td:nth-child(4) { padding-left: 8px; }
  .qol-compare .green_small,
  .qol-compare .green_light_small,
  .qol-compare .yellow_neutral_small,
  .qol-compare .red_light_small,
  .qol-compare .red_small {
    min-width: 0;
    padding: 3px 8px;
    font-size: 11px;
  }
}
