/* The tools index (/tools/), Jack's tool centre: pack platform/02_design.md sections 3 to 6 on Matrix Calm tokens
   (tokens.css). Loaded by the index only, after tools.css, so the tool pages and the platform pages are unchanged; every
   rule starts with .hub (the index's body) so that it wins over tools.css's element rules (.matrix-ui p, h2, h3).
   Page margins 32 / 24 / 20 px (16 px at 320 px), the tool entry 1120 px wide beside a 240 px navigation from
   1024 px; below 1024 px the navigation is a drawer and each product section folds to one row. */
.hub { --hub-margin: 20px; --hub-nav: 240px; --hub-gap: 32px; }
@media (max-width: 359.98px) { .hub { --hub-margin: 16px; } }
@media (min-width: 600px) { .hub { --hub-margin: 24px; } }
@media (min-width: 1024px) { .hub { --hub-margin: 32px; } }
.hub .wrap { width: min(100% - 2 * var(--hub-margin), calc(var(--hub-nav) + var(--hub-gap) + 1120px)); }
.hub :lang(zh) { letter-spacing: 0; }
/* Controls that work only with the page's script keep their place from the start and appear once it is ready. On a phone
   the favourites take no room until the script has placed them (hub.js placeMine), so the first screen shows tools. */
html:not([data-js="ready"]) .hub .hub-js { visibility: hidden; }
@media (max-width: 1023.98px) { html:not([data-js="ready"]) .hub .mine { display: none; } }

.hub .hub-layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.hub .hub-main { min-width: 0; padding-bottom: var(--matrix-space-48); }
.hub .hub-layout > .product-nav { display: none; }
@media (min-width: 1024px) {
  .hub .hub-layout { grid-template-columns: var(--hub-nav) minmax(0, 1120px); column-gap: var(--hub-gap); }
  .hub .hub-layout > .product-nav { display: block; position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; overscroll-behavior: contain; padding: var(--matrix-space-32) 0 var(--matrix-space-24); scrollbar-width: thin; }
}

/* ---------- the navigation of products: a column on wide screens, the drawer's content on narrow ones ---------- */
.hub .nav-title { margin: 0 0 var(--matrix-space-8); padding-inline: 18px; font-size: var(--matrix-type-caption); line-height: var(--matrix-leading-caption); font-weight: 600; color: var(--matrix-muted); }
.hub .nav-list { list-style: none; margin: 0; padding: 0 6px 6px; display: grid; gap: 2px; } /* 6 px around the links: room for the 3 px focus ring and its 3 px gap inside the scrolling column */
.hub .nav-list a { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--matrix-space-8); align-items: baseline; min-height: var(--matrix-control-min-height); padding: 6px 12px; border-radius: var(--matrix-radius-control); color: var(--matrix-text); text-decoration: none; transition: background-color var(--matrix-motion-fast) var(--matrix-ease); }
.hub .nav-name { font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); font-weight: 500; overflow-wrap: anywhere; }
.hub .nav-summary { grid-column: 1 / -1; grid-row: 3; font-size: var(--matrix-type-caption); line-height: var(--matrix-leading-caption); color: var(--matrix-muted); }
.hub .nav-english { grid-column: 1 / -1; grid-row: 2; font-size: var(--matrix-type-caption); line-height: var(--matrix-leading-caption); color: var(--matrix-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The filters: chips that combine, each a toggle button; a chosen one is marked by a tick as well as by its colour
   (section 5: a selected state changes shape). On a phone they open from one button, so the first screen shows tools. */
.hub .filters { margin-top: var(--matrix-space-16); }
.hub .filters-toggle { display: none; }
.hub .filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--matrix-space-8); }
.hub .filter-chip { min-height: 40px; }
.hub .filter-chip[aria-pressed="true"] { color: var(--matrix-selected-text); background: var(--matrix-selected); border-color: var(--matrix-brand); }
.hub .filter-chip[aria-pressed="true"] [lang] { color: inherit; }
.hub .filter-chip[aria-pressed="true"]::before { content: ""; display: inline-block; width: 5px; height: 10px; margin: 0 9px 3px 1px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.hub .filters-clear { min-height: 40px; padding: 6px 8px; border: 0; background: transparent; color: var(--matrix-link); font: inherit; font-size: var(--matrix-type-control); text-decoration: underline; cursor: pointer; }
.hub .filters-clear[hidden] { display: none; }
@media (max-width: 599.98px) {
  .hub .filters-toggle { display: inline-flex; align-items: center; column-gap: 4px; }
  .hub .filters:not(.is-open) .filter-chips { display: none; }
  .hub .filters.is-open .filter-chips { margin-top: var(--matrix-space-8); }
}
.hub .nav-count { grid-column: 2; grid-row: 1; font-size: var(--matrix-type-caption); color: var(--matrix-muted); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .hub .nav-list a:hover { background: var(--matrix-hover); } }
.hub .nav-list a[aria-current="true"] { background: var(--matrix-selected); color: var(--matrix-selected-text); }
.hub .nav-list a[aria-current="true"] :is(.nav-summary, .nav-english, .nav-count) { color: inherit; }
.hub .nav-list a[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--matrix-brand); }

