/* Directory & hub pages (w42-dirs, docs/DESIGN_SYSTEM.md "Directories"): /tools (+ ?q= results), /apps, category
   sites, /workflows, /docs. Every rule is scoped to `.dir` (a wrapper set only by these pages), so the home, tool
   pages, app pages and apps never see it. `.dir` sits on the hero section and on the content wrap (so <main> keeps
   its sections as direct children), `.dir-docs` on a wrapper around the docs column. Tokens and components (.btn, .link, .card) come from styles.css and
   platform.css; nothing here adds a colour, a button or a card variant of its own. */

/* ---------------------------------------------------------------- hero: flat canvas on the wrap lines */
.dir-hero { background: var(--canvas); padding: clamp(24px, 5vw, 64px) 0 clamp(32px, 5vw, 64px); }
.dir-hero .crumbs { margin-bottom: var(--sp-5); }
.dir-hero-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(24px, 4vw, 64px); align-items: start; }
.dir-hero-copy { min-width: 0; }
.dir-apps .dir-hero-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.dir-hero h1 { font-size: var(--fs-display); line-height: 1.04; letter-spacing: var(--display-tracking); margin: 0 0 var(--sp-4); max-width: 16ch; text-wrap: balance; }
.dir-hero .cat-head h1 { max-width: 18ch; }
.dir-hero .lede { font-size: clamp(1.05rem, 1rem + .3vw, 1.2rem); line-height: 1.55; color: var(--ink-2); max-width: 38rem; margin: 0 0 var(--sp-5); }
.dir-hero .cat-head { display: block; margin-bottom: var(--sp-5); }
.dir-hero .cat-head > div { margin-top: var(--sp-4); }
.dir-hero .cat-head p.muted { font-size: clamp(1.05rem, 1rem + .3vw, 1.2rem); color: var(--ink-2); margin-top: var(--sp-3); max-width: 36rem; }
.dir-hero .cat-badge { width: 52px; height: 52px; border-radius: var(--r-md); }
.dir-hero .cat-badge svg { width: 28px; height: 28px; }

/* real counts from the registry */
.dir-stats { list-style: none; margin: 0 0 var(--sp-5); padding: 0; display: flex; flex-wrap: wrap; gap: 8px 40px; }
.dir-stats li { display: grid; margin: 0; padding: 0; }
.dir-stats strong { font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.5rem, 1.3rem + .6vw, 1.75rem); line-height: 1.1; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.dir-stats span { font-size: var(--fs-sm); color: var(--muted); }

/* search: the form sits on the ground (no card around it), the submit is the system button */
.dir-hero .tool-search { margin-top: 0; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; max-width: 38rem; }
.dir-hero .tool-search label { font-weight: 600; color: var(--ink); }
.dir .tool-search .check-row input { min-height: 52px; border-radius: var(--r-sm); background: var(--surface); }
.dir .tool-search .check-row .btn { min-height: 52px; padding-inline: 24px; }
.dir .search-reset, .dir .tools-apps-hint { margin: var(--sp-3) 0 0; }
.dir-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: var(--sp-5) 0 0; }

/* ---------------------------------------------------------------- framed windows of real UI (hero, right column) */
.dir-window { margin: 0; min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.dir .dir-window-bar { display: flex; align-items: center; gap: 14px; margin: 0; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--canvas); font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; letter-spacing: 0; color: var(--muted); }
.dir-dots { display: inline-flex; gap: 6px; flex: none; }
.dir-dots i { width: 10px; height: 10px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 20%, transparent); }
.dir-window-body { padding: 20px; }

