/* Canadian Retirement Planner — faultycamera-inspired theme.
   Purple-first, cinematic, rounded cards, dark surfaces. */

:root {
  --bg: #120b1e;
  --bg-deep: #0b0713;
  --bg-raised: #1a1028;
  --bg-card: #221636;
  --bg-card-alt: #1b1129;
  --line: #392954;
  --line-strong: #4b356d;
  --text: #efe9fb;
  --text-dim: #b2a0d6;
  --text-muted: #8675a7;
  --purple: #8b5cf6;
  --purple-soft: #a78bfa;
  --purple-pale: #d8b4fe;
  --purple-deep: #6d28d9;
  --ok: #8be28b;
  --warn: #ff9f8c;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 18px 48px -20px rgba(14, 7, 28, 0.8);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(ellipse 60% 45% at 50% -8%, rgba(139, 92, 246, 0.24), transparent 62%),
    radial-gradient(ellipse 36% 35% at 90% 100%, rgba(109, 40, 217, 0.20), transparent 64%),
    linear-gradient(180deg, var(--bg-deep), var(--bg));
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(216, 180, 254, 0.05) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.24;
  mix-blend-mode: screen;
}

::selection { background: var(--purple-deep); color: #fff; }
a { color: inherit; }

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2rem;
  background: rgba(18, 11, 30, 0.74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(58, 42, 85, 0.35);
}

.nav-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.nav-brand span { color: var(--purple-soft); }
.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  margin-left: 1.6rem;
  font-size: 0.95rem;
  position: relative;
  transition: color 0.25s var(--ease);
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%; bottom: -4px;
  height: 2px;
  background: var(--purple);
  transition: right 0.3s var(--ease);
}
.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after { right: 0; }