/* ---------- first screen: the title, one line of purpose, the search and the filters ---------- */
.hub .hub-hero { padding-block: var(--matrix-space-32) var(--matrix-space-24); }
.hub .hub-hero h1 { margin: 0 0 var(--matrix-space-8); }
.hub .hub-hero .lead { margin: 0; max-width: 760px; font-size: var(--matrix-type-body); line-height: var(--matrix-leading-body); color: var(--matrix-text); }
.hub .hub-facts { margin: var(--matrix-space-8) 0 0; max-width: 760px; font-size: var(--matrix-type-table); line-height: var(--matrix-leading-table); color: var(--matrix-muted); }

.hub .finder { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "label" "field" "status"; align-items: center; column-gap: var(--matrix-space-8); max-width: 760px; margin-top: var(--matrix-space-24); }
.hub .finder-label { grid-area: label; margin-bottom: var(--matrix-space-8); font-weight: 600; font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); }
.hub .finder-label [lang], .hub .filters [lang], .hub .task-zh { font-weight: 400; color: var(--matrix-muted); }
.hub .finder-field { grid-area: field; position: relative; margin: 0; }
.hub .finder-field > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--matrix-muted); pointer-events: none; }
.hub .finder-field input { width: 100%; min-height: var(--matrix-touch-min); padding: 10px 12px 10px 44px; font-size: var(--matrix-type-control); }
.hub .finder-field.has-text input { padding-right: 52px; } /* room for the Clear button only while there is text to clear */
.hub .finder-field input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; } /* the page's own Clear button, the same in every browser */
.hub .search-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: inline-grid; place-items: center; border-color: transparent; background: transparent; color: var(--matrix-muted); }
.hub .nav-open { grid-area: open; display: none; }
.hub .search-status { grid-area: status; margin: var(--matrix-space-8) 0 0; font-size: var(--matrix-type-table); line-height: var(--matrix-leading-table); color: var(--matrix-muted); }
.hub .search-status:empty { margin: 0; }
/* A search for a common office tool that is not available yet: what is missing, and what the tools shown can and cannot do. */
.hub .search-note { max-width: 760px; margin-top: var(--matrix-space-12); padding: var(--matrix-space-12) var(--matrix-space-16); border: 1px solid var(--matrix-border); border-left: 3px solid var(--matrix-warning); border-radius: var(--matrix-radius-control); background: var(--matrix-surface); }
.hub .search-note[hidden] { display: none; }
/* While the note is shown, the count line is read out but not shown twice: the note says the same, with what to use instead. */
.hub .hub-hero:has(.search-note:not([hidden])) .search-status { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hub .search-note p { margin: 0; font-size: var(--matrix-type-table); line-height: var(--matrix-leading-table); color: var(--matrix-text); }
.hub .search-note p + p { margin-top: var(--matrix-space-4); }
@media (max-width: 1023.98px) {
  .hub .finder { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label open" "field field" "status status"; }
  .hub .finder-label { margin-bottom: 0; }
  .hub .nav-open { display: inline-flex; align-items: center; margin-bottom: var(--matrix-space-8); }
}

/* ---------- favourites and recently used: two quiet rows ---------- */
.hub .mine[hidden] { display: none; }
.hub .mine { display: grid; gap: var(--matrix-space-12); padding: var(--matrix-space-16) 0; border-block: 1px solid var(--matrix-border); }
.hub .mine-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--matrix-space-8) var(--matrix-space-12); min-width: 0; }
.hub .mine-label { flex: 0 0 8.5rem; margin: 0; font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); font-weight: 600; letter-spacing: 0; }
.hub .mine-hint { margin: 0; font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); color: var(--matrix-muted); }
.hub .mine-switch { display: inline-flex; align-items: center; gap: var(--matrix-space-8); min-height: var(--matrix-control-min-height); font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); color: var(--matrix-muted); cursor: pointer; }
.hub .mine-switch input { flex: none; width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--matrix-brand); }
.hub .quick-links { display: flex; flex-wrap: wrap; gap: var(--matrix-space-8); margin: 0; padding: 0; list-style: none; min-width: 0; }
.hub .quick-link { display: inline-flex; align-items: center; min-height: var(--matrix-control-min-height); padding: 6px 12px; border: 1px solid var(--matrix-control-border); border-radius: var(--matrix-radius-control); background: var(--matrix-surface); color: var(--matrix-link); font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); text-decoration: none; overflow-wrap: anywhere; }
@media (hover: hover) { .hub .quick-link:hover { background: var(--matrix-hover); } }
.hub .mine-status { margin: 0; font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); color: var(--matrix-warning); }
.hub .mine-status:empty { display: none; }
@media (max-width: 599.98px) { .hub .mine-label { flex-basis: auto; } }

