/* InvestAmerica design system */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #101828;
  --ink-2: #475467;
  --muted: #667085;
  --border: #e4e9f0;
  --accent: #1355c4;
  --accent-ink: #ffffff;
  --accent-soft: #e8effb;
  --up: #087f4f;
  --up-soft: #e5f5ee;
  --down: #d63b2f;
  --down-soft: #fdeceb;
  --warn-soft: #fff6e6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .09);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0b111c;
  --surface: #121a29;
  --surface-2: #1a2436;
  --ink: #e7ecf4;
  --ink-2: #aab4c5;
  --muted: #8492a9;
  --border: #24304a;
  --accent: #5b93f5;
  --accent-ink: #0b111c;
  --accent-soft: #16233c;
  --up: #34c98e;
  --up-soft: #12291f;
  --down: #f27a70;
  --down-soft: #331512;
  --warn-soft: #2e2410;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }

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

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
h3 { font-size: 1.12rem; }
p { margin: 0 0 1em; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  z-index: 200;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--ink);
  letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; flex: none; }
.brand .tld { color: var(--accent); }

.site-nav { margin-left: auto; }
.site-nav ul {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 500;
  font-size: .95rem;
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.header-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.theme-toggle:hover { background: var(--surface-2); }

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
}

@media (max-width: 800px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 8px 12px 14px;
  }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; }
  .site-nav a { padding: 12px; font-size: 1rem; }
}

/* Hero */
.hero {
  padding: 56px 0 30px;
}
.hero .eyebrow {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 99px;
  padding: 4px 12px;
  margin-bottom: 14px;
}
.hero h1 { max-width: 640px; }
.hero .lede {
  color: var(--ink-2);
  font-size: 1.12rem;
  max-width: 600px;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .96rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); text-decoration: none; }
.btn-sm { padding: 7px 13px; font-size: .88rem; }

/* Sections */
.section { padding: 34px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.section-head h2 { margin: 0; }
.section-head .sub { color: var(--muted); font-size: .92rem; margin: 0; }
.section-link { font-weight: 600; font-size: .93rem; white-space: nowrap; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 580px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Market tiles */
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tile .t-name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile .t-price {
  font-size: 1.22rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.tile .t-chg {
  font-size: .86rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tile .t-spark { margin-top: 6px; height: 34px; }
.tile .t-spark svg { display: block; width: 100%; height: 34px; }
.chg-up { color: var(--up); }
.chg-down { color: var(--down); }
.chg-flat { color: var(--muted); }
.badge-up, .badge-down, .badge-flat {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: .82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.badge-up { background: var(--up-soft); color: var(--up); }
.badge-down { background: var(--down-soft); color: var(--down); }
.badge-flat { background: var(--surface-2); color: var(--muted); }

.asof {
  color: var(--muted);
  font-size: .82rem;
}

.tiles-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 900px) { .tiles-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .tiles-row { grid-template-columns: 1fr 1fr; } }

/* Feature cards (calculators) */
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--ink);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.feature-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.feature-card .fc-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.feature-card h3 { margin: 4px 0 0; }
.feature-card p { margin: 0; color: var(--ink-2); font-size: .93rem; }
.feature-card .fc-go { margin-top: auto; padding-top: 8px; color: var(--accent); font-weight: 600; font-size: .9rem; }

/* News */
.news-list { display: grid; gap: 12px; }
.news-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: block;
  color: var(--ink);
  transition: border-color .15s ease;
}
.news-item:hover { border-color: var(--accent); text-decoration: none; }
.news-item h3 { font-size: 1rem; margin: 0 0 4px; }
.news-item .n-desc { color: var(--ink-2); font-size: .9rem; margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.news-item .n-meta { color: var(--muted); font-size: .8rem; display: flex; gap: 8px; align-items: center; }
.news-item .n-src {
  font-weight: 600;
  color: var(--accent);
}
.news-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Forms / calculators */
.calc-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) { .calc-layout { grid-template-columns: 1fr; } }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: 5px;
  color: var(--ink);
}
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field .range-val { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

.input-affix { position: relative; }
.input-affix .affix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .92rem;
  pointer-events: none;
}
.input-affix .prefix { left: 12px; }
.input-affix .suffix { right: 12px; }
.input-affix input.has-prefix { padding-left: 26px; }
.input-affix input.has-suffix { padding-right: 34px; }

/* Results */
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 480px) { .results-grid { grid-template-columns: 1fr; } }
.stat {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat .s-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .s-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat.s-hero { background: var(--accent-soft); }
.stat.s-hero .s-value { color: var(--accent); }
.stat.s-good .s-value { color: var(--up); }
.stat.s-bad .s-value { color: var(--down); }

.chart-box { margin: 6px 0 4px; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .84rem; color: var(--ink-2); margin-top: 8px; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Tables */
.table-wrap { overflow-x: auto; margin-top: 12px; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  text-align: right;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th {
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}
table.data tbody tr:hover { background: var(--surface-2); }

details.schedule { margin-top: 14px; }
details.schedule summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  padding: 6px 0;
}

/* Prose pages */
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.3em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .4em; }
.page-head { padding: 44px 0 8px; }
.page-head .sub { color: var(--ink-2); font-size: 1.05rem; max-width: 680px; }

.note {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--border) 60%, orange 20%);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .9rem;
  color: var(--ink-2);
  margin: 16px 0;
}

.disclaimer-inline {
  color: var(--muted);
  font-size: .82rem;
  margin-top: 14px;
}

/* FAQ */
.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 18px;
  margin-bottom: 10px;
}
.faq summary { font-weight: 600; cursor: pointer; padding: 10px 0; }
.faq details p { color: var(--ink-2); }

/* Ads */
.ad-slot {
  margin: 26px auto;
  text-align: center;
  min-height: 50px;
}
.ad-slot .ad-tag {
  display: block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* Loading / error states */
.state-msg {
  color: var(--muted);
  padding: 24px;
  text-align: center;
  font-size: .95rem;
}
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -4px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 36px 0 24px;
  font-size: .92rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 28px;
}
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.site-footer h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 8px; }
.site-footer a { color: var(--ink-2); }
.site-footer a:hover { color: var(--accent); }
.footer-about { color: var(--ink-2); }
.footer-legal {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
}

/* Utility */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.mt-0 { margin-top: 0; }
.center { text-align: center; }
