/* -----------------------------------------------------------
   MathCursor — Academic Artisanal theme
   Paper grid, ink blue, highlighter yellow, hand-drawn edges.
   ----------------------------------------------------------- */

:root {
  --paper:       #faf9f6;
  --paper-low:   #f4f3f1;
  --paper-mid:   #efeeeb;
  --paper-high:  #e9e8e5;
  --paper-rim:   #e3e2e0;
  --paper-white: #ffffff;

  --ink:         #00236f;         /* fountain pen ink blue */
  --ink-soft:    #264191;
  --ink-light:   #b6c4ff;
  --ink-tint:    #dce1ff;

  --red:         #bb0027;         /* teacher's red */
  --red-soft:    #e0283c;

  --yellow:      #fde047;         /* highlighter */

  --text:        #1a1c1a;
  --text-muted:  #444651;
  --rule:        #c5c5d3;
  --grid-line:   #e5e7eb;

  --font-head: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --gutter: 24px;
  --margin: 48px;
  --max-width: 1200px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100vh;
}

/* Paper grid — fixed behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-color: var(--paper);
  opacity: 0.5;
  z-index: -1;
  pointer-events: none;
}

/* ---------- Typography ---------- */

h1, h2, h3, h4 {
  font-family: var(--font-head);
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 600;
  line-height: 1.2;
}

h3 {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.3;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}
a:hover { color: var(--red); }

code {
  font-family: var(--font-mono);
  background: var(--paper-high);
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 0.92em;
  color: var(--ink);
}

/* Highlighter — yellow marker behind text */
.highlighter {
  background:
    linear-gradient(104deg,
      rgba(253, 224, 71, 0) 0.9%,
      rgba(253, 224, 71, 1) 2.4%,
      rgba(253, 224, 71, 0.5) 5.8%,
      rgba(253, 224, 71, 0.1) 93%,
      rgba(253, 224, 71, 0.7) 96%,
      rgba(253, 224, 71, 0) 98%),
    linear-gradient(183deg,
      rgba(253, 224, 71, 0) 0%,
      rgba(253, 224, 71, 0.3) 7.9%,
      rgba(253, 224, 71, 0) 15%);
  padding: 0.1em 0.3em;
  border-radius: 2px;
  display: inline;
  transform: rotate(-1deg);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--margin);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 249, 246, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--ink);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 var(--margin);
}

.brand {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  font-style: italic;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  gap: 28px;
  align-items: center;
  font-family: var(--font-head);
  font-weight: 500;
}

.nav a {
  color: rgba(0, 35, 111, 0.7);
  text-decoration: none;
  font-size: 0.95rem;
  padding-bottom: 2px;
  transition: color 0.15s ease;
}

.nav a:hover { color: var(--ink); }

/* Language toggle */
.lang-toggle {
  display: inline-flex;
  border: 2px solid var(--ink);
  border-radius: 0;
  overflow: hidden;
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.lang-toggle button {
  background: transparent;
  color: var(--ink);
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  text-transform: uppercase;
}

.lang-toggle button.active {
  background: var(--ink);
  color: var(--paper);
}

.lang-toggle button:not(.active):hover {
  background: var(--ink-tint);
}

/* ---------- Hero ---------- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 64px var(--margin);
}

section + section { margin-top: 96px; }

.hero {
  max-width: 900px;
}

.hero-tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--red-soft);
  color: var(--paper-white);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.hero h1 {
  margin-bottom: 20px;
}

.hero h1 .highlighter {
  font-style: italic;
}

.hero .lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 640px;
  line-height: 1.6;
  margin-bottom: 32px;
}

.cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.button {
  display: inline-block;
  padding: 14px 28px;
  border-radius: 0;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border: 2px solid var(--ink);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.button--primary {
  background: var(--ink);
  color: var(--paper);
}
.button--primary:hover {
  background: transparent;
  color: var(--ink);
}

.button--secondary {
  background: transparent;
  color: var(--ink);
}
.button--secondary:hover {
  background: var(--ink);
  color: var(--paper);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.badge {
  display: inline-block;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--ink);
  background: var(--paper-white);
  border: 1px solid var(--ink);
  border-radius: 0;
  letter-spacing: 0.02em;
}

.badge--soft {
  background: var(--yellow);
  border-color: var(--ink);
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Hero demo (typewriter → KaTeX) ---------- */

.demo-display {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  vertical-align: middle;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--ink);
  background: var(--paper-white);
  border: 1px solid var(--ink);
  padding: 2px 12px;
  min-width: 300px;
  height: 2em;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.25s ease, background 0.25s ease;
  opacity: 1;
}

.demo-display.demo-typing::after {
  content: "|";
  margin-left: 1px;
  color: var(--red);
  font-weight: 700;
  animation: demo-blink 0.9s step-end infinite;
}

.demo-display.demo-rendered {
  background: var(--yellow);
  border-color: var(--ink);
  font-family: var(--font-body);
  font-size: 1em;
}