/* ---------- one section per pack product: Matrix PDF first, then the pack's order ---------- */
.hub .product { padding-top: var(--matrix-space-32); scroll-margin-top: var(--matrix-space-16); }
.hub .product-title { margin: 0 0 var(--matrix-space-12); letter-spacing: 0; }
.hub .product-name { display: block; font-size: var(--matrix-type-section-title); line-height: var(--matrix-leading-section-title); font-weight: 600; letter-spacing: -0.01em; }
.hub .product-summary { display: block; margin-top: 2px; font-size: var(--matrix-type-table); line-height: var(--matrix-leading-table); font-weight: 400; color: var(--matrix-muted); }
.hub .product-count { display: none; }
.hub .product-title:focus { outline: none; } /* focused only to move the reading place there after a jump from the navigation */
.hub .task + .task { margin-top: var(--matrix-space-20); }
.hub .task-title { margin: 0 0 var(--matrix-space-8); font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); font-weight: 600; letter-spacing: 0; color: var(--matrix-text); }

/* The card: the whole card is one link; the star is its own control beside the link, placed over the card's corner. */
.hub .tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr)); gap: var(--matrix-space-12); margin: 0; padding: 0; list-style: none; }
.hub .tool { position: relative; min-width: 0; }
.hub .tool-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; height: 100%; padding: var(--matrix-space-12) var(--matrix-space-16) var(--matrix-space-16); border: 1px solid var(--matrix-border); border-radius: var(--matrix-radius-panel); background: var(--matrix-surface); color: var(--matrix-text); text-decoration: none; box-shadow: var(--matrix-shadow-card); transition: border-color var(--matrix-motion-fast) var(--matrix-ease); }
@media (hover: hover) { .hub .tool-card:hover { border-color: var(--matrix-brand); } }
.hub .tool-name { max-width: 100%; padding-right: 36px; font-size: var(--matrix-type-item-title); line-height: var(--matrix-leading-item-title); font-weight: 600; color: var(--matrix-link); overflow-wrap: anywhere; }
.hub .tool-zh { font-size: var(--matrix-type-control); line-height: var(--matrix-leading-control); font-weight: 500; color: var(--matrix-text); }
.hub .tool-en { font-size: var(--matrix-type-table); line-height: var(--matrix-leading-table); color: var(--matrix-muted); }
.hub .tool-card .tag { margin-top: var(--matrix-space-8); }
.hub .fav { position: absolute; top: 2px; right: 2px; display: inline-grid; place-items: center; border-color: transparent; background: transparent; color: var(--matrix-muted); }
@media (hover: hover) { .hub .fav:hover { background: var(--matrix-hover); color: var(--matrix-link); } }
.hub .fav[aria-pressed="true"] { color: var(--matrix-link); }
.hub .icon { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.hub .fav[aria-pressed="true"] .icon { fill: currentColor; }

/* Coming soon: the common office tools that are not available yet, as plain text, never as links or cards. */
.hub .soon { margin-top: var(--matrix-space-48); padding-top: var(--matrix-space-24); border-top: 1px solid var(--matrix-border); }
.hub .soon h2 { margin-bottom: var(--matrix-space-8); }
.hub .soon h2 [lang] { font-weight: 400; color: var(--matrix-muted); }
.hub .soon-lead { margin: 0 0 var(--matrix-space-16); max-width: 760px; font-size: var(--matrix-type-table); line-height: var(--matrix-leading-table); color: var(--matrix-muted); }
.hub .soon-list { display: flex; flex-wrap: wrap; gap: var(--matrix-space-8); margin: 0; padding: 0; list-style: none; }
.hub .soon-item { display: inline-flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--matrix-space-8); padding: 6px 12px; border: 1px dashed var(--matrix-control-border); border-radius: var(--matrix-radius-control); color: var(--matrix-text); font-size: var(--matrix-type-table); line-height: var(--matrix-leading-table); }
.hub .soon-zh { color: var(--matrix-muted); }
.hub .hub-about { margin-top: var(--matrix-space-40); }
.hub .hub-about .hub-facts { margin: 0 0 var(--matrix-space-12); max-width: 760px; font-size: var(--matrix-type-body); line-height: var(--matrix-leading-body); color: var(--matrix-text); }

