/* Find a playbook, ported from the phase 2 use case hub concept (uh-find): filters by team, industry and goal, a
   polite live count, removable chips, an empty state, and the playbook cards from HubDB. Logical properties
   throughout, so Arabic (dir="rtl") mirrors. */

/* The playbook cards: the workflows module's cards (styles from hubl-modules/workflows.module, Concept 4) with the
   concept's phase 3 changes, scoped to this section so they never meet the shared module's own rules. The template
   sets each card's --card field colour and --tilt by position. Logical properties, so Arabic mirrors; the
   hand-placed tilts mirror with the layout too (DESIGN.md, The Room To Translate Rule). They come first, so the
   finder's own grid rules below win at equal specificity. */
.uh-find .wf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(18px, 2.2vw, 30px); margin-top: clamp(40px, 5vw, 64px); }
[dir="rtl"] .uh-find .wf-grid { --tilt-dir: -1; }
/* Concept change for phase 3 (from the industry concept): each card spans its rows of the grid (logos, title,
   description, categories, industries, link), so the rows line up across cards. The lift shadow is pre-drawn on
   ::before and fades in; the card straightens and rises only when motion is welcome; focus lifts on :focus-visible. */
.uh-find .wf {
  position: relative; min-width: 0;
  display: grid; grid-row: span 5; grid-template-rows: subgrid; row-gap: 14px;
  padding: 24px 24px 22px; border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  rotate: calc(var(--tilt, 0deg) * var(--tilt-dir, 1));
  transition: rotate 280ms var(--ease-out), translate 280ms var(--ease-out);
}
@supports not (grid-template-rows: subgrid) {
  .uh-find .wf { display: flex; flex-direction: column; gap: 14px; }
}
.uh-find .wf::before {
  content: ""; position: absolute; inset: 0; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift); opacity: 0; pointer-events: none;
  transition: opacity 280ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .uh-find .wf:hover::before { opacity: 1; }
}
.uh-find .wf::after { content: ""; position: absolute; inset-inline: 0; top: 100%; height: 0; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .uh-find .wf:hover { rotate: 0deg; translate: 0 -6px; }
  .uh-find .wf:hover::after { height: 7px; }
}
.uh-find .wf:has(.h3 a:focus-visible)::before { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .uh-find .wf:has(.h3 a:focus-visible) { rotate: 0deg; translate: 0 -6px; }
}
.uh-find .wf-logos { display: flex; padding-inline-start: 10px; }
.uh-find .wf-logo {
  position: relative;
  width: 44px; height: 44px; margin-inline-start: -10px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  background: var(--logo-bg); border: 3px solid var(--card);
  box-shadow: 0 3px 6px -2px rgb(11 30 51 / 0.3);
}
.uh-find .wf-logo:first-child { z-index: 2; }
.uh-find .wf-logo img { width: 24px; height: 24px; }
.uh-find .wf .h3 { font-size: 1.28rem; }
.uh-find .wf .h3 a { text-decoration: none; }
.uh-find .wf .h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-lg); }
.uh-find .wf .h3 a:focus-visible { outline: none; }
.uh-find .wf .h3 a:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 4px; }
.uh-find .wf-desc { font-size: 16px; line-height: 1.5; color: var(--ink-soft); text-wrap: pretty; }
.uh-find .wf-cats { display: flex; flex-wrap: wrap; align-content: flex-start; align-items: center; gap: 6px; }
.uh-find .wf-open { margin-top: auto; display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; }
.uh-find .wf-open .i { width: 18px; height: 18px; }
@media (max-width: 1023px) {
  .uh-find .wf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 719px) {
  .uh-find .wf-grid { grid-template-columns: minmax(0, 1fr); }
  .uh-find .wf { rotate: calc(var(--tilt, 0deg) * var(--tilt-dir, 1) / 2); }
}
@media (prefers-reduced-motion: reduce) {
  .uh-find .wf, .uh-find .wf-open .i { transition: none; }
}

/* The finder: the filters sit beside the cards on wide screens and above them on narrow ones, where they fold into a
   disclosure. Each option shows how many playbooks it would leave, given the other filters; an option that would leave
   none stays choosable, so the empty state can be reached and explains itself. */
.uh-find-head { display: grid; gap: 14px 18px; max-width: 860px; }
.uh-find-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 32px clamp(28px, 3.5vw, 48px); align-items: start; margin-top: clamp(32px, 4vw, 52px); }
.uh-side { position: sticky; top: calc(var(--header-h) + 16px); min-width: 0; display: grid; gap: 12px; }
.uh-filters {
  min-width: 0;
  display: grid; gap: 12px; max-height: calc(100svh - var(--header-h) - 32px); overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 16px 18px; border-radius: 26px;
  border: 1px solid var(--line); color: var(--ink);
  box-shadow: var(--shadow-sm);
  scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent;
  /* Scroll shadows: when a short window cuts the panel, a soft shade at its edge says there's more */
  background:
    linear-gradient(var(--surface) 40%, transparent) top / 100% 36px no-repeat local,
    linear-gradient(transparent, var(--surface) 60%) bottom / 100% 36px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgb(11 30 51 / 0.16), transparent) top / 100% 14px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgb(11 30 51 / 0.16), transparent) bottom / 100% 14px no-repeat scroll;
  background-color: var(--surface);
}
.uh-filters-toggle {
  display: none; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  min-height: 52px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm);
  font: 800 16px/1.2 var(--text); cursor: pointer;
  transition: transform 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.uh-filters-tl { display: inline-flex; align-items: center; gap: 10px; }
