/* Change log (#28): the filter bar, active chips, month groups, and the responsive layout.
   Tokens only (no new colours, fonts, shadows or radii). Nothing here may scroll sideways:
   every text container has min-width: 0 and wraps anywhere. */

/* Filter bar */
.chg-filters {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.chg-search {
  display: grid;
  gap: 12px;
  align-items: end;
}
.chg-filters input[type="search"],
.chg-filters input[type="date"] {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-control);
  padding: 8px 12px;
}
.chg-apply {
  min-height: 44px;
}
.chg-search-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 12px;
}
.chg-hint {
  display: none; /* a phone has no "/" key to press; shown from 640px, beside the label */
  margin: 0;
}
/* The Filters disclosure: closed unless a filter is active, so the log itself starts high on the page. */
.chg-more-filters > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  list-style: none;
  border-color: var(--rule);
}
.chg-more-filters > summary::-webkit-details-marker {
  display: none;
}
.chg-more-filters > summary::before {
  content: "+";
  margin-right: 6px;
  font-weight: 800;
}
.chg-more-filters[open] > summary::before {
  content: "−";
}
.chg-active-n {
  color: var(--accent);
}
.chg-more-filters::details-content,
.chg-add::details-content {
  block-size: 0;
  overflow: clip;
  overflow-clip-margin: 8px; /* room for a focus ring */
  transition:
    block-size 300ms var(--ease-out),
    content-visibility 300ms allow-discrete;
}
.chg-more-filters[open]::details-content,
.chg-add[open]::details-content {
  block-size: auto;
}
.chg-facets {
  display: grid;
  gap: 14px;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--rule);
}
.chg-facet {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.chg-facet legend {
  padding: 0 0 6px;
  font: 700 14px/1.3 var(--body);
  color: var(--ink-2);
}
.chg-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.chg-opt {
  position: relative;
  min-height: 44px;
  overflow-wrap: anywhere;
}
.chg-opt input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.chg-opt .chg-opt-text {
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: inherit;
}
.chg-opt:has(input:checked) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.chg-opt:has(input:checked)::before {
  content: "✓";
  font-weight: 800;
}
.chg-opt:has(input:checked) .chg-opt-n {
  background: color-mix(in oklab, var(--bg) 22%, transparent);
  color: var(--bg);
}
.chg-opt:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.chg-custom {
  display: grid;
  gap: 8px;
  flex: 1 1 100%;
  min-width: 0;
}
.chg-custom-h {
  font: 700 14px/1.3 var(--body);
  color: var(--ink-2);
}
.chg-date-field {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--ink-2);
}
.chg-when-help {
  flex: 1 1 100%;
  margin: 0;
}

/* Active chips, notices, count */
.chg-results {
  min-width: 0;
  transition: opacity 160ms var(--ease-out);
}
.chg-results[aria-busy="true"] {
  opacity: 0.6;
}
.chg-active-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 10px;
}
.chg-active {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chg-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font: 650 14px/1.2 var(--body);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.chg-chip:hover {
  border-color: var(--ink-3);
}
.chg-x {
  font-size: 18px;
  line-height: 1;
  color: var(--ink-3);
}
.chg-chip:hover .chg-x {
  color: var(--bad);
}
.chg-notice {
  margin: 0 0 10px;
  padding: 10px 14px;
  overflow-wrap: anywhere;
  box-shadow: none;
}
.chg-count {
  margin: 0 0 6px;
  font: 650 15px/1.4 var(--body);
  color: var(--ink-2);
}

/* Groups */
.chg-group {
  margin-top: 22px;
}
.chg-group-h {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 0 0 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  font: 680 17px/1.2 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chg-group-n {
  font: 650 13px/1.2 var(--body);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
}
.chg-group-help {
  margin: -4px 0 12px;
}

/* Motion and the width-dependent layout of the bar and the cards (base card rules: desk-changes-cards.css) */
@media (prefers-reduced-motion: no-preference) {
  .chg-row:target {
    animation: chg-target 1600ms var(--ease-out) forwards;
  }
  @keyframes chg-target {
    to {
      outline-color: transparent;
    }
  }
  .chg-opt:hover {
    transform: translateY(-1px);
  }
}

@media (max-width: 639px) {
  /* Phone density: a fact is one "label  value" line, not a label over a value. */
  .chg-facts > div {
    grid-template-columns: 5.5rem minmax(0, 1fr);
    gap: 2px 10px;
    align-items: baseline;
  }
  .chg-facts .chg-more {
    grid-column: 2;
  }
  .chg-list {
    gap: 10px;
  }
  .chg-row {
    padding: 14px 16px;
  }
  .chg-body {
    gap: 8px;
  }
}
@media (min-width: 640px) {
  .chg-search {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .chg-hint:not([hidden]) {
    display: block;
  }
  .chg-opt,
  .chg-chip {
    min-height: 36px;
  }
  .chg-custom {
    grid-template-columns: auto minmax(0, 12rem) minmax(0, 12rem);
    align-items: center;
    justify-content: start;
    gap: 8px 14px;
  }
  .chg-date-field {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
  }
  .chg-row {
    grid-template-columns: 7rem minmax(0, 1fr);
    align-items: start;
  }
  .chg-date {
    display: grid;
    gap: 2px;
  }
  .chg-date-main + .chg-date-sub::before {
    content: none;
  }
  .chg-date-sub {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
  }
  .chg-text {
    font-size: 17px;
  }
  .chg-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .chg-add > summary,
  .chg-more-filters > summary {
    min-height: 36px;
  }
  .chg-details > summary {
    padding-block: 8px;
  }
}

@media (min-width: 1024px) {
  .chg-facet {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    align-items: start;
  }
  .chg-facet legend {
    float: left;
    width: 7rem;
    padding-top: 9px;
  }
  .chg-facet .chg-opts {
    grid-column: 2;
  }
  /* The sticky site header is one, two or three rows tall depending on the width, so its height
     is measured by the script (html.chg-sticky, --chg-header-h), never assumed: a fixed offset
     put the month heading underneath it. Without the script the heading scrolls with the page. */
  .chg-sticky .chg-group-h {
    position: sticky;
    top: var(--chg-header-h);
    z-index: 10;
  }
  .chg-row {
    grid-template-columns: 8.5rem minmax(0, 1fr);
    scroll-margin-top: 44px;
  }
  /* A #change-<key> target clears the header and the stuck month heading: 100px is the desk's
     scroll-padding-top (desk-motion.css), 56px the heading and a gap. */
  .chg-sticky .chg-row {
    scroll-margin-top: calc(var(--chg-header-h) - 100px + 56px);
  }
  .chg-facts {
    grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
  }
}
