/* Order-by election deadlines module (src/_includes/deadlines.njk) and the
   product-page deadline 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 ("On track" / "Hurry" / "Missed"). */

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

/* ---- Collapsed 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(--red);
}
.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; }

/* The panel is open without JS. deadlines-ui.js adds "js" (and "dl-collapsed" when the
   remembered state is closed) to <html> before the module is parsed, so there is no flash. */
html.js.dl-collapsed .dl-panel { display: none; }

/* ---- Expanded 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; }

.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: 60rem; }
.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 thead th a { color: #fff; text-decoration: none; border-bottom: 1px dotted #fff; margin-left: .25em; font-size: .9em; }
.dl-table thead th a:hover { border-bottom-style: solid; }
.dl-th-sub { display: block; font-weight: 400; font-size: .72rem; letter-spacing: 0; text-transform: none; opacity: .85; margin-top: .15rem; }
.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: 27%; }
.dl-row-custom th, .dl-row-custom td { background: var(--tint); }
.dl-election > span, .dl-cell > span { display: block; }
.dl-date { font-family: var(--display); font-weight: 700; font-size: 1.1rem; line-height: 1.15; }
.dl-name { font-weight: 700; margin-top: .1rem; }
.dl-where, .dl-notes, .dl-ev { font-size: .8rem; color: var(--slate); line-height: 1.4; margin-top: .25rem; }
.dl-ev { font-style: italic; }
.dl-remove {
  font: inherit; font-size: .8rem; color: var(--red); background: none; border: 0; padding: .2rem 0; margin-top: .3rem;
  cursor: pointer; text-decoration: underline;
}

/* Cell status label + dates */
.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-ok { color: #156B3E; background: #E6F4EC; border-left-color: #1B7F4B; }
.dl-status-hurry { color: #7A5212; background: #FBF0DB; border-left-color: #B7791F; }
.dl-status-missed { color: var(--red); background: #F9E6EB; border-left-color: var(--red); }
.dl-days { letter-spacing: .04em; }
.dl-primary { font-weight: 600; line-height: 1.35; }
.dl-primary strong { font-size: 1.05em; }
.dl-secondary { font-size: .82rem; color: var(--slate); line-height: 1.35; margin-top: .15rem; }
.dl-past { color: var(--slate); font-weight: 400; }
.dl-alt { display: inline-block; margin-top: .4rem; font-weight: 700; }

/* Rows beyond the default set hide only when JS is on (the button that reveals them needs JS). */
html.js .dl-row[data-extra="true"] { display: none; }
html.js .dl-table.dl-show-all .dl-row[data-extra="true"] { display: table-row; }
.dl-showall-wrap { margin: .9rem 0 0; }
.dl-showall { display: none; }
html.js .dl-showall { display: inline-block; }

/* "My election date" (needs JS: the row is computed in the browser and kept in localStorage) */
.dl-custom { display: none; margin: 1.1rem 0 0; padding: .9rem 1rem; background: var(--tint); border-left: 4px solid var(--navy); }
html.js .dl-custom { display: block; }
.dl-custom-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .8rem; }
.dl-custom-label { font-family: var(--display); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; }
.dl-custom input[type="date"] {
  font: inherit; font-size: 1rem; padding: .4rem .6rem; border: 2px solid var(--navy); border-radius: 3px; background: #fff; color: var(--navy);
  min-height: 2.6rem;
}
.dl-custom .btn { padding-top: .45rem; padding-bottom: .4rem; }
.dl-custom-help { margin: .5rem 0 0; font-size: .82rem; color: var(--slate); }
.dl-custom-error { margin: .5rem 0 0; font-size: .88rem; color: var(--red); font-weight: 700; }

/* Footnote + footer */
.dl-footnote { margin: .9rem 0 0; font-size: .85rem; color: var(--slate); line-height: 1.5; }
.dl-footnote sup { color: var(--navy); font-weight: 700; }
.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-how, .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: 540px) {
  .dl-bar { padding: .7rem .8rem; }
  .dl-panel { padding: .8rem .8rem 1rem; }
  .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-cell::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;
  }
  html.js .dl-table.dl-show-all .dl-row[data-extra="true"] { display: block; }
  .dl-custom-row { align-items: stretch; flex-direction: column; }
  .dl-custom .btn { text-align: center; }
}

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