/* ============================================================
   GO AI free tools — layered on styles.css
   Uses the site's existing custom properties (--bg, --fg, --muted,
   --dim, --border, --accent-gold, --accent-blue, --font-ui,
   --font-display, --r-*, --pad-x). Ship as /assets/tools.css
   ============================================================ */

/* The [hidden] attribute is display:none in the UA stylesheet, which ANY author
   display declaration outranks — and .tool-field/.tool-btn set flex. Without
   this, every hidden panel renders anyway (the compare-only fields showed up in
   search mode, the imperial height inputs sat next to the metric ones, and the
   Stop button was permanently visible). Keep this rule first. */
[hidden] { display: none !important; }

.tool-page {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(96px, 14vh, 150px) var(--pad-x) 80px;
}

.tool-hero { margin-bottom: clamp(28px, 5vh, 48px); }
.tool-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.6vw, 2.9rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.tool-hero p { color: var(--muted); font-size: 1.05rem; line-height: 1.65; margin: 0; max-width: 62ch; }
.tool-crumbs { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; color: var(--dim); margin-bottom: 20px; }
.tool-crumbs a { color: var(--muted); text-decoration: none; }
.tool-crumbs a:hover { color: var(--fg); }

/* ---------- Panels ---------- */
.tool-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-soft);
  padding: clamp(20px, 3vw, 30px);
  margin-bottom: 24px;
}
.tool-card + .tool-card { margin-top: 0; }

/* ---------- Form controls ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px 18px;
}
.tool-field { display: flex; flex-direction: column; gap: 7px; }
.tool-field label { font-size: 0.85rem; font-weight: 600; color: var(--fg); }
.tool-field .hint { font-size: 0.78rem; color: var(--dim); line-height: 1.45; }

.tool-input, .tool-select, .tool-textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  min-height: 44px;
  appearance: none;
  transition: border-color var(--d-fast) var(--ease-out);
}
.tool-input:focus, .tool-select:focus, .tool-textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
}
.tool-textarea { min-height: 150px; resize: vertical; line-height: 1.6; font-size: 0.95rem; }
.tool-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

/* segmented toggle (units, etc.) */
.tool-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px; gap: 3px; }
.tool-seg button {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 36px;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out);
}
.tool-seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

.tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-weight: 700; font-size: 0.95rem;
  padding: 12px 24px; min-height: 44px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--fg); color: var(--bg);
}
.tool-btn:hover { opacity: 0.9; }
.tool-btn--ghost { background: none; color: var(--fg); border: 1px solid var(--border-strong); }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Results ---------- */
.tool-result { margin-top: 4px; }
.tool-headline {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  padding: 22px 24px; margin-bottom: 18px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
}
.tool-headline .num {
  font-family: var(--font-display); font-size: clamp(2rem, 5vw, 2.6rem);
  font-weight: 800; line-height: 1; color: var(--fg);
}
.tool-headline .unit { color: var(--muted); font-size: 1rem; }
.tool-headline .label { color: var(--dim); font-size: 0.85rem; width: 100%; }

.tool-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.tool-stat {
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg); padding: 14px 16px;
}
.tool-stat .k { font-size: 0.78rem; color: var(--dim); display: block; margin-bottom: 5px; }
.tool-stat .v { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--fg); }
.tool-stat .sub { font-size: 0.78rem; color: var(--muted); display: block; margin-top: 3px; }

/* tables */
.tool-tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-sm); }
.tool-table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
.tool-table th, .tool-table td {
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border);
  color: var(--muted); vertical-align: top; line-height: 1.5;
}
.tool-table th { color: var(--fg); font-weight: 600; font-size: 0.82rem; white-space: nowrap; background: var(--bg-soft); }
.tool-table tr:last-child td { border-bottom: 0; }
.tool-table td.num, .tool-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tool-table tr[data-best="1"] td { color: var(--fg); }

/* the "show the working" block */
.tool-work {
  margin-top: 16px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg);
}
.tool-work summary {
  cursor: pointer; padding: 13px 16px; font-weight: 600; color: var(--fg);
  font-size: 0.92rem; list-style: none;
}
.tool-work summary::-webkit-details-marker { display: none; }
.tool-work summary::after { content: "+"; float: right; color: var(--accent-gold); }
.tool-work[open] summary::after { content: "–"; }
.tool-work .body { padding: 0 16px 16px; color: var(--muted); font-size: 0.9rem; line-height: 1.65; }
.tool-work code, .tool-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em; background: var(--section-card, oklch(0.985 0.01 80 / 0.05));
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
}

