/* IDEAS TOOLS GAIN WEALTH - Advanced Mathematics Toolkit
   Light theme with mint green (#AADD88) + pure cyan (#00FFFF) */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f3faf0;
  --bg-card: #ffffff;
  --bg-elevated: #eaf7e4;
  --bg-input: #f8fdf6;
  --border: #c5e6b8;
  --border-light: #aadd88;
  --text-primary: #1a2e1a;
  --text-secondary: #3d5c3d;
  --text-muted: #6b8f6b;
  --accent: #00ffff;
  --accent-hover: #00d4d4;
  --accent-dim: rgba(0, 255, 255, 0.18);
  --accent-glow: rgba(0, 255, 255, 0.4);
  --success: #4ade80;
  --warning: #f59e0b;
  --error: #ef4444;
  --purple: #a855f7;
  --green: #aadd88;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --nav-height: 68px;
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }

p { color: var(--text-secondary); }

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

/* ========== Layout ========== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container-wide {
  max-width: 1400px;
}

main {
  flex: 1;
  padding-top: var(--nav-height);
}

section {
  padding: 4rem 0;
}

/* ========== Navigation ========== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
  z-index: 1000;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.navbar.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.logo span { color: var(--accent); }
.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-links > li > a,
.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

.nav-links > li > a:hover,
.nav-dropdown-toggle:hover,
.nav-links > li > a.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  min-width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.6rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 100;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.dropdown-menu a {
  display: block;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}
.dropdown-menu a:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.dropdown-menu .cat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.5rem 0.9rem 0.25rem;
  font-weight: 600;
}

/* Mobile menu */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s;
}

.mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 999;
}
.mobile-menu.open { display: block; }
.mobile-menu a {
  display: block;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.mobile-menu a:hover { background: var(--bg-elevated); color: var(--accent); }
.mobile-cat {
  margin-top: 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #00cccc);
  color: #003333;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px var(--accent-glow);
  color: #003333;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-outline:hover {
  background: var(--accent-dim);
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

.btn-block { width: 100%; }

/* ========== Hero ========== */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 6rem 0 4rem;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#math-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 820px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: var(--accent-dim);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.hero h1 {
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, #1a2e1a 20%, #00aaaa 60%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 2.25rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-ctas {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-top: 4rem;
  flex-wrap: wrap;
}
.stat-item {
  text-align: center;
}
.stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  display: block;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ========== Category Cards ========== */
.section-header {
  text-align: center;
  margin-bottom: 3rem;
}
.section-header p {
  max-width: 560px;
  margin: 0.75rem auto 0;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  opacity: 0;
  transition: opacity 0.3s;
}
.category-card:hover {
  border-color: var(--border-light);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.category-card:hover::before { opacity: 1; }

.cat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-dim);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  margin-bottom: 1.1rem;
  color: var(--accent);
}

.category-card h3 {
  margin-bottom: 0.5rem;
}
.category-card p {
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}
.tool-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.category-card .btn {
  margin-top: 0.5rem;
}

/* ========== Tool Cards ========== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}
.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0, 255, 255, 0.15);
}
.tool-card h4 {
  margin-bottom: 0.4rem;
  font-size: 1.05rem;
}
.tool-card p {
  font-size: 0.88rem;
  flex: 1;
  margin-bottom: 1rem;
}
.tool-card .btn {
  align-self: flex-start;
}

/* ========== Tool Page Layout ========== */
.tool-header {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.tool-header .breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.tool-header .breadcrumb a { color: var(--text-secondary); }
.tool-header .breadcrumb a:hover { color: var(--accent); }
.tool-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 0.5rem;
}
.tool-header p {
  max-width: 700px;
}

