/* ==========================================================================
   sgoswami.com — shared stylesheet
   Newsreader (display) + Public Sans (text). Navy and gold on a warm ground.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;

  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-quiet: #EFECE4;
  --ink: #131A2B;          /* headings */
  --text: #2B3243;         /* body */
  --muted: #555C6B;        /* meta, captions (>= 5.9:1 on every ground) */
  --line: #DCD6C9;
  --accent: #1B2A4A;       /* navy: links, buttons, wordmark */
  --accent-hover: #2C4170;
  --on-accent: #FFFFFF;
  --gold: #87681F;         /* gold that passes 4.5:1 as small text */
  --rule: #B08D3E;         /* decorative gold */
  --focus: #9A7A30;
  --ph-bg: #FBF1D6;        /* placeholder highlight */
  --show-sun: none;        /* theme toggle shows the theme you'd switch to */
  --show-moon: inline;

  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-text: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  --container: 72rem;
  --gutter: 1rem;
  --section-space: clamp(3.5rem, 2.5rem + 5vw, 6.5rem);
  --radius: 4px;
}

/* Dark palette: follows the device setting unless the visitor picked a theme
   with the header toggle (stored as data-theme on <html>). Keep both blocks in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1424;
    --surface: #151D31;
    --surface-quiet: #121A2C;
    --ink: #F3EFE6;
    --text: #D6DAE2;
    --muted: #A3ABBC;
    --line: #283350;
    --accent: #D9BC77;
    --accent-hover: #E8D29C;
    --on-accent: #0E1424;
    --gold: #D9BC77;
    --rule: #B08D3E;
    --focus: #E3C887;
    --ph-bg: #3A3220;
    --show-sun: inline;
    --show-moon: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1424;
  --surface: #151D31;
  --surface-quiet: #121A2C;
  --ink: #F3EFE6;
  --text: #D6DAE2;
  --muted: #A3ABBC;
  --line: #283350;
  --accent: #D9BC77;
  --accent-hover: #E8D29C;
  --on-accent: #0E1424;
  --gold: #D9BC77;
  --rule: #B08D3E;
  --focus: #E3C887;
  --ph-bg: #3A3220;
  --show-sun: inline;
  --show-moon: none;
}
:root[data-theme="light"] { color-scheme: light; }

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }

h1, h2, h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p { margin: 0; }
p + p { margin-top: 1em; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

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

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
@media (min-width: 48em) { :root { --gutter: 2rem; } }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; color: var(--on-accent); }

/* Placeholder text you still need to replace. Remove the class when filled. */
.ph {
  background: var(--ph-bg);
  box-shadow: 0 0 0 1px var(--rule);
  border-radius: 2px;
  padding-inline: 0.2em;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 1.5rem;
  padding-block: 0.75rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.wordmark:hover { color: var(--accent-hover); }

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.4em;
}
.site-nav a:hover { color: var(--accent); text-decoration-color: var(--rule); }

.header-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Theme toggle: only shown when JS is available (html.js). */
.theme-toggle { display: none; }
.js .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.js .theme-toggle:hover { border-color: var(--line); color: var(--accent); }
.theme-toggle__sun { display: var(--show-sun); }
.theme-toggle__moon { display: var(--show-moon); }

.menu-toggle { display: none; }

@media (min-width: 48em) {
  .site-header__inner { flex-wrap: nowrap; }
  .site-nav { margin-left: auto; }
  .header-actions { order: 3; }
}

/* Mobile: the menu button only appears when JS is available (html.js). */
@media (max-width: 47.99em) {
  .site-nav { order: 3; }
  .js .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.875rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font: 500 0.9375rem/1 var(--font-text);
    cursor: pointer;
  }
  .js .menu-toggle:hover { border-color: var(--accent); }

  .menu-toggle__bars,
  .menu-toggle__bars::before,
  .menu-toggle__bars::after {
    display: block;
    width: 16px;
    height: 1.5px;
    background: currentColor;
    transition: transform 0.2s ease, background-color 0.2s ease;
  }
  .menu-toggle__bars { position: relative; }
  .menu-toggle__bars::before,
  .menu-toggle__bars::after { content: ""; position: absolute; left: 0; }
  .menu-toggle__bars::before { top: -5px; }
  .menu-toggle__bars::after { top: 5px; }
  .menu-toggle[aria-expanded="true"] .menu-toggle__bars { background: transparent; }
  .menu-toggle[aria-expanded="true"] .menu-toggle__bars::before { transform: translateY(5px) rotate(45deg); }
  .menu-toggle[aria-expanded="true"] .menu-toggle__bars::after { transform: translateY(-5px) rotate(-45deg); }

  .js .site-nav { display: none; flex-basis: 100%; }
  .js .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; padding-bottom: 0.75rem; }
  .js .site-nav ul { border-top: 1px solid var(--line); padding-top: 0.5rem; }
  .site-nav a { width: 100%; font-size: 1.0625rem; }
}

