/* ============================================================================
   modumatics.com — site styles.
   The WHOLE site uses the Toan Ngo PhD Thesis Design System (the same language
   as the /thesis/ reader): one maroon accent, warm ink-on-paper, ET Book serif,
   Quicksand brand mark, rectilinear + quiet, tufte (parchment) default with an
   ieee (white/navy/sans) alternate — toggled via data-theme, persisted under the
   SAME "thesis-theme" localStorage key the reader uses, so the look + the
   preference carry across the hub and the thesis seamlessly.
   Tokens below are vendored verbatim from the system's colors_and_type.css.
   ============================================================================ */

@import url('/assets/fonts.css');

:root {
  /* ---- core palette (darkred = the one brand accent) ---- */
  --darkred: #800000; --darkred-ink: #5e0000; --darkred-tint: #f3e3e3;
  --accent-soft: #9c5a52; --ref-ink: #571f1b;
  --slateblue: #3f5d7e; --gold: #b0892f; --rust: #a85a32; --deepteal: #2f7268;

  /* ---- neutrals & surfaces ---- */
  --ink: #322d27; --ink-2: #574f45; --ink-3: #8a8073;
  --rule: #e2dcd2; --rule-soft: #efeae1;
  --paper: #fcfbf8; --paper-warm: #f4efe6; --paper-edge: #e9e2d5;
  --parchment: #fbf6ec; --white: #ffffff;
  --ieee-bg: #ffffff; --ieee-ink: #2b2f37; --ieee-accent: #2c4a78; --ieee-rule: #dde0e6;

  /* ---- type families ---- */
  --serif: 'ET Book', 'TeX Gyre Pagella', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, 'Times New Roman', serif;
  --sans:  'Lato', 'Helvetica Neue', Arial, sans-serif;
  --mono:  'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
  --geometric: 'Quicksand', 'Futura', 'Century Gothic', 'Avenir Next', sans-serif;

  /* ---- type scale ---- */
  --leading-body: 1.62; --leading-tight: 1.28;
  --fs-display: 3.25rem; --fs-h1: 2.25rem; --fs-h2: 1.5rem; --fs-h3: 1.18rem;
  --fs-h4: 1.02rem; --fs-body: 1.0625rem; --fs-small: 0.9rem; --fs-xs: 0.78rem;

  /* ---- spacing, radii, elevation (rectilinear: tiny radii, quiet warm shadow) ---- */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --radius-sm: 2px; --radius-md: 4px; --radius-lg: 6px;
  --shadow-sm: 0 1px 2px rgba(40, 20, 10, 0.06);
  --shadow-md: 0 2px 8px rgba(40, 20, 10, 0.08);
  --shadow-lg: 0 8px 28px rgba(40, 20, 10, 0.12);
  --shadow-nav: 0 1px 0 var(--rule), 0 2px 12px rgba(40, 20, 10, 0.05);
  --hairline: 1px solid var(--rule);

  /* ---- semantic, theme-switched (tufte default) ---- */
  --page-bg: var(--parchment);
  --panel: color-mix(in srgb, var(--parchment) 82%, transparent);
  --fg: var(--ink); --fg2: var(--ink-2); --fg3: var(--ink-3);
  --surface: var(--paper);
  --accent: var(--darkred); --accent-ink: var(--darkred-ink); --accent-wash: var(--darkred-tint);
  --line: var(--rule);
  --body-font: var(--serif); --head-font: var(--serif);
  --h1-variant: small-caps;
  --page-max: 62rem; --measure: 40rem;
}

html[data-theme="tufte"] {
  --page-bg: var(--parchment); --panel: color-mix(in srgb, var(--parchment) 82%, transparent);
  --fg: var(--ink); --fg2: var(--ink-2); --fg3: var(--ink-3); --surface: var(--paper);
  --accent: var(--darkred); --accent-ink: var(--darkred-ink); --accent-wash: var(--darkred-tint);
  --line: var(--rule); --body-font: var(--serif); --head-font: var(--serif);
  --h1-variant: small-caps; --measure: 40rem;
}
html[data-theme="ieee"] {
  --page-bg: var(--ieee-bg); --panel: rgba(255, 255, 255, 0.85);
  --fg: var(--ieee-ink); --fg2: #3a3f4a; --fg3: #6a7180; --surface: var(--white);
  --accent: var(--ieee-accent); --accent-ink: #07163a; --accent-wash: #eef1f7;
  --line: var(--ieee-rule); --body-font: var(--sans); --head-font: var(--sans);
  --h1-variant: normal; --measure: 44rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
  color: var(--fg);
  font-family: var(--body-font);
  font-size: var(--fs-body);
  line-height: var(--leading-body);
  font-feature-settings: "onum" 1, "liga" 1, "kern" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }

