/* ============================================================
   Shared core styles for bhartendrasingh.com
   Loaded by every page (index, /now, /writing/*)
   ============================================================ */

:root {
  /* INSTITUTIONAL (default) — deep navy / bone / brass */
  --bg:        #EFE9DB;
  --bg-2:      #E5DDC9;
  --paper:     #F8F4E9;
  --deep:      #0B1F3A;
  --deep-2:    #07172C;
  --ink:       #0B1F3A;
  --ink-2:     #3B4A63;
  --ink-3:     #7B8497;
  --rule:      #D5CCB6;
  --rule-2:    #1B2C46;
  --accent:    #A8803F;
  --accent-2:  #8E6A2E;
  --accent-soft: #EDE2CB;

  --display: "Newsreader", "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --body:    "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --serif:   "Newsreader", Georgia, serif;
  --mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --display-weight: 500;
  --display-tracking: -0.022em;

  --maxw: 1240px;
  --gut:  clamp(20px, 4vw, 56px);
}

[data-theme="quant"] {
  --bg: #0E0E0C; --bg-2: #161613; --paper: #1A1A17;
  --deep: #050504; --deep-2: #000000;
  --ink: #F4F1E8; --ink-2: #B4AFA1; --ink-3: #6E6A5E;
  --rule: #2A2A24; --rule-2: #2A2A24;
  --accent: #FF5B1F; --accent-2: #E0481A; --accent-soft: #2A1A12;
  --display: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --serif:   "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --display-weight: 600;
  --display-tracking: -0.04em;
}

[data-theme="editorial"] {
  --bg: #EDE6D6; --bg-2: #E2D9C4; --paper: #F7F2E5;
  --deep: #1A1310; --deep-2: #0F0A08;
  --ink: #1A1310; --ink-2: #4A3F3A; --ink-3: #8B8079;
  --rule: #D5C9B0; --rule-2: #2A211C;
  --accent: #7A1F2B; --accent-2: #5C141E; --accent-soft: #E8D9D2;
  --display: "Spectral", "Source Serif 4", Georgia, serif;
  --body:    "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --serif:   "Spectral", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
::selection { background: var(--accent); color: var(--paper); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gut); }

/* Skip link */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper);
  padding: 10px 14px; border-radius: 0 0 8px 0;
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  z-index: 100;
}
.skip:focus { left: 0; }

/* Reveal animation */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .9s cubic-bezier(.2,.7,.2,1), transform .9s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .08s; }
.reveal.d2 { transition-delay: .16s; }
.reveal.d3 { transition-delay: .24s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ============================================================
   Nav (shared across all pages)
   ============================================================ */
.topnav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background .3s ease;
}
.topnav.stuck { border-bottom-color: var(--rule); }
.topnav .inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px var(--gut);
  max-width: var(--maxw); margin: 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; font-family: var(--display); font-weight: 600; letter-spacing: -.01em; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; transform: translateY(-1px); }
.brand .name { font-size: 17px; }
.brand .sub  { font-family: var(--mono); font-size: 11px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
.nav-links { display: flex; gap: 24px; font-size: 14px; color: var(--ink-2); }
.nav-links a { position: relative; }
.nav-links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 1px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform .35s ease;
}
.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after { transform: scaleX(1); }
.nav-links a[aria-current="page"] { color: var(--ink); }
.nav-cta {
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  padding: 9px 14px; border: 1px solid var(--ink); border-radius: 999px;
  transition: background .25s ease, color .25s ease;
  white-space: nowrap;
}
.nav-cta:hover { background: var(--ink); color: var(--paper); }
.nav-actions { display: flex; align-items: center; gap: 14px; }
.theme-switch {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px; border: 1px solid var(--rule); border-radius: 999px;
  background: color-mix(in oklab, var(--paper) 60%, transparent);
}
.theme-switch button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 4px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s ease;
}
.theme-switch button:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
.theme-switch button[aria-selected="true"] { background: var(--ink); }
.theme-switch .sw {
  width: 18px; height: 18px; border-radius: 50%;
  display: block; position: relative; overflow: hidden;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--ink) 12%, transparent) inset;
}
.theme-switch .sw-inst   { background: linear-gradient(135deg, #0B1F3A 0 50%, #A8803F 50% 100%); }
.theme-switch .sw-quant  { background: linear-gradient(135deg, #0E0E0C 0 50%, #FF5B1F 50% 100%); }
.theme-switch .sw-ed     { background: linear-gradient(135deg, #EDE6D6 0 50%, #7A1F2B 50% 100%); }
@media (max-width: 900px) {
  .theme-switch { display: none; }
  .nav-links { display: none; }
}
@media (max-width: 480px) {
  .topnav .inner { padding: 14px var(--gut); }
  .brand .sub { display: none; }
  .nav-cta { padding: 8px 12px; font-size: 11px; }
}

/* ============================================================
   Buttons (shared)
   ============================================================ */
.btn {
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  padding: 11px 18px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .25s ease, color .25s ease, border-color .25s ease, transform .25s ease;
}
.btn-primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); transform: translateY(-1px); }

/* ============================================================
   Section primitives (shared)
   ============================================================ */
section { padding: clamp(56px, 8vw, 104px) 0; position: relative; }
.section-head {
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 2.2fr);
  gap: clamp(24px, 5vw, 80px); align-items: end;
  margin-bottom: clamp(32px, 4vw, 56px);
}
@media (max-width: 760px) { .section-head { grid-template-columns: 1fr; gap: 16px; } }
.section-head .num { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; color: var(--ink-3); text-transform: uppercase; }
.section-head h2 {
  font-family: var(--display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking);
  font-size: clamp(30px, 4.4vw, 56px); line-height: 1.04; margin: 0;
  text-wrap: balance;
}
.section-head h2 em { font-family: var(--serif); font-style: italic; font-weight: 500; color: var(--accent); }
[data-theme="quant"] .section-head h2 em { font-style: normal; color: var(--accent); }
.section-head .lead {
  font-family: var(--body); font-weight: 400;
  font-size: clamp(17px, 1.4vw, 19px); color: var(--ink-2); max-width: 56ch; line-height: 1.55;
}
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow .bar { width: 28px; height: 1px; background: var(--accent); }

/* ============================================================
   Footer (shared)
   ============================================================ */
footer.foot {
  background: var(--deep-2); color: #8C8377; padding: 28px 0;
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
}
footer.foot .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
footer.foot a:hover { color: var(--accent); }