/* From 1024 px the products share one grid, in the page's order, row by row: a product takes as many columns as it has
   tools (data-span), up to the whole row, and so does each task group inside Matrix PDF; every card sits in the same
   columns as every other card (subgrid), so the page reads as tidy rows instead of 48 sections that each hold one card. */
@media (min-width: 1024px) {
  .hub .products { display: grid; grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr)); column-gap: var(--matrix-space-12); row-gap: var(--matrix-space-32); align-items: start; margin-top: var(--matrix-space-32); }
  .hub .product { display: grid; grid-template-columns: subgrid; grid-column: span 1; padding-top: 0; }
  .hub :is(.product, .task)[data-span="2"] { grid-column: span 2; }
  .hub :is(.product, .task)[data-span="all"] { grid-column: 1 / -1; }
  .hub :is(.product-title, .product-tools, .product-tools > .tool-grid, .task-title, .task > .tool-grid) { grid-column: 1 / -1; }
  .hub :is(.product-tools, .task, .tool-grid) { display: grid; grid-template-columns: subgrid; }
  .hub .product-tools { row-gap: var(--matrix-space-20); align-items: start; }
  .hub .task { grid-column: span 1; row-gap: 0; }
  .hub .task + .task { margin-top: 0; }
}

/* ---------- below 1024 px: each product folds to one row: its name, Chinese name and number of tools ---------- */
.hub .product-toggle { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; column-gap: var(--matrix-space-12); width: 100%; min-height: var(--matrix-touch-min); padding: var(--matrix-space-12) 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; letter-spacing: inherit; cursor: pointer; }
.hub .product-label { min-width: 0; }
.hub .product-toggle .product-count { display: inline; font-size: var(--matrix-type-caption); line-height: var(--matrix-leading-caption); font-weight: 400; color: var(--matrix-muted); font-variant-numeric: tabular-nums; }
.hub .product-toggle .icon { color: var(--matrix-muted); transition: transform var(--matrix-motion-fast) var(--matrix-ease); }
.hub .product-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.hub .is-folding .mine { border-bottom: 0; } /* the first product row's rule closes it */
.hub .is-folding .products { margin-top: var(--matrix-space-8); }
.hub .is-folding .product { padding-top: 0; border-top: 1px solid var(--matrix-border); }
.hub .is-folding .product:last-child { border-bottom: 1px solid var(--matrix-border); }
.hub .is-folding .product-title { margin: 0; }
.hub .is-folding .product-tools { padding-bottom: var(--matrix-space-16); }
.hub .is-folding .product-name { font-size: var(--matrix-type-item-title); line-height: var(--matrix-leading-item-title); letter-spacing: 0; }

