/* funds.css — NAV explorer + fund detail. Uses global.css design tokens. */

/* ---------- Explorer search ---------- */
.fund-search { position: relative; max-width: 680px; }
.fund-search-label { display: block; font-weight: 600; margin-bottom: .5rem; color: var(--ink); }
.fund-search input {
  width: 100%; padding: .9rem 1.1rem; font-size: 1.05rem; font-family: var(--ff-body);
  border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--ink); transition: border-color .15s;
}
.fund-search input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,123,110,.12); }
.fund-search-hint { margin-top: .5rem; font-size: .85rem; }

.fund-results {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% - 1.6rem);
  list-style: none; margin: 0; padding: .35rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 360px; overflow-y: auto;
}
.fund-results li { margin: 0; }
.fund-results a {
  display: block; padding: .6rem .75rem; border-radius: 8px; color: var(--ink);
  text-decoration: none; font-size: .95rem; line-height: 1.35;
}
.fund-results a:hover, .fund-results a:focus { background: var(--bg); color: var(--teal); }
.fund-result-empty { padding: .7rem .75rem; color: var(--muted); font-size: .9rem; }

/* ---------- Popular grid ---------- */
.fund-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem; margin-top: 1.25rem;
}
.fund-card {
  display: flex; flex-direction: column; gap: .55rem; padding: 1.25rem;
  text-decoration: none; color: var(--ink);
}
.fund-card-cat { align-self: flex-start; }
.fund-card-name { font-size: 1.08rem; line-height: 1.3; margin: 0; font-family: var(--ff-head); }
.fund-card-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; margin-top: auto; }
.fund-card-nav { font-family: var(--ff-mono); font-weight: 600; font-size: .95rem; }
.fund-card-ret { font-family: var(--ff-mono); font-size: .85rem; }
.fund-card-cta { font-size: .85rem; color: var(--teal); font-weight: 600; }

.is-up   { color: var(--green); }
.is-down { color: var(--red); }
.is-na   { color: var(--muted); }

/* ---------- Detail ---------- */
.fund-detail-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end;
  gap: 1rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem;
}
.fund-detail-name { font-size: clamp(1.5rem, 3.5vw, 2.1rem); margin: .5rem 0 .25rem; line-height: 1.2; }
.fund-detail-cat { margin: 0; font-size: .95rem; }
.fund-detail-nav { text-align: right; }
.fund-detail-nav-value { font-family: var(--ff-mono); font-size: 1.9rem; font-weight: 700; color: var(--teal); }
.fund-detail-nav-label { font-size: .82rem; }

.fund-detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
.fund-section-title { font-size: 1.15rem; margin: 0 0 1rem; }
.fund-chart-wrap { position: relative; height: 320px; }
.fund-chart-note, .fund-returns-note { font-size: .82rem; margin-top: .75rem; }

.fund-returns {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: .75rem;
}
.fund-return-cell {
  display: flex; flex-direction: column; gap: .2rem; padding: .75rem; border-radius: 10px;
  background: var(--bg); text-align: center;
}
.fund-return-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.fund-return-val { font-family: var(--ff-mono); font-weight: 700; font-size: 1.05rem; }

/* ---------- CTA ---------- */
.fund-detail-side { position: sticky; top: 1.5rem; }
.fund-cta-title { font-size: 1.2rem; margin: 0 0 .5rem; }
.fund-cta-form { margin-top: 1rem; display: flex; flex-direction: column; gap: .85rem; }
.fund-cta-fine { font-size: .78rem; margin-top: .75rem; }

.fund-disclaimer { font-size: .8rem; line-height: 1.55; margin-top: 2rem; }

@media (max-width: 860px) {
  .fund-detail-grid { grid-template-columns: 1fr; }
  .fund-detail-side { position: static; }
  .fund-detail-nav { text-align: left; }
}

/* ---------- Compare (interactive redesign) ---------- */
.cmp-builder { max-width: 560px; margin-bottom: 1.5rem; }
.cmp-search { position: relative; }
.cmp-search input {
  width: 100%; padding: .85rem 1.1rem; font-size: 1rem; font-family: var(--ff-body);
  border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
.cmp-search input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,123,110,.12); }
.cmp-search input:disabled { background: var(--bg); cursor: not-allowed; }

/* Autocomplete dropdown — absolute overlay directly under the input */
.cmp-results {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: .3rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 320px; overflow-y: auto;
}
.cmp-results li { margin: 0; }
.cmp-results button {
  display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: .6rem .75rem; border-radius: 8px; font: inherit; font-size: .95rem; line-height: 1.35; color: var(--ink);
}
.cmp-results button:hover { background: var(--bg); color: var(--teal); }
.cmp-result-empty { padding: .7rem .75rem; color: var(--muted); font-size: .9rem; }
.cmp-hint { margin-top: .6rem; font-size: .85rem; }
.cmp-loading { padding: 1rem 0; color: var(--muted); }

.cmp-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); }
table.cmp-grid { width: 100%; border-collapse: collapse; min-width: 520px; }
table.cmp-grid th, table.cmp-grid td { padding: .85rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.cmp-grid thead th { background: var(--bg); position: sticky; top: 0; }
table.cmp-grid .cmp-metric {
  color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; left: 0; background: var(--surface); z-index: 2;
}
table.cmp-grid thead .cmp-metric { background: var(--bg); z-index: 3; }
.cmp-fund-name { font-weight: 700; line-height: 1.3; font-family: var(--ff-head); color: var(--ink); text-decoration: none; }
.cmp-fund-name:hover { color: var(--teal); }
.cmp-fund-house { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.cmp-remove { display: inline-block; margin-top: .4rem; border: 0; background: none; color: var(--rose); font-size: .75rem; cursor: pointer; padding: 0; }
.cmp-remove:hover { text-decoration: underline; }
.cmp-nav { font-family: var(--ff-mono); font-weight: 700; color: var(--teal); }
.cmp-sub { font-size: .75rem; color: var(--muted); }
.cmp-ret { font-family: var(--ff-mono); font-weight: 700; }
.cmp-ret-row td { background: rgba(13,123,110,.02); }
.cmp-pill { display: inline-block; margin-left: .4rem; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .4rem; border-radius: 100px; vertical-align: middle; }
.cmp-pill.best { background: rgba(22,163,74,.14); color: var(--green); }
.cmp-pill.worst { background: rgba(220,38,38,.12); color: var(--red); }

.cmp-empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.cmp-empty-emoji { font-size: 2.5rem; margin-bottom: .5rem; }
.cmp-eg { border: 0; background: none; color: var(--teal); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.cmp-eg:hover { text-decoration: underline; }
