/* ==========================================================================
   Love of Maths — design tokens and base styles
   Palette: burgundy + gold on parchment. Academic, warm, a little playful.
   Type: Fraunces (display), Newsreader (prose), IBM Plex Mono (labels/maths)
   ========================================================================== */

:root {
  /* Ink & ground */
  --parchment:      #FAF6EF;
  --parchment-deep: #F3ECE0;
  --card:           #FFFDF9;
  --ink:            #1C1518;
  --ink-soft:       #443A40;
  --muted:          #6B5F67;
  --rule:           #E4DACA;
  --rule-strong:    #D3C5AE;

  /* Brand */
  --burgundy:       #70202F;
  --burgundy-deep:  #4A121C;
  --burgundy-tint:  #F5E9EA;
  --gold:           #B08828;
  --gold-bright:    #C9A03C;
  --gold-tint:      #FBF2DC;

  /* Type */
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --prose:   "Newsreader", "Hoefler Text", Georgia, serif;
  --mono:    "IBM Plex Mono", "SF Mono", Menlo, monospace;

  /* Rhythm */
  --gap-xs: .5rem;
  --gap-s:  1rem;
  --gap-m:  1.75rem;
  --gap-l:  3rem;
  --gap-xl: 5rem;
  --wrap:   68rem;
  --read:   38rem;

  --radius: 3px;
}

/* --------------------------------------------------------- reset & base */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--prose);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--burgundy); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--burgundy-deep); }

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

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 1.5rem; }
.read { max-width: var(--read); }

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--burgundy);
  color: #fff; padding: .6rem 1rem; z-index: 100;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---------------------------------------------------------------- type */

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 var(--gap-s);
  font-variation-settings: "SOFT" 20, "WONK" 1;
  text-wrap: balance;
}

p, li { text-wrap: pretty; }

h1 { font-size: clamp(2.4rem, 6.2vw, 4.1rem); }
h2 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); margin-top: 0; }
h3 { font-size: clamp(1.2rem, 2.2vw, 1.45rem); letter-spacing: -0.005em; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 var(--gap-s); max-width: 74ch; }
.center p, .center h2 { margin-inline: auto; }
p.lede {
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  line-height: 1.55;
  color: var(--ink-soft);
}

.eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 var(--gap-s);
  font-weight: 500;
}

.dot { color: var(--gold); }

em.flourish { font-style: normal; color: var(--gold); }

strong { font-weight: 600; }

blockquote {
  margin: var(--gap-m) 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--gold);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.1rem;
}

code, .math {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--gold-tint);
  padding: .1em .35em;
  border-radius: 2px;
}

hr { border: 0; border-top: 1px solid var(--rule); margin: var(--gap-l) 0; }

ul, ol { padding-left: 1.2rem; margin: 0 0 var(--gap-s); }
li { margin-bottom: .4rem; }

/* ------------------------------------------------------------ squared paper */

.grid-ground {
  background-image:
    linear-gradient(to right, rgba(112,32,47,.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(112,32,47,.055) 1px, transparent 1px);
  background-size: 26px 26px;
  background-position: center top;
}

/* ------------------------------------------------------------------- nav */

.nav {
  border-bottom: 1px solid var(--rule);
  background: rgba(250,246,239,.92);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky; top: 0; z-index: 40;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap-s); min-height: 4.2rem;
}
.nav-brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  font-variation-settings: "SOFT" 30, "WONK" 1;
  white-space: nowrap;
}
.nav-brand:hover { color: var(--burgundy); }

.nav-links { display: flex; align-items: center; gap: 1.35rem; }
.nav-links a {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
  text-decoration: none;
  padding: .3rem 0;
  border-bottom: 1.5px solid transparent;
}
.nav-links a:hover { color: var(--burgundy); border-bottom-color: var(--gold); }
.nav-links a.is-current { color: var(--burgundy); border-bottom-color: var(--burgundy); }

