/* ============================================================
   FreeMathHub – Shared Styles
   Global styles, navigation, footer, ads, premium gates
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --fmh-primary: #2563eb;
  --fmh-primary-dark: #1d4ed8;
  --fmh-primary-light: #3b82f6;
  --fmh-accent: #f59e0b;
  --fmh-accent-dark: #d97706;
  --fmh-success: #10b981;
  --fmh-danger: #ef4444;
  --fmh-bg: #f8fafc;
  --fmh-bg-alt: #f1f5f9;
  --fmh-surface: #ffffff;
  --fmh-text: #0f172a;
  --fmh-text-secondary: #475569;
  --fmh-text-muted: #94a3b8;
  --fmh-border: #e2e8f0;
  --fmh-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --fmh-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --fmh-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  --fmh-radius: 12px;
  --fmh-radius-sm: 8px;
  --fmh-radius-full: 9999px;
  --fmh-font: "Inter", system-ui, -apple-system, sans-serif;
  --fmh-max-width: 1200px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --fmh-bg: #0f172a;
    --fmh-bg-alt: #1e293b;
    --fmh-surface: #1e293b;
    --fmh-text: #f1f5f9;
    --fmh-text-secondary: #94a3b8;
    --fmh-text-muted: #64748b;
    --fmh-border: #334155;
    --fmh-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --fmh-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding: 0;
  font-family: var(--fmh-font);
  background: var(--fmh-bg);
  color: var(--fmh-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--fmh-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Navigation ---------- */
#fmh-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--fmh-border);
}

@media (prefers-color-scheme: dark) {
  #fmh-nav {
    background: rgba(15,23,42,0.92);
  }
}

.fmh-nav-inner {
  max-width: var(--fmh-max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.fmh-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--fmh-primary);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.fmh-logo:hover { text-decoration: none; opacity: 0.9; }

.fmh-menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--fmh-border);
  border-radius: var(--fmh-radius-sm);
  font-size: 20px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--fmh-text);
  margin-left: auto;
}

.fmh-nav-links {
  display: flex;
  gap: 8px;
  flex: 1;
}

.fmh-nav-links a {
  padding: 8px 14px;
  border-radius: var(--fmh-radius-full);
  font-size: 14px;
  font-weight: 500;
  color: var(--fmh-text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
}

.fmh-nav-links a:hover {
  background: var(--fmh-bg-alt);
  color: var(--fmh-text);
  text-decoration: none;
}

.fmh-nav-links a.active {
  background: var(--fmh-primary);
  color: #fff;
}

.fmh-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fmh-premium-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--fmh-radius-full);
}

.fmh-btn-primary-sm {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  background: var(--fmh-primary);
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--fmh-radius-full);
  text-decoration: none !important;
  transition: background 0.15s;
}
.fmh-btn-primary-sm:hover { background: var(--fmh-primary-dark); }

.fmh-btn-sm {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--fmh-bg-alt);
  color: var(--fmh-text-secondary) !important;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--fmh-radius-full);
  text-decoration: none !important;
  border: 1px solid var(--fmh-border);
  transition: all 0.15s;
}
.fmh-btn-sm:hover { background: var(--fmh-border); }

/* Mobile Nav */
@media (max-width: 768px) {
  .fmh-menu-toggle { display: block; }
  .fmh-nav-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 0;
  }
  .fmh-nav-links,
  .fmh-nav-actions {
    display: none;
    width: 100%;
    padding-top: 12px;
  }
  .fmh-nav-links { flex-direction: column; gap: 4px; }
  .fmh-nav-actions { padding-bottom: 8px; }
  #fmh-nav.open .fmh-nav-links,
  #fmh-nav.open .fmh-nav-actions {
    display: flex;
  }
}

/* ---------- Footer ---------- */
#fmh-footer {
  background: var(--fmh-bg-alt);
  border-top: 1px solid var(--fmh-border);
  margin-top: 80px;
  padding: 48px 24px 24px;
}

.fmh-footer-inner {
  max-width: var(--fmh-max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}

.fmh-footer-col h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--fmh-text);
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fmh-footer-col p {
  font-size: 14px;
  color: var(--fmh-text-secondary);
  margin: 0;
  line-height: 1.6;
}

.fmh-footer-col a {
  display: block;
  font-size: 14px;
  color: var(--fmh-text-secondary);
  padding: 4px 0;
  text-decoration: none;
}
.fmh-footer-col a:hover {
  color: var(--fmh-primary);
  text-decoration: none;
}

.fmh-footer-bottom {
  max-width: var(--fmh-max-width);
  margin: 32px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--fmh-border);
  text-align: center;
}

.fmh-footer-bottom p {
  font-size: 13px;
  color: var(--fmh-text-muted);
  margin: 0;
}

@media (max-width: 768px) {
  .fmh-footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}
@media (max-width: 480px) {
  .fmh-footer-inner {
    grid-template-columns: 1fr;
  }
}

/* ---------- Ad Slots ---------- */
/* Hidden until AdSense is approved and configured.
   Remove `display:none` once ads are live. */
.fmh-ad-slot,
.fmh-ad-remove {
  display: none !important;
}

/* ---------- Premium Gate ---------- */
.fmh-premium-gate {
  position: relative;
  border-radius: var(--fmh-radius);
  overflow: hidden;
}

.fmh-premium-gate .fmh-gate-content {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

.fmh-premium-gate .fmh-gate-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.85);
  z-index: 10;
  padding: 32px;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .fmh-premium-gate .fmh-gate-overlay {
    background: rgba(15,23,42,0.85);
  }
}

.fmh-gate-overlay h3 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
}

.fmh-gate-overlay p {
  font-size: 15px;
  color: var(--fmh-text-secondary);
  margin: 0 0 20px;
}

/* ---------- Utility Classes ---------- */
.fmh-container {
  max-width: var(--fmh-max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.fmh-section {
  padding: 64px 0;
}

.fmh-section-title {
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.fmh-section-subtitle {
  font-size: 18px;
  color: var(--fmh-text-secondary);
  text-align: center;
  margin: 0 0 48px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.fmh-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  background: var(--fmh-primary);
  color: #fff !important;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--fmh-radius-full);
  border: none;
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.fmh-btn-primary:hover {
  background: var(--fmh-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37,99,235,0.4);
}

.fmh-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  background: var(--fmh-surface);
  color: var(--fmh-text) !important;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--fmh-radius-full);
  border: 1px solid var(--fmh-border);
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.2s;
}
.fmh-btn-secondary:hover {
  background: var(--fmh-bg-alt);
  transform: translateY(-1px);
}

/* Card */
.fmh-card {
  background: var(--fmh-surface);
  border: 1px solid var(--fmh-border);
  border-radius: var(--fmh-radius);
  padding: 24px;
  transition: all 0.2s;
}
.fmh-card:hover {
  box-shadow: var(--fmh-shadow-lg);
  transform: translateY(-2px);
}

/* Badge */
.fmh-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--fmh-radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.fmh-badge-premium {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}
.fmh-badge-free {
  background: var(--fmh-success);
  color: #fff;
}
.fmh-badge-new {
  background: var(--fmh-danger);
  color: #fff;
}

/* Grid */
.fmh-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.fmh-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.fmh-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }

@media (max-width: 768px) {
  .fmh-grid-2, .fmh-grid-3, .fmh-grid-4 {
    grid-template-columns: 1fr;
  }
  .fmh-section-title { font-size: 28px; }
  .fmh-section { padding: 40px 0; }
}
@media (min-width: 769px) and (max-width: 1024px) {
  .fmh-grid-3, .fmh-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}
