/* ThinkaBell Tool Page Layout Enhancements
   ================================
   Shared layout, mobile, accessibility, and AdSense compliance styles for tool pages.
   ================================ */

/* ── Tool Hero ──────────────────────────────────────────── */
.tool-hero {
  text-align: center;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem);
  background: linear-gradient(180deg, var(--white) 0%, var(--paper) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}
.tool-hero__icon {
  width: 4rem; height: 4rem;
  margin: 0 auto 1rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(79,70,229,.08));
  font-size: 2rem;
  color: var(--amber-dark);
}
.tool-hero__title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  margin: 0 0 .5rem;
  line-height: 1.15;
  color: var(--ink);
}
.tool-hero__desc {
  font-size: var(--text-lg);
  color: var(--slate);
  margin: 0 0 .75rem;
  font-weight: 500;
}
.tool-hero__lead {
  font-size: var(--text-base);
  color: var(--moss);
  margin: 0;
  max-width: 60ch;
  margin-inline: auto;
  line-height: 1.6;
}

/* ── AdSense Compliance ─────────────────────────────────── */
.tb-ad-container {
  margin: 3rem 0;
  padding: 1.25rem;
  background: var(--paper);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  clear: both;
  min-height: 100px;
  contain: layout;
}
.tb-ad-label {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: .75rem;
}
.tb-ad-privacy {
  display: inline-block;
  margin-left: .5rem;
  font-size: .75rem;
  color: var(--amber-dark);
  text-decoration: none;
}
.tb-ad-privacy:hover { text-decoration: underline; }

/* Standard AdSense ad slot with consistent margins */
.tb-ad-slot--standard {
  margin-block: 3rem;
  clear: both;
  min-height: 90px;
}

/* In-article ad placed between content sections */
.tb-in-article-ad {
  margin-block: 2.5rem;
  clear: both;
  padding: 1rem 0;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}

/* Ensure ads are not too close to nav or interactive elements */
.tool-hero + .tb-ad-container,
.tb-form-card + .tb-ad-container,
.tb-result-grid + .tb-ad-container,
.tb-analysis-card + .tb-ad-container {
  margin-top: 3rem;
}

/* ── Form Layout & Validation ───────────────────────────── */
.tb-form-card {
  max-width: 42rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md), 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.tb-form-card:hover {
  border-color: var(--slate);
  box-shadow: var(--shadow-lg), 0 2px 8px rgba(0,0,0,.06);
}
.tb-form-card form {
  display: grid;
  gap: 1.25rem;
}
.tb-form__row {
  display: grid;
  gap: .4rem;
}
.tb-form__row label {
  font-weight: 600;
  font-size: .9rem;
  color: var(--ink);
}
.tb-form__row input,
.tb-form__row select,
.tb-form__row textarea {
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 1rem;
  background: var(--white);
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.tb-form__row input:focus,
.tb-form__row select:focus,
.tb-form__row textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
  outline: none;
}
.tb-form__row input:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,.12);
}
.tb-form__row .error-msg {
  font-size: .8rem;
  color: var(--danger-text);
  font-weight: 500;
}
.tb-form__row input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,.12);
}

/* ── Buttons & Actions ──────────────────────────────────── */
.tb-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 1.25rem;
}
.tb-action-row--start {
  justify-content: flex-start;
}
.tb-action-row .btn,
.tb-action-row button,
.tb-action-row .tb-btn,
.tb-action-row .tb-tool-btn {
  min-height: 44px;
  min-width: 44px;
}
.tb-action-row .btn--primary,
.tb-action-row .tb-btn--primary,
.tb-action-row .tb-tool-btn--primary {
  min-width: 120px;
}
.tb-action-row--start .btn--primary,
.tb-action-row--start .tb-btn--primary,
.tb-action-row--start .tb-tool-btn--primary {
  min-width: 120px;
}
.tb-sticky-actions {
  position: sticky;
  bottom: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(248,250,252,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: .75rem 1rem;
  padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  justify-content: flex-end;
  z-index: 100;
  margin-top: 1rem;
  border-radius: var(--radius-lg);
}
@media (min-width: 768px) {
  .tb-sticky-actions {
    position: static;
    background: transparent;
    border: none;
    padding: 0;
    padding-bottom: 0;
    backdrop-filter: none;
  }
}

/* ── Result Grid & Cards ────────────────────────────────── */
.tb-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: clamp(.75rem, 2vw, 1.25rem);
  margin-top: 1.5rem;
}
.tb-result-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform .25s ease, box-shadow .25s ease;
}
.tb-result-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.tb-result-card__label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--slate);
  margin-bottom: .35rem;
}
.tb-result-card__value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--amber-dark);
}
.tb-result-card__value--lg {
  font-size: 2rem;
}

/* ── Loading & Empty States ─────────────────────────────── */
.tb-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 2rem;
  color: var(--slate);
  font-weight: 500;
}
.tb-loading::before {
  content: "";
  width: 1.25rem; height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: tbSpin .8s linear infinite;
}
@keyframes tbSpin {
  to { transform: rotate(360deg); }
}
.tb-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--slate);
  grid-column: 1 / -1;
}
.tb-empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .7;
}
.tb-empty-state p {
  margin: 0;
  font-size: .95rem;
}

