/* ============================================
   KALSHI RESEARCH ASSISTANT — Main Stylesheet
   Reset · Variables · Typography · Base · Layout
   ============================================ */

/* --- Reset --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--text-primary);
  background-color: var(--bg-deep);
  overflow-x: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

ul,
ol {
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* --- Design Tokens --- */
:root {
  /* Surface palette — warm charcoal scale */
  --bg-deep: #110F0C;
  --bg-surface: #181612;
  --bg-elevated: #211E19;
  --bg-card: #1C1A15;
  --bg-card-hover: #23201A;

  /* Borders */
  --border: #2A2621;
  --border-light: #35302A;

  /* Text */
  --text-primary: #F0EBE3;
  --text-secondary: #A89F94;
  --text-muted: #6B6359;

  /* Brand accent — violet */
  --accent: #7B68EE;
  --accent-dim: rgba(123, 104, 238, 0.12);
  --accent-glow: rgba(123, 104, 238, 0.06);

  /* Status colors */
  --success: #50C878;
  --warning: #D4A026;
  --error: #FF6B6B;
  --pending: #A89F94;

  /* Typography */
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Manrope', 'Helvetica Neue', sans-serif;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 6rem;
  --space-2xl: 8rem;

  /* Layout */
  --container-max: 1140px;
  --container-pad: 1.5rem;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 0.2s;
  --duration-normal: 0.4s;
  --duration-slow: 0.7s;

  /* Depth */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* --- Typography Scale --- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2.8rem, 7vw, 5.5rem); }
h2 { font-size: clamp(2rem, 4vw, 3rem); }
h3 { font-size: clamp(1.3rem, 2.5vw, 1.7rem); }
h4 { font-size: clamp(1.05rem, 1.5vw, 1.2rem); }

p {
  color: var(--text-secondary);
  max-width: 65ch;
}

small {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

section {
  padding-block: var(--space-2xl);
}

/* --- Section Labels --- */
.section-label {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.section-heading {
  margin-bottom: var(--space-lg);
}

/* --- Utility Classes --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-accent {
  color: var(--accent);
}

.text-muted {
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

/* --- Scroll Animations --- */
[data-animate] {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
}

[data-animate].visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delays */
[data-animate-delay="1"] { transition-delay: 0.1s; }
[data-animate-delay="2"] { transition-delay: 0.2s; }
[data-animate-delay="3"] { transition-delay: 0.3s; }
[data-animate-delay="4"] { transition-delay: 0.4s; }
[data-animate-delay="5"] { transition-delay: 0.5s; }

/* --- Grain Texture Overlay --- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* --- Selection --- */
::selection {
  background: var(--accent);
  color: var(--bg-deep);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Focus Styles --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  :root {
    --container-pad: 1.25rem;
    --space-2xl: 5rem;
    --space-xl: 4rem;
  }

  section {
    padding-block: var(--space-xl);
  }
}