/* ---------- a phone's first screen: the title, one line, the search, the categories, then Matrix PDF's first tools ---------- */
@media (max-width: 599.98px) {
  .hub .hub-hero { padding-block: var(--matrix-space-12); }
  .hub .hub-hero h1 { margin-bottom: var(--matrix-space-4); }
  .hub .hub-hero .lead { font-size: var(--matrix-type-table); line-height: var(--matrix-leading-table); color: var(--matrix-muted); }
  .hub .finder { margin-top: var(--matrix-space-12); }
  .hub .filters { margin-top: var(--matrix-space-8); }
  .hub .is-folding .products { margin-top: 0; }
  .hub .product-toggle { padding-block: var(--matrix-space-8); }
  .hub .task + .task { margin-top: var(--matrix-space-16); }
  .hub .tool-card { padding: var(--matrix-space-8) var(--matrix-space-12) 10px; }
  .hub .tool-card .tag { margin-top: 2px; }
  /* a folded product takes one line when its Chinese name fits beside its name; a longer one moves whole to the next line */
  .hub .is-folding .product-name { display: inline; margin-right: var(--matrix-space-8); }
  .hub .is-folding .product-summary { display: inline-block; margin: 0; }
}

/* ---------- the drawer: the navigation of products as a sheet from the side, below 1024 px ---------- */
.hub .drawer { margin: 0; inset: 0 auto 0 0; width: min(85vw, 22rem); max-width: 100%; height: 100%; max-height: 100%; padding: 0; border: 0; border-radius: 0 var(--matrix-radius-sheet) var(--matrix-radius-sheet) 0; background: var(--matrix-surface-raised); color: var(--matrix-text); box-shadow: var(--matrix-shadow-dialog); overflow: hidden; }
.hub .drawer[open] { display: flex; flex-direction: column; }
.hub .drawer::backdrop { background: var(--matrix-overlay); }
.hub .drawer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--matrix-space-8); padding: var(--matrix-space-8) var(--matrix-space-8) var(--matrix-space-8) var(--matrix-space-20); border-bottom: 1px solid var(--matrix-border); }
.hub .drawer-title { margin: 0; font-size: var(--matrix-type-item-title); line-height: var(--matrix-leading-item-title); letter-spacing: 0; }
.hub .drawer-head .matrix-icon-button { display: inline-grid; place-items: center; }
.hub .drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-block: var(--matrix-space-8) var(--matrix-space-24); }
.hub .drawer-body .product-nav { display: block; }
.hub .drawer-body .nav-title { display: none; }

@media (pointer: coarse) {
  .hub :is(.quick-link, .nav-list a, .mine-switch) { min-height: var(--matrix-touch-min); }
  .hub .fav { top: 0; right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hub :is(.product-toggle .icon, .tool-card, .nav-list a) { transition: none; }
}
@media (forced-colors: active) {
  .hub .nav-list a[aria-current="true"]::before { background: Highlight; }
  .hub .fav[aria-pressed="true"] .icon { fill: ButtonText; }
}
/* In Chinese, the English half of a pair whose Chinese half stands beside it is not shown (queue row 101). */
html[data-lang="zh"] .hub .en-twin { display: none; }
