/* ==========================================================================
   KDFTek redesign v1 — Tool Page Template (Worker 4)
   --------------------------------------------------------------------------
   Scope: /tools/<slug>/ pages only. Pure CSS — zero JS changes, zero markup
   changes (the <link> tag is injected by the batch script; everything else
   restyles existing classes/ids the tool JS depends on).

   Builds on redesign-v1-tokens.css (loaded earlier in <head>): every new
   token reference carries a fallback to the site's legacy variables so the
   page still looks right if tokens ever fail to load.

   What this file does:
     1. Ad slots collapse gracefully when empty (no more blank "ADVERTISEMENT"
        gaps). A slot only renders once AdSense has actually filled it.
     2. The tool itself is the hero: bigger result display, generous inputs
        with clear focus rings, prominent action buttons.
     3. Related-tools grid picks up the shared card styles and gets a
        responsive layout mapping.
     4. Breadcrumb + page header polish.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Ad slots: collapse unless AdSense has filled them
   --------------------------------------------------------------------------
   AdSense marks each <ins class="adsbygoogle"> with data-ad-status="filled"
   once an ad renders (and "unfilled" when the request returns no ad), and a
   rendered ad always contains an <iframe>. Until either signal is present —
   before the ad request completes, when the request is blocked, or when it
   comes back empty — the whole slot (label included) stays out of layout,
   so empty "ADVERTISEMENT" boxes never render as blank gaps.
   The <ins> elements and adsbygoogle.js are untouched: filled ads keep
   working exactly as before. Browsers without :has() simply keep the old
   behaviour (progressive enhancement). */
/* stylelint-disable-next-line */
.ad-slot:not(:has(ins.adsbygoogle[data-ad-status="filled"])):not(:has(ins.adsbygoogle iframe)) {
  display: none;
}

/* When the sidebar ad never fills, collapse the rail as well and let the
   tool content use the full width instead of leaving a 300px dead column. */
.tool-layout:has(> .tool-rail:not(:has(ins.adsbygoogle[data-ad-status="filled"])):not(:has(ins.adsbygoogle iframe))) {
  grid-template-columns: minmax(0, 1fr);
}
.tool-layout:has(> .tool-rail:not(:has(ins.adsbygoogle[data-ad-status="filled"])):not(:has(ins.adsbygoogle iframe))) > .tool-rail {
  display: none;
}

/* When a slot IS showing, keep its label subtle and elegant. */
.ad-slot-label {
  font-size: 10px;
  letter-spacing: .16em;
  opacity: .7;
}

/* --------------------------------------------------------------------------
   2. The tool card is the hero
   -------------------------------------------------------------------------- */
.tool-page .tool-card {
  padding: clamp(24px, 4vw, 44px);
  border-radius: var(--radius-xl, 24px);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl, 0 24px 64px -12px rgba(15, 20, 17, .18));
}
.tool-page #tool {
  scroll-margin-top: 96px;
}

