/* =========================================================================
   Linesmith Labs — styles.css
   Minimalist quant-finance aesthetic. Dark-primary with a light theme.
   ========================================================================= */

/* ----- Theme tokens ----- */
:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --container: 1120px;
  --gutter: clamp(20px, 5vw, 48px);

  --radius: 12px;
  --radius-sm: 8px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* fluid type scale */
  --fs-hero: clamp(2.85rem, 7vw, 5.75rem);
  --fs-h2: clamp(1.7rem, 3.4vw, 2.6rem);
  --fs-h3: 1.075rem;
  --fs-lead: clamp(1.075rem, 1.9vw, 1.4rem);
  --fs-body: 1rem;
  --fs-small: 0.8125rem;
}

/* Dark (default) */
[data-theme="dark"] {
  --bg: #0a0c10;
  --bg-elev: #10131a;
  --bg-elev-2: #151925;
  --text: #e8ebf2;
  --text-muted: #9aa4b6;
  --text-dim: #69728590;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #5aa2ff;
  --accent-strong: #7cb6ff;
  --accent-contrast: #04122b;
  --grid-line: rgba(255, 255, 255, 0.05);
  --header-bg: rgba(10, 12, 16, 0.72);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 24px 60px -32px rgba(0, 0, 0, 0.8);
}

/* Light */
[data-theme="light"] {
  --bg: #fafbfc;
  --bg-elev: #ffffff;
  --bg-elev-2: #f3f5f9;
  --text: #0d1320;
  --text-muted: #545d6e;
  --text-dim: #8a93a3;
  --border: rgba(13, 19, 32, 0.1);
  --border-strong: rgba(13, 19, 32, 0.18);
  --accent: #1f6feb;
  --accent-strong: #1257c9;
  --accent-contrast: #ffffff;
  --grid-line: rgba(13, 19, 32, 0.05);
  --header-bg: rgba(250, 251, 252, 0.78);
  --shadow: 0 1px 2px rgba(13, 19, 32, 0.04), 0 24px 50px -34px rgba(13, 19, 32, 0.28);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.08; letter-spacing: -0.02em; font-weight: 600; margin: 0; }
p { margin: 0; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent); color: var(--accent-contrast); }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ----- Layout ----- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: clamp(72px, 12vw, 140px);
  position: relative;
}
.section--alt { background: var(--bg-elev); border-block: 1px solid var(--border); }

.mt-xl { margin-top: clamp(36px, 6vw, 64px); }

/* ----- Header ----- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.site-header.is-scrolled { border-bottom-color: var(--border); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 24px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 1.02rem;
  white-space: nowrap;
}
.wordmark__mark { color: var(--accent); flex: none; }
.wordmark__text { color: var(--text); }

.site-nav {
  display: flex;
  gap: 30px;
  margin-left: auto;
  margin-right: 8px;
}
.site-nav a {
  color: var(--text-muted);
  font-size: 0.925rem;
  font-weight: 450;
  position: relative;
  transition: color 0.2s var(--ease);
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -6px;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.28s var(--ease);
}
.site-nav a:hover { color: var(--text); }
.site-nav a:hover::after { transform: scaleX(1); }

.header-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 550;
  font-size: 0.94rem;
  border-radius: var(--radius-sm);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 13px 24px;
  font-weight: 600;
}
.btn--primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn--ghost {
  border-color: var(--border-strong);
  color: var(--text);
  padding: 9px 18px;
  background: transparent;
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--link {
  color: var(--text-muted);
  padding: 13px 6px;
}
.btn--link:hover { color: var(--text); }
.btn--link span { transition: transform 0.2s var(--ease); }
.btn--link:hover span { transform: translateX(3px); }

.header-cta { display: inline-flex; }

/* ----- Mobile menu ----- */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}
.menu-toggle span {
  display: block;
  width: 17px; height: 1.6px;
  margin-inline: auto;
  background: var(--text);
  transition: transform 0.28s var(--ease), opacity 0.2s var(--ease);
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.6px) rotate(-45deg); }

.mobile-nav[hidden] { display: none; }
.mobile-nav {
  display: flex;
  flex-direction: column;
  padding: 8px var(--gutter) 20px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(14px);
}
.mobile-nav a {
  padding: 13px 2px;
  color: var(--text-muted);
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
}
.mobile-nav a:last-child { border-bottom: none; }
.mobile-nav a:hover { color: var(--text); }

/* ----- Hero ----- */
.hero {
  position: relative;
  min-height: min(92vh, 860px);
  display: flex;
  align-items: center;
  padding-block: clamp(80px, 14vw, 160px);
  overflow: hidden;
}
.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.hero__fade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 80% 12%, transparent 40%, var(--bg) 100%),
    linear-gradient(to bottom, transparent 55%, var(--bg) 100%);
}
.hero__inner { position: relative; z-index: 2; max-width: 50rem; }

