/* Bio-age trends viewer — page-specific styles.
 *
 * Mirrors the visual idiom of bio-age.html / what-if.html (warm
 * cream surface, deep-teal accents, soft shadows, rounded corners).
 * Tokens come from main.css; nothing here introduces a new palette.
 */

/* Page shell ------------------------------------------------------- */

.trends-page {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  padding: 116px 0 80px;
  overflow: hidden;
}
.trends-page::before,
.trends-page::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.40;
  z-index: -1;
  pointer-events: none;
}
.trends-page::before {
  width: 520px; height: 520px; top: -160px; left: -180px;
  background: radial-gradient(circle, rgba(116, 199, 186, 0.55), transparent 70%);
}
.trends-page::after {
  width: 600px; height: 600px; top: 80px; right: -240px;
  background: radial-gradient(circle, rgba(14, 132, 121, 0.30), transparent 70%);
}

.trends-shell {
  width: min(880px, calc(100% - 2.5rem));
  margin: 0 auto;
  display: grid;
  gap: 22px;
}

/* Hero ------------------------------------------------------------- */

.trends-hero { text-align: center; padding: 8px 0 4px; }
.trends-hero .pill {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(14, 132, 121, 0.10);
  color: var(--teal-700);
  border-radius: var(--r-full);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.trends-hero h1 {
  font-size: clamp(2.2rem, 4.8vw, 3.2rem);
  line-height: 1.05;
  margin: 0 0 0.8rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.trends-hero .lede {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--ink-3);
  font-size: 1.08rem;
  line-height: 1.5;
}

/* Card primitive --------------------------------------------------- */

.trends-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(20px, 3.2vw, 28px);
  box-shadow: var(--shadow-sm);
}
.trends-card h2 {
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.trends-card-sub {
  margin: 0 0 1rem;
  color: var(--ink-4);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Hero stat row ---------------------------------------------------- */

.trends-stats {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 540px) {
  .trends-stats { grid-template-columns: 1.2fr 1fr 1fr; }
}

.trends-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: grid;
  gap: 4px;
}
.trends-stat-primary {
  background: linear-gradient(140deg, var(--teal-500) 0%, var(--teal-700) 100%);
  color: white;
  border: 0;
  box-shadow: 0 12px 30px rgba(7, 86, 79, 0.16);
}
.trends-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--ink-4);
}
.trends-stat-primary .trends-stat-label { color: rgba(255,255,255,0.8); }

.trends-stat-value {
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.trends-stat-primary .trends-stat-value { color: white; }
.trends-stat-sub {
  font-size: 0.82rem;
  color: var(--ink-4);
}
.trends-stat-primary .trends-stat-sub { color: rgba(255,255,255,0.78); }

.trends-stat-gap .gap-arrow {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink-4);
  margin-right: 2px;
}
.trends-stat-gap.gap-better .gap-arrow,
.trends-stat-gap.gap-better .trends-stat-value { color: var(--teal-700); }
.trends-stat-gap.gap-worse .gap-arrow,
.trends-stat-gap.gap-worse .trends-stat-value { color: var(--crimson-500); }

/* Trajectory commentary ------------------------------------------- */

.trends-commentary {
  margin: 6px 4px 0;
  padding: 14px 18px;
  background: rgba(14, 132, 121, 0.06);
  border-left: 3px solid var(--teal-500);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--ink-2);
  font-size: 0.97rem;
  line-height: 1.5;
}
.trends-commentary:empty { display: none; }

/* Chart card ------------------------------------------------------- */

.trends-chart-card { padding-bottom: 8px; }

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

.trends-range {
  display: inline-flex;
  background: var(--bg-2);
  border-radius: var(--r-full);
  padding: 3px;
  gap: 2px;
}
.range-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 6px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.range-btn:hover { color: var(--ink); }
.range-btn:focus-visible {
  outline: 2px solid var(--teal-500);
  outline-offset: 2px;
}
.range-btn.is-active {
  background: var(--surface);
  color: var(--teal-700);
  box-shadow: var(--shadow-xs);
}