.hero {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  padding: 6rem 1.5rem 4rem;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(139, 92, 246, 0.18), transparent 65%),
    radial-gradient(ellipse 38% 32% at 82% 92%, rgba(109, 40, 217, 0.16), transparent 68%);
  pointer-events: none;
}
.hero-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  background-image: radial-gradient(rgba(196, 181, 253, 0.055) 1px, transparent 1px);
  background-size: 3px 3px;
  animation: grain 1.2s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(1px, 1px); }
  100% { transform: translate(0, 0); }
}
.hero-inner {
  max-width: 880px;
  position: relative;
  z-index: 1;
}
.hero-kicker,
.section-kicker {
  color: var(--purple-soft);
  text-transform: uppercase;
  letter-spacing: 0.34em;
  font-size: 0.78rem;
  margin: 0 0 0.65rem;
}
.hero-title {
  font-size: clamp(2.7rem, 9vw, 5.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.02;
  margin: 0 0 1.8rem;
}
.glitch {
  position: relative;
  display: inline-block;
  background: linear-gradient(120deg, var(--purple-pale), var(--purple), var(--purple-pale));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sheen 7s var(--ease) infinite;
}
@keyframes sheen {
  0%, 100% { background-position: 0% 0; }
  50% { background-position: 100% 0; }
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.glitch::before { color: #e9d5ff; animation: flick-a 6s steps(1) infinite; }
.glitch::after { color: #7c3aed; animation: flick-b 6s steps(1) infinite; }
@keyframes flick-a {
  0%, 92.9%, 95.1%, 100% { opacity: 0; transform: none; }
  93% { opacity: 0.65; transform: translate(-3px, 1px); }
  94% { opacity: 0.38; transform: translate(2px, -1px); }
}
@keyframes flick-b {
  0%, 93.4%, 95.6%, 100% { opacity: 0; transform: none; }
  93.5% { opacity: 0.6; transform: translate(3px, -1px); }
  94.5% { opacity: 0.34; transform: translate(-2px, 2px); }
}
.hero-quote {
  margin: 0 auto;
  max-width: 760px;
}
.hero-quote p {
  font-size: clamp(1.05rem, 2.6vw, 1.35rem);
  font-style: italic;
  color: var(--purple-pale);
  line-height: 1.7;
}
.hero-sub,
.section-lead {
  max-width: 640px;
  margin: 1.35rem auto 0;
  color: var(--text-dim);
  font-size: 0.98rem;
}
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2.3rem;
  padding: 0.76rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--purple-pale);
  text-decoration: none;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease), transform 0.3s var(--ease);
}
.hero-cta:hover {
  border-color: var(--purple);
  background: rgba(139, 92, 246, 0.12);
  transform: translateY(2px);
}
.hero-cta svg { animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }

main {
  position: relative;
  z-index: 1;
}
.section {
  padding: 6rem 1.5rem;
}
.section-alt {
  background: rgba(26, 16, 40, 0.86);
  border-top: 1px solid rgba(58, 42, 85, 0.7);
  border-bottom: 1px solid rgba(58, 42, 85, 0.7);
}
.section-inner {
  max-width: 1080px;
  margin: 0 auto;
}
.section-title {
  font-size: clamp(1.8rem, 4.5vw, 2.7rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}
.planner-layout {
  display: grid;
  gap: 1.4rem;
}
.planner-copy {
  max-width: 720px;
}
.card {
  background: linear-gradient(160deg, rgba(34, 22, 54, 0.96), rgba(27, 17, 41, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.planner-card {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
fieldset {
  border: 1px solid rgba(58, 42, 85, 0.8);
  border-radius: calc(var(--radius) - 2px);
  padding: 1rem;
  margin: 0;
}
fieldset + fieldset { margin-top: 1rem; }
legend {
  font-weight: 700;
  padding: 0 0.5rem;
  font-size: 0.95rem;
  color: var(--purple-pale);
  letter-spacing: 0.02em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 16px;
}
label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
input, select {
  font: inherit;
  color: var(--text);
  background: rgba(11, 7, 19, 0.68);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.78rem 0.85rem;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease);
}
input:hover, select:hover { border-color: var(--line-strong); }
input:focus, select:focus {
  outline: none;
  border-color: var(--purple-soft);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.16);
  background: rgba(11, 7, 19, 0.82);
}
.toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(11, 7, 19, 0.55);
}
.toggle button {
  font: inherit;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 0.75rem 1.05rem;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.toggle button.active {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 1rem;
}
button.primary,
button.secondary {
  font: inherit;
  font-weight: 650;
  border-radius: 999px;
  padding: 0.82rem 1.2rem;
  cursor: pointer;
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease), color 0.25s var(--ease);
}
button.primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  border: 1px solid transparent;
  box-shadow: 0 12px 30px -16px rgba(139, 92, 246, 0.7);
}
button.secondary {
  background: rgba(11, 7, 19, 0.42);
  color: var(--text);
  border: 1px solid var(--line);
}
button.primary:hover,
button.secondary:hover,
.toggle button:hover {
  transform: translateY(-1px);
}
button.secondary:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}
.person-card {
  border: 1px solid rgba(58, 42, 85, 0.85);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.85rem;
  background: rgba(11, 7, 19, 0.28);
}
.person-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.98rem;
  color: var(--purple-pale);
}
.person-card .grid {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
}
.footnote {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.9rem;
}