.nav-cta {
  background: var(--burgundy);
  color: #fff !important;
  padding: .5rem .9rem !important;
  border-radius: var(--radius);
  border-bottom: 0 !important;
}
.nav-cta:hover { background: var(--burgundy-deep); }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--rule-strong);
  border-radius: var(--radius); padding: .45rem .6rem; cursor: pointer;
  font-family: var(--mono); font-size: .75rem; color: var(--ink);
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--card); border-bottom: 1px solid var(--rule);
    padding: .5rem 1.5rem 1.25rem;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .7rem 0; border-bottom: 1px solid var(--rule); font-size: .9rem; }
  .nav-cta { margin-top: .75rem; text-align: center; }
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: .82rem;
  letter-spacing: .04em;
  padding: .8rem 1.4rem;
  border-radius: var(--radius);
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--burgundy); color: #fff; }
.btn-primary:hover { background: var(--burgundy-deep); color: #fff; }
.btn-ghost { border-color: var(--rule-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--burgundy); color: var(--burgundy); }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: var(--gap-m); }

/* ---------------------------------------------------------------- layout */

.section { padding: var(--gap-xl) 0; border-top: 1px solid var(--rule); }
.section:first-of-type { border-top: 0; }
.section-tight { padding: var(--gap-l) 0; }

.hero { padding: clamp(3.5rem, 9vw, 6.5rem) 0 var(--gap-xl); }
.hero h1 { margin-bottom: var(--gap-m); max-width: 20ch; }
.hero .lede { max-width: 46ch; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-l); }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-m); }
.side-col { display: grid; grid-template-columns: 15rem 1fr; gap: var(--gap-l); }

@media (max-width: 860px) {
  .two-col, .three-col, .side-col { grid-template-columns: 1fr; gap: var(--gap-m); }
}

.stack > * + * { margin-top: var(--gap-m); }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: var(--gap-m);
}
.card h3 { margin-bottom: .5rem; }
.card p:last-child { margin-bottom: 0; }
.card.burgundy { border-top-color: var(--burgundy); }

.callout {
  background: var(--gold-tint);
  border-left: 3px solid var(--gold);
  padding: var(--gap-s) var(--gap-m);
  margin: var(--gap-m) 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.callout-title {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--burgundy); margin-bottom: .4rem;
}
.callout p { max-width: 74ch; }
.callout p:last-child { margin-bottom: 0; }
.callout.burgundy { background: var(--burgundy-tint); border-left-color: var(--burgundy); }

/* ------------------------------------------------------------ proof strip */

.proof { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-m); }
.proof-item .n {
  font-family: var(--display);
  font-size: clamp(1.45rem, 3.2vw, 2.25rem);
  font-weight: 600;
  color: var(--burgundy); line-height: 1.08; display: block;
  font-variation-settings: "SOFT" 20, "WONK" 1;
  letter-spacing: -0.02em;
}
.proof-item .l {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .05em;
  color: var(--muted); margin-top: .5rem; display: block;
}
@media (max-width: 700px) { .proof { grid-template-columns: repeat(2, 1fr); } }

/* ----------------------------------------------------------------- lists */

.numbered { list-style: none; padding: 0; counter-reset: step; }
.numbered > li {
  counter-increment: step; position: relative;
  padding-left: 3rem; margin-bottom: var(--gap-m);
}
.numbered > li::before {
  content: counter(step);
  position: absolute; left: 0; top: .05em;
  font-family: var(--mono); font-size: .8rem; font-weight: 600;
  color: var(--gold); border: 1.5px solid var(--gold);
  width: 2rem; height: 2rem; display: grid; place-items: center;
  border-radius: 50%;
}
.numbered h3 { margin-bottom: .3rem; }

.plain { list-style: none; padding: 0; }
.plain > li {
  padding: .85rem 0; border-bottom: 1px solid var(--rule);
  display: grid; grid-template-columns: 8.5rem 1fr;
  gap: var(--gap-s); align-items: baseline;
}
.plain > li:first-child { border-top: 1px solid var(--rule); }
.plain .tag {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--gold);
  line-height: 1.6;
}
@media (max-width: 560px) {
  .plain > li { grid-template-columns: 1fr; gap: .25rem; }
}

