/* =========================================================
   Dan's Website — styles
   Dark-first palette with a violet → cyan gradient accent
   ========================================================= */

:root,
[data-theme="dark"] {
  --bg: #0b0b14;
  --bg-alt: #11111d;
  --surface: #161625;
  --surface-2: #1d1d30;
  --text: #ececf5;
  --text-muted: #a1a1b8;
  --border: #2a2a40;
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --on-accent: #ffffff;
  --gradient: linear-gradient(120deg, #a78bfa 0%, #22d3ee 100%);
  --terminal-bg: #0d0d18;
  --good: #34d399;
  --warn: #f87171;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --radius: 16px;
  --header-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fbfbfe;
  --bg-alt: #f2f1fa;
  --surface: #ffffff;
  --surface-2: #f6f5fd;
  --text: #15142b;
  --text-muted: #5a5878;
  --border: #e2e0f0;
  --accent: #6d28d9;
  --accent-strong: #6d28d9;
  --gradient: linear-gradient(120deg, #6d28d9 0%, #0891b2 100%);
  --terminal-bg: #15142b;
  --good: #059669;
  --warn: #dc2626;
  --shadow: 0 10px 30px rgba(40, 30, 90, .1);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  transition: background-color .25s, color .25s;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 .6em; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0; padding: 0; list-style: none; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 820px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; padding: 10px 16px; background: var(--accent-strong); color: #fff; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.eyebrow {
  margin-bottom: .6rem;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .8rem 1.35rem;
  font: inherit;
  font-weight: 650;
  border-radius: 12px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, background-color .2s, border-color .2s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { color: #fff; background: var(--gradient); box-shadow: 0 6px 24px rgba(139, 92, 246, .35); }
.btn-primary:hover { box-shadow: 0 8px 30px rgba(139, 92, 246, .5); }
.btn-ghost { color: var(--text); background: transparent; border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-sm { padding: .55rem 1rem; font-size: .925rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.nav { display: flex; align-items: center; gap: 1rem; min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--gradient);
  color: #fff;
}
.nav-links { display: none; margin-left: auto; gap: 1.75rem; }
.nav-links a { color: var(--text-muted); font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.theme-toggle {
  margin-left: auto;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.theme-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 64px 0 72px; }
.hero-glow {
  position: absolute;
  inset: -30% -10% auto auto;
  width: 720px; height: 720px;
  background: radial-gradient(circle 300px at 38% 42%, rgba(139, 92, 246, .35), transparent),
              radial-gradient(circle 260px at 64% 60%, rgba(34, 211, 238, .22), transparent);
  filter: blur(20px);
  pointer-events: none;
}
[data-theme="light"] .hero-glow { opacity: .45; }
.hero-grid { position: relative; display: grid; gap: 2.5rem; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .35rem .85rem;
  font-size: .85rem; font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 25%, transparent); }
.hero h1 { font-size: clamp(2.3rem, 7vw, 4rem); font-weight: 850; margin-top: 1rem; }
.lead { font-size: clamp(1.05rem, 2.2vw, 1.2rem); color: var(--text-muted); max-width: 560px; margin-bottom: 2rem; }
.hero-cta { display: flex; flex-direction: column; gap: .75rem; }

.terminal {
  background: var(--terminal-bg);
  border: 1px solid #2a2a40;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-family: var(--mono);
  font-size: .95rem;
  color: #ececf5;
}
.terminal-bar { display: flex; align-items: center; gap: 7px; padding: 12px 14px; background: #161625; border-bottom: 1px solid #2a2a40; }
.terminal-bar span { width: 11px; height: 11px; border-radius: 50%; background: #3a3a55; }
.terminal-bar span:nth-child(1) { background: #f87171; }
.terminal-bar span:nth-child(2) { background: #fbbf24; }
.terminal-bar span:nth-child(3) { background: #34d399; }
.terminal-bar p { margin: 0 0 0 auto; font-size: .8rem; color: #8b8ba7; }
.terminal-body { padding: 20px 18px 22px; min-height: 150px; }
.t-line { margin: 0 0 .9rem; overflow-wrap: anywhere; }
.t-prompt { color: #a78bfa; font-weight: 700; }
.caret { display: inline-block; width: 9px; height: 1.1em; margin-left: 2px; vertical-align: -3px; background: #22d3ee; animation: blink 1s steps(1) infinite; }
.t-status { margin: 0; min-height: 1.5em; color: #34d399; opacity: 0; transition: opacity .3s; }
.t-status.show { opacity: 1; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section-alt { background: var(--bg-alt); }
.section-head { text-align: center; max-width: 700px; margin: 0 auto 2.75rem; }
.section-head h2 { font-size: clamp(1.7rem, 4.2vw, 2.6rem); font-weight: 800; }
.section-sub { color: var(--text-muted); font-size: 1.075rem; margin: 0; }

/* Steps */
.steps { display: grid; gap: 1.25rem; counter-reset: none; }
.step {
  position: relative;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.step-num {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  margin-bottom: 1rem;
  font-weight: 800;
  color: #fff;
  background: var(--gradient);
  border-radius: 10px;
}
.step h3 { font-size: 1.2rem; }
.step p { color: var(--text-muted); margin: 0; }

/* ---------- Demos ---------- */
.demos { display: grid; gap: 1.25rem; }
.demo {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.demo-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.demo h3 { font-size: 1.25rem; margin-bottom: .35rem; }
.ask { margin: 0; font-size: .9rem; color: var(--text-muted); }
.ask q { font-style: italic; }
.demo-actions { display: flex; gap: .5rem; align-items: center; }
.demo-hint { margin: 1rem 0 0; font-size: .85rem; color: var(--text-muted); text-align: center; }
kbd { padding: .1rem .4rem; font-family: var(--mono); font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; }
select,
.loan input {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
select { padding: .5rem .7rem; }

/* Palette */
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 150px;
  border-radius: 12px;
  overflow: hidden;
  transition: background-color .35s;
}
.swatch-copy {
  position: absolute; inset: 0;
  width: 100%; border: 0;
  background: transparent;
  cursor: copy;
}
.swatch-info {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: .25rem;
  padding: .5rem .55rem;
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 600;
  pointer-events: none;
}
.swatch-lock {
  pointer-events: auto;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  padding: 0;
  color: inherit;
  background: rgba(255, 255, 255, .18);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.swatch-lock svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.swatch-lock[aria-pressed="true"] { background: rgba(0, 0, 0, .35); color: #fff; }

/* Reaction test */
.react-pad {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  width: 100%;
  min-height: 190px;
  padding: 1.5rem;
  font: inherit;
  color: #fff;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s;
  background: #4c3a8f;
}
.react-pad[data-state="waiting"] { background: #b4373f; }
.react-pad[data-state="go"] { background: #059669; }
.react-pad[data-state="early"] { background: #92400e; }
.react-big { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; }
.react-small { font-size: .9rem; opacity: .9; }
.react-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: 1rem; text-align: center; }
.react-stats p { margin: 0; padding: .6rem; font-size: .8rem; color: var(--text-muted); background: var(--surface-2); border-radius: 10px; }
.react-stats strong { display: block; font-size: 1.05rem; color: var(--text); }

/* Loan calculator */
.loan { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1.25rem; }
.loan label { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--text-muted); min-width: 0; }
.input-prefix, .input-suffix { position: relative; display: flex; align-items: center; }
.loan input { width: 100%; min-width: 0; padding: .55rem .6rem; font-size: .95rem; }
.input-prefix input { padding-left: 1.4rem; }
.input-suffix input { padding-right: 2.2rem; }
.input-prefix > span[aria-hidden], .input-suffix > span[aria-hidden] { position: absolute; color: var(--text-muted); font-size: .85rem; pointer-events: none; }
.input-prefix > span[aria-hidden] { left: .6rem; }
.input-suffix > span[aria-hidden] { right: .6rem; }
.loan input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.loan input[aria-invalid="true"] { border-color: var(--warn); }
.loan-result { display: flex; align-items: center; gap: 1.25rem; }
.donut { flex: 0 0 120px; width: 120px; height: 120px; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 16; }
.donut-track { stroke: #22d3ee; }
.donut-principal { stroke: #8b5cf6; stroke-linecap: butt; transition: stroke-dasharray .5s ease; }
.loan-figures p { margin: 0 0 .25rem; font-size: .9rem; color: var(--text-muted); }
.loan-figures strong { color: var(--text); }
.loan-monthly span { display: block; font-size: 1.9rem; font-weight: 800; line-height: 1.1; color: var(--text); }
.loan-monthly small { font-size: .85rem; }
.loan-total { margin-top: .4rem !important; padding-top: .4rem; border-top: 1px solid var(--border); }
.key { display: inline-block; width: 10px; height: 10px; margin-right: .4rem; border-radius: 3px; }
.key-principal { background: #8b5cf6; }
.key-interest { background: #22d3ee; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--gradient);
  border-radius: 2px;
}
.timeline li { position: relative; padding-bottom: 2rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: calc(-2rem + 1px);
  top: .35rem;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
}
.timeline h3 { font-size: 1.15rem; margin-bottom: .4rem; }
.timeline p { margin: 0; color: var(--text-muted); }

/* ---------- Cards ---------- */
.cards { display: grid; gap: 1.25rem; }
.card {
  padding: 1.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform .25s, border-color .25s;
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.card svg {
  width: 44px; height: 44px;
  padding: 10px;
  margin-bottom: 1rem;
  fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  background: var(--gradient);
  border-radius: 12px;
}
.card h3 { font-size: 1.15rem; }
.card p { margin: 0; color: var(--text-muted); }

/* ---------- Footer ---------- */
.site-footer { padding: 2rem 0; border-top: 1px solid var(--border); font-size: .9rem; color: var(--text-muted); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; }
.footer-inner p { margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  z-index: 300;
  padding: .7rem 1.1rem;
  font-size: .9rem; font-weight: 600;
  color: #fff;
  background: #15142b;
  border: 1px solid #2a2a40;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 560px) {
  .palette { grid-template-columns: 1fr; }
  .swatch { min-height: 64px; }
  .loan { grid-template-columns: 1fr; }
  .loan-result { flex-direction: column; align-items: flex-start; }
}

@media (min-width: 560px) {
  .hero-cta { flex-direction: row; flex-wrap: wrap; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 860px) {
  .nav-links { display: flex; }
  .theme-toggle { margin-left: 1rem; }
  .hero { padding: 104px 0 112px; }
  .hero-grid { grid-template-columns: 1.15fr 1fr; gap: 3.5rem; }
  .section { padding: 100px 0; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .demos { grid-template-columns: repeat(2, 1fr); }
  .demo-wide { grid-column: 1 / -1; }
  .swatch { min-height: 190px; }
  .cards { grid-template-columns: repeat(3, 1fr); }
}

/* Touch screens have no Space bar */
@media (hover: none) {
  .kbd-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}
