/* calculator.css — Bendunomics GDP Catch-Up Calculator */
/* No Google Fonts — system font stack only, zero third-party requests */

/* Variables defined in site.css */

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(232,168,56,0.06) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Crect width='60' height='60' fill='none'/%3E%3Cpath d='M0 60L60 0' stroke='%23ffffff' stroke-width='0.15' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  position: relative;
  z-index: 1;
}

/* HEADER */
header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 32px;
  margin-bottom: 40px;
}

.header-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 12px;
}

h1 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 900;
  line-height: 1.1;
  color: var(--text);
}

h1 span { color: var(--gold); }

.header-sub {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 15px;
  max-width: 580px;
}

/* LAYOUT */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 700px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.country-badge {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.badge-a { background: rgba(88,166,255,0.15); color: var(--blue-a); border: 1.5px solid var(--blue-a); }
.badge-b { background: rgba(63,185,80,0.15); color: var(--blue-b); border: 1.5px solid var(--blue-b); }

.card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

/* SEARCH */
.select-wrapper { position: relative; margin-bottom: 16px; }

.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--gold); }
.search-input::placeholder { color: var(--text-dimmer); }

.dropdown-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.dropdown-list.open { display: block; }

.dropdown-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}

.dropdown-item:hover { background: rgba(255,255,255,0.05); }

.item-region {
  font-size: 11px;
  color: var(--text-dimmer);
  margin-left: auto;
}

/* STATS */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-dimmer);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.stat-value.loading {
  color: var(--text-dimmer);
  font-size: 13px;
  font-weight: 400;
  animation: pulse 1.5s ease-in-out infinite;
}

.stat-value.color-a { color: var(--blue-a); }
.stat-value.color-b { color: var(--blue-b); }
.stat-value.small { font-size: 15px; }

.growth-sub {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-dimmer);
  margin-top: 3px;
  font-family: var(--font-mono);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* OPTIONS */
.options-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.options-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  margin-bottom: 20px;
}

.options-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
}

.toggle-label {
  font-size: 13px;
  color: var(--text-dim);
  flex: 1 1 auto;
  min-width: 0;
}

.toggle-label strong {
  white-space: nowrap;
}

.toggle-label-right {
  flex-shrink: 0;
}

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle input {
  display: none;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 99px;
  transition: background 0.2s;
}

.toggle input:checked + .toggle-track {
  background: var(--gold);
}

.toggle-thumb {
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.toggle input:checked ~ .toggle-thumb {
  transform: translateX(18px);
}

/* MANUAL INPUT */
.manual-input-section {
  margin-top: 16px;
  display: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.manual-input-section.visible { display: block; }

.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.input-label {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 140px;
}

.number-input {
  width: 100px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s;
}

.number-input:focus { border-color: var(--gold); }

.input-unit {
  font-size: 13px;
  color: var(--text-dimmer);
  font-family: var(--font-mono);
}

/* RESULT */
.result-card {
  background: linear-gradient(135deg, rgba(232,168,56,0.08) 0%, rgba(13,17,23,0) 60%);
  border: 1px solid rgba(232,168,56,0.3);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: none;
}

.result-card.visible { display: block; }

.result-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--gold-dim);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.result-main {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.result-years {
  font-family: var(--font-serif);
  font-size: clamp(48px, 8vw, 80px);
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
}

.result-unit {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 300;
  color: var(--text-dim);
}

.result-target-year {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-dim);
  margin-left: 4px;
}

.result-detail {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.7;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}

.result-detail strong { color: var(--text); }
.result-detail em { color: var(--text-dimmer); font-style: normal; font-size: 13px; }

.no-catchup {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 10px;
}

.already-ahead {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--blue-b);
  margin-bottom: 10px;
}

/* CHART */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  display: none;
}

.chart-card.visible { display: block; }

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.chart-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  gap: 20px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-dim);
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

canvas { max-height: 360px; }

/* DATA SOURCE */
.data-source {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.8;
}

.data-source strong { color: var(--text); font-weight: 600; }

.data-source a {
  color: var(--gold);
  text-decoration: none;
}

.data-source a:hover { text-decoration: underline; }

.data-source .mono {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--blue-a);
}

/* MISC */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-text { font-size: 12px; color: var(--danger); margin-top: 8px; }
.hint-text { font-size: 12px; color: var(--text-dimmer); margin-top: 6px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Utility classes replacing inline style= attributes ─────────────────── */
.hidden { display: none; }

/* stat-box that spans both columns */
.stat-box.stat-box-full { grid-column: 1 / -1; }

/* also handle the plain replacement class name */
.stat-box-full { grid-column: 1 / -1; }

/* manual input note paragraph */
.manual-note {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

/* country A label in manual section */
.label-a { color: var(--blue-a); }

/* legend colour dots */
.legend-dot.dot-a { background: var(--blue-a); }
.legend-dot.dot-b { background: var(--blue-b); }

/* stats-row is display:grid when visible — hidden class overrides to none */
.stats-row { display: grid; }
.stats-row.hidden { display: none; }