/* ---------- Shared pieces ---------- */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--gold);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: "";
  width: 2rem;
  height: 2px;
  background: var(--rule);
}

.meta {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.meta .sep { margin-inline: 0.4em; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.5rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}
.button--primary { background: var(--accent); color: var(--on-accent); }
.button--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.button--secondary { background: transparent; color: var(--accent); }
.button--secondary:hover { background: var(--surface); color: var(--accent); }

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--rule);
}
.text-link:hover { text-decoration-color: currentColor; }

.section { padding-block: var(--section-space); border-top: 1px solid var(--line); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-bottom: 2rem;
}
.section-title { font-size: clamp(1.875rem, 1.5rem + 1.4vw, 2.5rem); }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(2.5rem, 1.5rem + 5vw, 6rem) var(--section-space); }
.hero__grid { display: grid; gap: 2rem; align-items: center; }
.hero__photo { justify-self: start; }
.hero__photo img {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-quiet);
}
.hero__text { display: flex; flex-direction: column; gap: 1.25rem; }
.hero__title { max-width: 14em; font-size: clamp(2.25rem, 1.5rem + 3vw, 3.75rem); line-height: 1.08; }.hero__lede { max-width: 36rem; font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem); line-height: 1.6; }
.hero .button-row { margin-top: 0.5rem; }

@media (min-width: 48em) {
  .hero__grid { grid-template-columns: minmax(0, 1fr) 15rem; gap: clamp(2.5rem, 5vw, 4rem); }
  .hero__photo { order: 2; justify-self: stretch; }
  .hero__photo img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 5;
    border-radius: var(--radius);
  }
}
@media (min-width: 64em) { .hero__grid { grid-template-columns: minmax(0, 1fr) 20rem; } }

/* ---------- About ---------- */
.about__grid { display: grid; gap: 3rem; }
@media (min-width: 56em) { .about__grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(3rem, 6vw, 6rem); } }
.about__bio { max-width: 38rem; font-size: 1.125rem; }

