/* Shared internal detail controls. Load after youth-detail, before mobile-layout.
   Only /entry/ and /tool/ are actions here; tool official-site links stay separate. */
a:is([href^="/entry/"],[href^="/tool/"]) {
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease,
    box-shadow 160ms ease, opacity 160ms ease;
  -webkit-tap-highlight-color: #ffe60040;
  text-underline-offset: 4px;
}
body[data-ui-edition] a:is([href^="/entry/"],[href^="/tool/"]):focus-visible {
  outline: 2px solid #171717;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px #171717;
  text-decoration: underline;
}
a:is([href^="/entry/"],[href^="/tool/"]):active {
  opacity: .92;
  box-shadow: inset 0 0 0 2px #171717;
  transition-duration: 0s;
}
/* Match the existing KSI controls without turning titles into buttons. */
body[data-ui-edition] :is(.m-card-bottom>a[href^="/entry/"],a.m-card-bottom[href^="/entry/"],.tool-card>.tool-info,.m-space-card-bottom>span:first-child) {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #bcbab0;
  border-radius: 4px;
  background: #f4f3ef;
  color: #171717;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
body[data-ui-edition] .m-space-card-bottom>span:first-child::after { content: '↗'; }
body[data-ui-edition] :is(.m-card-bottom>a[href^="/entry/"],a.m-card-bottom[href^="/entry/"],.tool-card>.tool-info):focus-visible,
body[data-ui-edition] .m-space-cover:focus-visible .m-space-card-bottom>span:first-child {
  background: #ffe600;
  border-color: #171717;
  text-decoration: none;
}
@media (hover: hover) and (pointer: fine) {
  a:is([href^="/entry/"],[href^="/tool/"]):hover { text-decoration: underline; }
  body[data-ui-edition] :is(.m-card-bottom>a[href^="/entry/"],a.m-card-bottom[href^="/entry/"],.tool-card>.tool-info):hover,
  body[data-ui-edition] .m-space-cover:hover .m-space-card-bottom>span:first-child {
    background: #ffe600;
    border-color: #171717;
    box-shadow: inset 0 0 0 1px #17171710;
    text-decoration: none;
  }
  body[data-ui-edition] :is(a.m-event-cover,a.m-space-cover):hover { text-decoration: none; }
}
body[data-ui-edition] :is(.m-card-bottom>a[href^="/entry/"],a.m-card-bottom[href^="/entry/"],.tool-card>.tool-info):active,
body[data-ui-edition] .m-space-cover:active .m-space-card-bottom>span:first-child {
  background: #171717;
  color: #ffe600;
  border-color: #171717;
  transition-duration: 0s;
}
body[data-ui-edition] a.m-card-bottom:active>span { color: inherit; }
/* Equal grid tracks plus flexible bodies align footers without a card height.
   Reset legacy clamps explicitly: height:auto alone still truncates the copy. */
.module-page .m-card-grid { align-items: stretch; }
.m-card-grid>:is(.m-event,.m-policy,.m-space) { display: flex; flex-direction: column; min-width: 0; }
.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-card-bottom { margin-top: auto; }
.module-space .m-space-cover { flex: 1; height: auto; min-height: 0; }
body[data-ui-edition] :is(.m-event-body,.m-policy)>p,
body[data-ui-edition] .tool-card .tool-tile-copy :is(h3,p) {
  display: block;
  height: auto;
  max-height: none;
  overflow: visible;
  white-space: normal;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow-wrap: anywhere;
}
.m-card-grid :is(h3,p,dd,.m-policy-meta,.m-policy-support) { min-width: 0; overflow-wrap: anywhere; }
body[data-ui-edition] :is(.m-policy,.m-event) .m-card-bottom,
.module-space .m-space-card-bottom { flex-wrap: nowrap; align-items: flex-end; }
body[data-ui-edition] .m-policy .m-card-bottom>a,
.module-space .m-space-card-bottom>span:first-child { flex: none; }
body[data-ui-edition] .m-policy .m-card-bottom>span,
.module-space .m-space-card-bottom>span:last-child { min-width: 0; overflow-wrap: anywhere; }
.module-space .m-space-card-bottom>span:last-child { text-align: right; }
/* Keep the tile flexible: its independent official-site link fills surplus space. */
body[data-ui-edition] .tool-card>.tool-info { flex: none; }
/* Media frames are exclusive to community list cards, never the detail gallery. */
.module-space .m-space-cover .m-space-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  flex: none;
  overflow: hidden;
  border-radius: 4px;
  background: #f4f3ef;
}
.module-space .m-space-cover .m-space-card-image { display: block; width: 100%; height: 100%; object-fit: cover; }
body[data-ui-edition] .m-event-cover>img,
.module-space .m-space-cover .m-space-card-image { transition: transform 300ms ease, opacity 160ms ease; }
@media (prefers-reduced-motion: no-preference) {
  body[data-ui-edition] .m-event-cover:focus-visible>img,
  .module-space .m-space-cover:focus-visible .m-space-card-image { transform: scale(1.025); }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .module-space .m-space-cover:hover .m-space-card-image { transform: scale(1.025); }
}
body[data-ui-edition] .m-event .m-event-cover:active>img,
.module-space .m-space-cover:active .m-space-card-image { transform: none; opacity: .92; transition-duration: 0s; }
/* The cities are filters, not links. Retain their structure and mobile visibility.
   !important is limited to padding because modules.css already marks it important. */