.demo-display.demo-fading { opacity: 0; }

@keyframes demo-blink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .demo-display.demo-typing::after { animation: none; }
  .demo-display { transition: none; }
}

/* ---------- Section heading ---------- */

.section h2 {
  border-left: 4px solid var(--red);
  padding-left: 20px;
  margin-bottom: 12px;
}

.section > .container > p {
  max-width: 720px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* ---------- Sketch card (hand-drawn) ---------- */

.sketch-card {
  background: var(--paper-white);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 28px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sketch-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}

.sketch-card--red {
  box-shadow: 4px 4px 0 var(--red);
}
.sketch-card--red:hover {
  box-shadow: 6px 6px 0 var(--red);
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.card {
  background: var(--paper-white);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 28px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}

.card--red { box-shadow: 4px 4px 0 var(--red); }
.card--red:hover { box-shadow: 6px 6px 0 var(--red); }

.card h3 {
  margin-bottom: 12px;
}

.card-quote {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--red);
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.02em;
}

/* ---------- Steps (comment ça marche) ---------- */

.steps {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
  display: grid;
  gap: 20px;
}

.steps li {
  background: var(--paper-white);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 24px 28px 24px 80px;
  counter-increment: step;
  position: relative;
}

.steps li::before {
  content: counter(step) ".";
  position: absolute;
  left: 28px;
  top: 22px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--ink);
}

.steps h3 { margin-bottom: 6px; }

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

/* ---------- Features ---------- */

.features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.features li {
  background: var(--paper-white);
  border: 1px solid var(--ink);
  padding: 22px 24px;
  color: var(--text-muted);
}

.features strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 6px;
}

/* ---------- Examples (multilingue) ---------- */

.examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.example {
  background: var(--paper-white);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 22px 24px;
}

.example-lang {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  padding: 4px 10px;
  margin-bottom: 14px;
}

.example-input,
.example-output {
  display: block;
  margin: 8px 0;
  line-height: 1.6;
}

.example-output { color: var(--ink); }

.example-label {
  display: inline-block;
  min-width: 72px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-right: 8px;
}

/* ---------- Install ---------- */

.install-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: grid;
  gap: 20px;
  counter-reset: install;
}

.install-steps li {
  background: var(--paper-white);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 24px 28px;
}

.install-steps h3 { margin-bottom: 8px; }

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

.install-cmd {
  background: var(--ink);
  color: var(--paper);
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.5;
  margin: 14px 0;
  border: none;
}

.install-cmd code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

.install-note {
  margin-top: 28px;
  padding: 18px 22px;
  background: var(--yellow);
  border: 1px solid var(--ink);
  font-size: 0.95rem;
  color: var(--ink);
}

.install-note a { color: var(--ink); font-weight: 600; }

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

.faq {
  display: grid;
  gap: 12px;
  max-width: 820px;
}

.faq details {
  background: var(--paper-white);
  border: 1px solid var(--ink);
  padding: 16px 22px;
  transition: box-shadow 0.15s ease;
}

.faq details[open] {
  box-shadow: 4px 4px 0 var(--ink);
}

.faq summary {
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 500;
  list-style: none;
  position: relative;
  padding-right: 32px;
  color: var(--ink);
  font-size: 1.05rem;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: -2px;
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  transition: transform 0.2s ease;
}

.faq details[open] summary::after {
  content: "−";
  color: var(--red);
}

.faq details p {
  margin: 12px 0 0;
  color: var(--text-muted);
  max-width: none;
}

/* ---------- Signup form (Google Form embed) ---------- */

.signup {
  max-width: 760px;
  margin: 0 auto;
}

.signup-head {
  text-align: center;
  margin-bottom: 32px;
}

.signup-head h2 {
  border-left: none;
  padding-left: 0;
  display: inline-block;
}

.signup-head p {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-top: 8px;
}

.signup-frame {
  background: var(--paper-white);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 8px;
}

.signup-frame iframe {
  display: block;
  width: 100%;
  min-height: 800px;
  border: 0;
  background: var(--paper-white);
}

.signup-fallback {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 2px solid var(--ink);
  margin-top: 96px;
  padding: 32px 0;
  background: var(--paper);
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-head);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

.site-footer a {
  color: rgba(0, 35, 111, 0.7);
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
}

.site-footer a:hover { color: var(--ink); }

.site-footer nav {
  display: flex;
  gap: 28px;
}

/* ---------- Responsive ---------- */

@media (max-width: 780px) {
  :root { --margin: 24px; }
  .nav { display: none; }
  .site-header .container,
  main,
  .container { padding-left: 24px; padding-right: 24px; }
  main { padding-top: 40px; padding-bottom: 40px; }
  section + section { margin-top: 64px; }
  .sketch-card, .card, .steps li, .install-steps li, .example {
    box-shadow: 3px 3px 0 var(--ink);
  }
  .demo-display {
    min-width: 0;
    width: 100%;
    margin-top: 12px;
  }
}
