/* ILR Calculator tools
 * Tool blocks, date inputs, trips, result panels, launcher grid, modals, checklist modal
 * and the lifeline widget. Colours come only from the theme tokens (tokens.css). The theme
 * owns .btn, .field, .input, .select, .textarea, .card, .notice, .eyebrow, .meta, .grid;
 * anything here for those classes is a tool-scoped override.
 */

/* ---------- tool block ---------- */

.tool { position: relative; }
.tool--main { margin-bottom: 24px; }
.tool__head { margin-bottom: 20px; }
.tool__head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.tool__title { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; line-height: 1.2; margin: 0; color: var(--ink); }
.tool__body > .field + .field,
.tool__body > .field + .trips,
.tool__body > .tool__row + .trips,
.tool__body > .field + fieldset { margin-top: 16px; }
.tool__row { margin-bottom: 4px; }
.tool__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.tool__actions .btn { flex: 1 1 auto; }
@media (min-width: 720px) { .tool__actions .btn { flex: 0 0 auto; } }
.tool__error { margin: 12px 0 0; }
.tool__error[hidden] { display: none; }
.tool__note { margin: 16px 0 0; }
.tool__note a { color: var(--accent); }

.tool__result { margin-top: 16px; }
.tool__result:empty { display: none; }
.tool__result.is-filled { padding-top: 16px; border-top: 1px solid var(--rule); }
.tool__result .notice { margin: 10px 0 0; }
.tool__result .meta { margin: 10px 0 0; }
.tool__result .meta a { color: var(--accent); }

.result__line { margin: 0 0 6px; font-size: 1rem; color: var(--ink-2); }
.result__line strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.result__line strong { font-weight: 600; }
.result__list { list-style: none; margin: 8px 0 0; padding: 0; font-size: .9375rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.result__list li { padding: 5px 0; border-top: 1px solid var(--rule); }
.result__list li:first-child { border-top: 0; }

.field__req { color: var(--danger); font-weight: 600; }
.field__opt { color: var(--muted); font-weight: 400; font-size: .8125rem; }
.field__note { color: var(--muted); font-weight: 400; font-size: .75rem; margin-left: 2px; }

/* checkbox rows (points tool, consent) */
.checks { border: 0; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
@media (min-width: 720px) { .checks { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .9375rem; color: var(--ink-2); line-height: 1.45; cursor: pointer; min-height: 28px; }
.check input { flex: 0 0 auto; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); }
.check--consent { font-size: .8125rem; color: var(--muted); margin-top: 14px; }

.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: .875rem; font-weight: 500; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 32px; }
.link-btn:hover { color: var(--accent-ink); }
.link-btn:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

/* ---------- date input (text + native calendar) ---------- */

.date-input { position: relative; display: block; }
.date-input__text { padding-right: 52px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.date-input__cal { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: var(--r-sm); color: var(--muted); cursor: pointer; }
.date-input__cal:hover { color: var(--accent); background: var(--surface-2); }
.date-input__cal:focus-visible { outline: none; box-shadow: var(--focus); }
.date-input__native { position: absolute; top: 0; right: 0; width: 48px; height: 100%; opacity: 0; pointer-events: none; }
.date-input.is-error .date-input__text { border-color: var(--danger); }
.date-input.is-error + .help { color: var(--danger); }

/* ---------- trips ---------- */

.trips { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule); }
.trips__head:empty { display: none; }
.trips__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 12px; }
.trips__title { font-family: var(--sans); font-weight: 600; font-size: 1rem; margin: 0; color: var(--ink); }
.trips__hint { margin: 0 0 12px; }
.trips__list:empty { display: none; }
.trips__list { display: grid; gap: 12px; margin-bottom: 12px; }
.trip { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface-2); }
.trip__dates { display: grid; gap: 12px; }
@media (min-width: 720px) {
  .trip { grid-template-columns: 1fr auto; align-items: end; }
  .trip__dates { grid-template-columns: 1fr 1fr; }
}
.trip__days .input { max-width: 240px; }
.trip__remove { justify-self: start; }
@media (min-width: 720px) { .trip__remove { justify-self: end; } }
.tool[data-abs-mode="days"] .trip__dates { display: none; }
.tool:not([data-abs-mode="days"]) .trip__days { display: none; }

/* ---------- main result panel ---------- */