/* notes / warnings */
.tool-note {
  margin-top: 16px; padding: 13px 16px; border-radius: var(--r-sm);
  font-size: 0.88rem; line-height: 1.6; color: var(--muted);
  border: 1px solid var(--border); background: var(--bg);
}
.tool-note--warn { border-color: oklch(0.75 0.14 55 / 0.5); }
.tool-note strong { color: var(--fg); }

/* ---------- Explainer prose under the tool (this is what ranks) ---------- */
.tool-prose { margin-top: 48px; max-width: 68ch; }
.tool-prose h2 {
  font-family: var(--font-display); font-size: clamp(1.3rem, 2.5vw, 1.6rem);
  font-weight: 700; margin: 36px 0 12px; letter-spacing: -0.01em;
}
.tool-prose h3 { font-family: var(--font-display); font-size: 1.08rem; font-weight: 700; margin: 26px 0 8px; }
.tool-prose p, .tool-prose li { color: var(--muted); font-size: 1rem; line-height: 1.72; }
.tool-prose p { margin: 0 0 15px; }
.tool-prose ul, .tool-prose ol { margin: 0 0 15px; padding-left: 22px; }
.tool-prose li { margin-bottom: 6px; }
.tool-prose li::marker { color: var(--accent-gold); }
.tool-prose a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.tool-prose a:hover { text-decoration-color: var(--accent-gold); }
.tool-prose strong { color: var(--fg); font-weight: 600; }

.tool-faq details {
  border: 1px solid var(--border); border-radius: var(--r-sm);
  margin-bottom: 10px; background: var(--bg-soft);
}
.tool-faq summary { cursor: pointer; padding: 14px 18px; font-weight: 600; color: var(--fg); list-style: none; }
.tool-faq summary::-webkit-details-marker { display: none; }
.tool-faq summary::after { content: "+"; float: right; color: var(--accent-gold); }
.tool-faq details[open] summary::after { content: "–"; }
.tool-faq details p { padding: 0 18px 14px; margin: 0; }

/* ---------- CTA ---------- */
.tool-cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
  margin: 44px 0 8px; padding: 24px 26px;
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: linear-gradient(135deg, oklch(0.16 0.02 82 / 0.6), oklch(0.14 0.02 250 / 0.4));
}
.tool-cta img { width: 60px; height: 60px; border-radius: 13px; }
.tool-cta-copy { flex: 1; min-width: 220px; }
.tool-cta-copy h2 { font-family: var(--font-display); margin: 0 0 5px; font-size: 1.15rem; color: var(--fg); }
.tool-cta-copy p { margin: 0; font-size: 0.92rem; color: var(--muted); line-height: 1.55; }

/* ---------- Tools index ---------- */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.tools-card {
  display: flex; flex-direction: column; gap: 9px; padding: 24px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-soft); text-decoration: none; color: var(--fg);
  transition: border-color var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out);
}
.tools-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.tools-card h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin: 0; line-height: 1.3; }
.tools-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.55; margin: 0; flex: 1; }
.tools-card .for { font-size: 0.78rem; color: var(--dim); }

/* results list (app store tool) */
.tool-list { display: grid; gap: 10px; }
.tool-row {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--bg);
}
.tool-row img { width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0; background: var(--bg-soft); }
.tool-row .meta { flex: 1; min-width: 0; }
.tool-row .name { font-weight: 600; color: var(--fg); font-size: 0.96rem; display: block; }
.tool-row .sub { color: var(--dim); font-size: 0.82rem; display: block; margin-top: 2px; }
.tool-row .rank { font-family: var(--font-display); font-size: 1.1rem; font-weight: 800; color: var(--dim); width: 30px; text-align: right; flex-shrink: 0; }
.tool-row a { color: var(--fg); text-decoration: none; }
.tool-row a:hover { text-decoration: underline; }

.tool-status { color: var(--dim); font-size: 0.9rem; padding: 12px 0; }
.tool-status[data-error] { color: oklch(0.75 0.16 30); }

@media (max-width: 640px) {
  .tool-page { padding-top: 88px; }
  .tool-headline { padding: 18px; }
}
