/* "When will it arrive?" timeline module (src/_includes/deadlines.njk) and the
   product-page arrival note (src/_includes/deadline-note.njk).
   Data: src/_data/elections.json + leadTimes.json. Math: src/assets/js/deadlines.js.
   Status colors always sit next to a text label. */

.dl { border: 2px solid var(--navy); border-radius: 4px; background: #fff; margin: 0 0 2.2rem; font-size: .95rem; }

/* ---- Bar (always visible) ---- */
.dl-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.2rem;
  padding: .75rem 1rem; background: var(--tint); border-left: 4px solid var(--navy);
}
.dl-bar-text { margin: 0; flex: 1 1 22rem; font-weight: 600; line-height: 1.45; }
.dl-toggle {
  font: inherit; font-weight: 700; color: var(--red); background: none; border: 0; padding: .25rem 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: .15em;
  display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap;
}
.dl-toggle:hover { color: var(--red-dark); }
.dl-chevron {
  display: inline-block; width: .55em; height: .55em; margin-top: -.3em;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform .15s ease, margin .15s ease;
}
.dl-toggle[aria-expanded="true"] .dl-chevron { transform: rotate(-135deg); margin-top: .25em; }

/* Open by default; a page can start it closed with .dl-closed on the section (dlOpen = false before the
   include, as /products/ does). deadlines-ui.js adds "js" plus the visitor's remembered choice
   ("dl-collapsed" / "dl-expanded") to <html> before the module is parsed, so there is no flash; the
   remembered choice wins over the page default. Without the script everything stays visible. */
html.js .dl.dl-closed .dl-panel { display: none; }
html.js.dl-collapsed .dl .dl-panel { display: none; }
html.js.dl-expanded .dl .dl-panel { display: block; }

/* Compact bar (dlCompact = true): the approval date lives in the bar and every arrival date on the page
   counts from it; the bar text is one short line. */
.dl-bar-approval { display: flex; align-items: center; gap: .6rem; flex: 0 0 auto; }
.dl-bar-approval label { font-family: var(--display); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--navy); white-space: nowrap; }
.dl-bar-approval input[type="date"] {
  font: inherit; font-size: 1rem; font-weight: 600; color: var(--navy); background: #fff;
  border: 2px solid var(--navy); border-radius: 3px; padding: .3rem .55rem; min-height: 2.4rem; max-width: 100%;
}
.dl-bar-text-compact { font-weight: 400; color: var(--slate); flex: 1 1 16rem; }
.dl-bar-text-compact .dl-bar-next { font-weight: 700; color: var(--navy); white-space: nowrap; }

/* ---- Panel ---- */
.dl-panel { padding: 1rem 1rem 1.25rem; }
.dl-heading { font-family: var(--display); font-weight: 700; text-transform: uppercase; font-size: 1.3rem; line-height: 1.1; margin: 0 0 .35rem; }
.dl-intro { margin: 0 0 1rem; color: var(--slate); max-width: 60em; }

/* Controls */
.dl-controls { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; align-items: flex-end; margin: 0 0 .6rem; }
.dl-control { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.dl-control label { font-family: var(--display); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--navy); }
.dl-control select, .dl-control input[type="date"] {
  font: inherit; font-size: 1rem; color: var(--navy); background: #fff;
  border: 2px solid var(--navy); border-radius: 3px; padding: .4rem .6rem; min-height: 2.6rem; max-width: 100%;
}
.dl-control select { max-width: 32rem; }
.dl-context { margin: 0 0 .9rem; font-size: .88rem; color: var(--slate); line-height: 1.5; }
.dl-roll { margin: 0 0 .9rem; font-size: .88rem; color: var(--navy); font-weight: 600; }
.dl-error { margin: 0 0 .9rem; font-size: .88rem; color: var(--red); font-weight: 700; }