.snapshot__title { margin-bottom: 1.25rem; font-family: var(--font-text); line-height: 1.4; }
.timeline { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.timeline li {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding-block: 0.875rem;
  border-bottom: 1px solid var(--line);
}
.timeline__role { color: var(--ink); font-weight: 600; line-height: 1.4; }
.timeline__org { display: block; font-weight: 400; }
.timeline__years { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.education { margin-top: 1.25rem; color: var(--muted); font-size: 0.9375rem; line-height: 1.6; }

/* ---------- Selected work ---------- */
.work__intro { max-width: 40rem; margin-top: 0.75rem; color: var(--muted); font-size: 1.0625rem; }
.work__list {
  display: grid;
  gap: 0 clamp(2rem, 5vw, 4rem);
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 48em) { .work__list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.work__item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--line);
}
.work__org { color: var(--gold); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.work__title { font-size: clamp(1.25rem, 1.15rem + 0.45vw, 1.5rem); line-height: 1.25; }
.work__desc { max-width: 34rem; color: var(--text); font-size: 0.9375rem; line-height: 1.6; }

.earlier__title { margin: 2.5rem 0 0.25rem; font-family: var(--font-text); line-height: 1.4; }
.earlier__list {
  display: grid;
  gap: 0 clamp(2rem, 5vw, 4rem);
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 48em) { .earlier__list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.earlier__list li {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-block: 1rem;
  border-top: 1px solid var(--line);
}
.earlier__name {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.3;
}
.earlier__desc { max-width: 34rem; color: var(--muted); font-size: 0.875rem; line-height: 1.55; }

/* ---------- Post cards (home feature + writing list) ---------- */
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: clamp(1.5rem, 1rem + 2vw, 2.5rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
}
.post-card:hover { border-color: var(--rule); }
.post-card__title { font-size: clamp(1.5rem, 1.25rem + 0.9vw, 1.875rem); text-wrap: pretty; }
.post-card__title a { color: var(--ink); text-decoration: none; }
/* The title link covers the whole card. */
.post-card__title a::after { content: ""; position: absolute; inset: 0; }
.post-card:hover .post-card__title a { color: var(--accent); }
.post-card__title a:focus-visible { outline: none; }
.post-card:has(.post-card__title a:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.post-card__summary { flex: 1; }
.post-card__more { margin-top: 0.5rem; color: var(--accent); font-weight: 600; }

/* ---------- Ventures (deliberately quieter) ---------- */
.ventures { background: var(--surface-quiet); }
.ventures .section-title { font-size: clamp(1.5rem, 1.3rem + 0.9vw, 1.875rem); }
.ventures__intro { max-width: 40rem; margin-top: 0.75rem; color: var(--muted); font-size: 1rem; }

.ventures__grid {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 48em) { .ventures__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64em) { .ventures__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; } }

.venture {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  padding: 1.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.venture__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.venture__label { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.venture__tag {
  padding: 0.125rem 0.625rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.venture__title { margin-top: 0.25rem; font-size: 1.375rem; font-weight: 600; }
.venture__desc { flex: 1; color: var(--text); font-size: 0.9375rem; line-height: 1.6; }
.venture .text-link { align-self: flex-start; font-size: 0.9375rem; }

/* ---------- Contact ---------- */
.contact__inner { max-width: 44rem; }
.contact__title { font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem); }
.contact__lede { margin-top: 1rem; font-size: 1.125rem; }
.contact__links {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.contact__links li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.contact__links .meta { font-size: 0.75rem; }
.contact__links a {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  overflow-wrap: anywhere;
  font-size: 1.0625rem;
  font-weight: 500;
  text-decoration-color: var(--rule);
}

/* ---------- Writing list page ---------- */
.page-intro { padding-block: clamp(2.5rem, 1.5rem + 5vw, 5.5rem) clamp(2rem, 1.5rem + 2vw, 3rem); }
.page-intro__title { font-size: clamp(2.5rem, 1.6rem + 3.6vw, 4rem); }
.page-intro__lede { max-width: 38rem; margin-top: 1rem; font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem); }
.page-intro__aside { margin-top: 1rem; color: var(--muted); font-size: 0.9375rem; }
.page-intro__aside a { display: inline-flex; align-items: center; min-height: 44px; }

.post-list { display: grid; gap: 1.25rem; margin: 0; padding: 0; list-style: none; }
@media (min-width: 56em) { .post-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.post-list > li { display: flex; }
.post-list > li > .post-card { flex: 1; }

/* ---------- Article ---------- */
.article { padding-block: clamp(2.5rem, 1.5rem + 5vw, 5rem) var(--section-space); }
.article__inner { max-width: 42rem; margin-inline: auto; }   /* ~68 characters per line */
.article__title { margin-top: 1rem; font-size: clamp(2.125rem, 1.4rem + 3vw, 3.25rem); line-height: 1.1; }
.article__subtitle {
  margin-top: 1.25rem;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  font-style: italic;
  line-height: 1.45;
}
.article__byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 1.75rem;
  padding-block: 1rem;
  border-block: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9375rem;
}
.article__byline strong { color: var(--ink); font-weight: 600; }
.article__disclosure { margin-top: 1.5rem; color: var(--muted); font-size: 0.9375rem; font-style: italic; }

.prose { margin-top: 2rem; font-size: 1.1875rem; line-height: 1.75; }
.prose p + p { margin-top: 1.25em; }
.prose h2 { margin: 2.25em 0 0.6em; font-size: 1.75rem; }
.prose h3 { margin: 1.75em 0 0.5em; font-size: 1.375rem; }
.prose a { text-decoration-color: var(--rule); }
.prose a:hover { text-decoration-color: currentColor; }
.prose blockquote {
  margin: 2em 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--rule);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-style: italic;
  line-height: 1.5;
}
.prose code {
  padding: 0.1em 0.35em;
  background: var(--surface-quiet);
  border-radius: 3px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.85em;
}
.table-wrap { margin: 1.75em 0; overflow-x: auto; }
.prose table { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.5; }
.prose th, .prose td { padding: 0.75rem 0.75rem 0.75rem 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose thead th { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--rule); }
.prose tbody th { color: var(--ink); font-weight: 600; width: 9rem; }
.prose ul, .prose ol { margin: 1.25em 0; padding-left: 1.25em; }
.prose .article__links { margin-top: 2.5em; color: var(--muted); font-size: 0.9375rem; line-height: 1.8; }
.prose li + li { margin-top: 0.4em; }

.article__end {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9375rem;
}
.article__end a { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- 404 ---------- */
.not-found { padding-block: clamp(4rem, 3rem + 6vw, 8rem); }
.not-found .page-intro__title { margin-top: 1rem; }
.not-found p:not(.eyebrow) { max-width: 34rem; margin-top: 1rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); }
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-block: 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.site-footer__links { display: flex; flex-wrap: wrap; gap: 0 1.5rem; margin: 0; padding: 0; list-style: none; }
.site-footer__links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  text-decoration-color: transparent;
}
.site-footer__links a:hover { color: var(--accent); text-decoration-color: var(--rule); }
