/* Shared presentation for the five browser-side analysis tools. */

.tool-page {
  --tool-border: #d9e8e0;
  --tool-soft: #eef8f4;
  --tool-shadow: 0 18px 48px rgba(26, 58, 42, 0.08);
  overflow-wrap: anywhere;
}

.tool-page .site-shell {
  width: min(1120px, calc(100% - 32px));
}

.tool-page main,
.tool-layout,
.tool-content,
.tool-panel,
.tool-workspace,
.tool-results,
.tool-chart,
.tool-chart-wrap,
.tool-table-wrap {
  min-width: 0;
  max-width: 100%;
}

.tool-layout {
  width: 100%;
  margin: 0 auto 40px;
}

.tool-content {
  padding: clamp(24px, 4vw, 46px);
  border: 1px solid rgba(8, 127, 91, 0.1);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--tool-shadow);
}

.tool-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: 12px 0 30px;
  border-bottom: 1px solid var(--line);
}

.tool-hero-copy {
  min-width: 0;
}

.tool-kicker,
.tool-eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tool-hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(30px, 5vw, 50px);
  line-height: 1.16;
  letter-spacing: -0.045em;
}

.tool-hero p:not(.tool-kicker):not(.tool-eyebrow) {
  max-width: 780px;
  margin: 14px 0 0;
  color: #53635b;
  font-size: 15px;
  line-height: 1.85;
}

.tool-hero-badge {
  align-self: start;
}

.tool-workspace {
  margin-top: 28px;
}

.tool-panel {
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--tool-border);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(26, 58, 42, 0.045);
}

.tool-panel + .tool-panel,
.tool-results + .tool-panel,
.tool-panel + .tool-results {
  margin-top: 20px;
}

.tool-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.tool-panel-heading h2,
.tool-panel-heading h3 {
  margin: 0;
  line-height: 1.3;
}

.tool-panel-heading p {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.tool-form {
  margin: 0;
}

.tool-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  align-items: end;
  gap: 16px;
}

.tool-field {
  min-width: 0;
}

.tool-field label,
.tool-field > span,
.tool-label {
  display: block;
  margin-bottom: 7px;
  color: #35473e;
  font-size: 12px;
  font-weight: 850;
}

.tool-field small,
.tool-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.tool-input,
.tool-select,
.tool-field input,
.tool-field select,
.tool-field textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid #ccdcd3;
  border-radius: 12px;
  outline: 0;
  background: #fbfdfc;
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.tool-field textarea {
  min-height: 112px;
  resize: vertical;
}

.tool-select,
.tool-field select {
  cursor: pointer;
}

.tool-input:hover,
.tool-select:hover,
.tool-field input:hover,
.tool-field select:hover,
.tool-field textarea:hover {
  border-color: rgba(8, 127, 91, 0.45);
  background: #fff;
}

.tool-input:focus-visible,
.tool-select:focus-visible,
.tool-field input:focus-visible,
.tool-field select:focus-visible,
.tool-field textarea:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(8, 127, 91, 0.14);
  background: #fff;
}

.tool-input[aria-invalid="true"],
.tool-select[aria-invalid="true"],
.tool-field [aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(217, 76, 76, 0.1);
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.tool-button,
.tool-submit,
.tool-actions button,
.tool-actions a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  color: #fff;
  border: 1px solid var(--green);
  border-radius: 12px;
  background: var(--green);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.tool-button:hover,
.tool-submit:hover,
.tool-actions button:hover,
.tool-actions a:hover {
  border-color: #056b4c;
  background: #056b4c;
  transform: translateY(-1px);
}

.tool-button:focus-visible,
.tool-submit:focus-visible,
.tool-actions button:focus-visible,
.tool-actions a:focus-visible,
.tool-related-link:focus-visible {
  outline: 3px solid rgba(8, 127, 91, 0.24);
  outline-offset: 3px;
}

.tool-button.secondary,
.tool-button.is-secondary,
.tool-actions .secondary {
  color: var(--green);
  border-color: rgba(8, 127, 91, 0.28);
  background: var(--green-soft);
}

.tool-button.secondary:hover,
.tool-button.is-secondary:hover,
.tool-actions .secondary:hover {
  border-color: rgba(8, 127, 91, 0.42);
  background: #d9f2e8;
}

.tool-button:disabled,
.tool-submit:disabled,
.tool-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.tool-status {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 0;
  padding: 11px 13px;
  color: #425048;
  border: 1px solid var(--tool-border);
  border-radius: 12px;
  background: #f7faf8;
  font-size: 12px;
  line-height: 1.55;
}

.tool-status:empty {
  display: none;
}

.tool-status.is-loading,
.tool-status[data-state="loading"] {
  color: #245a49;
  border-color: rgba(8, 127, 91, 0.22);
  background: var(--green-soft);
}

.tool-status.is-success,
.tool-status[data-state="success"] {
  color: #086b4e;
  border-color: rgba(8, 127, 91, 0.28);
  background: #eaf8f2;
}

.tool-status.is-error,
.tool-status[data-state="error"] {
  color: #a23535;
  border-color: rgba(217, 76, 76, 0.25);
  background: var(--red-soft);
}

.tool-spinner {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: tool-spin 700ms linear infinite;
}

@keyframes tool-spin {
  to { transform: rotate(360deg); }
}

.tool-results {
  margin-top: 22px;
}

.tool-results[aria-busy="true"] {
  opacity: 0.68;
}

.tool-summary-grid,
.tool-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 14px;
}

