/* ── Brand tokens ─────────────────────────────────────────────────────────── */
:root {
  --blurple:        #4739E6;
  --blurple-hover:  #392DC7;
  --blurple-eyebrow:#4739E6;

  --text-heading:   #000000;
  --text-body:      #464646;
  --text-secondary: #6A6A6A;
  --text-tertiary:  #A1A1A1;

  --border:         #CECECE;
  --bg-section:     #F4F4F4;
  --bg-card:        #FFFFFF;
  --bg-page:        #FFFFFF;

  /* data-viz: one per factor */
  --viz-climate:    #4739E6;
  --viz-type:       #4361F7;
  --viz-cost:       #3195F7;
  --viz-language:   #32D1CA;

  /* reason badge colors */
  --badge-close:    #E65239;
  --badge-region:   #E6A039;
  --badge-cap:      #9B59B6;
  --badge-out:      #6A6A6A;

  --radius-btn:  3px;
  --radius-card: 8px;
  --radius-chip: 4px;

  --shadow-btn:
    0 4px 4px rgba(8,8,8,.08),
    0 1px 2px rgba(8,8,8,.2),
    inset 0 1px 1px rgba(255,255,255,.2),
    inset 0 6px 12px rgba(255,255,255,.12);

  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blurple-eyebrow: #6E73F9;
    --text-heading:    #FFFFFF;
    --text-body:       #CECECE;
    --text-secondary:  #A1A1A1;
    --border:          rgba(255,255,255,.1);
    --bg-section:      #1A1A1A;
    --bg-card:         rgba(255,255,255,.06);
    --bg-page:         #111111;
  }
}

[data-theme="dark"] {
  --blurple-eyebrow: #6E73F9;
  --text-heading:    #FFFFFF;
  --text-body:       #CECECE;
  --text-secondary:  #A1A1A1;
  --border:          rgba(255,255,255,.1);
  --bg-section:      #1A1A1A;
  --bg-card:         rgba(255,255,255,.06);
  --bg-page:         #111111;
}

/* ── Reset / base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--text-body);
  background: var(--bg-page);
  line-height: 1.6;
}

/* ── Typography scale ─────────────────────────────────────────────────────── */
h1 { font-size: 4.75rem; font-weight: 600; line-height: 1.25; color: var(--text-heading); }
h2 { font-size: 3.25rem; font-weight: 600; line-height: 1.25; color: var(--text-heading); }
h3 { font-size: 2.25rem; font-weight: 600; line-height: 1.25; color: var(--text-heading); }
h4 { font-size: 1.35rem; font-weight: 600; line-height: 1.25; color: var(--text-heading); }

.paragraph-r { font-size: 1.125rem; line-height: 1.6; }
.paragraph-s { font-size: 0.875rem; line-height: 1.6; }
.paragraph-l { font-size: 1rem; font-weight: 600; line-height: 1.6; }

.eyebrow {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  color: var(--blurple-eyebrow);
  display: block;
  margin-bottom: 8px;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px;
}

.content-inner {
  max-width: 800px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.site-header .container {
  display: flex;
  align-items: center;
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.logo {
  display: block;
  height: 24px;
  width: auto;
}

/* light mode: show dark logo, hide light logo */
.logo-light { display: none; }
.logo-dark  { display: block; }

/* dark mode: show light logo, hide dark logo */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-dark  { display: none; }
  :root:not([data-theme="light"]) .logo-light { display: block; }
}
[data-theme="dark"] .logo-dark  { display: none; }
[data-theme="dark"] .logo-light { display: block; }
[data-theme="light"] .logo-dark  { display: block; }
[data-theme="light"] .logo-light { display: none; }

/* header right slot */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle:hover {
  color: var(--blurple);
  border-color: var(--blurple);
}
.theme-toggle:focus-visible {
  outline: 3px solid var(--blurple);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) { .theme-toggle { transition: none; } }

/* show sun in dark mode, moon in light mode */
.icon-moon { display: block; }
.icon-sun  { display: none; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun  { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon { display: none; }
  :root:not([data-theme="light"]) .icon-sun  { display: block; }
}
[data-theme="light"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun  { display: none; }

/* beta pill */
.beta-pill {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06rem;
  color: var(--blurple);
  background: rgba(71,57,230,.12);
  border: 1px solid rgba(71,57,230,.25);
  border-radius: 100px;
  padding: 1px 7px;
  vertical-align: middle;
  line-height: 1.6;
  margin-left: 6px;
  position: relative;
  top: -1px;
}

/* ── Hero / search ────────────────────────────────────────────────────────── */
.hero {
  background: var(--bg-section);
  padding: 80px 0;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: 2.75rem;
  margin: 8px 0 16px;
}

.hero .subtitle {
  color: var(--text-secondary);
  margin-bottom: 40px;
}

/* ── Search control ───────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 260px;
}

#search-input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text-body);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  outline: none;
  transition: border-color 0.15s;
}

#search-input:focus {
  border-color: var(--blurple);
  box-shadow: 0 0 0 3px rgba(71,57,230,.15);
}

#search-input::placeholder { color: var(--text-tertiary); }

/* autocomplete dropdown */
#autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 100;
  list-style: none;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

#autocomplete-list[hidden] { display: none; }

#autocomplete-list li {
  padding: 10px 16px;
  font-size: 0.9375rem;
  cursor: pointer;
  color: var(--text-body);
  border-bottom: 1px solid var(--border);
}
#autocomplete-list li:last-child { border-bottom: none; }

#autocomplete-list li:hover,
#autocomplete-list li[aria-selected="true"] {
  background: var(--bg-section);
  color: var(--text-heading);
}

#autocomplete-list li mark {
  background: transparent;
  color: var(--blurple);
  font-weight: 600;
}