.result { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--rule); }
.result[hidden] { display: none; }
.result__title { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; margin: 0 0 14px; color: var(--ink); }
.result__subtitle { font-family: var(--sans); font-weight: 600; font-size: .9375rem; margin: 20px 0 10px; color: var(--ink); }
.result__grid { display: grid; gap: 1px; margin: 16px 0; padding: 0; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; }
@media (min-width: 720px) { .result__grid { grid-template-columns: repeat(3, 1fr); } }
.result__stat { background: var(--surface); padding: 14px 16px; margin: 0; }
.result__stat dt { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.result__stat dd { margin: 0; font-size: 1.25rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.result__status { margin-top: 12px; }
.result__meter .meter { margin-top: 0; margin-bottom: 14px; }
.result__status .notice { margin: 0; }
.result__explain { margin: 10px 0 0; padding: 10px 14px; font-size: .9375rem; color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-md); }
.result__trips { margin-top: 8px; }
.result .meta { margin-top: 16px; }

.scenario { padding: 14px 16px; border-left: 3px solid var(--rule-2); background: var(--surface-2); border-radius: 0 var(--r-md) var(--r-md) 0; }
.scenario__title { margin: 0 0 4px; font-family: var(--serif); font-weight: 500; font-size: 1.25rem; color: var(--ink); }
.scenario__text { margin: 0; color: var(--ink-2); }
.scenario--ok { border-left-color: var(--ok); background: var(--ok-soft); }
.scenario--warn { border-left-color: var(--warn); background: var(--warn-soft); }
.scenario--danger { border-left-color: var(--danger); background: var(--danger-soft); }
.scenario--info { border-left-color: var(--accent); background: var(--accent-soft); }

/* meters (worst window, per-trip) */
.meter { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); }
.meter__title { margin: 0 0 8px; font-size: .9375rem; font-weight: 600; color: var(--ink); }
.meter__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: .875rem; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.meter__value { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.meter__track { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.meter__fill { height: 100%; background: var(--ok); border-radius: 3px; }
.meter--warn .meter__fill { background: var(--warn); }
.meter--warn .meter__value { color: var(--warn); }
.meter--danger .meter__fill { background: var(--danger); }
.meter--danger .meter__value { color: var(--danger); }
.meter .notice { margin: 10px 0 0; font-size: .875rem; }

/* next-step promos inside the result panel */
.promo-row { display: grid; gap: 12px; margin-top: 20px; }
@media (min-width: 720px) { .promo-row { grid-template-columns: 1fr 1fr; } }
.promo { display: grid; gap: 6px; justify-items: start; padding: 14px 16px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); }
.promo p { margin: 0; font-size: .9375rem; color: var(--ink-2); }
.promo .promo__title { font-weight: 600; color: var(--ink); }
.promo .btn { margin-top: 6px; }

/* key rules band */
.rules { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--rule); }
.rules__title { font-family: var(--sans); font-weight: 600; font-size: 1rem; margin: 0 0 8px; color: var(--ink); }
.rules__list { margin: 0; padding-left: 1.1em; font-size: .9375rem; color: var(--ink-2); }
.rules__list li { margin: 4px 0; }
.rules__list strong { color: var(--ink); font-weight: 600; }
.rules__list a { color: var(--accent); }

/* ---------- lead forms ---------- */

.review { margin-bottom: 24px; }
.review[hidden] { display: none; }
.review__title { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; margin: 6px 0 8px; color: var(--ink); }
.review > p { max-width: 70ch; color: var(--ink-2); }

.lead-form { margin-top: 16px; }
.lead-form__grid { display: grid; gap: 14px; }
@media (min-width: 720px) {
  .lead-form__grid { grid-template-columns: 1fr 1fr; }
  .lead-form__grid .field--wide { grid-column: 1 / -1; }
  .lead-form__grid--stack { grid-template-columns: 1fr; }
}
.lead-form__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.lead-form__error { margin: 12px 0 0; }
.lead-form__error[hidden] { display: none; }
.lead-form .tool__actions { margin-top: 16px; }
.form__status { margin: 10px 0 0; font-size: .9375rem; color: var(--muted); }
.form__status:empty { display: none; }
.form__status--ok { color: var(--ok); }
.form__status--error { color: var(--danger); }
.lead-form.is-sent .tool__actions { display: none; }

/* ---------- checklist CTA and modal ---------- */

.checklist-cta { display: grid; gap: 8px; justify-items: start; }
.checklist-cta__title { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; margin: 0; color: var(--ink); }
.checklist-cta > p { margin: 0 0 6px; max-width: 60ch; color: var(--ink-2); }
.checklist-cta.is-highlighted { border-color: var(--accent); background: var(--accent-soft); }
.checklist-consent[hidden] { display: none; }
.checklist-done { display: grid; gap: 14px; justify-items: start; }
.checklist-done[hidden] { display: none; }
.checklist-done .notice { margin: 0; width: 100%; }

