/* ===== MATH Keys — shared site styles =====
   Palette and typography follow the extension's style guide
   (chrome_extention/math_extention_main.css): mint keys, deep
   teal-green ink, the #589983→#3C7871 gradient, Fira Sans. */
:root {
  --ink: #212529;
  --ink-muted: #5a6862;
  --heading: #022e16;
  --accent: #3C7871;
  --accent-dark: #2e5f59;
  --grad: linear-gradient(#589983, #3C7871);
  --grad-hover: linear-gradient(#66a893, #458a80);
  --key-bg: #DCEEE7;
  --key-bg-hover: #C7E5D9;
  --key-bg-active: #B3DBC9;
  --key-text: #0B4A3B;
  --bg: #ffffff;
  --bg-soft: #f3f7f5;
  --bg-mint: #e8f3ee;
  --border: #d8e3de;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(2, 46, 22, 0.07);
  --shadow-soft: 0 2px 12px rgba(2, 46, 22, 0.05);
  --maxw: 1120px;
  --header-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Fira Sans", "Segoe UI", Roboto, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; color: var(--heading); }

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

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

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(243, 247, 245, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.site-header.is-scrolled {
  border-bottom-color: var(--border);
  background: rgba(255, 255, 255, 0.94);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 12px 20px;
  min-height: var(--header-h);
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
  color: var(--accent);
  white-space: nowrap;
  z-index: 2;
}

.brand-logo {
  width: 24px;
  height: 24px;
  display: block;
}
.brand:hover { text-decoration: none; }
.brand span { color: var(--ink); font-weight: 400; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.main-nav a {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.main-nav a:hover {
  background: var(--key-bg);
  text-decoration: none;
  color: var(--key-text);
}
.main-nav a.active {
  color: var(--accent);
  font-weight: 600;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--heading);
  cursor: pointer;
  z-index: 2;
}

.nav-toggle-bars {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s ease, transform 0.15s var(--ease), background 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary { background: var(--grad); color: #fff; }
.btn-primary:hover { background: var(--grad-hover); color: #fff; }

.btn-key { background: var(--key-bg); color: var(--key-text); }
.btn-key:hover { background: var(--key-bg-hover); color: var(--key-text); }
.btn-key:active { background: var(--key-bg-active); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; }

.btn-text {
  background: transparent;
  color: var(--key-text);
  padding: 10px 14px;
  font-weight: 600;
}
.btn-text:hover { color: var(--accent); transform: none; }

.header-cta {
  white-space: nowrap;
  padding: 7px 14px;
  font-size: 0.85rem;
  border-radius: 8px;
}

@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; }

  .header-actions {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(320px, 88vw);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 0;
    padding: calc(var(--header-h) + 16px) 20px 28px;
    background: var(--bg);
    border-left: 1px solid var(--border);
    box-shadow: -12px 0 40px rgba(2, 46, 22, 0.08);
    transform: translateX(100%);
    transition: transform 0.3s var(--ease);
    z-index: 1;
  }

  body.nav-open .header-actions {
    transform: translateX(0);
  }

  .main-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    order: 2;
  }

  .main-nav a {
    padding: 12px 14px;
    font-size: 1rem;
  }

  .header-cta {
    order: -1;
    text-align: center;
    margin-bottom: 8px;
  }

  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(2, 46, 22, 0.28);
    z-index: 40;
  }

  body.nav-open .site-header { z-index: 51; }
}

/* ---------- Homepage hero ---------- */
.hero {
  position: relative;
  min-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 60% at 70% 40%, rgba(88, 153, 131, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 15% 80%, rgba(220, 238, 231, 0.9), transparent 50%),
    linear-gradient(165deg, #eef5f2 0%, #f7faf8 45%, #e3efe9 100%);
  color: var(--heading);
}

.hero-copy {
  position: relative;
  z-index: 2;
  padding: 40px 0 20px;
  max-width: 560px;
  animation: heroRise 0.85s var(--ease) both;
}

.hero-brand {
  margin: 0 0 14px;
  font-size: clamp(2.75rem, 7vw, 4.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1.05;
}

.hero-brand span {
  color: var(--heading);
  font-weight: 400;
}

.hero-headline {
  margin: 0 0 12px;
  font-size: clamp(1.35rem, 2.8vw, 1.75rem);
  font-weight: 600;
  color: var(--heading);
  letter-spacing: -0.01em;
}

.hero-tagline {
  margin: 0 0 28px;
  font-size: 1.1rem;
  color: var(--ink-muted);
  max-width: 420px;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.hero-visual {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: auto;
  animation: heroFade 1s var(--ease) 0.15s both;
}

.hero-visual img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(48vh, 420px);
  object-fit: cover;
  object-position: top center;
  mask-image: linear-gradient(to bottom, transparent 0%, #000 6%, #000 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 6%, #000 88%, transparent 100%);
}

@media (min-width: 900px) {
  .hero {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(340px, 1.15fr);
    align-items: center;
    gap: 32px;
    padding: 0;
    min-height: calc(100vh - var(--header-h));
  }

  .hero .container {
    display: contents;
  }

  .hero-copy {
    padding: 64px 0 64px 24px;
    margin-left: max(0px, calc((100vw - var(--maxw)) / 2));
    max-width: 480px;
  }

  .hero-visual {
    height: 100%;
    min-height: calc(100vh - var(--header-h));
    display: flex;
    align-items: stretch;
    margin: 0;
  }

  .hero-visual img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: left center;
    mask-image: linear-gradient(to right, transparent 0%, #000 12%, #000 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 12%, #000 100%);
  }
}

@keyframes heroRise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes heroFade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Sections ---------- */
.section {
  padding: 80px 0;
}

.section.alt {
  background: var(--bg-soft);
}

.section-head {
  max-width: 560px;
  margin-bottom: 40px;
}

.section-head.centered {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.section h2 {
  margin: 0 0 10px;
  font-size: clamp(1.65rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
}

.section .sub {
  margin: 0;
  color: var(--ink-muted);
  font-size: 1.05rem;
}

.reveal {
  animation: heroRise 0.7s var(--ease) both;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

@supports not (animation-timeline: view()) {
  .reveal { animation: none; }
}

/* how-to steps — lean numbered rows */
.steps {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--border);
}

.step-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 20px 28px;
  align-items: start;
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}

.step-num {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
  padding-top: 4px;
}

.step-row h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  color: var(--heading);
}

.step-row p {
  margin: 0;
  color: var(--ink-muted);
  max-width: 520px;
}

@media (min-width: 720px) {
  .step-row {
    grid-template-columns: 72px 160px 1fr;
    align-items: center;
  }

  .step-row img {
    width: 100%;
    height: 96px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: var(--bg-mint);
  }
}

.step-row img {
  display: none;
}

@media (min-width: 720px) {
  .step-row img { display: block; }
}

/* compatibility — quiet line */
.compat-line {
  text-align: center;
  color: var(--ink-muted);
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.01em;
}

.compat-line strong {
  color: var(--key-text);
  font-weight: 600;
}

/* modes — featured stage + list */
.modes-stage {
  display: grid;
  gap: 36px;
  align-items: center;
}

@media (min-width: 880px) {
  .modes-stage {
    grid-template-columns: 1.2fr 0.9fr;
    gap: 48px;
  }
}

.modes-visual {
  position: relative;
  border-radius: 0;
  overflow: hidden;
  background: var(--bg-mint);
  min-height: 280px;
}

.modes-visual img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

.mode-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.mode-list li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  cursor: default;
  border-left: 3px solid transparent;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.mode-list li[data-active="true"],
.mode-list li:hover {
  background: var(--key-bg);
  border-left-color: var(--accent);
}

.mode-list h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--key-text);
}

.mode-list p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* two-column (about, etc.) */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
}

.split img {
  width: 100%;
  border-radius: var(--radius);
}

@media (max-width: 800px) {
  .split { grid-template-columns: 1fr; }
}

.split ul { padding-left: 20px; }
.split li { margin-bottom: 6px; }

/* page hero + content */
.page-hero {
  padding: 56px 0 40px;
  background:
    radial-gradient(700px 280px at 10% 0%, rgba(88, 153, 131, 0.14), transparent),
    var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.page-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
}

.page-hero .lead {
  margin: 0;
  max-width: 560px;
  font-size: 1.1rem;
  color: var(--ink-muted);
}

.page-content {
  padding: 48px 0 72px;
  max-width: 760px;
  margin: 0 auto;
}

.page-content h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.35rem;
}

.page-content h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.1rem;
  color: var(--key-text);
}

.page-content .lead {
  color: var(--ink-muted);
  font-size: 1.1rem;
}

.page-content code {
  background: var(--key-bg);
  color: var(--key-text);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.9em;
}

.page-content ul {
  padding-left: 1.25rem;
}

.page-content li {
  margin-bottom: 0.45rem;
  color: var(--ink);
}

/* tables */
.latex-table {
  width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.latex-table th,
.latex-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.latex-table th {
  background: var(--key-bg);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--key-text);
}

.latex-table tr:last-child td { border-bottom: none; }

.latex-table code {
  background: var(--key-bg);
  color: var(--key-text);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
}

/* forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 28px;
}
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

label {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 6px;
  color: var(--heading);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  transition: border-color 0.15s ease;
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-status {
  display: none;
  color: var(--accent);
  font-weight: 600;
  margin-top: 12px;
}

/* about */
.about-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 48px;
  align-items: start;
  margin-top: 8px;
}
@media (max-width: 760px) { .about-grid { grid-template-columns: 1fr; } }
.about-grid img {
  width: 100%;
  border-radius: var(--radius);
}

/* CTA band */
.cta-band {
  background:
    radial-gradient(600px 240px at 20% 0%, rgba(255, 255, 255, 0.12), transparent),
    linear-gradient(125deg, #589983, #3C7871);
  color: #fff;
  text-align: center;
  padding: 64px 24px;
}

.cta-band h2 {
  margin: 0 0 10px;
  color: #fff;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.cta-band p {
  margin: 0 auto 24px;
  max-width: 480px;
  opacity: 0.92;
}

.cta-band .btn {
  background: #fff;
  color: var(--accent);
}
.cta-band .btn:hover {
  background: var(--key-bg);
  color: var(--key-text);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--key-text);
  color: #cfe5db;
  padding: 40px 0;
  font-size: 0.9rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  align-items: center;
  justify-content: space-between;
}

.site-footer a { color: #DCEEE7; }
.site-footer .brand { color: #8FDDC0; }
.site-footer .brand span { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-copy,
  .hero-visual,
  .reveal {
    animation: none !important;
  }
  .btn:hover { transform: none; }
  .header-actions { transition: none; }
}
