/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 0 2ch; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2ch; }
body { padding: 2lh 0; }

/* Column sections */
.column-here, .column-there { padding: 2lh 4ch; }
.column-here h4, .column-there h4 { margin-bottom: 1lh; color: var(--foreground2); }
.column-here h4::before { content: "[ " !important; }
.column-here h4::after { content: " ]"; }
.column-there h4::before { content: "[ " !important; }
.column-there h4::after { content: " ]"; }

/* Override WebTUI min-width on inputs */
input, select { min-width: 0 !important; }

#geo-status { font-weight: var(--font-weight-normal); color: var(--foreground2); }

/* Form elements */
label { display: block; margin-bottom: 1lh; font-weight: var(--font-weight-bold); }
label input, label select { margin-top: 0.25lh; display: block; }
label small { font-weight: var(--font-weight-normal); color: var(--foreground2); }

input[type="text"], input[type="number"], select, textarea {
  background: var(--background1); color: var(--foreground0);
  font-family: var(--font-family); font-size: var(--font-size);
  line-height: var(--line-height); border: none; outline: none;
  height: 3lh; padding: 1lh 1ch; width: 100%; box-sizing: border-box;
}
input::placeholder { color: var(--foreground2); }
input.invalid { border: 2px solid #dc3545 !important; }

/* Hero */
.hero { text-align: center; padding: 2lh 1ch 1lh; margin-bottom: 1lh; }
.hero h1 { font-size: 1.5rem; margin-bottom: 0.5lh; }
.hero h1::before { content: "> " !important; }
.hero p { color: var(--foreground2); margin: 0; }

/* Autocomplete */
label:has(.autocomplete-results) { position: relative; }
.autocomplete-results {
  position: absolute; z-index: 1000;
  background: var(--background0); border: 2px solid var(--foreground2);
  max-height: 200px; overflow-y: auto;
  width: 100%; display: none; top: 100%; left: 0;
}
.autocomplete-results.active { display: block; }
.autocomplete-item { padding: 0.5lh 1ch; cursor: pointer; border-bottom: 1px solid var(--background2); }
.autocomplete-item:hover { background: var(--foreground0); color: var(--background0); }
.autocomplete-item:last-child { border-bottom: none; }

/* Loading */
#loading {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); z-index: 999;
  padding: 1ch;
}
#loading-box {
  background: var(--background0); color: var(--foreground0);
  padding: 2lh 4ch; min-width: 36ch; max-width: 50ch; width: auto; text-align: center;
}
#loading-title { font-weight: var(--font-weight-bold); margin-bottom: 1lh; font-size: 1.1rem; }
#loading-stage { color: var(--foreground1); margin-bottom: 0.5lh; min-height: 1.5lh; }
#loading-gif { display: block; margin: 0 auto 1lh; max-width: 100%; max-height: 200px; border-radius: 4px; }
#loading-stream { color: var(--foreground2); font-size: 0.75rem; margin-bottom: 1lh; min-height: 1.5lh; max-width: 100%; word-wrap: break-word; overflow-wrap: break-word; opacity: 0.7; }
#loading-bar {
  height: 1lh; background: var(--background2); position: relative; overflow: hidden;
}
#loading-fill {
  display: block; height: 100%; width: 0%;
  background: var(--foreground2); transition: width 0.4s ease;
}

/* Caveats */
#caveats { margin-top: 1lh; padding: 1.5lh 4ch; }
#caveats strong { color: #ffc107; }
#caveats ul { margin: 0.5lh 0 0 2ch; padding: 0; font-size: 0.85rem; color: var(--foreground2); }
#caveats li { margin-bottom: 0.25lh; }

/* Winner banner */
#winner-banner { text-align: center; padding: 1.5lh 4ch; margin-bottom: 1.5lh; font-weight: var(--font-weight-bold); }
#winner-banner.winner-a { border: 2px solid #28a745; color: #28a745; }
#winner-banner.winner-b { border: 2px solid #4a9eff; color: #4a9eff; }
#winner-banner.tie { border: 2px solid #ffc107; color: #ffc107; }