/* ----------------------------------------------------------------- table */

.table-wrap { overflow-x: auto; margin: var(--gap-m) 0; }
table { border-collapse: collapse; width: 100%; min-width: 40rem; font-size: .95rem; }
th, td { text-align: left; padding: .75rem .9rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--burgundy);
  border-bottom: 1.5px solid var(--rule-strong); white-space: nowrap;
}
tbody tr:hover { background: var(--parchment-deep); }
td .wk { font-family: var(--mono); font-size: .8rem; color: var(--muted); }

/* ------------------------------------------------------------------ news */

.news-item { padding: var(--gap-m) 0; border-bottom: 1px solid var(--rule); }
.news-item:first-child { border-top: 1px solid var(--rule); }
.news-date {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em;
  color: var(--muted); text-transform: uppercase;
}
.news-item h3 { margin: .4rem 0 .5rem; }
.news-why {
  margin-top: .75rem; padding-left: 1rem; border-left: 2px solid var(--gold);
  font-size: .97rem; color: var(--ink-soft);
}
.news-why strong { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); display: block; margin-bottom: .2rem; }

/* ------------------------------------------------------------------ FAQ */

details.faq {
  border-bottom: 1px solid var(--rule); padding: var(--gap-s) 0;
}
details.faq:first-of-type { border-top: 1px solid var(--rule); }
details.faq summary {
  cursor: pointer; font-family: var(--display); font-size: 1.1rem;
  font-weight: 600; list-style: none; display: flex; gap: .75rem;
  align-items: baseline; font-variation-settings: "SOFT" 20, "WONK" 1;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before { content: "+"; color: var(--gold); font-family: var(--mono); }
details.faq[open] summary::before { content: "−"; }
details.faq > *:not(summary) { margin-top: var(--gap-s); max-width: var(--read); }

/* ------------------------------------------------------------------ form */

.field { margin-bottom: var(--gap-s); }
.field label {
  display: block; font-family: var(--mono); font-size: .74rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin-bottom: .35rem;
}
.field input, .field select, .field textarea {
  width: 100%; padding: .7rem .8rem; font-family: var(--prose); font-size: 1rem;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
}
.field textarea { min-height: 8rem; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--burgundy); outline-offset: 1px; border-color: var(--burgundy);
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--parchment-deep);
  padding: var(--gap-xl) 0 var(--gap-m);
  margin-top: var(--gap-xl);
}
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--gap-l); }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr; gap: var(--gap-m); } }

.footer-grid h4 {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--burgundy); margin-bottom: .75rem;
}
.footer-grid ul { list-style: none; padding: 0; }
.footer-grid li { margin-bottom: .45rem; }
.footer-grid a { color: var(--ink-soft); text-decoration: none; font-size: .95rem; }
.footer-grid a:hover { color: var(--burgundy); text-decoration: underline; }

.brand-line {
  font-family: var(--display); font-size: 1.35rem; font-weight: 700;
  letter-spacing: -0.02em; font-variation-settings: "SOFT" 30, "WONK" 1;
}
.tagline-small {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--gold); margin-top: .3rem;
}

.footer-meta {
  margin-top: var(--gap-l); padding-top: var(--gap-s);
  border-top: 1px solid var(--rule-strong);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--gap-s);
  font-family: var(--mono); font-size: .72rem; color: var(--muted);
}

/* -------------------------------------------------------------- utility */

.muted { color: var(--muted); }
.small { font-size: .92rem; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }

.placeholder {
  background: repeating-linear-gradient(45deg, var(--gold-tint), var(--gold-tint) 8px, #fff 8px, #fff 16px);
  border: 1px dashed var(--gold); padding: .15em .45em; border-radius: 2px;
  font-family: var(--mono); font-size: .82em;
}
