/*
 * utils-page.css — shell for the free-tool pages under /utilities/<util>.
 *
 * utils.html is the base for ~27 tools; utils2.html serves the AI detector.
 * Both keep their markup close to what it was, because each child template
 * fills {% block util %} with jQuery-bound ids and inline-styled controls —
 * so the shell is restyled here rather than rewritten per page.
 *
 * Linked from base2.html's <head> (guarded on `util_data`), not from
 * utils.html, because the children override {% block head %} without super().
 * That also means a page's own <style> block still wins over everything here.
 *
 * Component vocabulary follows sapling-ds.css.
 */

/* ---------------------------------------------------------------------------
 * Layout
 *
 * The tool column comes first in source order so it is what you land on — the
 * old shell put the sidebar's prose above the tool on narrow viewports.
 * ------------------------------------------------------------------------- */
.utils-shell {
  padding-bottom: 4rem;
}
/* Lift the tool row into the hero band, same device as /grammar-check. */
.utils-row {
  position: relative;
  z-index: 1;
  margin-top: -3rem;
}
/* .utils-row is a flexbox and a flex item defaults to min-width:auto, so a
   child whose min-content is wider than the row refuses to shrink and pushes
   the page into horizontal scroll on phones. */
.utils-row,
.utils-row > *,
.utils-description,
.utils-description > * {
  min-width: 0;
  max-width: 100%;
}

/* ---------------------------------------------------------------------------
 * Tool panel
 * ------------------------------------------------------------------------- */
.utils-tool {
  padding: 1.75rem;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-panel);
  background: #fff;
  box-shadow: 0 18px 40px rgb(16 20 45 / 12%);
}
.utils-tool > h2:first-child,
.utils-tool > h3:first-child {
  margin-top: 0;
}
/* The tools' inputs are inline-styled in each child template (border, radius,
   padding all set on the element), so unifying them needs !important. Only the
   chrome and the width cap are touched — sizing stays with the page that knows
   the tool.
   Matched by exclusion rather than [type="text"]: several of these inputs carry
   no type attribute at all (an attribute selector matches the attribute, not
   the defaulted-to value), including the two that used to overflow. */
.utils-tool textarea,
.utils-tool select,
.utils-tool input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]) {
  border: 1px solid #c9cfe6 !important;
  border-radius: var(--border-radius-lg) !important;
  color: var(--ds-ink) !important;
  background-color: #fff;
  /* `size="30"` at 14pt renders ~364px, which pushed the whole page sideways
     on a 390px phone (/utilities/medical-spellcheck, pharma-spellcheck,
     pagecheck). Let them shrink instead. */
  max-width: 100%;
}
.utils-tool textarea:focus,
.utils-tool select:focus,
.utils-tool input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):focus {
  outline: 2px solid var(--ds-accent-soft);
  outline-offset: 2px;
  border-color: var(--sapling-blue) !important;
}

/* The action button every tool renders. It was #651fff purple — off-brand and
   the only place that colour appears on the site. main2.css's global
   `.btn { border: 0 }` is why it needs an explicit border to keep its shape. */
.trigger-button,
a.trigger-button,
button.trigger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.6rem 1.25rem;
  border: 1px solid var(--sapling-blue);
  border-radius: var(--border-radius-lg);
  background-color: var(--sapling-blue);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.25;
  box-shadow: 0 6px 16px rgb(45 58 140 / 22%);
  transition: background-color var(--transition-fast), border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}
.trigger-button:hover,
a.trigger-button:hover,
button.trigger-button:hover {
  background-color: var(--sapling-blue-dark);
  border-color: var(--sapling-blue-dark);
  color: #fff;
  text-decoration: none;
}
.trigger-button:focus-visible {
  outline: 2px solid var(--ds-accent-soft);
  outline-offset: 2px;
}
.trigger-button[disabled] {
  opacity: 0.55;
  box-shadow: none;
}

/* Results lists the tools append to. */
.utils-tool .s2s-result,
.utils-tool .list-group-item {
  border-color: var(--ds-line);
}

/* ---------------------------------------------------------------------------
 * Sidebar
 * ------------------------------------------------------------------------- */
.utils-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.utils-card {
  padding: 1.25rem;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-panel);
  background: #fff;
}
.utils-card h2,
.utils-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ds-ink);
}
.utils-card p {
  color: var(--ds-ink-soft);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}
.utils-card p:last-child,
.utils-card .s-btn:last-child {
  margin-bottom: 0;
}
.utils-card .s-btn {
  width: 100%;
  margin-bottom: 0.5rem;
}
/* main2.css styles .util-tag as a grey 1px box; make them read as chips. */
.utils-card .util-tag {
  padding: 0.2em 0.7em;
  border: 1px solid var(--ds-line);
  border-radius: var(--border-radius-pill);
  background-color: var(--ds-surface);
  color: var(--ds-ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
  margin-right: 0.25em;
}
.utils-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* utils2.html lays the same cards out in a row under a full-width tool rather
   than in a column beside it. */
.utils-cards-row {
  margin-top: 2.5rem;
}
.utils-cards-row > [class*="col-"] {
  display: flex;
  margin-bottom: 1rem;
}
.utils-cards-row .utils-card {
  width: 100%;
}

/* ---------------------------------------------------------------------------
 * Long-form copy below the tool
 * ------------------------------------------------------------------------- */
.utils-description {
  max-width: 46rem;
  margin: 3rem auto 0;
  color: var(--ds-ink-soft);
  line-height: 1.7;
}
.utils-description h2,
.utils-description h3 {
  color: var(--ds-ink);
}
.utils-tool h2,
.utils-tool h3 {
  color: var(--ds-ink);
}

@media (max-width: 991px) {
  .utils-row {
    margin-top: -2rem;
  }
  .utils-sidebar {
    margin-top: 1rem;
  }
}
@media (max-width: 700px) {
  .utils-tool {
    padding: 1.1rem;
  }
  .utils-shell {
    padding-bottom: 2.5rem;
  }
}
