/*
 * Planner page. A calm deal schedule: white paper, slate ink, one ledger-green accent, and dates
 * in tabular figures so they line up like a ledger. System fonts only (the CSP blocks web fonts).
 * Contrast on white (computed): ink 15.6:1, muted 6.9:1, accent 7.8:1, control borders 4:1,
 * error 7.8:1; on the accent tint: muted 6.2:1, accent 7:1.
 * The one emphasised element is the key-dates panel; everything else stays quiet.
 */
:root {
  --ink: #1c2430;
  --muted: #4f5b67;
  --paper: #ffffff;
  --accent: #1f5c4f;
  --accent-strong: #174a3f;
  --accent-tint: #eef4f2;
  --rule: #d5dbe0;
  --control: #75808b;
  --warning-tint: #fbf1de;
  --error: #a4161a;
  color: var(--ink);
  background: var(--paper);
  font-family: system-ui, "Segoe UI", "Arial Hebrew", "Noto Sans Hebrew", Arial, sans-serif;
  font-size: 106.25%;
  line-height: 1.6;
}

body {
  margin: 0;
}

.page-header,
main,
.page-footer {
  margin-inline: auto;
  max-width: 60rem;
  padding-inline: 1.25rem;
}

/* Running text keeps a readable measure; the plan table may use the full width. */
.page-header > *,
form,
.page-footer > * {
  max-width: 42rem;
}

