/**
 * math-tools.css — Standar Bersama Kalkulator Matematika Bantukerjain.com
 * Anti-AI-Slop Engineering:
 * - Palet Slate dewasa & kontras tinggi (#0F172A, #F8FAFC, #E2E8F0, aksen #2563EB)
 * - Task-first above the fold (breadcrumb tipis, H1 ringkas, alat langsung terlihat)
 * - Touch target >= 44px, ukuran font input >= 16px (anti auto-zoom mobile)
 * - font-variant-numeric: tabular-nums untuk seluruh angka, tabel, & rumus
 * - Zero horizontal overflow pada 360px, 390px, 768px, dan 1280px
 */

:root {
  --math-bg: #ffffff;
  --math-surface: #f8fafc;
  --math-surface-muted: #f1f5f9;
  --math-text: #0f172a;
  --math-text-secondary: #475569;
  --math-text-body: #334155;
  --math-border: #e2e8f0;
  --math-border-strong: #cbd5e1;
  --math-accent: #2563eb;
  --math-accent-hover: #1d4ed8;
  --math-accent-soft: #eff6ff;
  --math-error-bg: #fef2f2;
  --math-error-border: #fecaca;
  --math-error-text: #991b1b;
  --math-success-bg: #f0fdf4;
  --math-success-border: #bbf7d0;
  --math-success-text: #166534;
}

/* ===== Shared Page Shell & Overflow-X Guardrails ===== */
:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) {
  background-color: var(--math-surface);
  color: var(--math-text);
  overflow-x: clip;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) [hidden] {
  display: none !important;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .wrap {
  max-width: 1180px;
  padding: 0 12px;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 640px) {
  :is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .wrap {
    padding: 0 16px;
  }
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .breadcrumb {
  padding: 4px 0 0;
  font-size: 0.76rem;
  color: var(--math-text-secondary);
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .hero {
  padding: 2px 0 10px;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .hero h1 {
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  font-weight: 800;
  color: var(--math-text);
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 0 0 2px;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .hero .lead {
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--math-text-secondary);
  margin: 0;
}

/* ===== Standardized Inputs, Controls & Touch Targets (>=44px, >=16px) ===== */
:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page)
  :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
  font-size: max(1rem, 16px);
  min-height: 44px;
  color: var(--math-text);
  font-variant-numeric: tabular-nums;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page)
  :is(button, [role="button"], .btn-secondary, summary) {
  min-height: 44px;
  touch-action: manipulation;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page)
  :is(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--math-accent);
  outline-offset: 2px;
}

/* ===== Shared Tabular-Nums & Surface Panes ===== */
:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page)
  :is(table, th, td, code, pre, .tabular-nums) {
  font-variant-numeric: tabular-nums;
}

:is(
  .math-pane,
  .sci-calc-card,
  .sci-history-card,
  .graph-sidebar,
  .graph-stage,
  .graph-table-section,
  .matrix-input-pane,
  .matrix-result-pane,
  .stats-input-pane,
  .stats-result-pane
) {
  background: var(--math-bg);
  border: 1px solid var(--math-border);
  border-radius: 12px;
  min-width: 0;
  max-width: 100%;
}

/* ===== Shared Error & Status Callouts ===== */
.math-error-box {
  padding: 10px 12px;
  border: 1px solid var(--math-error-border);
  border-left: 3px solid #dc2626;
  border-radius: 8px;
  background: var(--math-error-bg);
  color: var(--math-error-text);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 12px;
}

/* ===== Below-the-Fold Editorial, Formulas, References & FAQ ===== */
:is(.math-guide-section, .sci-guide-section, .graph-guide-section, .matrix-guide-section, .stats-guide-section) {
  border-top: 1px solid var(--math-border);
  padding: 18px 0;
}

:is(.math-guide-section, .sci-guide-section, .graph-guide-section, .matrix-guide-section, .stats-guide-section) h2 {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--math-text);
  margin: 0 0 8px;
}

:is(.math-guide-section, .sci-guide-section, .graph-guide-section, .matrix-guide-section, .stats-guide-section) p {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--math-text-body);
  max-width: 80ch;
  margin: 0 0 12px;
}

:is(.math-guide-section, .sci-guide-section, .graph-guide-section, .matrix-guide-section, .stats-guide-section) details {
  border-bottom: 1px solid var(--math-border);
  background: transparent;
}

:is(.math-guide-section, .sci-guide-section, .graph-guide-section, .matrix-guide-section, .stats-guide-section)
  details:last-of-type {
  border-bottom: none;
}

