/* Tools: calculators, checkers and the checklist. */

.tool-page {
    display: grid;
    gap: var(--space-6);
}

.tool-page > * {
    min-width: 0;
}

.tool-form {
    max-width: 44rem;
}

.tool-span {
    grid-column: 1 / -1;
}

.tool-form > button {
    grid-column: 1 / -1;
    justify-self: start;
}

.tool-note {
    color: var(--color-muted);
    font-size: var(--step--1);
}

.tool-print {
    background: var(--color-surface);
    border-color: var(--color-control-border);
    color: var(--color-ink);
}

.tool-print:hover {
    background: var(--color-canvas);
    border-color: var(--color-ink);
}

.tool-checklist {
    display: grid;
    gap: var(--space-3);
    max-width: 48rem;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: check;
}

.tool-checklist li {
    position: relative;
    margin: 0;
    padding: var(--space-4) var(--space-4) var(--space-4) 3.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    counter-increment: check;
}

.tool-checklist li::before {
    content: counter(check);
    position: absolute;
    left: var(--space-4);
    top: var(--space-4);
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--color-brand-tint-strong);
    color: var(--color-brand-deep);
    font-size: var(--step--1);
    font-weight: 700;
}

@media (min-width: 48rem) {
    .tool-form {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .tool-form fieldset {
        grid-column: 1 / -1;
    }
}

@media print {
    .tool-no-print {
        display: none !important;
    }

    .tool-checklist li {
        break-inside: avoid;
    }
}

/* Driving assumptions and method notes: closed sections with a chevron */

.tool-assumptions,
.tool-method {
    padding: 0 var(--space-4);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.tool-method {
    max-width: 56rem;
}

.tool-assumptions > summary,
.tool-method > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 3.25rem;
    color: var(--color-ink);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.tool-assumptions > summary::-webkit-details-marker,
.tool-method > summary::-webkit-details-marker {
    display: none;
}

.tool-assumptions > summary::after,
.tool-method > summary::after {
    content: "";
    flex: none;
    width: 0.55rem;
    height: 0.55rem;
    margin-top: -0.25rem;
    border-right: 2px solid var(--color-brand-deep);
    border-bottom: 2px solid var(--color-brand-deep);
    transform: rotate(45deg);
    transition: transform var(--speed) var(--ease);
}

.tool-assumptions[open] > summary::after,
.tool-method[open] > summary::after {
    margin-top: 0.25rem;
    transform: rotate(-135deg);
}

.tool-assumptions[open],
.tool-method[open] {
    padding-bottom: var(--space-4);
}

.tool-assumptions__fields {
    display: grid;
    gap: var(--space-2) var(--space-4);
    margin-top: var(--space-2);
}

.tool-method > p {
    max-width: var(--measure);
}

.tool-form:not(:has([name="nights"] option[value="custom"]:checked)) [data-custom-nights] {
    display: none;
}

.tool-page .callout,
.tool-page .key-facts,
.tool-page .data-table {
    max-width: 56rem;
}

.tool-page .sources {
    max-width: var(--measure);
}

.tool-page > :is(p, ul, ol, h2, h3),
.tool-form > p {
    margin: 0;
}

/* Fields carry their own message line, so rows sit close together. */

.tool-form {
    row-gap: var(--space-2);
}

.tool-form > .tool-assumptions,
.tool-form > fieldset {
    margin-bottom: var(--space-3);
}

@media (min-width: 48rem) {
    .tool-assumptions__fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* The heading of a result: the page scrolls to it after the form is sent. */

.tool-result-title {
    margin: 0;
    padding-top: var(--space-5);
    border-top: 1px solid var(--color-border);
    scroll-margin-top: calc(var(--header-height) + 0.5rem);
}

/* The result has its own heading, so the fact block does not repeat one. */

.tool-result-title ~ .key-facts > h2 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}