/* Verdict */
#verdict-box { text-align: center; padding: 0.5lh 0 1lh; color: var(--foreground1); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: 1fr; gap: 1lh; margin-bottom: 1.5lh; }
@media (min-width: 768px) { .stats-grid { grid-template-columns: 1fr auto 1fr; gap: 2ch; } }

.vs-divider {
  display: none; align-items: center; justify-content: center;
  font-weight: var(--font-weight-bold); color: var(--foreground2);
  width: 4ch; align-self: center;
}
@media (min-width: 768px) { .vs-divider { display: flex; } }

/* Location cards */
.location-card { padding: 2lh 4ch; }
.location-card.winner { border-color: #28a745; }
.location-card.loser { opacity: 0.5; }
.location-card h4 { margin-bottom: 1lh; }
.location-card h4::before { content: "[ "; }
.location-card h4::after { content: " ]"; }
.location-card .section-label { margin: 1lh 0 0.5lh; color: var(--foreground2); font-size: 0.85rem; font-weight: var(--font-weight-bold); }

/* Stat table */
.stat-table { width: 100%; border-collapse: collapse; }
.stat-table td { padding: 0.25lh 0; }
.stat-table td:first-child { color: var(--foreground2); padding-right: 2ch; }
.stat-table td:last-child { text-align: right; font-family: var(--font-family); }
.stat-table tr.highlight td { font-weight: var(--font-weight-bold); }
.stat-table tr.highlight td:last-child { color: var(--foreground0); }
.stat-table tr + tr td { border-top: 1px solid var(--background2); }

/* Buying power */
.buying-power { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--background2); }
.bp-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 0.75lh 1ch; background: var(--background0); text-align: center; gap: 0.25lh;
}
.bp-val { font-weight: var(--font-weight-bold); font-size: 1.1rem; }
.bp-lbl { font-size: 0.75rem; color: var(--foreground2); }

