/* CityDataLab styles  -  adapted from London Property Analytics */

:root {
  --primary-color: #1a1a2e;
  --secondary-color: #3498db;
  --accent-color: #1abc9c;
  --city-color: #2e86c1;       /* overridden per-city by nav.js */
  --light-bg: #f8f9fa;
  --dark-bg: #1a1a2e;
  --text-color: #333;
  --light-text: #f8f9fa;
  --border-radius: 8px;
  --box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  --transition: all 0.3s ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Open Sans', sans-serif;
  line-height: 1.5;
  color: var(--text-color);
  background-color: #fff;
  font-size: 14px;
}

h1,h2,h3,h4,h5,h6 {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p  { margin-bottom: 0.6rem; }

a { color: var(--secondary-color); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-color); }

ul { list-style: none; }
.normal-list { list-style: disc; padding-left: 1.5rem; }
img { max-width: 100%; height: auto; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container       { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-wide  { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background-color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  gap: 1rem;
}

.logo { font-family: 'Montserrat',sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--primary-color); }
.logo span { color: var(--accent-color); }

nav ul { display: flex; flex-wrap: wrap; }
nav ul li { margin-left: 1rem; }
nav ul li a {
  color: var(--primary-color);
  font-weight: 600;
  padding: 0.5rem 0;
  position: relative;
}
nav ul li a::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 0; height: 2px;
  background-color: var(--city-color);
  transition: var(--transition);
}
nav ul li a:hover::after,
nav ul li a.active::after { width: 100%; }

/* City switcher dropdown */
#city-switcher { display: flex; align-items: center; margin-left: 0.75rem; }

/* Desktop: on city-specific pages, place the city dropdown immediately
   to the LEFT of the nav buttons by reordering it (order:1) and giving
   it margin-left:auto. The auto-margin absorbs the remaining row space
   before justify-content kicks in, so the dropdown and nav cluster on
   the right with no gap between them. Root pages (no switcher) fall
   back to the base rule's justify-content:space-between, which already
   pins the nav to the right. */
@media (min-width: 769px) {
  #city-switcher { order: 1; margin-left: auto; }
  nav { order: 2; }
}
#city-select {
  padding: 0.3rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.85rem;
  background: #fff;
  cursor: pointer;
  color: var(--primary-color);
}
#city-select:focus { outline: none; border-color: var(--accent-color); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 0.4rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  flex-direction: column;
  justify-content: space-around;
}
.mobile-menu-btn span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--primary-color);
  border-radius: 2px;
}

a.footer { color: #bbb; }
a.footer:hover { color: var(--light-text); }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: var(--light-text);
  padding: 1.5rem 0;
  text-align: center;
}
.hero h1 { color: var(--light-text); margin-bottom: 0.4rem; }
.hero p  { font-size: 0.95rem; max-width: 800px; margin: 0 auto; }

.hero.hero-compact { padding: 1.2rem 0 1rem; }
.hero.hero-compact h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.hero.hero-compact p  { font-size: 0.85rem; opacity: 0.92; margin-bottom: 0; }

/* ── Sections ───────────────────────────────────────────────────────────── */
section { padding: 2rem 0; }

section.sect-compact { padding: 0.85rem 0; }
section.sect-compact + section.sect-compact { padding-top: 0; }

.section-title { text-align: center; margin-bottom: 0.75rem; }
.section-title h2 { position: relative; display: inline-block; padding-bottom: 0.3rem; font-size: 1.25rem; }
.section-title h2::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 2px;
  background-color: var(--accent-color);
}