/* ── Mobile Optimization ────────────────────────────────── */
@media (max-width: 767px) {
  .tool-hero {
    text-align: left;
  }
  .tool-hero__icon {
    margin: 0 0 .75rem;
  }
  .tb-form-card {
    padding: 1.25rem;
  }
  .tb-form__row {
    grid-template-columns: 1fr;
  }
  .tb-action-row {
    flex-direction: column;
    align-items: stretch;
  }
  .tb-action-row .btn,
  .tb-action-row button {
    width: 100%;
    justify-content: center;
  }
  .tb-result-grid {
    grid-template-columns: 1fr;
  }
  .tb-sticky-actions {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 0;
    right: 0;
    border-radius: 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0,0,0,.08);
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
  }
  .tb-sticky-actions .btn,
  .tb-sticky-actions button {
    flex: 1;
    justify-content: center;
  }
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Touch target minimums */
  .tb-form__row input,
  .tb-form__row select,
  .tb-form__row textarea,
  .tb-form__row label,
  .tb-result-card,
  .tb-result-card *,
  .tb-action-row .btn,
  .tb-action-row button,
  .tb-sticky-actions .btn,
  .tb-sticky-actions button,
  .tool-hero__icon,
  .tb-tool-output {
    min-height: 44px;
  }
  .tb-form__row label {
    display: flex;
    align-items: center;
  }
}

/* ── Accessibility ──────────────────────────────────────── */
.tb-sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; white-space: nowrap; clip-path: inset(50%);
}
.tb-tool-output:empty::before {
  content: "Results will appear here...";
  color: var(--slate);
  font-style: italic;
  display: block;
  padding: 1rem;
  text-align: center;
}
.tb-metric-card[aria-hidden="true"] {
  opacity: .5;
}

/* Benefit Cards - Why Choose This Tool */
.tb-benefits {
  max-width: 72rem;
  margin: 2rem auto 0;
  padding: 0 clamp(1rem, 4vw, 2rem);
}
.tb-benefits .tb-section__title {
  text-align: center;
  margin-bottom: 1.5rem;
}
.tb-benefit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}
.tb-benefit-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
.tb-benefit-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.tb-benefit-card__icon {
  font-size: 2rem;
  margin-bottom: .75rem;
}
.tb-benefit-card__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 .5rem;
}
.tb-benefit-card__desc {
  font-size: .9rem;
  color: var(--slate);
  line-height: 1.6;
  margin: 0;
}

/* Related Tools Cards */
.tb-related-section {
  max-width: 72rem;
  margin: 2rem auto 0;
  padding: 0 clamp(1rem, 4vw, 2rem);
}
.tb-related-section h2 {
  text-align: center;
  margin-bottom: 1.5rem;
}
.tb-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: clamp(1rem, 2vw, 1.25rem);
}
.tb-related-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.tb-related-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--amber);
}
.tb-related-card__icon {
  font-size: 1.5rem;
  margin-bottom: .5rem;
}
.tb-related-card__title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 .35rem;
}
.tb-related-card__desc {
  font-size: .85rem;
  color: var(--slate);
  line-height: 1.5;
  margin: 0;
}

/* Step Cards for How-To */
.tb-howto {
  max-width: 72rem;
  margin: 2rem auto 0;
  padding: 0 clamp(1rem, 4vw, 2rem);
}
.tb-howto h2 {
  text-align: center;
  margin-bottom: 1rem;
}
.tb-howto > p {
  text-align: center;
  color: var(--slate);
  max-width: 60ch;
  margin-inline: auto;
  margin-bottom: 1.5rem;
}
.tb-howto ol {
  max-width: 640px;
  margin-inline: auto;
  padding-left: 0;
  list-style: none;
  counter-reset: step;
}
.tb-howto li {
  counter-increment: step;
  position: relative;
  padding-left: 3.5rem;
  margin-bottom: 1.25rem;
  font-size: .95rem;
  line-height: 1.6;
  color: var(--slate);
}
.tb-howto li:before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 2.25rem;
  height: 2.25rem;
  background: var(--amber-dark);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  font-family: var(--font-mono);
}
.tb-howto li strong {
  display: block;
  color: var(--ink);
  margin-bottom: .25rem;
}

/* AdSense content block */
.tb-ad-content-block {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2rem);
}
.tb-ad-content-block h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0 0 1rem;
}
.tb-ad-content-block p {
  font-size: var(--text-base);
  color: var(--slate);
  line-height: 1.7;
  margin: 0 0 1rem;
}
.tb-ad-content-block p:last-child {
  margin-bottom: 0;
}

/* ── Touch Targets ──────────────────────────────────────── */
button, .btn, .tb-btn, .tb-tool-btn, .tb-card, .tb-filter-tab, .tb-tool-card-enhanced, [role="button"], input[type="submit"], input[type="button"], .tb-action-row button, .tb-sticky-actions button, .tb-related-card {
  min-height: 44px;
  min-width: 44px;
}
.tb-form__row input, .tb-form__row select, .tb-form__row textarea {
  min-height: 44px;
}
.tb-filter-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Empty States ───────────────────────────────────────── */
.tb-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--slate);
  grid-column: 1 / -1;
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}
.tb-empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .7;
}
.tb-empty-state p {
  margin: 0;
  font-size: .95rem;
}
.tb-upload-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--slate);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--paper);
}
.tb-upload-empty__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: .6;
}
.tb-upload-empty p {
  margin: 0;
  font-size: 1rem;
}
