/* Wasm Tools — site styles. Light theme with dark-mode support. */

:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #5b6b7f;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --panel: #101a2e;
    --text: #e6edf7;
    --muted: #93a4bb;
    --accent: #60a5fa;
    --accent-soft: #1e3a5f;
    --border: #1f2c47;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.site {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.15rem;
}

.brand-accent { color: var(--accent); }

.site-nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}

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

/* Main / hero */
.site-main { flex: 1; padding: 24px 0 48px; }

.hero { text-align: center; padding: 36px 12px 28px; }
.hero.small { padding: 20px 12px; }

.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  line-height: 1.2;
  margin: 0 0 12px;
}

.hero p { color: var(--muted); max-width: 640px; margin: 8px auto; }

/* Category blocks + cards */
.category-block { margin: 34px 0; }

.category-head h2 { margin: 0; font-size: 1.25rem; }
.category-head h2 a { color: var(--text); text-decoration: none; }
.category-head h2 a:hover { color: var(--accent); }
.category-head p { color: var(--muted); margin: 4px 0 14px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.tool-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.tool-card h3 { margin: 0 0 6px; font-size: 1.02rem; }
.tool-card p { margin: 0 0 10px; color: var(--muted); font-size: 0.9rem; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.cli { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.badge.soon { background: transparent; border: 1px dashed var(--border); color: var(--muted); }

/* Tool page */
.tool-page { max-width: 860px; margin: 0 auto; }

.tool-head h1 { margin: 8px 0 6px; }
.tool-desc { color: var(--muted); margin: 0 0 20px; }

.tool-body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.tool-loading { color: var(--muted); padding: 12px 0; }
.tool-loading.hidden, .hidden { display: none; }

.text-tool { display: flex; flex-direction: column; gap: 12px; }

.tool-input, .tool-output {
  width: 100%;
  min-height: 220px;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

.tool-controls, .op-buttons, .output-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover { filter: brightness(1.1); color: #fff; }

.indent-picker { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.indent-picker select { margin-left: 4px; }

.tool-status { color: var(--muted); font-size: 0.88rem; margin: 0; min-height: 1.2em; visibility: hidden; }
.tool-status.visible { visibility: visible; }

.privacy-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.cli-note {
  margin-top: 26px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.cli-note h2 { font-size: 1.05rem; margin: 0 0 8px; }
.cli-note p { color: var(--muted); margin: 0 0 10px; font-size: 0.92rem; }

.cli-note pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.coming-soon { color: var(--muted); text-align: center; padding: 30px 0; }

/* JS tool mount area */
.js-tool-mount { min-height: 120px; }

/* Prose pages */
.prose { max-width: 760px; margin: 0 auto; }
.prose h1 { margin-top: 12px; }
.prose li { margin: 8px 0; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 30px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* JS-tool inner widgets (rendered inside .js-tool-mount by tool bundles) */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }

.file-list { list-style: none; margin: 12px 0; padding: 0; }
.file-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg);
  font-size: 0.9rem;
}
.file-list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list li .meta { color: var(--muted); font-size: 0.8rem; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.result-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  font-size: 0.85rem;
}

.result-card img, .result-card video { width: 100%; display: block; }
.result-card .result-actions { padding: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

.progress-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 10px 0; }
.progress-bar .fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.2s ease; }

.field-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.field-row label { color: var(--muted); font-size: 0.88rem; }
.field-row input[type="text"], .field-row input[type="number"], .field-row select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.error-box {
  border: 1px solid #f87171;
  background: rgba(248, 113, 113, 0.08);
  color: #b91c1c;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin: 10px 0;
}

@media (prefers-color-scheme: dark) {
  .error-box { color: #fca5a5; }
}

/* Binary-output preview (e.g. SVG → PNG result image) */
.tool-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    repeating-conic-gradient(var(--border) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px;
  padding: 12px;
  text-align: center;
}
.tool-preview img { max-width: 100%; max-height: 420px; }

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 14px 0 4px;
}
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { margin: 0 6px; }

/* SEO content blocks under tools */
.prose-block {
  margin-top: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
}
.prose-block h2 { margin: 0 0 10px; font-size: 1.15rem; }
.prose-block p { color: var(--muted); margin: 6px 0; }

.how-to { margin: 8px 0; padding-left: 22px; }
.how-to li { margin: 8px 0; color: var(--muted); }

/* Long-form guide sections on tool pages. */
.guide h3 { margin: 22px 0 6px; font-size: 1.02rem; }
.guide h3:first-of-type { margin-top: 4px; }
.guide ul { margin: 8px 0; padding-left: 22px; }
.guide li { margin: 6px 0; color: var(--muted); }
.guide-table { overflow-x: auto; margin: 10px 0; }
.guide table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.guide th, .guide td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.guide th { background: var(--accent-soft); }
.guide td { color: var(--muted); }

.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 8px 0;
  padding: 10px 14px;
  background: var(--bg);
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}
.faq-item p { margin: 8px 0 2px; color: var(--muted); }