.tool-summary-card,
.tool-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--tool-border);
  border-radius: 16px;
  background: #fbfdfc;
}

.tool-summary-card > span,
.tool-card-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
}

.tool-summary-card > strong,
.tool-card-value {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.tool-summary-card > small,
.tool-card-note {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.tool-summary-card.positive,
.tool-card.positive {
  border-color: rgba(8, 127, 91, 0.25);
  background: #effaf6;
}

.tool-summary-card.negative,
.tool-card.negative {
  border-color: rgba(217, 76, 76, 0.2);
  background: #fff6f6;
}

.tool-chart,
.tool-chart-wrap {
  position: relative;
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--tool-border);
  border-radius: 16px;
  background: #f7faf8;
}

.tool-chart canvas,
.tool-chart-wrap canvas,
canvas.tool-chart-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: clamp(280px, 42vw, 430px);
  touch-action: pan-y;
}

.tool-chart-caption {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.tool-table-wrap {
  width: 100%;
  margin-top: 18px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--tool-border);
  border-radius: 15px;
  background: #fff;
  contain: inline-size;
  -webkit-overflow-scrolling: touch;
}

.tool-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  color: #47574f;
  font-size: 12px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

.tool-table th,
.tool-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #e4ece7;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.tool-table th {
  color: #195743;
  background: var(--tool-soft);
  font-size: 11px;
  font-weight: 900;
}

.tool-table tbody tr:last-child td {
  border-bottom: 0;
}

.tool-table tbody tr:hover {
  background: #f8fbf9;
}

.tool-table .numeric {
  text-align: right;
}

.tool-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 5px 9px;
  color: var(--green);
  border: 1px solid rgba(8, 127, 91, 0.18);
  border-radius: 999px;
  background: var(--green-soft);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
}