.kicker {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.kicker::before {
  content: "";
  width: 26px; height: 1px;
  background: var(--accent);
  display: inline-block;
}

.hero__title {
  font-size: var(--fs-hero);
  font-weight: 600;
  letter-spacing: -0.035em;
}
.hero__subhead {
  margin-top: 28px;
  font-size: var(--fs-lead);
  color: var(--text-muted);
  max-width: 38ch;
  line-height: 1.5;
}
.hero__actions {
  margin-top: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ----- Section heads ----- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 28px;
}
.section-index {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.05em;
  padding-top: 4px;
}
.section-title { font-size: var(--fs-h2); }

.lead {
  font-size: var(--fs-lead);
  color: var(--text-muted);
  max-width: 64ch;
  line-height: 1.55;
}

/* ----- Grids ----- */
.grid { display: grid; gap: clamp(16px, 2.2vw, 24px); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

/* ----- Cards ----- */
.card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(22px, 3vw, 32px);
  position: relative;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), background 0.3s var(--ease);
}
.section--alt .card { background: var(--bg); }
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card__num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.card__title { font-size: var(--fs-h3); margin-top: 14px; }
.card--feature .card__title { margin-top: 0; }
.card__body { margin-top: 12px; color: var(--text-muted); font-size: 0.96rem; line-height: 1.6; }

.card--feature {
  padding-top: clamp(26px, 3vw, 34px);
}
.card--feature::before {
  content: "";
  position: absolute;
  top: 0; left: clamp(22px, 3vw, 32px);
  width: 26px; height: 2px;
  background: var(--accent);
}

/* ----- Markets ----- */
.markets {
  list-style: none;
  margin: clamp(36px, 6vw, 64px) 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.market {
  display: flex;
  align-items: baseline;
  gap: clamp(18px, 4vw, 48px);
  padding: clamp(26px, 3.4vw, 38px) 0;
  border-bottom: 1px solid var(--border);
  transition: padding-left 0.3s var(--ease);
}
.market:hover { padding-left: 10px; }
.market__id {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  flex: none;
  width: 3ch;
}
.market__body { display: flex; flex-direction: column; gap: 6px; }
.market__name { font-size: clamp(1.25rem, 2.6vw, 1.8rem); font-weight: 550; letter-spacing: -0.02em; }
.market__desc { color: var(--text-muted); font-size: 1rem; }

/* ----- Principles ----- */
.principle {
  padding-top: 22px;
  border-top: 1px solid var(--border-strong);
}
.principle__title { font-size: 1.15rem; font-weight: 600; }
.principle__body { margin-top: 10px; color: var(--text-muted); font-size: 0.96rem; line-height: 1.6; }

/* ----- Contact ----- */
.section--contact { position: relative; }
.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(28px, 5vw, 64px);
  max-width: 880px;
}
.contact-block { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.contact-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}
.contact-note { color: var(--text-muted); font-size: 0.96rem; line-height: 1.6; }
.contact-email {
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-weight: 550;
  letter-spacing: -0.01em;
  color: var(--text);
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 3px;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
  word-break: break-word;
}
.contact-email:hover { color: var(--accent); border-color: var(--accent); }

/* ----- Footer ----- */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: clamp(48px, 7vw, 80px);
  background: var(--bg);
}
.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.wordmark--footer { font-size: 1.05rem; }
.footer-tagline {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.footer-legal { display: flex; flex-direction: column; gap: 16px; max-width: 76ch; }
.disclaimer { color: var(--text-muted); font-size: var(--fs-small); line-height: 1.65; }
.legal-line { color: var(--text-dim); font-size: var(--fs-small); }
.copyright { color: var(--text-dim); font-size: var(--fs-small); margin-top: 4px; }

/* ----- Reveal animation ----- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }
/* stagger children within a grid/row */
.grid .reveal:nth-child(2) { transition-delay: 0.06s; }
.grid .reveal:nth-child(3) { transition-delay: 0.12s; }
.grid .reveal:nth-child(4) { transition-delay: 0.18s; }

/* ----- Responsive ----- */
@media (max-width: 940px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .site-nav, .header-cta { display: none; }
  .menu-toggle { display: flex; }
}
@media (max-width: 620px) {
  .grid--2, .grid--4 { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
  .hero__title { letter-spacing: -0.03em; }
  .footer-top { flex-direction: column; align-items: flex-start; }
  .section-head { gap: 12px; }
}

/* Section scroll offset for sticky header */
:where(#what, #lab, #markets, #principles, #contact) { scroll-margin-top: 84px; }

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