/* Calculators. Hubs and articles keep article.css; this file is the form and the result. */

body[data-page="tool"] .doc-wrap {
  width: min(100%, 68rem);
}

.tool-kicker {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.guide-index .tool-kicker {
  margin-top: 0;
}

.tool-layout {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.tool-form,
.tool-result {
  padding: 1.1rem 1.15rem 1.25rem;
  background: var(--white);
  border: 1px solid var(--line);
}

.tool-form fieldset {
  min-width: 0;
  margin: 1rem 0 0;
  padding: 0.95rem 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.tool-form legend {
  padding: 0;
  font-weight: 600;
}

.tool-fields {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.tool-field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
}

.tool-hint {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.tool-field input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
}

.tool-field select {
  margin-top: 0.4rem;
}

.tool-field input:focus-visible,
.tool-field select:focus-visible,
.tool-choice input:focus-visible,
.tool-text-btn:focus-visible,
.tool-form .btn:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.tool-error {
  margin-top: 0.35rem;
  color: #6e2a22;
  font-size: 0.88rem;
  line-height: 1.4;
}

.tool-choice {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin-top: 0.55rem;
}

.tool-choice input {
  margin-top: 0.2rem;
  accent-color: var(--green);
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1.1rem;
}

.tool-text-btn {
  min-height: 2.75rem;
  padding: 0.35rem 0;
  border: 0;
  background: transparent;
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 0.16em;
  cursor: pointer;
}

.tool-text-btn:hover {
  color: var(--green-hover);
}

.tool-room + .tool-room {
  margin-top: 0.95rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}

.tool-room-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.tool-room-head h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.tool-result h2 {
  font-size: 1.35rem;
  scroll-margin-top: calc(var(--header) + 1rem);
}

.tool-result-empty {
  margin-top: 0.45rem;
  color: var(--muted);
  line-height: 1.5;
}

.tool-figure {
  margin-top: 0.75rem;
  font-family: var(--serif);
  font-size: clamp(1.85rem, 3vw, 2.45rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.tool-figure span {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
}

.tool-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  line-height: 1.4;
}

.tool-line span {
  color: var(--muted);
}

.tool-line strong {
  font-weight: 600;
  text-align: right;
}

.tool-interpret {
  margin-top: 0.85rem;
  line-height: 1.55;
}

.tool-form .tool-hint a {
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.tool-form .tool-hint a:hover {
  color: var(--green);
}

body[data-page="tool"] [hidden],
body[data-page="tools"] [hidden] {
  display: none !important;
}

body[data-page="tool"] .doc-sources {
  display: grid;
  gap: 0.65rem;
  margin-top: 1.15rem;
  padding-left: 0;
  list-style: none;
}

body[data-page="tool"] .doc-sources li + li {
  margin-top: 0;
}

body[data-page="tool"] .doc-sources a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  min-height: 3.4rem;
  padding: 0.8rem 0.95rem;
  background: var(--white);
  border: 1px solid var(--line);
  text-decoration: none;
  line-height: 1.35;
}

body[data-page="tool"] .doc-sources a::after {
  content: "";
  width: 2.15rem;
  height: 2.15rem;
  flex: none;
  background-color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h12M9 3.5 13.5 8 9 12.5' fill='none' stroke='%23f3f6f4' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.85rem;
  transition: transform 0.35s var(--ease);
}

body[data-page="tool"] .doc-sources a:hover {
  color: inherit;
  border-color: var(--ink);
}

body[data-page="tool"] .doc-sources a:hover::after {
  transform: translateX(0.28rem);
}

body[data-page="tool"] .doc-sources a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

@media (min-width: 720px) {
  .tool-fields-2 {
    grid-template-columns: 1fr 1fr;
  }

  body[data-page="tool"] .doc-sources {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-page="tool"] .doc-sources a::after {
    transition: none;
  }
}

@media (min-width: 900px) {
  .tool-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(16rem, 0.85fr);
    align-items: start;
  }

  .tool-result {
    position: sticky;
    top: calc(var(--header) + 1rem);
  }
}