.tool-badge.neutral { color: #526159; border-color: var(--line); background: #f4f7f5; }
.tool-badge.positive { color: #087252; border-color: rgba(8, 127, 91, 0.24); background: #eaf8f2; }
.tool-badge.warning { color: #9a6410; border-color: rgba(213, 138, 21, 0.24); background: #fff7e8; }
.tool-badge.negative { color: #ad3d3d; border-color: rgba(217, 76, 76, 0.22); background: var(--red-soft); }

.tool-formula,
.tool-method,
.tool-limitations,
.tool-source,
.tool-note {
  margin-top: 20px;
  padding: 18px 20px;
  border: 1px solid var(--tool-border);
  border-radius: 16px;
  background: #f8fbf9;
}

.tool-formula { border-color: rgba(128, 87, 199, 0.18); background: #f8f5fd; }
.tool-method { border-color: rgba(8, 127, 91, 0.2); background: var(--green-soft); }
.tool-limitations { border-color: rgba(213, 138, 21, 0.22); background: #fff9ed; }
.tool-source { border-color: #dce6e0; background: #f7f9f8; }

.tool-formula h2,
.tool-formula h3,
.tool-method h2,
.tool-method h3,
.tool-limitations h2,
.tool-limitations h3,
.tool-source h2,
.tool-source h3,
.tool-note h2,
.tool-note h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.tool-formula p,
.tool-method p,
.tool-limitations p,
.tool-source p,
.tool-note p,
.tool-limitations li,
.tool-method li {
  margin-top: 0;
  color: #526159;
  font-size: 12px;
  line-height: 1.8;
}

.tool-formula p:last-child,
.tool-method p:last-child,
.tool-limitations p:last-child,
.tool-source p:last-child,
.tool-note p:last-child {
  margin-bottom: 0;
}

.tool-formula code,
.tool-formula .formula {
  display: block;
  max-width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  overflow-wrap: anywhere;
  color: #503a78;
  border-radius: 10px;
  background: rgba(128, 87, 199, 0.08);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: normal;
}

.tool-source a,
.tool-method a,
.tool-limitations a,
.tool-note a {
  color: var(--green);
  font-weight: 800;
}

.tool-related {
  margin-top: 30px;
}

.tool-related > h2,
.tool-related > h3 {
  margin: 0 0 14px;
}

.tool-related-grid,
.tool-related-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
}

.tool-related-link,
.tool-related-links a {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  color: #28594a;
  border: 1px solid var(--tool-border);
  border-radius: 14px;
  background: #fff;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.45;
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.tool-related-link:hover,
.tool-related-links a:hover {
  color: var(--green);
  border-color: rgba(8, 127, 91, 0.35);
  background: var(--green-soft);
  transform: translateY(-1px);
}

.tool-related-link::after,
.tool-related-links a::after {
  content: "→";
  flex: 0 0 auto;
  font-size: 16px;
}

.tool-ad,
.tool-page .guide-ad {
  min-width: 0;
  min-height: 170px;
  margin: 30px 0;
  padding: 14px;
  overflow: hidden;
  border: 1px dashed #d7e3dc;
  border-radius: 15px;
  background: #fbfcfb;
}

.tool-ad > span,
.tool-page .guide-ad > span {
  display: block;
  margin-bottom: 8px;
  color: #9da8a2;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.tool-ad .adsbygoogle,
.tool-page .guide-ad .adsbygoogle {
  width: 100%;
  max-width: 100%;
  min-height: 130px;
}

/* Interactive forms and result grids must not be split by Auto ads. */
.tool-workspace > .google-auto-placed,
.tool-workspace > ins.adsbygoogle:not(.tool-fixed-ad),
.tool-form > .google-auto-placed,
.tool-results > .google-auto-placed,
.tool-results > ins.adsbygoogle:not(.tool-fixed-ad),
[data-ad-exclusion-target^="tool-"] > .google-auto-placed,
[data-ad-exclusion-target^="tool-"] > ins.adsbygoogle:not(.tool-fixed-ad) {
  display: none !important;
}

.tool-empty {
  padding: 24px;
  color: var(--muted);
  border: 1px dashed #ccdcd3;
  border-radius: 16px;
  background: #fafcfb;
  line-height: 1.75;
  text-align: center;
}

@media (max-width: 760px) {
  .tool-page .site-shell {
    width: min(100% - 24px, 1120px);
  }

  .tool-content {
    padding: 22px 18px;
    border-radius: 22px;
  }

  .tool-hero {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 14px;
    padding-bottom: 24px;
  }

  .tool-form-grid,
  .tool-summary-grid,
  .tool-card-grid,
  .tool-related-grid,
  .tool-related-links {
    grid-template-columns: 1fr;
  }

  .tool-panel-heading {
    flex-direction: column;
    gap: 8px;
  }

  .tool-actions > *,
  .tool-button,
  .tool-submit {
    flex: 1 1 100%;
    width: 100%;
  }

  .tool-chart,
  .tool-chart-wrap {
    padding: 8px;
  }

  .tool-chart canvas,
  .tool-chart-wrap canvas,
  canvas.tool-chart-canvas {
    height: 300px;
  }

  .tool-formula,
  .tool-method,
  .tool-limitations,
  .tool-source,
  .tool-note {
    padding: 16px;
  }
}

@media (max-width: 420px) {
  .tool-content {
    padding: 18px 14px;
  }

  .tool-panel {
    padding: 16px 13px;
    border-radius: 18px;
  }

  .tool-hero h1 {
    font-size: clamp(28px, 10vw, 38px);
  }

  .tool-chart canvas,
  .tool-chart-wrap canvas,
  canvas.tool-chart-canvas {
    height: 270px;
  }

  .tool-status,
  .tool-summary-card,
  .tool-card,
  .tool-empty {
    padding-left: 13px;
    padding-right: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool-page *,
  .tool-page *::before,
  .tool-page *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