h1 {
  font-size: clamp(1.75rem, 1.35rem + 1.6vw, 2.375rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 2.5rem 0 1rem;
}

h3 {
  font-size: 1.125rem;
  margin: 1.75rem 0 0.5rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- header ---- */

.page-header {
  padding-block: 2.5rem 1rem;
}

.intro {
  font-size: 1.125rem;
  margin: 0 0 1rem;
}

.privacy-note,
.noscript {
  background: var(--accent-tint);
  border-radius: 6px;
  font-size: 0.9375rem;
  margin: 0;
  padding: 0.75rem 1rem;
}

/* ---- form: sections grouped by spacing and headings, not boxes ---- */

form {
  margin-block-start: 1.5rem;
}

fieldset {
  border: 0;
  margin: 0 0 2rem;
  min-width: 0;
  padding: 0;
}

legend {
  font-size: 1.125rem;
  font-weight: 700;
  margin-block-end: 0.75rem;
  padding: 0;
}

fieldset.payment {
  margin: 0;
  padding-block: 0.75rem;
}

fieldset.payment + fieldset.payment {
  border-block-start: 1px solid var(--rule);
}

fieldset.payment legend {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  margin-block-end: 0.25rem;
}

.field {
  margin-block: 0.25rem 0.5rem;
}

.field label {
  display: block;
  margin-block-end: 0.25rem;
}

.date-words {
  color: var(--muted);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  margin: 0.25rem 0 0;
  min-height: 1.5em;
}

.choice {
  align-items: flex-start;
  display: flex;
  gap: 0.6rem;
  margin-block: 0.5rem;
}

.choices-inline .choice {
  display: inline-flex;
  margin-inline-end: 1.75rem;
}

.choice input {
  accent-color: var(--accent);
  flex: none;
  height: 1.25rem;
  margin: 0.2rem 0 0;
  width: 1.25rem;
}

input[type="date"],
input[type="number"] {
  background: var(--paper);
  border: 1px solid var(--control);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
  min-height: 2.75rem;
  padding: 0.4rem 0.6rem;
}

input[type="number"] {
  width: 5.5rem;
}

input[aria-invalid="true"] {
  border: 2px solid var(--error);
}

button {
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  min-height: 2.75rem;
  padding: 0.45rem 1.1rem;
}

button:hover {
  background: var(--accent-tint);
}

button:disabled {
  border-color: var(--control);
  color: var(--muted);
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
  font-size: 1.0625rem;
  padding: 0.65rem 1.6rem;
}

button.primary:hover {
  background: var(--accent-strong);
}

button.remove-payment,
button.link-button {
  background: transparent;
  border: 0;
  min-height: 0;
  padding: 0.25rem 0;
  text-align: start;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* The one framed area of the form: the editable lead times, closed by default. */
.lead-times {
  border: 1px solid var(--rule);
  border-radius: 8px;
  margin-block-end: 2rem;
  padding-inline: 1rem;
}

.lead-times summary {
  cursor: pointer;
  font-weight: 700;
  padding-block: 0.85rem;
}

.lead-times[open] {
  padding-block-end: 1rem;
}

.hint {
  color: var(--muted);
  font-size: 0.9375rem;
  margin: 0 0 0.5rem;
}

.field-error {
  color: var(--error);
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0.25rem 0 0;
}

/* :not([hidden]) so the hidden attribute still hides rows a deal does not need. */
.lead-time:not([hidden]) {
  align-items: center;
  border-block-end: 1px solid var(--rule);
  column-gap: 0.75rem;
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) auto auto auto;
  padding-block: 0.6rem;
}

.lead-time .field-error {
  grid-column: 1 / -1;
}

.unit,
.lead-source {
  font-size: 0.9375rem;
}

.lead-times > button {
  margin-block-start: 1rem;
}

.error-summary {
  border: 2px solid var(--error);
  border-radius: 8px;
  margin-block-end: 2rem;
  padding: 0.75rem 1rem;
}

.error-summary-title {
  font-size: 1.0625rem;
  margin: 0 0 0.25rem;
}

.error-summary ul {
  margin: 0;
  padding-inline-start: 1.25rem;
}

/* ---- result ---- */

.result {
  border-block-start: 1px solid var(--rule);
  margin-block-start: 3rem;
}

/* The input summary, the readable source addresses and the site line exist for paper only. */
.print-only,
.print-url {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-block: 0 1.5rem;
}

.key-dates {
  background: var(--accent-tint);
  border-radius: 10px;
  margin-block-end: 2rem;
  padding: 1.25rem 1.5rem 1.5rem;
}

.key-dates h3 {
  color: var(--accent);
  font-size: 1rem;
  margin: 0 0 1rem;
}

#key-dates {
  display: grid;
  gap: 1.25rem 2rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  margin: 0;
}

.key-date dt {
  color: var(--muted);
  font-size: 0.9375rem;
}

.key-date dd {
  margin: 0.2rem 0 0;
}

.key-date-value {
  display: block;
  font-size: 1.375rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.3;
}

.key-date-detail {
  display: block;
  font-size: 0.9375rem;
  margin-block-start: 0.2rem;
}

.warning {
  background: var(--warning-tint);
  border-radius: 8px;
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  width: 100%;
}

caption {
  font-weight: 700;
  padding-block: 0.5rem;
  text-align: start;
}

th,
td {
  border-block-end: 1px solid var(--rule);
  padding: 0.65rem 0.5rem;
  text-align: start;
  vertical-align: top;
}

thead th {
  border-block-end: 2px solid var(--ink);
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 600;
}

tbody th {
  font-weight: 600;
}

/* Wide screens show long dates; the stacked phone layout shows labels and short dates. */
.cell-label,
.date-short {
  display: none;
}

.badge {
  border-radius: 4px;
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0 0.4rem;
  white-space: nowrap;
}

.late-badge {
  background: var(--error);
  color: var(--paper);
}

.badge.estimate {
  border: 1px solid var(--control);
}

.computed-on {
  color: var(--muted);
  font-size: 0.9375rem;
}

/* ---- footer ---- */

.page-footer {
  border-block-start: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9375rem;
  margin-block-start: 3rem;
  padding-block: 1.5rem 3rem;
}

.page-footer h2 {
  color: var(--ink);
  font-size: 1.0625rem;
  margin-block: 1.5rem 0.5rem;
}

.disclaimer {
  color: var(--ink);
  font-weight: 600;
  margin-block-start: 0;
}

.sources {
  margin: 0;
  padding-inline-start: 1.25rem;
}

/* ---- phones and 200% zoom: each step becomes a stacked block (screens only; print keeps the table) ---- */

@media screen and (max-width: 40rem) {
  .page-header {
    padding-block-start: 1.5rem;
  }

  .lead-time:not([hidden]) {
    grid-template-columns: auto 1fr;
    row-gap: 0.25rem;
  }

  .lead-time label,
  .lead-time .lead-source {
    grid-column: 1 / -1;
  }

  .key-dates {
    padding: 1rem;
  }

  .table-wrap {
    overflow-x: visible;
  }

  /* Explicit ARIA roles in the markup keep the table semantics when display changes. */
  #plan-table,
  #plan-table caption,
  #plan-table tbody,
  #plan-table tr,
  #plan-table th,
  #plan-table td {
    display: block;
  }

  #plan-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  #plan-table tr {
    border-block-end: 1px solid var(--rule);
    padding-block: 0.75rem;
  }

  #plan-table th,
  #plan-table td {
    border: 0;
    padding: 0.1rem 0;
  }

  #plan-table tbody th {
    font-size: 1.0625rem;
    padding-block-end: 0.35rem;
  }

  #plan-table td {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.5rem;
  }

  .cell-label {
    color: var(--muted);
    display: block;
    flex: 0 0 6.5rem;
    font-size: 0.9375rem;
  }

  .date-long {
    display: none;
  }

  .date-short {
    display: inline;
  }
}

/* Windows high-contrast mode: backgrounds disappear, so groups get a border. */
@media (forced-colors: active) {
  .privacy-note,
  .noscript,
  .key-dates,
  .warning,
  .badge {
    border: 1px solid CanvasText;
  }

  :focus-visible {
    outline-color: Highlight;
  }
}
