/* Detail entry feedback only. Routing, search and other actions stay untouched.
   Covers card titles/CTAs, event covers, community covers/tree links,
   policy-match results, future tool links and the tool introduction button. */
:is(a[href^="#/entry/"], a[href^="#/space/"], a[href^="#/tool/"], button[data-tool-detail]) {
  --detail-motion-duration: 160ms;
  --detail-motion-ease: cubic-bezier(.2,.7,.2,1);
  transition: color var(--detail-motion-duration) var(--detail-motion-ease),
    background-color var(--detail-motion-duration) var(--detail-motion-ease),
    border-color var(--detail-motion-duration) var(--detail-motion-ease),
    box-shadow var(--detail-motion-duration) var(--detail-motion-ease),
    transform var(--detail-motion-duration) var(--detail-motion-ease);
  -webkit-tap-highlight-color: rgba(36,75,216,.12);
}
/* One CTA treatment across every list, including the tool introduction action.
   Existing full-width event/tool placement is retained; titles remain text links.
   The shared trailing ↗ is already present in each CTA's accessible text. */
:is(.m-card-bottom > a[href^="#/entry/"], .m-space-cover .m-card-bottom > span:first-child, button[data-tool-detail]) {
  min-height: 44px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #c7d0e8;
  border-radius: 4px;
  color: var(--accent);
  background-color: white;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
  text-decoration: none;
}
.m-space-cover .m-card-bottom > span:first-child {
  transition: color 160ms var(--detail-motion-ease), background-color 160ms var(--detail-motion-ease),
    border-color 160ms var(--detail-motion-ease), box-shadow 160ms var(--detail-motion-ease),
    transform 160ms var(--detail-motion-ease);
}
.m-space-cover .m-card-bottom > span:first-child::after { content: "↗"; }
/* The inset ring remains visible inside overflow-clipped cards. */
:is(a[href^="#/entry/"], a[href^="#/space/"], a[href^="#/tool/"], button[data-tool-detail]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--accent-hover);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
:is(.m-card-bottom > a[href^="#/entry/"], button[data-tool-detail]):focus-visible,
.m-space-cover:focus-visible .m-card-bottom > span:first-child {
  color: var(--accent-hover);
  background-color: var(--accent-soft);
  border-color: var(--accent);
  text-decoration: none;
}
/* Fine-pointer hover only: no lingering hover state after tapping on phones. */
@media (hover: hover) and (pointer: fine) {
  :is(a[href^="#/entry/"], a[href^="#/space/"], a[href^="#/tool/"], button[data-tool-detail]):hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
  }
  :is(.m-card-bottom > a[href^="#/entry/"], button[data-tool-detail]):hover,
  .m-space-cover:hover .m-card-bottom > span:first-child {
    color: var(--accent-hover);
    background-color: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: 0 2px 6px rgba(36,75,216,.10);
    transform: translateY(-1px);
    text-decoration: none;
  }
  :is(a.m-event-cover, a.m-space-cover, a.m-tree-entry, a.match-result):hover {
    box-shadow: inset 0 -2px 0 var(--accent);
    text-decoration: none;
  }
}
/* Instant down-state, including touch and native keyboard button activation.
   No scale or dimensions change, so text stays sharp and the grid stays still. */
:is(a[href^="#/entry/"], a[href^="#/space/"], a[href^="#/tool/"], button[data-tool-detail]):active {
  color: var(--accent-hover);
  background-color: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
  transform: none;
  transition-duration: 0s;
}
:is(.m-card-bottom > a[href^="#/entry/"], button[data-tool-detail]):active,
.m-space-cover:active .m-card-bottom > span:first-child {
  transition-duration: 0s;
  transform: none;
  background-color: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.15);
}
/* Override the older generic button:hover rule for this button alone. */
@media (hover: none), (pointer: coarse) {
  button[data-tool-detail]:hover:not(:active) {
    color: var(--accent);
    background-color: white;
    border-color: #c7d0e8;
    box-shadow: none;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  :is(a[href^="#/entry/"], a[href^="#/space/"], a[href^="#/tool/"], button[data-tool-detail], .m-space-cover .m-card-bottom > span:first-child) {
    transition: none;
    transform: none !important;
  }
}
@media (forced-colors: active) {
  :is(a[href^="#/entry/"], a[href^="#/space/"], a[href^="#/tool/"], button[data-tool-detail]):focus-visible {
    outline-color: Highlight;
  }
}
/* Same-row CTAs follow the tallest card, not the amount of copy above them.
   Keep every height content-led, including single-column mobile lists. */
.m-card-grid > .m-event {
  display: flex;
  flex-direction: column;
}
.m-card-grid > .m-event > .m-event-cover { flex: none; }
.m-card-grid > .m-event > .m-event-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.m-card-grid > .m-event .m-mini-facts { margin-bottom: 16px; }
.m-card-grid > .m-event .m-card-bottom { margin-top: auto; }
/* A long publisher can wrap independently without lifting the adjacent CTA. */
.m-card-grid > :is(.m-event, .m-policy) .m-card-bottom { align-items: flex-end; }
.m-card-grid > :is(.m-event, .m-policy) :is(h3, p, dd, .m-policy-meta, .m-policy-support, .m-card-bottom > span) {
  min-width: 0;
  overflow-wrap: anywhere;
}
/* Community's CTA is the first footer item: keep its label and the metadata
   on one flex row so a long metadata value cannot create a row below it. */
.space-grid > .m-space .m-card-bottom {
  flex-wrap: nowrap;
  align-items: flex-end;
}
.space-grid > .m-space .m-card-bottom > span:first-child { flex: none; }
.space-grid > .m-space .m-card-bottom > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

/* Community list images mirror the activity card's gentle 1.025x zoom.
   Scope to the card link: images in the detail carousel never animate here. */
@media (prefers-reduced-motion: no-preference) {
  .community-card-link .community-image-frame img {
    transition: transform 300ms ease, opacity 160ms ease;
  }
  .community-card-link:focus-visible .community-image-frame img {
    transform: scale(1.025);
  }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .community-card-link:hover .community-image-frame img {
    transform: scale(1.025);
  }
}
/* Immediate press feedback also works on touch, with no sticky hover zoom. */
.community-card-link:active .community-image-frame img {
  transform: none;
  opacity: .92;
  transition-duration: 0s;
}
@media (prefers-reduced-motion: reduce) {
  .community-card-link .community-image-frame img {
    transition: none;
    transform: none !important;
  }
}
