/* ==========================================================================
   ToolHex design system — mobile-first, no framework.
   "Workshop" palette: warm paper, ink, burnt orange, deep green accent.
   ========================================================================== */

:root {
  --bg: #faf7f2;          /* warm paper */
  --surface: #ffffff;
  --ink: #201d1a;         /* warm near-black */
  --muted: #6e675f;       /* warm gray */
  --faint: #a39e93;
  --brand: #c2410c;       /* burnt orange */
  --brand-dark: #9a3412;
  --brand-soft: #fbede3;  /* light orange tint */
  --green: #2e7d4f;       /* trust / success accent */
  --border: #e8e2d8;      /* warm hairline */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(32, 29, 26, .07);
  --max: 1080px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1 0 auto; }

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 16px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.02em;
}
.logo em { font-style: normal; color: var(--brand); }
.logo:hover { text-decoration: none; }
.logo-mark { display: block; flex-shrink: 0; }
.site-nav { display: flex; gap: 18px; font-size: .95rem; }
.site-nav a { color: var(--muted); font-weight: 500; }
.site-nav a:hover { color: var(--brand); text-decoration: none; }

/* ---------- Tools drawer (hamburger menu) ---------- */
.menu-btn {
  background: none;
  border: 0;
  padding: 8px;
  margin-left: -8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--ink);
  border-radius: 8px;
}
.menu-btn:hover { color: var(--brand); background: var(--brand-soft); }
@media (max-width: 720px) { .site-nav { display: none; } }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 40;
}
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  max-width: 86vw;
  background: var(--surface);
  z-index: 50;
  transform: translateX(-102%);
  transition: transform .22s ease;
  box-shadow: 0 0 40px rgba(15, 23, 42, .18);
  overflow-y: auto;
  padding: 16px 20px 32px;
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
body.drawer-open { overflow: hidden; }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.drawer-title { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.drawer-close {
  background: none;
  border: 0;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.drawer-close:hover { color: var(--brand); background: var(--brand-soft); }
.drawer-home {
  display: block;
  padding: 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .92rem;
}
.drawer-home:hover { background: var(--brand-soft); text-decoration: none; }
.drawer-section { margin-top: 12px; }
.drawer-section-name {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--faint);
  font-weight: 700;
}
.drawer-section-toggle {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
}
.drawer-section-toggle:hover { background: var(--brand-soft); }
.drawer-section-toggle:hover .drawer-section-name,
.drawer-section-toggle:hover .drawer-chevron { color: var(--brand); }
.drawer-chevron { color: var(--faint); transition: transform .2s ease; flex-shrink: 0; }
.drawer-section-toggle[aria-expanded="true"] .drawer-chevron { transform: rotate(180deg); }
.drawer-links { padding: 2px 0 6px 6px; }
.drawer-section a {
  display: block;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 500;
  font-size: .95rem;
}
.drawer-section a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer-backdrop { transition: none; }
}

/* ---------- Page head ---------- */
.page-head { padding: 44px 0 8px; }
.page-head h1 {
  font-size: clamp(1.65rem, 4.5vw, 2.45rem);
  line-height: 1.15;
  margin: 0 0 10px;
  letter-spacing: -.025em;
}
.lead { color: var(--muted); font-size: 1.05rem; margin: 0; max-width: 62ch; }

/* ---------- Category sections (hub) ---------- */
.tool-section { margin-top: 36px; }
.tool-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  font-size: 1.25rem;
  letter-spacing: -.015em;
}
.tool-section-title::before {
  content: "";
  width: 4px;
  height: 1.15em;
  border-radius: 2px;
  background: var(--brand);
}
.tool-section > p { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 24px 0 8px;
}
@media (min-width: 640px) { .tool-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .tool-grid { grid-template-columns: repeat(3, 1fr); } }

.tool-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tool-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: 0 6px 16px rgba(32, 29, 26, .10);
}
.tool-card h2, .tool-card h3 { margin: 0 0 6px; font-size: 1.12rem; color: var(--ink); letter-spacing: -.01em; }
.tool-card p { margin: 0; color: var(--muted); font-size: .95rem; }
.tool-card .badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--green);
  margin-bottom: 8px;
}
.tool-card .badge.soon { color: var(--faint); }