/* ---------- launcher grid ---------- */

.tools-grid { display: grid; gap: 12px; }
@media (min-width: 560px) { .tools-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .tools-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
.tool-card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 20px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); transition: border-color .15s; }
.tool-card:hover { border-color: var(--rule-2); }
.tool-card:focus-within { border-color: var(--accent); }
.tool-card__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tool-card__badge { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: var(--r-sm); padding: 2px 8px; }
.tool-card__num { font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tool-card__name { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 1.25rem; line-height: 1.25; color: var(--ink); }
.tool-card__link { color: inherit; text-decoration: none; }
.tool-card__link::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-lg); }
.tool-card__link:focus-visible { outline: none; }
.tool-card__link:focus-visible::after { box-shadow: var(--focus); }
.tool-card__desc { margin: 0; font-size: .9375rem; line-height: 1.55; color: var(--ink-2); flex: 1 1 auto; }
.tool-card__desc a { position: relative; z-index: 1; color: var(--accent); }
.tool-card__cta { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; min-height: 32px; font-size: .875rem; font-weight: 600; color: var(--accent); text-decoration: none; align-self: flex-start; }
.tool-card:hover .tool-card__cta { color: var(--accent-ink); }

.tool-inline { margin: 24px 0; }

/* ---------- modals ---------- */

.modal { position: fixed; inset: 0; z-index: 1700; display: flex; align-items: flex-end; justify-content: center; padding: 0; background: rgba(21, 27, 43, .55); opacity: 0; transition: opacity .18s ease; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal.is-open { opacity: 1; }
.modal[hidden] { display: none; }
.modal__panel { width: 100%; max-height: 100%; overflow-y: auto; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-1); outline: none; }
.modal__head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px var(--gutter); background: var(--surface); border-bottom: 1px solid var(--rule); }
.modal__title { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 1.25rem; line-height: 1.25; color: var(--ink); }
.modal__close { flex: 0 0 auto; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--rule-2); border-radius: var(--r-md); color: var(--ink); cursor: pointer; }
.modal__close:hover { background: var(--surface-2); }
.modal__close:focus-visible { outline: none; box-shadow: var(--focus); }
.modal__body { padding: 20px var(--gutter) 28px; }
.modal__body > .meta { margin: 0 0 14px; }
@media (min-width: 720px) {
  .modal { align-items: center; padding: 24px; }
  .modal__panel { width: min(560px, 100%); max-height: calc(100vh - 48px); border-radius: var(--r-lg); }
  .modal--sm .modal__panel { width: min(440px, 100%); }
  .modal__head { padding: 18px 24px; }
  .modal__body { padding: 20px 24px 24px; }
}
body.has-modal { overflow: hidden; }

/* ---------- lifeline widget (fixed, bottom right) ---------- */

.lifeline { position: fixed; right: var(--gutter); bottom: var(--gutter); left: var(--gutter); z-index: 1400; padding: 20px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--shadow-1); opacity: 0; transition: opacity .25s ease; max-height: calc(100vh - 32px); overflow-y: auto; }
.lifeline.is-visible { opacity: 1; }
.lifeline[hidden] { display: none; }
@media (min-width: 560px) { .lifeline { left: auto; width: 360px; right: 24px; bottom: 24px; } }
.lifeline__close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: var(--r-sm); color: var(--muted); cursor: pointer; }
.lifeline__close:hover { color: var(--ink); background: var(--surface-2); }
.lifeline__close:focus-visible { outline: none; box-shadow: var(--focus); }
.lifeline__title { margin: 0 32px 6px 0; font-family: var(--serif); font-weight: 500; font-size: 1.2rem; line-height: 1.25; color: var(--ink); }
.lifeline__text { margin: 0; font-size: .9375rem; color: var(--ink-2); }
.lifeline__tap { display: none; margin: 4px 32px 0 0; padding: 0; background: none; border: 0; font: inherit; font-size: .875rem; color: var(--accent); text-align: left; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 32px; }
.lifeline__tap:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
@media (max-width: 559px) {
  .lifeline { padding: 14px 16px; }
  .lifeline__text { display: none; }
  .lifeline__tap { display: block; }
  .lifeline:not(.is-expanded) .lifeline__body { display: none; }
}
.lifeline .lead-form { margin-top: 14px; }
.lifeline .lead-form__grid { grid-template-columns: 1fr; gap: 10px; }
.lifeline .check--consent { margin-top: 10px; font-size: .75rem; }
.lifeline .tool__actions { margin-top: 12px; }
.lifeline .tool__actions .btn { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .modal, .lifeline, .tool-card { transition: none; }
}