.results-stack {
  display: grid;
  gap: 1rem;
  margin-top: 1.4rem;
}
#hero.summary-hero {
  background:
    linear-gradient(140deg, rgba(139, 92, 246, 0.20), rgba(27, 17, 41, 0.95)),
    rgba(34, 22, 54, 0.94);
  border-color: rgba(139, 92, 246, 0.35);
}
#hero {
  color: var(--text-dim);
  font-size: 0.98rem;
}
#hero .big {
  display: inline-block;
  font-size: clamp(3rem, 8vw, 4.8rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.04em;
}
#hero .strategy {
  color: var(--purple-pale);
  font-weight: 700;
}
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.18rem 0.72rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge.ok {
  background: rgba(139, 226, 139, 0.12);
  color: var(--ok);
}
.badge.warn {
  background: rgba(255, 159, 140, 0.12);
  color: var(--warn);
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.tile {
  background: linear-gradient(160deg, rgba(34, 22, 54, 0.92), rgba(19, 12, 32, 0.92));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}
.tile .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.tile .value {
  font-size: 1.4rem;
  font-weight: 750;
  margin-top: 0.2rem;
  color: var(--text);
}
.tile .delta {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}
.delta.up { color: var(--ok); }
.delta.down { color: var(--warn); }
.explain p { margin: 0.7rem 0; }
.card-title,
.viz-title {
  font-weight: 750;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
  color: var(--text);
}
.viz-subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.viz-root {
  position: relative;
  padding: 1.4rem;
}
.viz-svg {
  width: 100%;
  height: auto;
  display: block;
}
.viz-grid {
  stroke: rgba(74, 53, 109, 0.9);
  stroke-width: 1;
}
.viz-axis {
  stroke: rgba(91, 67, 128, 0.95);
  stroke-width: 1;
}
.viz-ref {
  stroke: rgba(167, 139, 250, 0.9);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.viz-tick {
  fill: var(--text-muted);
  font-size: 11px;
}
.viz-endlabel {
  fill: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
}
.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0.45rem 0 0.9rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.viz-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.viz-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 2px;
}
.viz-tooltip {
  display: none;
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: rgba(18, 11, 30, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.65);
  padding: 0.75rem 0.9rem;
  font-size: 0.8rem;
  min-width: 160px;
}
.viz-tip-head {
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: var(--text);
}
.viz-tip-foot {
  color: var(--text-dim);
  margin-top: 0.35rem;
  border-top: 1px solid rgba(58, 42, 85, 0.65);
  padding-top: 0.35rem;
}
.viz-tooltip .viz-swatch { margin-right: 5px; }
.viz-tablewrap { overflow-x: auto; }
.viz-table {
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
  width: 100%;
}
.viz-table th,
.viz-table td {
  padding: 0.4rem 0.65rem;
  text-align: right;
  border-bottom: 1px solid rgba(58, 42, 85, 0.65);
  font-variant-numeric: tabular-nums;
}
.viz-table th {
  color: var(--text-dim);
  font-weight: 700;
  position: sticky;
  top: 0;
  background: rgba(34, 22, 54, 0.98);
}
.viz-table td:first-child,
.viz-table th:first-child { text-align: left; }
.linklike {
  background: none;
  border: none;
  color: var(--purple-pale);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  padding: 0;
}
.assumptions {
  margin: 0;
  padding-left: 1.15rem;
}
.assumptions li {
  margin: 0.45rem 0;
  color: var(--text-dim);
}
.footer {
  text-align: center;
  padding: 3.5rem 1.5rem 4rem;
  color: var(--text-dim);
  font-style: italic;
}
.footer-fine {
  font-style: normal;
  font-size: 0.8rem;
  margin-top: 0.5rem;
  opacity: 0.6;
  letter-spacing: 0.1em;
}
.hidden { display: none; }

@media (min-width: 920px) {
  .planner-layout {
    grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
    align-items: start;
  }
  .planner-copy {
    position: sticky;
    top: 6.5rem;
    align-self: start;
  }
}

@media (max-width: 700px) {
  .nav { padding: 0.9rem 1rem; }
  .nav-links a { margin-left: 1rem; }
  .hero { padding: 5.5rem 1rem 3.5rem; }
  .section { padding: 4.5rem 1rem; }
  .card, .viz-root { padding: 1.1rem; }
  .actions { flex-direction: column; }
  button.primary, button.secondary { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-grain,
  .glitch,
  .glitch::before,
  .glitch::after,
  .hero-cta svg {
    animation: none;
  }
}