.trends-chart-legend {
  display: flex;
  gap: 18px;
  margin: 4px 0 12px;
  font-size: 0.78rem;
  color: var(--ink-4);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  width: 14px; height: 3px; border-radius: 2px;
  display: inline-block;
}
.legend-bio {
  background: linear-gradient(90deg, #0E8479, #07564F);
  height: 3px;
}
.legend-chrono {
  background: repeating-linear-gradient(90deg, #A6AEAE 0 4px, transparent 4px 8px);
  height: 2px;
  margin-top: 1px;
}

.trends-chart-host {
  position: relative;
  width: 100%;
  margin-top: 6px;
}
.trends-chart-svg {
  width: 100%;
  height: 280px;
  display: block;
}
.chart-grid {
  stroke: rgba(14, 30, 30, 0.06);
  stroke-width: 1;
}
.chart-axis-label {
  font-size: 11px;
  fill: var(--ink-4);
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.chart-dot { transition: r 120ms ease; }
.chart-hit:hover + .chart-dot,
.chart-hit:focus + .chart-dot { r: 5; }

.trends-chart-empty {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-4);
  font-size: 0.92rem;
  background: var(--bg-2);
  border-radius: var(--r-md);
  margin-top: 6px;
}

/* Tooltip ---------------------------------------------------------- */

.trends-tooltip {
  position: absolute;
  background: var(--ink);
  color: white;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  min-width: 140px;
  z-index: 5;
  line-height: 1.4;
}
.tt-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: rgba(255,255,255,0.9);
  font-size: 0.78rem;
}
.tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,0.85);
}
.tt-row strong {
  margin-left: auto;
  color: white;
  font-weight: 600;
}
.tt-swatch {
  width: 10px;
  height: 2px;
  display: inline-block;
  border-radius: 1px;
}
.tt-bio { background: linear-gradient(90deg, #0E8479, #07564F); height: 3px; }
.tt-chrono {
  background: repeating-linear-gradient(90deg, #A6AEAE 0 3px, transparent 3px 6px);
}

/* Best-day banner -------------------------------------------------- */

.trends-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(242, 169, 59, 0.10), rgba(14, 132, 121, 0.06));
  border: 1px solid rgba(242, 169, 59, 0.22);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.banner-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(242, 169, 59, 0.16);
  color: var(--amber-500);
  display: flex;
  align-items: center;
  justify-content: center;
}
.banner-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.banner-copy strong {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.98rem;
}
.banner-copy span {
  color: var(--ink-4);
  font-size: 0.86rem;
}

/* Domain breakdown ------------------------------------------------- */

.trends-domain-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
@media (min-width: 540px) {
  .trends-domain-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 760px) {
  .trends-domain-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.trends-domain {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.trends-domain:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.trends-domain-name {
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.trends-domain-impact {
  font-size: 0.85rem;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.domain-arrow { font-weight: 700; font-size: 0.95rem; }

.trends-domain-younger { border-color: rgba(14, 132, 121, 0.24); background: rgba(14, 132, 121, 0.04); }
.trends-domain-younger .domain-arrow,
.trends-domain-younger .trends-domain-impact { color: var(--teal-700); }

.trends-domain-older { border-color: rgba(201, 52, 58, 0.24); background: rgba(201, 52, 58, 0.04); }
.trends-domain-older .domain-arrow,
.trends-domain-older .trends-domain-impact { color: var(--crimson-500); }

.trends-domain-neutral .domain-arrow { color: var(--ink-5); }

/* CTA -------------------------------------------------------------- */

.trends-cta {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(180deg, var(--surface), rgba(248, 253, 250, 0.7));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}
.trends-cta-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
}
.trends-cta-text strong { color: var(--ink); font-weight: 600; }
.trends-cta-text span {
  color: var(--ink-3);
  font-size: 0.94rem;
  line-height: 1.4;
}

/* Anonymous (logged-out) --------------------------------------------*/

.trends-anon-card {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(20px, 3vw, 32px);
  box-shadow: var(--shadow-sm);
  align-items: center;
}
@media (min-width: 720px) {
  .trends-anon-card { grid-template-columns: 1.1fr 1fr; }
}
.trends-anon-mock {
  background: linear-gradient(160deg, #F2F8F6 0%, #DDEEEA 100%);
  border-radius: var(--r-md);
  padding: 14px 12px;
  border: 1px solid rgba(14, 132, 121, 0.10);
}
.trends-anon-mock svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
}
.trends-anon-copy h2 {
  font-size: 1.4rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.trends-anon-copy p {
  margin: 0 0 18px;
  color: var(--ink-3);
  line-height: 1.55;
  font-size: 0.98rem;
}
.trends-anon-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.trends-anon-bullets {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  color: var(--ink-3);
  font-size: 0.92rem;
}
.trends-anon-bullets li {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bullet-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal-500);
  flex-shrink: 0;
}

/* Empty state ------------------------------------------------------ */

.trends-empty-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(20px, 3vw, 32px);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.trends-empty-card h2 {
  font-size: 1.4rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.trends-empty-card p {
  margin: 0 auto 18px;
  max-width: 36rem;
  color: var(--ink-3);
  line-height: 1.55;
}
.trends-empty-actions {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Loading skeleton ------------------------------------------------- */

.trends-loading { display: grid; gap: 14px; }
.trends-skel {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-md);
  animation: trends-shimmer 1.5s ease-in-out infinite;
}
.trends-skel-hero { height: 92px; }
.trends-skel-chart { height: 280px; }
.trends-skel-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.trends-skel-domain { height: 78px; }

@keyframes trends-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error state ------------------------------------------------------ */

.trends-error {
  background: rgba(201, 52, 58, 0.05);
  border: 1px solid rgba(201, 52, 58, 0.20);
  border-radius: var(--r-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.trends-error strong {
  color: var(--crimson-500);
  font-weight: 600;
}
.trends-error span {
  color: var(--ink-3);
  font-size: 0.92rem;
  line-height: 1.5;
}
.trends-error-actions { margin-top: 8px; }

/* Reduce motion ---------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .trends-skel { animation: none; }
  .trends-domain { transition: none; }
}