.module-space .m-tree-city { padding: 10px 14px !important; min-height: 44px; gap: 12px; border-radius: 6px; }
.module-space .m-tree-entry { padding: 10px 14px 10px 24px; border-radius: 6px; min-height: 44px; overflow-wrap: anywhere; }
body[data-ui-edition] .module-space :is(.m-tree-city,.m-tree-entry):focus-visible { outline: 2px solid #171717; outline-offset: -3px; box-shadow: none; background: #fff8c2; }
@media (hover: none), (pointer: coarse) {
  .module-space .m-space:hover { border-color: var(--gray-200); box-shadow: none; }
  .module-space .m-tree-city:hover:not(.active):not(:active):not(:focus-visible) { background: var(--ksi-white); }
  body[data-ui-edition] .m-event:hover .m-event-cover>img,
  .module-space .m-space-cover:hover .m-space-card-image { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  a:is([href^="/entry/"],[href^="/tool/"]),
  body[data-ui-edition] :is(.m-card-bottom>a[href^="/entry/"],a.m-card-bottom[href^="/entry/"],.tool-card>.tool-info,.m-space-card-bottom>span:first-child),
  .module-space .m-space,
  .module-space .m-space-cover .m-space-card-image { transition: none; transform: none !important; }
}
@media (forced-colors: active) {
  a:is([href^="/entry/"],[href^="/tool/"]):focus-visible,
  body[data-ui-edition] .module-space :is(.m-tree-city,.m-tree-entry):focus-visible { outline-color: Highlight; }
  body[data-ui-edition] :is(.m-card-bottom>a[href^="/entry/"],a.m-card-bottom[href^="/entry/"],.tool-card>.tool-info,.m-space-card-bottom>span:first-child) { border-color: ButtonText; color: ButtonText; }
}
/* Text-only posters also grow with long titles, rather than clipping at 112px. */
.module-training .m-event-text-cover { height: auto; min-height: 112px; }
/* No persistent hover styles inherited from generic module links on touch. */
@media (hover: none), (pointer: coarse) {
  .module-page a:is([href^="/entry/"],[href^="/tool/"]):hover:not(:active):not(:focus-visible) { text-decoration: none; }
}
/* Retire the old parent-hover sideways CTA motion; all buttons now use color feedback. */
body[data-ui-edition] :is(.m-policy,.m-demand,.m-capability):is(:hover,:focus-within) .m-card-bottom>a { transform: none; }
/* A shared one-pixel lift adds feedback without the legacy sideways jump. */
@media(hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference){
 body[data-ui-edition] :is(.m-card-bottom>a[href^="/entry/"],a.m-card-bottom[href^="/entry/"],.tool-card>.tool-info):hover{transform:translateY(-1px);transition:transform 160ms ease,background-color 160ms ease,border-color 160ms ease}
 body[data-ui-edition] .m-space-cover:hover .m-space-card-bottom>span:first-child{transform:translateY(-1px);transition:transform 160ms ease,background-color 160ms ease,border-color 160ms ease}
 body[data-ui-edition] :is(.m-card-bottom>a[href^="/entry/"],a.m-card-bottom[href^="/entry/"],.tool-card>.tool-info):active,
 body[data-ui-edition] .m-space-cover:active .m-space-card-bottom>span:first-child{transform:none;transition-duration:0s}
}
@media(max-width:768px){
 .module-space .m-tree-city{max-width:min(18rem,100%);white-space:normal;overflow-wrap:anywhere;text-align:left}
}
@media(hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference){
 body[data-ui-edition] .tool-card>.tool-info:hover{transform:translateY(-1px)!important}
 body[data-ui-edition] .tool-card>.tool-info:active{transform:none!important}
}
/* The model solution cards share the same natural footer alignment. */
.bw-delivery-grid{align-items:stretch}
.bw-delivery-grid>.bw-card{display:flex;flex-direction:column}
.bw-delivery-grid>.bw-card>.bw-btn{align-self:flex-start;margin-top:auto;min-height:44px}
.module-space .m-tree-city{overflow-wrap:anywhere}