/* --- Result panel: the star of the page --- */
.tool-page .tool-result {
  background: linear-gradient(165deg, var(--brand-50, #f0fdf4) 0%, #ffffff 78%);
  border: 1px solid var(--line-brand, rgba(22, 163, 74, .28));
  border-radius: var(--radius-lg, 16px);
  padding: clamp(26px, 4vw, 40px) clamp(20px, 4vw, 36px);
  box-shadow: var(--shadow-md, 0 4px 12px -2px rgba(15, 20, 17, .08)), inset 0 1px 0 #ffffff;
}
.tool-page .tool-result .big {
  font-size: clamp(44px, 10vw, 84px);
  font-weight: var(--weight-extrabold, 800);
  letter-spacing: var(--tracking-display, -.025em);
  line-height: 1.02;
  color: var(--brand-800, #166534);
  overflow-wrap: anywhere;
}
.tool-page .tool-result .meta {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brand-800, #166534);
}
.tool-page .tool-result .stat-list strong {
  font-size: 1.25rem;
}
.tool-page .tool-result .hint {
  font-size: 13px;
}

/* --- Inputs: generous padding, clear focus rings --- */
.tool-page .tool-controls label {
  gap: 10px;
  font-size: var(--text-sm, .875rem);
  font-weight: 600;
}
.tool-page .tool-controls input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
.tool-page .tool-controls select,
.tool-page .tool-controls textarea {
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-md, 12px);
  border: 1.5px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-size: 16px; /* keeps iOS from zooming on focus */
  line-height: 1.4;
  transition: border-color var(--dur-fast, 150ms), box-shadow var(--dur-fast, 150ms), background var(--dur-fast, 150ms);
}
.tool-page .tool-controls input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):hover,
.tool-page .tool-controls select:hover,
.tool-page .tool-controls textarea:hover {
  border-color: rgba(22, 163, 74, .45);
}
.tool-page .tool-controls input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):focus,
.tool-page .tool-controls select:focus,
.tool-page .tool-controls textarea:focus {
  outline: none;
  border-color: var(--brand-600, var(--green, #16a34a));
  box-shadow: 0 0 0 4px rgba(22, 163, 74, .16);
  background: #ffffff;
}
.tool-page .tool-controls input::placeholder,
.tool-page .tool-controls textarea::placeholder {
  color: var(--muted);
  opacity: .7;
}
.tool-page .file-drop input[type="file"] {
  border-radius: 14px;
  padding: 14px;
  transition: border-color var(--dur-fast, 150ms), background var(--dur-fast, 150ms);
}
.tool-page .file-drop input[type="file"]:hover {
  border-color: rgba(22, 163, 74, .45);
  background: var(--brand-50, #f0fdf4);
}

/* --- Segmented toggle (unit switchers etc.): iOS-style pill --- */
.tool-page .seg {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
}
.tool-page .seg button {
  border: 0;
  background: transparent;
  border-radius: 11px;
  padding: 12px 16px;
  min-height: 48px;
  font-weight: 700;
  color: var(--muted);
  transition: background var(--dur-fast, 150ms), color var(--dur-fast, 150ms), box-shadow var(--dur-fast, 150ms);
}
.tool-page .seg button.on {
  background: #ffffff;
  color: var(--brand-800, #166534);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 20, 17, .06));
}
.tool-page .seg button:not(.on):hover {
  color: var(--ink);
  background: rgba(255, 255, 255, .65);
}

/* --- Action buttons: big, tactile, on-brand --- */
.tool-page .tool-card .btn {
  min-height: 52px;
  padding: 0 26px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform var(--dur-fast, 150ms), box-shadow var(--dur-base, 250ms), filter var(--dur-fast, 150ms), background var(--dur-fast, 150ms);
}
.tool-page .tool-card .btn-primary {
  background: var(--grad-brand, linear-gradient(135deg, #22c55e 0%, #16a34a 100%));
  color: #ffffff;
  border: 0;
  box-shadow: var(--shadow-brand-lg, 0 16px 48px -12px rgba(22, 163, 74, .5));
}
.tool-page .tool-card .btn-primary:hover {
  transform: translateY(-1px);
  filter: saturate(1.12);
}
.tool-page .tool-card .btn-primary:active {
  transform: translateY(0);
  filter: none;
}
.tool-page .tool-card .btn:focus-visible {
  outline: 3px solid rgba(22, 163, 74, .45);
  outline-offset: 2px;
}
.tool-page .tool-result .btn-row {
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   3. Related tools: responsive grid mapping over the shared card styles
   --------------------------------------------------------------------------
   The markup already uses the shared .tools-grid / .tool-tile card classes
   (Worker 3's listing stylesheet styles those globally), so this only maps
   the section layout: auto-filling responsive columns instead of a fixed
   3-column grid. */
.tool-page .tool-more {
  margin-top: 56px;
  max-width: none;
}
.tool-page .tool-more h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: var(--tracking-tight, -.02em);
  margin-bottom: 6px;
}
.tool-page .tool-more .tools-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 22px;
}

/* --------------------------------------------------------------------------
   4. Breadcrumb + page header polish
   -------------------------------------------------------------------------- */
.tool-page .crumbs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-full, 999px);
  padding: 9px 20px;
  margin: 0 0 28px;
  font-size: 13px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 20, 17, .06));
}
.tool-page .crumbs a {
  color: var(--brand-700, #15803d);
  font-weight: 600;
  text-decoration: none;
}
.tool-page .crumbs a:hover {
  color: var(--brand-800, #166534);
  text-decoration: underline;
}
.tool-page .crumbs > span {
  color: var(--muted);
  opacity: .55;
}
.tool-page .crumbs > span:last-child {
  color: var(--ink);
  font-weight: 700;
  opacity: 1;
}

.tool-page .tool-hero {
  max-width: 780px;
  margin-bottom: 34px;
}
.tool-page .tool-hero-top {
  margin-bottom: 4px;
}
.tool-page .tool-hero-top .tool-icon {
  display: inline-grid;
  place-items: center;
  line-height: 0;
  box-sizing: content-box;
  padding: 11px;
  border-radius: 18px;
  background: var(--grad-brand-soft, linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%));
  border: 1px solid var(--line-brand, rgba(22, 163, 74, .28));
  color: var(--brand-700, #15803d);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 20, 17, .06));
}
.tool-page .tool-hero h1 {
  font-size: clamp(2.25rem, 5.5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: var(--tracking-display, -.025em);
  line-height: 1.06;
  margin: 16px 0 14px;
  color: var(--ink);
}
.tool-page .tool-hero > p {
  font-size: 17px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 64ch;
}

/* --------------------------------------------------------------------------
   5. Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 560px) {
  .tool-page .tool-card {
    padding: 22px 18px;
    border-radius: 18px;
  }
  .tool-page .tool-result {
    padding: 24px 18px;
  }
  .tool-page .tool-hero h1 {
    font-size: clamp(2rem, 9vw, 2.6rem);
  }
  .tool-page .crumbs {
    padding: 8px 16px;
    margin-bottom: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool-page .tool-card .btn,
  .tool-page .tool-controls input,
  .tool-page .tool-controls select,
  .tool-page .tool-controls textarea,
  .tool-page .seg button {
    transition: none;
  }
}

/* --- Duplicate-result guard (2026-10-03): tool pages render exactly one
   .tool-result / .big. Hide any runtime-injected duplicates. No-op for
   correct markup. --- */
.tool-card .tool-result ~ .tool-result,
.tool-card .tool-result .big ~ .big{display:none}
