/* =========================================================
   babapic — Tool subpage styles (Phase 3)
   Loaded on every /{slug}/ page, after components.css.
   Homepage keeps using home.css instead; the two never overlap.
   ========================================================= */

/* ---- Tool hero (H1 + lead paragraph) ----
   Carries the same ambient drift as the homepage hero, but lighter and
   CSS-only (pseudo-elements) since this markup is generated per tool
   page and shouldn't need template changes for a decorative touch. */
.tool-hero {
  position: relative;
  overflow: hidden;
  padding-block: var(--space-8) var(--space-6);
  text-align: center;
}

.tool-hero::before,
.tool-hero::after {
  content: "";
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.25;
  pointer-events: none;
}

.tool-hero::before {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle at 30% 30%, var(--color-accent), transparent 70%);
  top: -160px;
  left: -60px;
  animation: drift-a var(--dur-drift) ease-in-out infinite;
}

.tool-hero::after {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle at 70% 70%, #6f9599, transparent 70%);
  top: -60px;
  right: -40px;
  animation: drift-b calc(var(--dur-drift) * 1.2) ease-in-out infinite;
}

.tool-hero > .container {
  position: relative;
  z-index: 1;
}

@media (max-width: 640px) {
  .tool-hero::after {
    display: none;
  }

  .tool-hero::before {
    opacity: 0.15;
  }
}

.tool-hero__title {
  max-width: 26ch;
  margin-inline: auto;
}

.tool-hero__lead {
  max-width: 60ch;
  margin: var(--space-4) auto 0;
  font-size: var(--fs-body-lg);
  color: var(--color-text-muted);
}

/* ---- Tool stage: dropzone + controls + status/error/result ---- */
.tool-stage {
  max-width: 640px;
  margin: var(--space-7) auto 0;
}

/* .dropzone sets display:flex as an author rule, which otherwise beats the
   UA stylesheet's [hidden]{display:none} — restate it explicitly so
   tool-runtime.js can toggle these panels with the plain `hidden` attribute. */
.tool-stage [hidden] {
  display: none !important;
}

.tool-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.tool-control {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1 1 180px;
}

.tool-control label {
  font-size: var(--fs-small);
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
}

.tool-control input[type="number"],
.tool-control select {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--color-text);
  font-size: var(--fs-small);
}

.tool-control input[type="range"] {
  accent-color: var(--color-accent);
  width: 100%;
}

.tool-control--checkbox {
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
}

.tool-control--checkbox input {
  width: 18px;
  height: 18px;
}

/* ---- Utility panel: base64 encode/decode text in/out (Phase 4, batch 4) ---- */
.tool-utility {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.tool-utility__label {
  font-size: var(--fs-small);
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
}

.tool-utility__textarea {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  resize: vertical;
  width: 100%;
}

.tool-stage__result .tool-utility__textarea {
  margin-bottom: var(--space-4);
}

.tool-control input[type="text"],
.tool-control input[type="color"] {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--color-text);
  font-size: var(--fs-small);
}

.tool-control input[type="color"] {
  padding: var(--space-1, 4px);
  height: 40px;
}

.tool-stage__status {
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--fs-body);
  padding: var(--space-6) 0;
}

.tool-stage__error {
  background: rgba(178, 59, 59, 0.08);
  border: 1px solid rgba(178, 59, 59, 0.3);
  color: var(--color-danger);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-4);
  font-size: var(--fs-small);
}

.tool-stage__result {
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
}

.tool-stage__result-info {
  color: var(--color-text-heading);
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-4);
}

.tool-stage__result-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
}

/* ---- Explainer block ---- */
.tool-explainer {
  max-width: 68ch;
  margin-inline: auto;
}

.tool-explainer p + p {
  margin-top: var(--space-4);
}

.tool-explainer p {
  color: var(--color-text-muted);
  line-height: var(--lh-body);
}

/* Editorial drop cap on the opening paragraph — CSS-only, no markup change. */
.tool-explainer p:first-of-type::first-letter {
  float: left;
  font-family: var(--font-serif);
  font-size: 3.4em;
  line-height: 0.85;
  font-weight: var(--fw-semibold);
  color: var(--color-accent);
  padding-right: var(--space-2);
  padding-top: 0.05em;
}

/* ---- FAQ width constraint (matches homepage) ---- */
.tool-faq .faq-list {
  max-width: 760px;
  margin-inline: auto;
}

/* ---- Related tools ---- */
.related-tools .tool-grid {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
  .related-tools .tool-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .tool-controls {
    flex-direction: column;
  }
}