/* ---- masthead (sticky, blurred, hairline — mirrors the reader nav) ---- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--panel);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: var(--hairline);
  box-shadow: var(--shadow-nav);
}
.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: min(100% - 2.5rem, var(--page-max));
  margin: 0 auto;
  padding: var(--space-3) 0;
}

/* brand = maroon monogram tile + letterspaced Quicksand wordmark */
.brand { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.brand .monogram { width: 30px; height: 30px; display: block; border-radius: var(--radius-lg); }
.brand .wordmark {
  font-family: var(--geometric);
  font-weight: 600;
  font-size: 1.18rem;
  letter-spacing: 0.06em;
  color: var(--fg);
}

.nav { display: flex; align-items: center; gap: var(--space-5); }
.nav a {
  font-family: var(--sans);
  font-size: var(--fs-small);
  letter-spacing: 0.01em;
  color: var(--fg2);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: background 120ms ease, color 120ms ease;
}
.nav a:hover { color: var(--accent); background: var(--accent-wash); }

/* theme seam: tufte / ieee segmented control (same options as the reader) */
.theme {
  display: inline-flex;
  border: var(--hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.theme button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg3);
  padding: 5px 9px;
  cursor: pointer;
  font: inherit;
  transition: background 120ms ease, color 120ms ease;
}
.theme button + button { border-left: var(--hairline); }
.theme button:hover { color: var(--fg); }
.theme button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---- layout ---- */
main {
  flex: 1 0 auto;
  width: min(100% - 2.5rem, var(--page-max));
  margin: 0 auto;
  padding: var(--space-8) 0 var(--space-7);
}

/* ---- hero ---- */
.eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--space-3);
}
.hero h1 {
  font-family: var(--head-font);
  font-weight: 700;
  font-size: var(--fs-display);
  line-height: var(--leading-tight);
  font-variant: var(--h1-variant);
  letter-spacing: 0.01em;
  color: var(--fg);
  margin: 0 0 var(--space-4);
}
.lede {
  font-family: var(--body-font);
  font-size: var(--fs-h3);
  line-height: 1.5;
  color: var(--fg2);
  max-width: var(--measure);
  margin: 0;
}

/* the signature 0.5pt centred rule at 50% width, between major moves */
.section-rule { border: 0; height: 0.5pt; width: 50%; margin: var(--space-7) auto; background: var(--ink-3); opacity: 0.5; }

/* ---- section head (small-caps mono label) ---- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin: var(--space-7) 0 var(--space-5);
  padding-bottom: var(--space-2);
  border-bottom: var(--hairline);
}
.section-head h2 {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg2);
  margin: 0;
}
.section-head .count { font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg3); }

/* ---- functions grid (the modular launcher; typographic, near-iconless) ---- */
.functions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: var(--space-4);
}
.fn-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-5) var(--space-5);
  background: var(--surface);
  border: var(--hairline);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--fg);
  transition: box-shadow 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.fn-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); transform: translateY(-1px); }
.fn-card .fn-kicker {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.fn-card .fn-title {
  font-family: var(--head-font);
  font-weight: 700;
  font-size: var(--fs-h2);
  line-height: var(--leading-tight);
  color: var(--fg);
}
.fn-card .fn-desc { font-family: var(--body-font); font-size: var(--fs-small); color: var(--fg2); margin: var(--space-1) 0 0; line-height: 1.5; }
.fn-card .fn-go { margin-top: var(--space-3); font-family: var(--sans); font-size: var(--fs-small); font-weight: 700; color: var(--accent); }
.fn-card:hover .fn-go { color: var(--accent-ink); }

.fn-card.slot {
  border-left: var(--hairline);
  border-style: dashed;
  box-shadow: none;
  background: transparent;
  color: var(--fg3);
  justify-content: center;
}
.fn-card.slot:hover { transform: none; box-shadow: none; border-color: var(--line); }
.fn-card.slot .fn-kicker { color: var(--fg3); }
.fn-card.slot .fn-desc { color: var(--fg3); }

/* ---- prose (about), per .ds-prose rhythm ---- */
.prose { max-width: var(--measure); }
.prose h1 {
  font-family: var(--head-font); font-weight: 700; font-size: var(--fs-h1);
  font-variant: var(--h1-variant); letter-spacing: 0.01em; line-height: var(--leading-tight);
  color: var(--fg); margin: 0 0 var(--space-5);
}
.prose h2 {
  font-family: var(--head-font); font-weight: 700; font-size: var(--fs-h2);
  color: var(--fg); margin: var(--space-7) 0 var(--space-3);
}
.prose p { margin: 0 0 var(--space-4); color: var(--fg); }
.prose ul { margin: 0 0 var(--space-4); padding-left: 1.2rem; color: var(--fg); }
.prose li { margin: var(--space-2) 0; }
.prose a { color: var(--accent); font-weight: 600; border-radius: 3px; padding: 0 1px; transition: background 120ms ease; }
.prose a:hover { background: var(--accent-wash); }
.prose em { font-style: italic; }

/* ---- footer (quiet runhead) ---- */
footer { flex-shrink: 0; border-top: var(--hairline); margin-top: var(--space-7); }
.foot-inner {
  width: min(100% - 2.5rem, var(--page-max));
  margin: 0 auto;
  padding: var(--space-5) 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-family: var(--sans);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  color: var(--fg3);
}
.foot-inner a { color: var(--fg2); }
.foot-inner a:hover { color: var(--accent); }

@media (max-width: 540px) {
  :root { --fs-display: 2.6rem; }
  main { padding: var(--space-6) 0 var(--space-6); }
  .section-head { margin-top: var(--space-6); }
}