:is(.math-guide-section, .sci-guide-section, .graph-guide-section, .matrix-guide-section, .stats-guide-section) summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 12px 4px;
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--math-text);
  cursor: pointer;
}

:is(.math-guide-section, .sci-guide-section, .graph-guide-section, .matrix-guide-section, .stats-guide-section)
  summary:hover {
  color: var(--math-accent);
}

:is(.math-guide-section, .sci-guide-section, .graph-guide-section, .matrix-guide-section, .stats-guide-section)
  .faq-body {
  padding: 0 4px 14px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--math-text-secondary);
  max-width: 80ch;
}

.math-formula-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin: 12px 0;
}

@media (min-width: 768px) {
  .math-formula-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.math-formula-item {
  border-left: 3px solid var(--math-accent);
  padding: 6px 0 6px 14px;
}

.math-formula-item h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--math-text);
  margin: 0 0 4px;
}

.math-formula-code {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 0.85rem;
  color: var(--math-text);
  font-variant-numeric: tabular-nums;
  margin: 0 0 4px;
  word-break: break-word;
}

/* ==========================================================================
   Shared B2B Sponsorship & Dual Feedback Strip (Matematika Pages)
   ========================================================================== */
:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .b2b-sponsor-slot {
  margin: 24px 0 18px;
  padding: 16px 20px;
  background: var(--math-bg);
  border: 1px solid var(--math-border);
  border-left: 4px solid var(--math-accent);
  border-radius: 8px;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .sponsor-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .sponsor-copy {
  flex: 1 1 280px;
  min-width: 0;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .sponsor-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--math-accent);
  margin-bottom: 4px;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .sponsor-text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--math-text-secondary);
  line-height: 1.5;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--math-text);
  background: var(--math-surface);
  border: 1px solid var(--math-border-strong);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .btn-secondary:hover {
  background: var(--math-surface-muted);
  border-color: #94a3b8;
  color: var(--math-text);
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .sponsor-cta {
  white-space: nowrap;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .feedback-strip {
  margin: 20px 0 28px;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .feedback-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .feedback-card {
  background: var(--math-bg);
  border: 1px solid var(--math-border);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .feedback-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--math-text);
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .feedback-card p {
  font-size: 0.85rem;
  color: var(--math-text-secondary);
  margin: 0 0 14px;
  line-height: 1.5;
  flex: 1;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .feedback-btn {
  align-self: flex-start;
}

@media (max-width: 640px) {
  :is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .feedback-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===== Generic Share Tool Integration (share-tool.js) ===== */
:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .bk-hero-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 2px;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .hero .bk-hero-head > h1 {
  flex: 1 1 200px;
  min-width: 0;
  margin: 0;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .bk-share-btn {
  width: auto;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--math-text);
  background: var(--math-bg);
  border: 1px solid var(--math-border-strong);
  border-radius: 8px;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .bk-share-btn:hover:not(:disabled) {
  background: var(--math-surface-muted);
  border-color: #94a3b8;
  color: var(--math-text);
}

/* ===== Bagikan Hasil & Restore URL UI (math-share.js) ===== */
:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--math-border);
  min-width: 0;
  max-width: 100%;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-box--stage {
  margin-top: 0;
  padding: 10px 12px 12px;
  background: var(--math-surface);
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  border: 1px solid var(--math-border-strong);
  border-radius: 8px;
  background: var(--math-bg);
  color: var(--math-text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-btn:hover:not(:disabled) {
  background: var(--math-surface-muted);
  border-color: #94a3b8;
  color: var(--math-text);
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-btn svg {
  flex-shrink: 0;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-disclosure {
  margin: 6px 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--math-text-secondary);
  max-width: none;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-status:empty {
  display: none;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-status {
  margin: 6px 0 0;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--math-accent-hover);
  overflow-wrap: anywhere;
  max-width: none;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-manual {
  margin-top: 8px;
  min-width: 0;
  max-width: 100%;
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-manual-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--math-text-body);
}

:is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-url {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--math-border-strong);
  border-radius: 8px;
  background: var(--math-surface);
  color: var(--math-text);
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: max(1rem, 16px);
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-all;
  resize: none;
}

/* ===== Print Report Cleanliness ===== */
@media print {
  :is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .no-print,
  :is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .b2b-sponsor-slot,
  :is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .feedback-strip,
  :is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) #shareResultBtn,
  :is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) .math-share-box {
    display: none !important;
  }

  :is(.math-page, .sci-page, .graph-page, .matrix-page, .stats-page) {
    background: #ffffff;
  }
}