.sect-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 0.5rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sect-header h2 { font-size: 1.15rem; margin: 0; }
.sect-header p  { margin: 0; font-size: 0.82rem; color: #6b7280; max-width: 640px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  background-color: var(--accent-color);
  color: #fff;
  padding: 0.45rem 1.1rem;
  border-radius: 20px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn:hover { background-color: var(--secondary-color); color: #fff; }

/* ── Grid ────────────────────────────────────────────────────────────────── */
.row { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.col-md-4, .col-md-6, .col-md-8, .col-md-12 { margin-bottom: 0; padding: 0; }
.col-md-4  { flex: 0 0 calc(33.333% - 1rem); max-width: calc(33.333% - 1rem); }
.col-md-6  { flex: 0 0 calc(50% - 0.75rem);  max-width: calc(50% - 0.75rem); }
.col-md-8  { flex: 0 0 calc(66.667% - 0.5rem); max-width: calc(66.667% - 0.5rem); }
.col-md-12 { flex: 0 0 100%;    max-width: 100%; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.6rem; }

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panel {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
  padding: 0.6rem 0.75rem 0.4rem;
  margin-bottom: 0.6rem;
  border: 1px solid #edf0f2;
}
.panel-title    { font-family: 'Montserrat',sans-serif; font-size: 0.9rem; font-weight: 600; margin: 0 0 0.2rem; color: var(--primary-color); }
.panel-subtitle { font-size: 0.78rem; color: #6b7280; margin: 0 0 0.3rem; }
.panel-note     { font-size: 0.82rem; color: #4b5563; line-height: 1.55; margin: 0.2rem 0 0.55rem; }
.panel-note b   { color: var(--primary-color); }

/* ── KPI strip ───────────────────────────────────────────────────────────── */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.kpi       { background: #fff; border-radius: var(--border-radius); padding: 0.9rem 1rem; box-shadow: 0 2px 8px rgba(0,0,0,0.04); border: 1px solid #edf0f2; }
.kpi .kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; font-weight: 600; }
.kpi .kpi-value { font-family: 'Montserrat',sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--primary-color); margin-top: 0.1rem; }
.kpi .kpi-value.pos { color: #16a085; }
.kpi .kpi-value.neg { color: #c0392b; }

/* ── Plots ───────────────────────────────────────────────────────────────── */
.plot    { width: 100%; min-height: 220px; }
.plot-sm { min-height: 180px; }
.plot-md { min-height: 320px; }
.plot-lg { min-height: 440px; }

.plot.loading::before { content: 'Loading…'; display: block; text-align: center; color: #9ca3af; font-size: 0.85rem; padding: 2rem 0; }

/* ── Factor panels ────────────────────────────────────────────────────────── */
.factor-cards { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }

.factor-panel {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
  border: 1px solid #edf0f2;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.factor-panel:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); }

.factor-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  background: linear-gradient(90deg, #f8fafc, #fff);
  border-bottom: 1px solid #edf0f2;
  flex-wrap: wrap;
}
.factor-panel-title         { display: flex; align-items: baseline; gap: 0.6rem; }
.factor-panel-title .factor-name    { font-family: 'Montserrat',sans-serif; font-size: 1.1rem; font-weight: 700; color: var(--primary-color); }
.factor-panel-title .factor-feature { font-family: 'Menlo','Consolas',monospace; font-size: 0.75rem; color: #6b7280; background: #f3f4f6; padding: 0.1rem 0.5rem; border-radius: 4px; }

.factor-panel-stats          { display: flex; gap: 1rem; font-size: 0.82rem; color: #6b7280; }
.factor-panel-stats b        { color: var(--primary-color); font-weight: 600; }
.factor-panel-stats .pos     { color: #16a085; font-weight: 600; }
.factor-panel-stats .neg     { color: #c0392b; font-weight: 600; }

.factor-panel-body  { padding: 0.4rem 0.5rem 0.3rem; }

.factor-2x2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
/* When a factor has no transacted-distribution data, the Beta panel spans the
   second row so the grid stays balanced instead of leaving an empty cell. */
.factor-2x2--no-dist .mini-panel--beta { grid-column: 1 / -1; }

.factor-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.factor-nav-card {
  display: block;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-top: 4px solid var(--city-color, #2e86c1);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.factor-nav-card:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.factor-nav-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary-color);
  line-height: 1.25;
  min-height: 2.4em;
  display: flex;
  align-items: flex-start;
}
.factor-nav-return {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.5rem;
  letter-spacing: -0.02em;
}
.factor-nav-label {
  font-size: 0.7rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.1rem;
}
.factor-nav-return.pos { color: #16a34a; }
.factor-nav-return.neg { color: #dc2626; }

.mini-panel         { background: #fafbfc; border-radius: 6px; padding: 0.3rem 0.45rem 0.15rem; border: 1px solid #edf0f2; }
.mini-panel-title   { font-size: 0.78rem; font-weight: 600; color: var(--primary-color); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 0.2rem; }
.mini-panel-caption { font-size: 0.7rem; color: #8b95a1; margin: 0 0 0.2rem; }

/* ── Factor summary cards (home/trends) ──────────────────────────────────── */
.factor-card {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  transition: box-shadow 0.2s ease;
  height: 100%;
}
.factor-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.factor-card h3 { color: var(--secondary-color); margin-bottom: 0.4rem; }

/* ── City cards (homepage) ───────────────────────────────────────────────── */
.city-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }

.city-card {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 1.1rem 1.2rem;
  border-top: 4px solid var(--city-card-color, #ccc);
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  display: block;
}
.city-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.12); transform: translateY(-2px); color: inherit; }
.city-card.unavailable { opacity: 0.55; cursor: default; pointer-events: none; }

.city-card-flag  { font-size: 1.8rem; margin-bottom: 0.3rem; }
.city-card-name  { font-family: 'Montserrat',sans-serif; font-weight: 700; font-size: 1rem; color: var(--primary-color); }
.city-card-meta  { font-size: 0.78rem; color: #6b7280; margin-top: 0.2rem; }
.city-card-badge { display: inline-block; margin-top: 0.4rem; padding: 0.1rem 0.5rem; font-size: 0.7rem; font-weight: 600; border-radius: 10px; background: #e8f8f5; color: #16a085; }
.city-card-badge.coming-soon { background: #f3f4f6; color: #9ca3af; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group    { margin-bottom: 0.8rem; }
.form-control  { width: 100%; padding: 0.5rem 0.65rem; border: 1px solid #eee; border-radius: var(--border-radius); font-family: 'Open Sans',sans-serif; background: #f9f9f9; transition: var(--transition); }
.form-control:focus { border-color: var(--accent-color); outline: none; background: #fff; box-shadow: 0 0 0 3px rgba(26,188,156,0.1); }
label { display: block; margin-bottom: 0.5rem; font-weight: 600; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table { width: 100%; table-layout: fixed; }
table td { width: 50%; text-align: left; padding: 0; }

.table-tight { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.table-tight th, .table-tight td { padding: 0.35rem 0.5rem; border-bottom: 1px solid #edf0f2; text-align: right; }
.table-tight th:first-child, .table-tight td:first-child { text-align: left; }
.table-tight thead th { background: #f8fafc; font-weight: 600; color: #4b5563; position: sticky; top: 0; }
.table-tight tr:last-child td { border-bottom: none; }

/* ── Factor description ──────────────────────────────────────────────────── */
.factor-desc {
  font-size: 0.82rem;
  color: #6b7280;
  margin: 0.3rem 0 0;
  line-height: 1.4;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer { background-color: var(--primary-color); color: var(--light-text); padding: 1.5rem 0 0.75rem; }
.footer-content { display: flex; flex-wrap: wrap; margin-bottom: 1rem; }
.footer-column  { flex: 1; min-width: 250px; margin-bottom: 0.75rem; padding-right: 1.5rem; }
.footer-column h3 { color: var(--light-text); margin-bottom: 0.5rem; font-size: 1rem; }
.footer-column ul li a { color: #bbb; }
.footer-column ul li a:hover { color: var(--light-text); }
.copyright { text-align: center; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.9rem; color: #bbb; }

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.8s ease forwards; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 992px) {
  .col-md-4, .col-md-6, .col-md-8 { flex: 0 0 100%; max-width: 100%; }
  .footer-column { flex: 0 0 50%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  nav ul {
    display: none; flex-direction: column;
    position: absolute; top: 100%; right: 0;
    min-width: 200px; background: #fff;
    box-shadow: 0 5px 10px rgba(0,0,0,0.1);
    padding: 0.5rem 0;
    z-index: 10;
  }
  nav ul.show { display: flex; }
  nav ul li { margin: 0; }
  nav ul li a { display: block; padding: 0.75rem 1.25rem; }
  nav ul li a::after { display: none; }
  .footer-column { flex: 0 0 100%; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  .factor-2x2 { grid-template-columns: 1fr; }
  .city-cards { grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); }
  #city-switcher { margin-left: 0; }
}
