/*
 * Thai FX Compare UI foundation — Issue #27.
 * Loaded after the legacy stylesheet. This is the canonical home for shared
 * design tokens and new Transfer/Cash UI decisions, NOT a new place to append
 * emergency per-release CSS. Retire matching legacy declarations incrementally.
 * No external font/network dependencies. All changes intentionally UI-only.
 */
:root {
  --fx-bg: #f6f7f8;
  --fx-surface: #ffffff;
  --fx-surface-soft: #f0f4f9;
  --fx-ink: #192638;
  --fx-muted: #58677c;
  --fx-subtle: #718196;
  --fx-line: #dce3eb;
  --fx-primary: #2457ca;
  --fx-primary-hover: #1848b4;
  --fx-primary-soft: #eaf1ff;
  --fx-positive: #08784c;
  --fx-caution: #98571d;
  --fx-error: #a52830;
  --fx-radius-sm: 10px;
  --fx-radius-md: 16px;
  --fx-radius-lg: 22px;
  --fx-shadow: 0 7px 26px rgba(24, 39, 64, .05);
  --fx-body-size: 16px;
  --fx-help-size: 14px;
  --fx-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", Tahoma, Arial, sans-serif;
}
html { color-scheme: light; }
html body {
  background: var(--fx-bg);
  color: var(--fx-ink);
  font-family: var(--fx-font);
  font-size: var(--fx-body-size);
  font-synthesis: none;
}
html[lang="th"] body { font-family: var(--fx-font); }
body .app { width: min(1200px, calc(100% - 40px)) !important; max-width: 100%; }
.app :is(.hero-v2, .hero-v2-copy, .hero-v2-art, .cash-hero, .cash-hero-copy, .cash-dashboard, .cash-builder-grid, .cash-field, .cash-answer, .cash-answer-total) { min-width: 0; }
.app :is(button, input, select, textarea) { font-family: inherit; }
.app :is(button, input, select, textarea, a, summary):focus-visible {
  outline: 3px solid var(--fx-primary);
  outline-offset: 3px;
}
.app :is(input, select, textarea) { accent-color: var(--fx-primary); }
.app :is(input, select, textarea):disabled { cursor: not-allowed; opacity: .6; }
.app :is(button, select, summary) { touch-action: manipulation; }
.app [hidden] { display: none !important; }

/* One consistent navigation/brand treatment on both consumer pages. */
.app .topbar {
  min-height: 68px !important;
  height: auto !important;
  padding: 10px 0 !important;
  border-bottom: 1px solid var(--fx-line) !important;
  background: transparent !important;
  gap: 12px;
}
.app .brand-mark {
  border-radius: 11px !important;
  background: var(--fx-ink) !important;
  box-shadow: none !important;
}
.app .brand-copy > strong {
  font-size: 16px !important;
  font-weight: 750 !important;
  letter-spacing: -.02em;
  color: var(--fx-ink);
}
.app .top-actions { gap: 6px !important; }
.app .top-actions :is(.api-header-link, .admin-health-link, .feedback-header-button, .language-toggle) {
  min-height: 40px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: var(--fx-radius-sm) !important;
  color: var(--fx-muted) !important;
  box-shadow: none !important;
}
.app .top-actions .language-toggle {
  color: var(--fx-ink) !important;
  background: var(--fx-surface) !important;
  border: 1px solid var(--fx-line) !important;
}
.app .top-actions :is(a, button):hover { background: var(--fx-surface-soft) !important; color: var(--fx-ink) !important; }
.app .header-freshness { font-size: 12px !important; }
.app .product-mode-nav {
  display: flex;
  width: max-content;
  max-width: 100%;
  margin: 18px 0 0;
  padding: 5px;
  gap: 5px;
  border: 1px solid var(--fx-line);
  border-radius: 14px;
  background: var(--fx-surface-soft);
  box-shadow: none;
}
.app .product-mode-nav a {
  min-height: 42px;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--fx-muted);
}
.app .product-mode-nav a.active {
  color: var(--fx-ink);
  background: var(--fx-surface);
  box-shadow: 0 2px 8px rgba(24,39,64,.10);
}
.app .product-mode-nav a:hover { color: var(--fx-primary); }
.fx-mobile-links { display: none; }

