/* Date calculator (/tools/date-calculator). Shares tools.css for the heading, checks, help text and copy buttons. */
.date-app { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
/* The tabs (what to work out) and, beside them, one answer or a whole list. The second control is quieter, so the two never read as one row of tabs. */
.date-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 24px 24px 0; }
.date-modes { display: inline-flex; padding: 4px; border: 1px solid #ccd5e3; border-radius: 6px; background: #fff; }
.date-modes button { padding: 9px 18px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-soft); font-size: .84rem; font-weight: 600; cursor: pointer; }
.date-modes button[aria-selected="true"] { background: var(--accent); color: #fff; }
.date-amounts { display: inline-flex; padding: 3px; border: 1px solid #d5dce7; border-radius: 6px; background: #f3f6fa; }
.date-amounts button { padding: 8px 14px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-soft); font-size: .8rem; font-weight: 600; cursor: pointer; }
.date-amounts button:hover { color: var(--ink); }
.date-amounts button[aria-pressed="true"] { background: #fff; color: var(--accent); box-shadow: 0 1px 2px #18202b1a, inset 0 0 0 1px #c6d3f6; }

/* The question reads as one sentence; its controls wrap in pairs that belong together. */
.date-question { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0; padding: 22px 24px; font-size: 1.22rem; font-weight: 500; line-height: 1.4; }
.date-question[hidden], .date-question [hidden] { display: none; }
.date-group, .date-field { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.date-field { gap: 4px 10px; }
.date-question input, .date-question select { width: auto; min-height: 46px; padding: 8px 10px; border: 1px solid #b6c0cf; border-radius: var(--radius); background: #fff; color: var(--ink); font-size: 1.05rem; font-weight: 500; }
/* Menus fit the chosen word ("days", "business days") where browsers can size them that way. */
.date-question select, .date-format select { field-sizing: content; min-width: 5.5em; }
#date-amount { width: 7ch; text-align: right; font-variant-numeric: tabular-nums; }
.date-question input[aria-invalid="true"] { border-color: #c65335; box-shadow: inset 0 0 0 1px #c65335; }
.date-today { padding: 6px 2px; font-size: .8rem; font-weight: 600; }

/* The answer keeps its height between states, so typing never makes the page jump. */
.date-answer { min-height: 176px; margin: 0 24px; padding: 20px 24px 22px; border: 1px solid #d7e1ef; border-radius: 8px; background: #eef3fb; }
.date-answer[hidden] { display: none; }
.date-answer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.date-answer-head h2 { margin: 0; color: #51637c; font-size: .62rem; }
.date-answer-head .copy-control { padding: 4px 10px; font-size: .8rem; font-weight: 600; }
.date-answer-main { margin: 8px 0 6px; color: #162d4b; font-size: clamp(1.5rem, 3.4vw, 2.15rem); font-weight: 500; line-height: 1.25; letter-spacing: -.02em; }
.date-answer.is-message .date-answer-main { color: var(--ink-soft); font-size: 1.1rem; letter-spacing: 0; }
.date-answer.is-problem { border-color: #efc7bb; background: #fff4f0; }
.date-answer.is-problem .date-answer-main { color: #8b2913; font-size: 1rem; line-height: 1.6; letter-spacing: 0; }
.date-answer-detail { margin: 0 0 16px; color: #51637c; font-size: .86rem; }
.date-answer-detail:empty { display: none; }
.date-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 24px; margin: 0; }
.date-facts:empty { display: none; }
.date-facts div { min-width: 0; padding-top: 10px; border-top: 1px solid #d0dbec; }
.date-facts dt { color: #51637c; font: 500 .62rem/1.5 var(--mono); letter-spacing: .09em; text-transform: uppercase; }
.date-facts dd { margin: 4px 0 0; color: #162d4b; font-size: .9rem; overflow-wrap: anywhere; }
.date-notes { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.date-notes:empty { display: none; }
.date-notes li { padding: 10px 12px; border-left: 3px solid var(--accent); border-radius: 0 4px 4px 0; background: #fff; color: #29456e; font-size: .84rem; line-height: 1.55; }

.date-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 14px 24px 18px; font-size: .84rem; }
.date-actions .text-button { font-weight: 600; }
.date-customize-summary { color: var(--ink-soft); font-size: .78rem; }
.date-customize { display: inline-flex; align-items: center; gap: 8px; }
.date-customize .site-icon { width: 18px; height: 18px; }
.date-customize[aria-expanded="true"] { color: var(--ink); }

.date-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 32px; padding: 4px 24px 26px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; background: var(--paper-soft); }
.date-settings[hidden], .date-setting[hidden] { display: none; }
.date-setting { min-width: 0; max-width: 620px; margin: 0; padding: 0; border: 0; }
.date-setting legend { padding: 20px 0 0; font-size: .9rem; font-weight: 600; }
.date-setting-help { margin: 4px 0 0; color: var(--ink-soft); font-size: .78rem; line-height: 1.55; }
/* Choices are whole rows, the size of the page's other controls, each showing what it would make of the answer. */
.date-choices { display: grid; gap: 8px; margin: 12px 0 0; }
.date-choice { position: relative; display: block; cursor: pointer; }
/* The real radio stays in place, unseen, so the keyboard, screen readers and forms work as usual. */
.date-choice input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; }
.date-choice > span { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 10px 14px; border: 1px solid #ccd5e3; border-radius: 6px; background: #fff; transition: border-color .15s, background .15s; }
.date-choice > span::before { content: ''; flex: 0 0 18px; height: 18px; border: 2px solid #9aaac2; border-radius: 50%; background: #fff; box-sizing: border-box; }
.date-choice:hover > span { border-color: #9fb4d8; }
.date-choice input:checked + span { border-color: var(--accent); background: #f2f5ff; box-shadow: inset 0 0 0 1px var(--accent); }
.date-choice input:checked + span::before { border: 5px solid var(--accent); }
.date-choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.date-choice strong { font-size: .86rem; font-weight: 600; color: var(--ink); }
.date-choice small { margin-left: auto; padding-left: 8px; color: #51637c; font-size: .8rem; white-space: nowrap; }
.date-choice small:empty { display: none; }
.date-choice input:checked + span small { color: var(--accent); font-weight: 600; }
.date-holidays { margin: 10px 0 0; font-size: .78rem; }
.date-holidays[hidden] { display: none; }
.date-holidays summary { color: var(--accent); cursor: pointer; padding: 4px 0; }
.date-holidays table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: .74rem; }
.date-holidays th, .date-holidays td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.date-holidays th { color: var(--ink-soft); font-weight: 600; }
.date-extra-label { display: block; margin: 18px 0 6px; font-size: .84rem; font-weight: 600; }
.date-extra-label span { color: var(--ink-soft); font-weight: 400; }
#date-extra { display: block; width: 100%; min-height: 84px; padding: 10px 12px; border: 1px solid #b6c0cf; border-radius: var(--radius); background: #fff; color: var(--ink); font-size: .86rem; line-height: 1.6; resize: vertical; }
#date-extra[aria-invalid="true"], #date-extra-status.is-problem { border-color: #c65335; color: #8b2913; }
.date-order-switch { padding: 0; font: inherit; font-weight: 600; }

/* A list: dates on the left, one answer per line on the right. */
.date-list { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); margin: 0 24px; border: 1px solid var(--line); border-radius: 8px; }
.date-list[hidden] { display: none; }
.date-list-side { display: flex; flex-direction: column; min-width: 0; }
.date-list-side + .date-list-side { border-left: 1px solid var(--line); }
.date-list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; min-height: 54px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: .82rem; font-weight: 600; }
.date-list-head > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-weight: 400; }
.date-list-head .text-button { font-size: .78rem; }
.date-list-head .copy-control { padding: 3px 8px; }
.date-format { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--ink-soft); }
.date-format[hidden] { display: none; }
.date-format select { width: auto; min-height: 32px; padding: 4px 6px; font-size: .74rem; }
#date-list-input { flex: 1; width: 100%; min-height: 300px; padding: 14px 16px; border: 0; resize: vertical; font: .84rem/1.75 var(--mono); color: var(--ink); background: #fff; }
#date-list-input:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.date-table-wrap { flex: 1; min-height: 300px; max-height: 420px; overflow: auto; }
.date-table-wrap:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
/* Narrow screens scroll the table sideways inside its box instead of breaking dates mid-number. */
.date-table-wrap table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: .78rem; }
.date-table-wrap th { position: sticky; top: 0; padding: 9px 12px; background: #f6f8fb; box-shadow: inset 0 -1px 0 var(--line); color: var(--ink-soft); font-size: .7rem; font-weight: 600; text-align: left; white-space: nowrap; }
.date-table-wrap td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: break-word; }
.date-table-wrap td small { display: block; margin-top: 2px; color: var(--ink-soft); font-size: .68rem; white-space: nowrap; }
.date-table-wrap td.date-line { width: 1%; color: #7b8595; font-family: var(--mono); text-align: right; }
.date-table-wrap td.date-result { color: #162d4b; font-weight: 600; white-space: nowrap; }
.date-table-wrap tr.is-problem td { background: #fff4f0; color: #8b2913; }
.date-table-empty { margin: 0; padding: 16px; color: var(--ink-soft); font-size: .8rem; }
.date-table-empty[hidden] { display: none; }
.date-list-info { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--ink-soft); font: .66rem/1.6 var(--mono); }
.date-list-info:empty { display: none; }
.date-list-error { grid-column: 1 / -1; margin: 0; border-radius: 0 0 8px 8px; }

@media (max-width: 720px) {
    .date-list { grid-template-columns: minmax(0, 1fr); }
    .date-list-side + .date-list-side { border-left: 0; border-top: 1px solid var(--line); }
    #date-list-input { min-height: 200px; }
    .date-table-wrap { min-height: 160px; max-height: 360px; }
}
@media (max-width: 560px) {
    .date-bar { padding: 16px 16px 0; }
    .date-modes, .date-amounts { display: flex; flex: 1 1 100%; }
    .date-modes button, .date-amounts button { flex: 1; }
    .date-question { padding: 18px 16px; font-size: 1.08rem; }
    .date-question input, .date-question select { font-size: 16px; }
    .date-answer, .date-list { margin: 0 16px; }
    .date-answer { padding: 16px 16px 18px; }
    .date-actions { padding: 12px 16px 16px; }
    .date-settings { grid-template-columns: minmax(0, 1fr); padding: 0 16px 20px; }
    .date-choice small { font-size: .76rem; }
    #date-extra, .date-format select { font-size: 16px; }
}