.uh-filters-tl .i { width: 20px; height: 20px; }
.uh-filters-toggle .uh-n { background: var(--green); color: var(--on-bright); }
.uh-filters-toggle .chev { width: 18px; height: 18px; transition: rotate 200ms var(--ease-out); }
.uh-filters-toggle[aria-expanded="true"] .chev { rotate: 180deg; }
.uh-filters-toggle:active { transform: scale(0.98); }
.uh-clear {
  min-height: 44px; padding: 0 6px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--accent-ink); font: 700 15px/1.2 var(--text);
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.25em; cursor: pointer;
}
.uh-clear[hidden] { display: none; }
.uh-group { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 12px 0 0; border: 0; border-top: 1px solid var(--line); }
.uh-group legend { float: left; width: 100%; padding: 0 0 8px; font: 800 15px/1.3 var(--text); }
.uh-group legend + * { clear: both; }
.uh-group:first-of-type { padding-top: 0; border-top: 0; }
.uh-opts { display: flex; flex-wrap: wrap; gap: 6px; }
/* An option: a pill with its count. Chosen, it turns green (a chosen answer, DESIGN.md); with none left, it fades. */
.uh-opt {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 5px 0 12px;
  border-radius: 999px; border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font: 700 14px/1.2 var(--text); cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, opacity 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.uh-opt::after { content: ""; position: absolute; inset: -3px 0; }
.uh-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.uh-n {
  min-width: 24px; padding: 2px 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft);
  font: 700 12px/1.3 var(--text); font-variant-numeric: tabular-nums; text-align: center;
  transition: background-color 160ms ease, color 160ms ease;
}
/* A choice snaps on (arrow keys move it, and the cards change at once), and the one it replaces fades off */
.uh-opt:has(input:checked) { border-color: var(--green); background: var(--green); color: var(--on-bright); transition: none; }
.uh-opt:has(input:checked) .uh-n { background: color-mix(in srgb, var(--sheet-bg) 75%, transparent); color: var(--ink); transition: none; }
.uh-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.uh-opt.is-none:not(:has(input:checked)) { opacity: 0.55; border-style: dashed; }
@media (hover: hover) and (pointer: fine) {
  .uh-opt:not(:has(input:checked)):hover { border-color: var(--ink-soft); }
}
@media (pointer: coarse) {
  .uh-opt { min-height: 40px; }
}
.uh-platform { display: flex; align-items: flex-start; gap: 8px; font-size: 15px; line-height: 1.45; color: var(--ink-soft); max-width: 60ch; }
.uh-platform img { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.uh-platform b { color: var(--ink); }
/* The results: one line saying how many match (a polite live region), the filters in use, then the cards */
.uh-results { min-width: 0; }
.uh-results-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-height: 44px; }
.uh-count { font: 700 17px/1.4 var(--text); font-variant-numeric: tabular-nums; }
.uh-active { display: flex; flex-wrap: wrap; gap: 6px; }
.uh-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 8px 0 13px;
  border: 0; border-radius: 999px;
  background: var(--field-green); color: var(--ink);
  font: 700 14px/1.2 var(--text); cursor: pointer;
  position: relative;
  transition: background-color 160ms ease, transform 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.uh-chip::after { content: ""; position: absolute; inset: -4px 0; }
.uh-chip .i { width: 16px; height: 16px; }
.uh-chip:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .uh-chip:hover { background: color-mix(in srgb, var(--green) 40%, var(--field-green)); }
}
.wf-grid.uh-grid { margin-top: 22px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.uh-grid .wf { grid-row: span 6; }
.uh-grid .wf[hidden] { display: none; }
.uh-goal .i { width: 13px; height: 13px; color: var(--ink-soft); }
.uh-find .wf-ind { font-size: 14px; line-height: 1.45; color: var(--ink-soft); text-wrap: pretty; }
.uh-find .wf-ind span { font-weight: 700; }
/* No match: what to loosen, one button per filter in use, and the way back to all of them */
.uh-empty { display: grid; gap: 12px; justify-items: start; margin-top: 22px; padding: clamp(22px, 3vw, 34px); border-radius: 26px; border: 1.5px dashed var(--line-strong); background: var(--surface); }
.uh-empty[hidden] { display: none; }
.uh-empty-t { font: 800 1.3rem/1.3 var(--text); letter-spacing: -0.01em; text-wrap: balance; }
.uh-empty p { color: var(--ink-soft); max-width: 52ch; text-wrap: pretty; }
.uh-empty-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.uh-empty p a { color: var(--accent-ink); font-weight: 700; }
.uh-empty-btns .btn { --b-bg: var(--surface-2); --b-ink: var(--ink); box-shadow: none; gap: 10px; }
.uh-empty-btns .btn .uh-n { background: var(--surface); }
.uh-empty-btns .btn-primary { --b-bg: var(--btn-bg); --b-ink: var(--btn-ink); box-shadow: var(--shadow-sm); }
@media (hover: hover) and (pointer: fine) {
  .uh-empty-btns .btn:not(.btn-primary):hover { --b-bg: var(--field-green); }
}
@media (max-width: 1279px) {
  .uh-find-grid { grid-template-columns: minmax(0, 264px) minmax(0, 1fr); column-gap: 28px; }
  .uh-filters { padding-inline: 16px; }
}
@media (max-width: 1023px) {
  .uh-find-grid { grid-template-columns: minmax(0, 1fr); }
  .uh-side { position: static; }
  .uh-filters { max-height: none; overflow: visible; }
  .uh-find.is-js .uh-filters-toggle { display: flex; }
  .uh-filters[hidden] { display: none; }
}
@media (max-width: 719px) {
  .wf-grid.uh-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .uh-chip:active, .uh-filters-toggle:active { transform: none; }
  .uh-filters-toggle .chev { transition: none; }
}