.btn-primary {
  padding: 14px 28px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.025rem;
  color: #FFFFFF;
  background: var(--blurple);
  border: none;
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--blurple-hover); }
.btn-primary:focus-visible {
  outline: 3px solid var(--blurple);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary { transition: none; }
}

.search-error {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--badge-close);
  width: 100%;
}
.search-error[hidden] { display: none; }

/* ── Results section ──────────────────────────────────────────────────────── */
#results {
  padding: 80px 0;
}

#results[hidden] { display: none; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
#empty-state {
  padding: 80px 0;
  color: var(--text-secondary);
}

#empty-state[hidden] { display: none; }

/* ── Origin summary card ─────────────────────────────────────────────────── */
.origin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 28px 32px;
  margin-bottom: 56px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.origin-card-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.origin-card-header h2 {
  font-size: 1.75rem;
}

.origin-code-badge {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  padding: 2px 8px;
}

.origin-country {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.attr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.attr-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  padding: 8px 14px;
  min-width: 110px;
}

.attr-chip-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06rem;
  color: var(--text-tertiary);
}

.attr-chip-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Section headers ─────────────────────────────────────────────────────── */
.section-head {
  margin-bottom: 32px;
}

.section-head h3 {
  font-size: 1.5rem;
  margin-top: 4px;
}

/* ── Destination cards grid ──────────────────────────────────────────────── */
.dest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 64px;
}

.dest-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.dest-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.rank-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blurple);
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dest-name {
  flex: 1;
}

.dest-name h4 {
  font-size: 1.0625rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dest-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* total score */
.score-display {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.score-numeral {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-heading);
  line-height: 1;
}

.score-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05rem;
}

/* factor bars */
.factor-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.factor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
}

.factor-label {
  width: 60px;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.factor-track {
  flex: 1;
  height: 6px;
  background: var(--bg-section);
  border-radius: 3px;
  overflow: hidden;
}

.factor-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
@media (prefers-reduced-motion: reduce) { .factor-fill { transition: none; } }

.factor-fill[data-factor="climate"]  { background: var(--viz-climate); }
.factor-fill[data-factor="type"]     { background: var(--viz-type); }
.factor-fill[data-factor="cost"]     { background: var(--viz-cost); }
.factor-fill[data-factor="language"] { background: var(--viz-language); }

.factor-value {
  width: 30px;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-body);
  flex-shrink: 0;
}

/* why kept */
.why-kept {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reason-chip {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-chip);
  background: rgba(71,57,230,.1);
  color: var(--blurple);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.why-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ── Excluded candidates ─────────────────────────────────────────────────── */
.excluded-section {
  margin-bottom: 48px;
}

.excluded-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 20px;
}

.excl-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 16px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.excl-row:first-child {
  border-top: 1px solid var(--border);
}

.excl-left {}

.excl-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}

.excl-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.excl-reason-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.excl-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.excl-score {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
}

.excl-score-label {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04rem;
}

.reason-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-chip);
  text-transform: uppercase;
  letter-spacing: 0.04rem;
  white-space: nowrap;
  color: #FFFFFF;
}

.reason-badge[data-reason="close"]  { background: var(--badge-close); }
.reason-badge[data-reason="region"] { background: var(--badge-region); }
.reason-badge[data-reason="cap"]    { background: var(--badge-cap); }
.reason-badge[data-reason="out"]    { background: var(--badge-out); }

.excl-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 12px 0 0;
  line-height: 1.6;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  background: var(--bg-section);
}

.site-footer p {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

/* ── Focus ring ───────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--blurple);
  outline-offset: 2px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .hero { padding: 64px 0; }
  #results { padding: 64px 0; }
}

@media (max-width: 767px) {
  .container { padding: 0 20px; }

  h1, .hero h1 { font-size: 2rem; }
  h3 { font-size: 1.4rem; }
  h4 { font-size: 1.25rem; }

  .hero { padding: 48px 0; }
  #results { padding: 48px 0; }
  #empty-state { padding: 48px 0; }

  .search-wrap { flex-direction: column; }
  .search-input-wrap { min-width: 100%; width: 100%; }
  .btn-primary { width: 100%; text-align: center; }

  .dest-grid { grid-template-columns: 1fr; }

  .excl-row { grid-template-columns: 1fr; }
  .excl-right { flex-direction: row; align-items: center; }
}