/* Pros/Cons */
.pros-cons { margin-top: 1lh; padding-top: 1lh; border-top: 1px solid var(--background2); font-size: 0.85rem; }
.pros span, .cons span { display: block; padding: 0.15lh 0; }
.pros span::before { content: "+ "; color: #28a745; font-weight: var(--font-weight-bold); }
.cons span::before { content: "- "; color: #dc3545; font-weight: var(--font-weight-bold); }

/* Key metric */
#key-metric { padding: 2lh 4ch; margin-bottom: 1.5lh; }
#key-metric .section-label { margin-bottom: 1lh; color: var(--foreground2); font-size: 0.85rem; text-align: center; font-weight: var(--font-weight-bold); }
.bar-row { display: flex; align-items: center; gap: 1ch; margin-bottom: 0.5lh; }
.bar-label { width: 14ch; flex-shrink: 0; font-size: 0.85rem; color: var(--foreground2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-container { flex: 1; height: 1lh; background: var(--background2); overflow: hidden; }
.bar { height: 100%; transition: width 0.5s ease; }
.bar-a { background: #28a745; }
.bar-b { background: #4a9eff; }
.bar-value { min-width: 6ch; font-weight: var(--font-weight-bold); text-align: right; white-space: nowrap; }

/* Meta section */
#meta-section { margin-top: 1lh; padding: 0.75lh 3ch; color: var(--foreground2); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 2ch; justify-content: center; border: 1px solid #ffc107; }
.meta-item strong { color: var(--foreground1); margin-left: 0.5ch; }

/* Action buttons */
.action-buttons { display: flex; gap: 2ch; margin-top: 1.5lh; justify-content: center; }
.share-btn, .new-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5lh 2ch; text-decoration: none;
  cursor: pointer; border: 1px solid var(--foreground2); background: transparent;
  color: var(--foreground0); font-family: var(--font-family); font-size: var(--font-size);
}
.share-btn:hover, .new-btn:hover { background: var(--foreground0); color: var(--background0); }

/* Form actions */
.job-picker { margin-bottom: 1lh; text-align: center; }
.job-picker select { display: inline; width: auto; margin-left: 1ch; }
#job-label { color: var(--foreground2); }
.form-actions { margin-top: 1lh; }
.form-actions #compare-btn { width: 100%; }
#compare-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Salary row */
.salary-row { display: grid; grid-template-columns: 2fr 1fr; gap: 1ch; align-items: end; }

/* Period toggle */
.label-with-toggle { display: flex; justify-content: space-between; align-items: center; }
.period-toggle { font-size: 0.75rem; font-weight: normal; }
.period-link { color: var(--foreground2); text-decoration: none; padding: 0 0.5ch; transition: all 0.15s; }
.period-link.active { background: var(--foreground0); color: var(--background0); }
.period-link:hover:not(.active) { color: var(--foreground0); }

/* City input with dice */
.city-input-wrap { position: relative; }
.city-input-wrap input { width: 100%; padding-right: 3ch; }
.dice-btn {
  position: absolute; right: 1ch; top: 50%; transform: translateY(-50%);
  cursor: pointer; user-select: none; font-size: 1rem; line-height: 1;
}
.dice-btn:hover { transform: translateY(-50%) scale(1.2); }

/* Footer */
.site-footer { margin-top: 3lh; text-align: center; padding: 1.5lh; color: var(--foreground2); }
.made-by { margin-top: 0.5lh; font-size: 0.85rem; }
.made-by a { color: var(--foreground1); }
.easter-egg { display: inline-block; transition: transform 0.2s; text-decoration: none; }
.easter-egg:hover { transform: scale(1.25); }

/* Discover section */
#discover-section { margin-top: 2lh; }
.discover-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1ch; }
.discover-col { padding: 1.5lh 3ch; }
.discover-col h4 { margin: 0 0 0.5lh 0; font-size: 0.9rem; }
.discover-col-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5lh; }
.discover-col-header h4 { margin-bottom: 0; }
.discover-tabs { display: flex; gap: 1ch; }
.discover-tab { color: var(--foreground2); text-decoration: none; padding: 0.25lh 1ch; font-size: 0.85rem; }
.discover-tab.active { color: var(--foreground0); border-bottom: 1px solid var(--foreground0); }
.discover-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5lh 0; border-bottom: 1px solid var(--background2); }
.discover-item:last-child { border-bottom: none; }
.discover-item a { color: var(--foreground1); text-decoration: none; font-size: 0.85rem; }
.discover-item a:hover { color: var(--foreground0); }
.discover-item .views { color: var(--foreground2); font-size: 0.8rem; white-space: nowrap; }
#discover-recent:empty::after, #discover-popular:empty::after { content: 'No comparisons yet.'; color: var(--foreground2); font-size: 0.85rem; }

/* World map */
#world-map-section { margin-top: 2lh; }
.map-title { text-align: center; margin-bottom: 1lh; font-size: 0.9rem; }
#world-map-container { width: 100%; overflow: hidden; }
#world-map-container svg { width: 100%; height: auto; display: block; }
.wmap-country { fill: var(--background1); stroke: var(--background2); stroke-width: 0.3; }
.wmap-arc { fill: none; stroke: var(--foreground2); stroke-dasharray: 3,2; cursor: pointer; }
.wmap-arc:hover { opacity: 1 !important; stroke: var(--foreground0); }
.wmap-city circle { transition: fill 0.15s; }
.wmap-city:hover circle.wmap-dot { fill: var(--foreground0); }
.map-tooltip {
  display: none; position: fixed; z-index: 100;
  background: var(--background0); border: 1px solid var(--foreground2);
  padding: 0.25lh 1ch; font-size: 0.75rem; color: var(--foreground0);
  pointer-events: none; white-space: nowrap;
}
.map-tooltip.active { display: block; }

/* Mobile */
@media (max-width: 768px) {
  .grid { grid-template-columns: 1fr; }
  .bar-label { min-width: 10ch; font-size: 0.75rem; }
  .discover-columns { grid-template-columns: 1fr; }
  #loading-box { min-width: auto; max-width: 95vw; }
  #world-map-section { margin-top: 1lh; }
}