/* /tools "Start here": rows of real tools (name + tagline), category colour as a small mark only */
.dir-window .start-chips { display: grid; gap: 0; padding: 6px; }
.dir-window .start-chips li { margin: 0; }
.dir-window .start-chips a { display: grid; grid-template-columns: 10px minmax(0, 1fr); column-gap: 14px; align-items: baseline; padding: 10px 14px; border: 0; border-radius: var(--r-md); background: none; color: var(--ink); font-size: inherit; font-weight: inherit; text-decoration: none; }
.dir-window .start-chips a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.dir-window .start-chips a:hover .dir-row-name { text-decoration: underline; text-underline-offset: .18em; }
.dir-dot { grid-row: 1; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); align-self: center; }
.dir-row-name { grid-column: 2; font-weight: 600; line-height: 1.3; }
.dir-row-line { grid-column: 2; min-width: 0; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* category hero: the most-used tool, its real fields and example values (text, not controls) */
.dir-preview-line { margin: 0 0 var(--sp-4); color: var(--ink-2); }
.dir-preview-rows { margin: 0 0 var(--sp-5); display: grid; gap: 10px; }
.dir-preview-rows > div { display: grid; gap: 4px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--canvas); }
.dir-preview-rows dt { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.dir-preview-rows dd { margin: 0; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dir-preview-go { margin: 0; }
.dir-preview-go .btn { width: 100%; }

/* /apps: the most used app's screenshot in a framed window (no caption) */
.dir-shot { margin: 0; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.dir-shot a { display: block; overflow: hidden; }
.dir-shot img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top left; transition: transform .4s var(--ease); }
.dir-shot a:hover img { transform: scale(1.025); }
.dir .app-overview-counts { margin: 0; }
/* "Related tools" links under each goal: 44px tap targets (they sit side by side, separated by a dot) */
.dir .app-goal-tools a { display: inline-block; padding-block: 10px; }

/* ---------------------------------------------------------------- sections below the hero */
.dir .search-results { margin: var(--sp-6) 0 var(--sp-7); }
.dir .themes, .dir .category, .dir .app-goals { margin-top: var(--sp-7); }
.dir .themes > h2, .dir .category > h2, .dir .app-goals > h2 { margin: 0 0 var(--sp-4); }
/* group names: sentence case headings, never uppercase kickers */
.dir .group-h, .dir .group-label { margin: var(--sp-6) 0 var(--sp-3); padding: 0; border: 0; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink); }
.dir .group { margin-top: var(--sp-8); padding-top: var(--sp-6); border-top: 1px solid var(--line); }
.dir .theme-grid { gap: 12px; }
.dir .theme a { box-shadow: none; padding: 14px 16px; }
.dir .theme a:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.dir .cat-nav a::before { background: var(--accent); }
.dir .cards { gap: 16px; }
.dir .category .cat-head { display: block; margin-bottom: var(--sp-4); } /* badge above the heading: headings stay on the wrap line */
.dir .category .cat-head > div { margin-top: var(--sp-3); }
.dir .category .cat-badge { width: 40px; height: 40px; border-radius: var(--r-sm); }
.dir .cat-more > summary { min-height: 44px; display: inline-flex; align-items: center; }

/* /workflows: steps as a chain of real tools */
.dir-wf-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.dir .dir-wf-cards .card h2 { font-size: 1.15rem; }
.dir .dir-wf-cards .dir-steps-label { margin: auto 0 6px; padding-top: var(--sp-3); }
.dir-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; counter-reset: step; }
.dir-steps li { counter-increment: step; display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--canvas); font-size: var(--fs-sm); color: var(--ink-2); }
.dir-steps li::before { content: counter(step); font-weight: 700; color: var(--primary-text); font-variant-numeric: tabular-nums; }
.dir .workflows-more { margin: var(--sp-6) 0; }
/* clear air before a change of block (feedback callout, day card, footer): nothing sits flush on a rule */
.dir .category { margin-bottom: var(--sp-7); }
.dir .small-themes { padding-bottom: var(--sp-7); }
.dir > .uw-day, .dir .uw-day-foot { margin-top: var(--sp-6); }
.dir .app-goals { margin-bottom: var(--sp-7); }

/* /docs: system type on the reading column, code as framed windows */
.dir-docs .prose { padding-top: clamp(24px, 5vw, 64px); padding-bottom: var(--sp-8); }
.dir-docs .prose h1 { font-size: var(--fs-display); line-height: 1.04; letter-spacing: var(--display-tracking); margin: 0 0 var(--sp-4); }
.dir-docs .prose .lede { font-size: clamp(1.05rem, 1rem + .3vw, 1.2rem); color: var(--ink-2); }
.dir-docs .prose h2 { margin-top: var(--sp-7); }
.dir-docs .prose > ul { padding-inline-start: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.dir-docs .prose > ul > li { margin: 0; padding: 12px 18px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.dir-docs .prose > ul > li:first-child { border-top: 0; }
.dir-docs .prose pre { border: 1px solid var(--line); border-radius: var(--r-lg); }

/* the hero holds the first screen on its own (the next heading never peeks in) on desktop-sized windows */
@media (min-width: 901px) and (min-height: 700px) {
  .dir-hero.dir-tools, .dir-hero.dir-category, .dir-hero.dir-apps { min-height: calc(100svh - var(--header-h)); box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; }
  :is(.dir-hero.dir-tools, .dir-hero.dir-category, .dir-hero.dir-apps) > .wrap { width: 100%; box-sizing: border-box; }
}

/* ---------------------------------------------------------------- widths */
@media (max-width: 900px) {
  .dir-hero-grid, .dir-apps .dir-hero-grid { grid-template-columns: minmax(0, 1fr); }
  .dir-hero h1 { max-width: none; }
}
@media (max-width: 560px) {
  .dir-stats { gap: 8px 28px; }
  .dir-actions .btn { width: 100%; }
  .dir-window-body { padding: 16px; }
  .dir .tool-search .check-row .btn { width: 100%; }
}

/* ---------------------------------------------------------------- preferences */
@media (prefers-reduced-motion: reduce) {
  .dir-shot img { transition: none; }
  .dir-shot a:hover img, .dir .theme a:hover { transform: none; }
}
@media (forced-colors: active) {
  .dir-window, .dir-shot, .dir-preview-rows > div, .dir-steps li { border: 1px solid CanvasText; }
  .dir-dot, .dir-dots i { forced-color-adjust: none; background: CanvasText; }
}
@media print {
  .dir-window, .dir-shot, .dir-actions { display: none !important; }
  .dir-hero { padding: 0 0 12px; }
  .dir-hero-grid { display: block; }
}