/* ---------- Tool UI ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.dropzone p { margin: 6px 0; }
.dropzone .hint { color: var(--faint); font-size: .85rem; }

.btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

label { font-weight: 600; font-size: .95rem; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
select, input[type="number"], input[type="text"], textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  max-width: 100%;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  color: var(--green);
  font-weight: 600;
}

/* ---------- Ad slot: fixed size, empty, no layout shift ---------- */
.ad-slot {
  min-height: 250px;
  margin: 32px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, #f3eee5, #f3eee5 10px, #ece6d9 10px, #ece6d9 20px);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--faint);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* ---------- Content (500+ word sections, FAQ) ---------- */
.content { max-width: 75ch; padding-bottom: 16px; }
.content h2 { font-size: 1.4rem; margin: 2rem 0 .5rem; letter-spacing: -.015em; }
.content h3 { font-size: 1.1rem; margin: 1.5rem 0 .25rem; }
.content p, .content li { color: #403a33; }
.content ul, .content ol { padding-left: 1.4rem; }

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 0;
}
.faq summary { font-weight: 600; cursor: pointer; }
.faq details p { margin: 8px 0 2px; }

/* ---------- Tool controls & results ---------- */
.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}
@media (min-width: 700px) { .controls { grid-template-columns: repeat(3, 1fr); align-items: end; } }
.control label { display: block; margin-bottom: 4px; }
.control select, .control input { width: 100%; }

.results { margin-top: 24px; }
.results-title { margin: 0 0 4px; font-size: 1.2rem; }
.results-summary { margin: 0 0 12px; color: var(--green); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.results-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.results-table th, .results-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.results-table th {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.saved { color: var(--green); font-weight: 700; }
.larger { color: #b42318; font-weight: 700; }
.btn-small { padding: 6px 12px; font-size: .85rem; border-radius: 6px; }
.results-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Queue & progress (tool workflow) ---------- */
.queue { margin-top: 14px; }
.queue-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}
.queue-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.queue-list li:last-child { border-bottom: 0; }
.queue-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg);
}
.queue-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .9rem;
}
.queue-size { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.queue-remove {
  background: none;
  border: 0;
  color: var(--faint);
  cursor: pointer;
  font-size: 1.15rem;
  padding: 4px 8px;
  line-height: 1;
}
.queue-remove:hover { color: var(--brand); }

.actions-row { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

.progress-wrap { margin-top: 16px; }
.progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width .2s ease;
}
.progress-status { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }

/* Indeterminate progress (for blocking WASM jobs) — compositor-thread animation */
.progress-bar.indeterminate {
  width: 40%;
  transition: none;
  animation: indet-slide 1.1s ease-in-out infinite;
}
@keyframes indet-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
  .progress-bar.indeterminate { animation: none; width: 100%; opacity: .4; }
}

/* ---------- Text tools ---------- */
.text-tool textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  font: inherit;
  line-height: 1.55;
  padding: 12px 14px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.stat-num { display: block; font-size: 1.25rem; font-weight: 800; color: var(--brand); letter-spacing: -.02em; }
.stat-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.output-meta { color: var(--muted); font-size: .88rem; margin: 10px 0 0; }
.checkbox-row { display: flex; gap: 8px 20px; flex-wrap: wrap; margin-top: 12px; font-size: .92rem; }
.checkbox-row label { display: flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
.checkbox-row input { accent-color: var(--brand); }
.field-row { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
@media (min-width: 640px) { .field-row { grid-template-columns: 1fr 1fr; } }
.field-row label { display: block; margin-bottom: 4px; }
.field-row input[type="text"] { width: 100%; }

/* ---------- Footer ---------- */
.site-footer {
  background: #1c1a17;
  color: #cfc9be;
  margin-top: 64px;
  padding: 32px 0;
  font-size: .9rem;
  flex-shrink: 0;
}
.site-footer a { color: #cfc9be; }
.site-footer a:hover { color: #fff; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.site-footer p { margin: 0; color: #8f887c; }
