/* Portfolio Construction Intelligence: shared base.
   Tokens, fonts, body defaults, nav, buttons, badge and shared motion.
   Linked first by both pages (/ and /test). Page-only styles live with each page. */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Nunito:wght@800&display=swap");

:root {
  /* Surfaces and ink */
  --bg: #f5f5f5;
  --panel: #fff;
  --hairline: #00000012;
  --hairline-strong: #0000001f;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --muted: #86868b;
  --faint: #aeaeb2;
  /* Small text uses these, so it reads at 4.5:1 or more on --bg and --panel.
     --muted and --faint stay for lines, dots, rings and icons. */
  --muted-text: #6e6e73;
  --link: #0066cc;
  --accent: #0a84ff;
  --accent-soft: #0a84ff1f;

  /* Check states */
  --ok: #1f9d55;
  --warn: #c98a00;
  --bad: #e5484d;

  /* Quadrants */
  --q-db: #0a84ff; /* deflationary boom */
  --q-ib: #f5a524; /* inflationary boom */
  --q-ix: #e5484d; /* inflationary bust */
  --q-dx: #7c5cff; /* deflationary bust */

  /* Motion */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --dur-fast: 160ms;
  --dur: 300ms;
  --reveal-dur: 700ms;
  --stagger: 60ms;

  /* Type */
  --font-display: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --track-display: -0.085em;
  --track-ui: -0.02em;

  /* Shape */
  --radius-btn: 12px;
  --radius-nav-btn: 10px;
  --radius-card: 20px;
  --gutter: 24px;
  --nav-h: 68px;
  --content-w: 1180px;

  color-scheme: light;
}

/* ---------- Reset and body defaults ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: var(--track-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

::selection { background: var(--accent-soft); }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.display {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: var(--track-display);
  line-height: .95;
}

.num { font-variant-numeric: tabular-nums; }

/* ---------- Nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
}

.nav-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: min(var(--content-w), 100% - 2 * var(--gutter));
  height: 100%;
  margin: 0 auto;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  justify-self: start;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  white-space: nowrap;
}

.nav-mark {
  flex: none;
  width: 22px;
  height: 22px;
  transition: transform 500ms var(--ease-out);
}

.nav-brand:hover .nav-mark { transform: rotate(90deg); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links a {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease-out);
}

.nav-links a:hover { color: var(--text); }

.nav-end { justify-self: end; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.btn:active { transform: translateY(0) scale(.98); }

.btn-glyph {
  flex: none;
  width: 15px;
  height: 15px;
  margin-right: -3px;
  transition: transform var(--dur-fast) var(--ease-out);
}

.btn-dark {
  background: var(--text);
  color: #fff;
}

.btn-dark:hover {
  background: #000;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -8px #0000004d;
}

.btn-dark:hover .btn-glyph { transform: translateX(2px); }

.btn-dark:active {
  transform: translateY(0) scale(.98);
  box-shadow: none;
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-nav-btn);
  font-size: 13px;
  gap: 7px;
}

.btn-sm .btn-glyph { width: 13px; height: 13px; }

.btn-icon {
  width: 36px;
  padding: 0;
}

.btn-icon .btn-glyph { margin: 0; }

.btn-link {
  color: var(--text);
  gap: 9px;
}

.btn-link:hover {
  color: #000;
  transform: translateY(-1px);
}

.btn-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-soft);
  transition:
    transform var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}

.btn-link:hover .btn-dot,
.btn-link[aria-expanded="true"] .btn-dot {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---------- Badge ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px 0 12px;
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-2);
  white-space: nowrap;
  transition:
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

a.badge:hover {
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px -6px #0000001f;
}

.badge-dot {
  position: relative;
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.badge-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  animation: dot-pulse 2.4s var(--ease-out) infinite;
}

.badge-chevron {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--muted);
  transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

a.badge:hover .badge-chevron {
  color: var(--text-2);
  transform: translateX(2px);
}

/* ---------- Footer note (both pages) ---------- */

.site-foot {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--muted-text);
  text-align: center;
}

/* ---------- Shared motion ---------- */

/* Reveal: fade, 12px rise, blur 6px to 0. Set --i on each element for a 60ms stagger. */
.reveal {
  animation: reveal var(--reveal-dur) var(--ease-out) both;
  animation-delay: calc(var(--reveal-base, 0ms) + var(--i, 0) * var(--stagger));
}

.reveal-fade {
  animation: fade-in var(--reveal-dur) var(--ease-out) both;
  animation-delay: calc(var(--reveal-base, 0ms) + var(--i, 0) * var(--stagger));
}

/* Hold reveals while fonts load (class set by page script, removed on load or after a cap). */
.fonts-pending .reveal,
.fonts-pending .reveal-fade { animation-play-state: paused; }

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dot-pulse {
  0% { transform: scale(1); opacity: .55; }
  70%, 100% { transform: scale(2.8); opacity: 0; }
}

/* ---------- Phone width ---------- */

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
    --nav-h: 60px;
  }

  .nav-links { display: none; }
  .nav-inner { grid-template-columns: 1fr auto; }

  /* Nav button keeps its name for screen readers, shows only the glyph. */
  .nav-cta { width: 36px; padding: 0; gap: 0; }
  .nav-cta .btn-glyph { margin: 0; }
  .nav-cta-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---------- Reduced motion: no movement, instant ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }

  .reveal,
  .reveal-fade,
  .badge-dot::after { animation: none !important; }

  .btn:hover,
  .btn:active,
  a.badge:hover,
  .btn-link:hover { transform: none; }

  .nav-brand:hover .nav-mark,
  .btn-dark:hover .btn-glyph,
  a.badge:hover .badge-chevron { transform: none; }
}