/* Shared hero hierarchy: calm title, concise supporting text and consistent artwork. */
.app .hero-v2-copy, .app .cash-hero-copy { min-width: 0; }
.app :is(.hero-v2-copy, .cash-hero-copy) .eyebrow {
  font-size: 13px !important;
  font-weight: 650 !important;
  letter-spacing: .04em !important;
  color: var(--fx-primary) !important;
}
.app :is(.hero-v2-copy, .cash-hero-copy) h1 {
  color: var(--fx-ink);
  font-weight: 780;
  letter-spacing: -.035em;
  line-height: 1.12;
  text-wrap: balance;
}
.app :is(.hero-v2-copy, .cash-hero-copy) .hero-sub {
  color: var(--fx-muted) !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  line-height: 1.65 !important;
  max-width: 62ch;
}
.app .hero-highlight { color: var(--fx-primary) !important; }
.app .cash-hero.fx-shared-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 300px);
  column-gap: clamp(22px, 3vw, 46px);
  row-gap: 16px;
  align-items: center;
  padding: 36px 0 20px;
}
.app .cash-hero.fx-shared-hero h1 { font-size: clamp(38px, 4.6vw, 58px); }
.app .cash-hero.fx-shared-hero .hero-line { display: block; }
.app .cash-hero.fx-shared-hero .hero-v2-art { width: 100%; justify-self: end; }
.app .cash-hero.fx-shared-hero .hero-v2-image {
  display: block;
  width: min(100%, 300px) !important;
  max-width: 100% !important;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
}
.app .cash-hero.fx-shared-hero .cash-builder { grid-column: 1 / -1; margin-top: 4px; }

/* Surface, controls and actions — shared across the two calculators. */
.app :is(.card, .sentence-builder) {
  border: 1px solid var(--fx-line) !important;
  border-radius: var(--fx-radius-md) !important;
  background: var(--fx-surface) !important;
  box-shadow: var(--fx-shadow) !important;
}
.app .sentence-builder { padding: clamp(16px, 2vw, 23px); }
.app :is(.retro-select, .cash-select, .cash-amount-pair, .exchange-box, .exchange-output) {
  border-radius: var(--fx-radius-sm) !important;
  border-color: var(--fx-line) !important;
  box-shadow: none !important;
}
.app :is(.retro-select, .cash-select, .cash-amount-pair select, .exchange-box input, .cash-amount-pair input) {
  font-size: 16px !important;
  font-weight: 500 !important;
  color: var(--fx-ink) !important;
}
.app :is(.retro-select, .cash-select) { min-height: 48px; }
.app .cash-amount-pair, .app .exchange-box { min-height: 48px; }
.app :is(.retro-primary, .cash-compare) {
  background: var(--fx-primary) !important;
  color: #fff !important;
  border: 1px solid var(--fx-primary) !important;
  border-radius: var(--fx-radius-sm) !important;
  box-shadow: none !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  min-height: 48px !important;
  cursor: pointer;
}
.app :is(.retro-primary, .cash-compare):hover {
  background: var(--fx-primary-hover) !important;
  border-color: var(--fx-primary-hover) !important;
}
.app :is(.retro-primary, .cash-compare):active { transform: translateY(1px); }
.app .cash-field > span, .app .cash-denomination > span {
  color: var(--fx-muted);
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1.45;
}
.app .cash-builder-grid { gap: 12px; }
.app .cash-builder-meta .scenario-hint,
.app .cash-context-item > span,
.app .cash-answer-total > span,
.app .cash-answer-rate > span {
  font-size: 13px;
  line-height: 1.5;
  color: var(--fx-muted);
}
.app :is(.scenario-hint, .cash-chart-description, .cash-directory-panel > p) { font-size: 13px; line-height: 1.55; }
.app .cash-answer {
  border-color: var(--fx-line) !important;
  background: var(--fx-surface) !important;
}
.app .cash-answer-total > strong { font-variant-numeric: tabular-nums lining-nums; overflow-wrap: anywhere; line-height: 1.12; }
.app .cash-answer-total > small, .app .cash-answer-rate > small { font-size: 12px; }
.app .cash-answer-rate > strong { font-variant-numeric: tabular-nums; }
.app .cash-provider-line span { font-size: 12px; }
.app .cash-provider-badge {
  border-radius: 10px;
  background: var(--fx-primary-soft);
  color: var(--fx-primary);
}
.app :is(.cash-dashboard, .cash-chart-card, .cash-directory-panel) { min-width: 0; }
.app :is(.cash-chart-card, .chart-card, .full-chart-card) { overflow: hidden; }
.app :is(.cash-dashboard, .summary-grid, .cash-chart-card) strong { font-variant-numeric: tabular-nums lining-nums; }