.tool-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}
@media (max-width: 900px) {
  .tool-workspace { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}
.panel-title .icon { color: var(--accent); }

/* Forms */
.form-group {
  margin-bottom: 1.15rem;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea.form-control {
  min-height: 100px;
  resize: vertical;
}
select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.2rem;
}

.matrix-input {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.matrix-row {
  display: flex;
  gap: 0.4rem;
}
.matrix-cell {
  width: 70px;
  text-align: center;
  padding: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.matrix-cell:focus {
  outline: none;
  border-color: var(--accent);
}

/* Output */
.output-area {
  min-height: 200px;
}
.result-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  overflow-x: auto;
}
.result-highlight {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.steps-container {
  margin-top: 1.25rem;
}
.step {
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-elevated);
  margin-bottom: 0.6rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
}
.step-num {
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.5rem;
}

.action-bar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* Collapsible */
.how-it-works {
  margin-top: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.how-it-works summary {
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.how-it-works summary::-webkit-details-marker { display: none; }
.how-it-works[open] summary {
  border-bottom: 1px solid var(--border);
}
.how-it-works .content {
  padding: 1.25rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.how-it-works .content p { margin-bottom: 0.75rem; }

/* ========== Footer ========== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 3.5rem 0 1.5rem;
  margin-top: auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}
@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .footer-grid { grid-template-columns: 1fr; }
}
.footer-brand .logo { margin-bottom: 0.75rem; }
.footer-brand p {
  font-size: 0.9rem;
  max-width: 260px;
}
.footer h5 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.footer ul {
  list-style: none;
}
.footer ul li { margin-bottom: 0.5rem; }
.footer ul a {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.footer ul a:hover { color: var(--accent); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ========== Misc Pages ========== */
.page-hero {
  padding: 3rem 0 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.page-hero h1 { margin-bottom: 0.5rem; }
.content-block {
  max-width: 800px;
  margin: 0 auto 3rem;
}
.content-block h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.35rem;
}
.content-block p, .content-block li {
  margin-bottom: 0.85rem;
  color: var(--text-secondary);
}
.content-block ul { padding-left: 1.5rem; }

/* Contact form */
.contact-form {
  max-width: 560px;
  margin: 0 auto;
}
.contact-form .form-group { margin-bottom: 1.25rem; }

/* 404 */
.error-page {
  text-align: center;
  padding: 6rem 1rem;
}
.error-page .code {
  font-size: 6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  margin-bottom: 1rem;
}

/* Recently used */
.recent-tools {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}
.recent-chip {
  padding: 0.4rem 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.recent-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Loading */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 1rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.katex-display { overflow-x: auto; overflow-y: hidden; }

/* Search */
.search-wrap {
  position: relative;
  max-width: 320px;
}
.search-wrap input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-primary);
  font-size: 0.9rem;
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
}
.search-wrap .search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.search-results.open { display: block; }
.search-results a {
  display: block;
  padding: 0.7rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.search-results a:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Responsive nav */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .search-wrap { display: none; }
}

/* ========== Enhanced Mobile (10/10) ========== */
@media (max-width: 900px) {
  .nav-inner { padding: 0 0.85rem; }
  .logo { font-size: 1.15rem; }
  .logo-icon { width: 32px; height: 32px; font-size: 1rem; }
  .hero { min-height: 85vh; padding: 5rem 0 3rem; }
  .hero h1 { font-size: clamp(1.7rem, 8vw, 2.4rem); }
  .hero-sub { font-size: 1rem; padding: 0 0.5rem; }
  .hero-stats { gap: 1.5rem; margin-top: 2.5rem; }
  .stat-num { font-size: 1.5rem; }
  .categories-grid { grid-template-columns: 1fr; gap: 1rem; }
  .tools-grid { grid-template-columns: 1fr; }
  .tool-workspace { grid-template-columns: 1fr; gap: 1.25rem; }
  .panel { padding: 1.15rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.75rem; }
  .footer { padding: 2.5rem 0 1.25rem; }
  .page-hero { padding: 2rem 0 1.25rem; }
  .matrix-cell { width: 56px !important; font-size: 0.85rem; }
  .btn { padding: 0.7rem 1.2rem; }
  .btn-block { width: 100%; }
  section { padding: 2.5rem 0; }
  .container { padding: 0 1rem; }
  .hero-ctas { flex-direction: column; align-items: stretch; padding: 0 1rem; }
  .hero-ctas .btn { width: 100%; }
  .mobile-menu a { padding: 1rem 1.1rem; font-size: 1.05rem; }
  .hamburger { padding: 10px; }
  .hamburger span { width: 26px; height: 2.5px; }
  .form-control, .matrix-cell { font-size: 16px; } /* prevents iOS zoom */
  .tool-header { padding: 1.75rem 0 1rem; }
  .tool-header h1 { font-size: 1.45rem; }
  .recent-tools { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .hero-stats { gap: 1rem; }
  .stat-label { font-size: 0.7rem; }
  .category-card, .tool-card { padding: 1.15rem; }
  .footer-bottom { flex-direction: column; text-align: center; gap: 0.5rem; }
}