/* "Which election is yours?" */
.dl-which { margin: 0 0 1rem; }
.dl-which-h { margin: 0 0 .4rem; font-weight: 700; }
.dl-elections { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.dl-pick {
  width: 100%; text-align: left; font: inherit; color: var(--navy); background: #fff; cursor: pointer;
  border: 2px solid var(--line); border-radius: 4px; padding: .5rem .7rem; line-height: 1.35;
}
.dl-pick:hover { border-color: var(--navy); }
.dl-pick[aria-pressed="true"] { border-color: var(--navy); background: var(--tint); }
.dl-pick:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.dl-pick-date { font-family: var(--display); font-weight: 700; }
.dl-pick-name { font-weight: 600; }
.dl-pick-who { display: block; font-size: .82rem; color: var(--slate); margin-top: .1rem; }
.dl-which-note { margin: .5rem 0 0; font-size: .85rem; color: var(--slate); }

/* Table */
.dl-table-wrap { overflow-x: auto; border: 2px solid var(--navy); border-radius: 4px; background: #fff; }
.dl-table { width: 100%; border-collapse: collapse; min-width: 56rem; }
.dl-table thead th {
  background: var(--navy); color: #fff; text-align: left; vertical-align: bottom;
  font-family: var(--display); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em;
  padding: .55rem .8rem;
}
.dl-table tbody th, .dl-table tbody td {
  text-align: left; vertical-align: top; font-weight: 400;
  padding: .75rem .8rem; border-top: 1px solid var(--line);
}
.dl-table tbody th { width: 19%; }
.dl-how { width: 27%; font-size: .88rem; color: var(--slate); line-height: 1.45; }
.dl-how .dl-fn-ref { color: var(--navy); text-decoration: none; border-bottom: 1px dotted var(--navy); margin-left: .2em; font-size: .9em; }
.dl-window { width: 22%; }
.dl-window strong { font-size: 1.02em; line-height: 1.35; }
.dl-opt { display: block; font-weight: 700; line-height: 1.3; }
.dl-opt-sub { display: block; font-size: .8rem; color: var(--slate); margin-top: .15rem; }
.dl-fit > span { display: block; }
.dl-status {
  display: inline-block; font-family: var(--display); font-size: .72rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; line-height: 1.5;
  padding: .1em .55em; border-radius: 2px; border-left: 3px solid currentColor; margin-bottom: .35rem;
}
.dl-status-before-ev { color: #156B3E; background: #E6F4EC; border-left-color: #1B7F4B; }
.dl-status-around-ev { color: #1B5E63; background: #E3F2F3; border-left-color: #247C83; }
.dl-status-during-ev { color: #7A5212; background: #FBF0DB; border-left-color: #B7791F; }
.dl-status-late-risk { color: var(--red); background: #F9E6EB; border-left-color: var(--red); }
.dl-status-too-late { color: #4A4F57; background: #ECEEF1; border-left-color: #6B7280; }
.dl-sentence { line-height: 1.4; }
.dl-latest { margin-top: .35rem; font-size: .85rem; color: var(--slate); line-height: 1.4; }
.dl-alt { font-weight: 700; white-space: nowrap; }

/* Fine print + footer */
.dl-fine { margin: .9rem 0 0; padding-left: 1.2rem; font-size: .85rem; color: var(--slate); line-height: 1.5; }
.dl-fine li { margin: .25rem 0; }
.dl-foot { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .6rem; }
.dl-links { margin: 0; font-size: .92rem; }
.dl-links a { margin-right: .9rem; white-space: nowrap; }
.dl-links a:last-child { margin-right: 0; }
.dl-disclaimer { margin: 0; font-size: .85rem; color: var(--slate); line-height: 1.5; }
.dl-cta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: .4rem 0 0; }
.dl-cta p { margin: 0; font-weight: 600; }

/* Product-page note */
.deadline-note { display: block; }
.deadline-note-link { white-space: nowrap; }

/* ---- Stacked cards on phones ---- */
@media (max-width: 640px) {
  .dl-bar { padding: .7rem .8rem; }
  .dl-bar-approval { width: 100%; justify-content: space-between; }
  .dl-bar-approval input[type="date"] { flex: 1 1 auto; min-width: 0; }
  .dl-bar-text-compact .dl-bar-next { white-space: normal; }
  .dl-panel { padding: .8rem .8rem 1rem; }
  .dl-controls { flex-direction: column; align-items: stretch; }
  .dl-control select { max-width: none; }
  .dl-table { min-width: 0; }
  .dl-table, .dl-table tbody, .dl-table tr, .dl-table tbody th, .dl-table tbody td { display: block; width: auto; }
  .dl-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .dl-table .dl-row { border-top: 2px solid var(--navy); padding: .2rem 0 .5rem; }
  .dl-table tbody .dl-row:first-child { border-top: 0; }
  .dl-table tbody th { border: 0; padding: .8rem .8rem .3rem; }
  .dl-table tbody td { border: 0; padding: .45rem .8rem; }
  .dl-table tbody td::before {
    content: attr(data-label); display: block;
    font-family: var(--display); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
    color: var(--slate); margin-bottom: .2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dl-chevron { transition: none; }
}