/* Semantic colors are reserved for actual outcomes, not decorative surfaces. */
.app :is(.status-live, .status-fresh, .best-row .saving) { color: var(--fx-positive); }
.app .alert { color: var(--fx-error); border-color: #f0c6c9; background: #fff5f5; }
.app .muted, .app .checked { color: var(--fx-muted); }
.app :is(.site-legal-links a, .soft-button, .cash-help-card a):hover { color: var(--fx-primary); }
@media (prefers-reduced-motion: reduce) {
  .app *, .app *::before, .app *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 900px) {
  body .app { width: min(100% - 28px, 1200px) !important; }
  .app .cash-hero.fx-shared-hero { grid-template-columns: minmax(0, 1fr) minmax(150px, 220px); }
}
@media (max-width: 680px) {
  body .app { width: calc(100% - 28px) !important; }
  .app .topbar { min-height: 58px !important; }
  .app .top-actions { gap: 4px !important; }
  .app .top-actions :is(.api-header-link, .admin-health-link) { display: none !important; }
  .app .top-actions :is(.feedback-header-button, .language-toggle) { font-size: 13px !important; min-height: 38px !important; }
  .app .brand-copy > strong { font-size: 14px !important; }
  .app .product-mode-nav { width: 100%; margin-top: 12px; }
  .app .product-mode-nav a { flex: 1; padding: 10px 8px; font-size: 14px; min-height: 42px; }
  .fx-mobile-links { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin: 11px 2px 4px; }
  .fx-mobile-links a { color: var(--fx-muted); font-size: 13px; font-weight: 600; text-decoration: none; }
  .fx-mobile-links a:hover { color: var(--fx-primary); text-decoration: underline; }
  .app .cash-hero.fx-shared-hero {
    grid-template-columns: minmax(0, 1fr) minmax(72px, 24vw);
    gap: 10px;
    padding: 24px 0 14px;
  }
  .app .cash-hero.fx-shared-hero h1 { font-size: clamp(28px, 8vw, 42px); }
  .app .cash-hero.fx-shared-hero .hero-v2-image { width: 100% !important; max-width: 125px !important; height: auto; }
  .app :is(.hero-v2-copy, .cash-hero-copy) .hero-sub { font-size: 14px !important; line-height: 1.55 !important; }
  .app .cash-hero.fx-shared-hero .cash-builder { grid-column: 1 / -1; }
  .app .cash-builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) !important; gap: 11px; }
  .app .cash-builder-grid > * { grid-column: 1 / -1 !important; min-width: 0; }
  .app .cash-builder-grid .cash-reverse { justify-self: center; width: 38px; height: 34px; min-height: 34px; transform: rotate(90deg); }
  .app .cash-amount-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(96px, 35%); width: 100%; }
  .app .cash-amount-pair input { min-width: 0; width: 100%; }
  .app .cash-builder-meta { align-items: flex-start; }
  .app .cash-compare { width: 100%; min-height: 50px !important; }
  .app .cash-answer { gap: 14px; }
  .app .cash-answer-total > strong { font-size: clamp(24px, 8vw, 34px); }
}
@media (max-width: 380px) {
  .app .cash-hero.fx-shared-hero { grid-template-columns: minmax(0, 1fr) 75px; gap: 7px; }
  .app .cash-hero.fx-shared-hero h1 { font-size: 29px; }
  .app .brand-copy > strong { font-size: 13px !important; }
  .app .top-actions .feedback-header-button { padding-inline: 6px !important; }
  .app .cash-hero.fx-shared-hero .hero-v2-image { max-width: 75px !important; }
}


/* Exact branch discovery is a secondary Cash task, not a system health tab. */
.app .fx-cash-locations-link {
 display:inline-flex;align-items:center;min-height:42px;
 margin-top:10px;padding:9px 13px;border:1px solid #c6d8fb;
 border-radius:var(--fx-radius-sm);background:var(--fx-primary-soft);
 color:var(--fx-primary);font-size:14px;font-weight:700;
 text-decoration:none;box-shadow:none;
}
.app .fx-cash-locations-link:hover {background:#dce9ff;}
.app .cash-directory-map-link {font-size:14px;line-height:1.6;color:var(--fx-primary);}


/* The Cash historical tooltip separates a provider's recorded observation
   time from its quote value. Never cram provenance into the amount column. */
.cash-history-tip-row > small {
  grid-column: 2 / -1;
  justify-self: end;
  text-align: right;
  font-size: 11px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  color: #dbe5f4;
}
