/* /chinese-resources/ — built by scripts/build-resources.py */
.res-page { padding-block: var(--space-6) var(--space-8); }
.res-page h1 { font-size: var(--size-2xl); margin-block-end: var(--space-3); }
.res-page .lede { max-width: var(--measure-text); color: var(--c-muted); font-size: var(--size-md); }

.res-jump ul { list-style: none; padding: 0; margin: var(--space-5) 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.res-jump a { display: inline-block; padding: var(--space-1) var(--space-3); border: 1px solid var(--c-rule);
  border-radius: var(--radius-pill); text-decoration: none; color: var(--c-ink); font-size: var(--size-xs); background: var(--c-sheet); }
.res-jump a:hover { border-color: var(--c-brand); }
.res-jump span { color: var(--c-muted); margin-inline-start: var(--space-1); }

.res-tools { position: sticky; top: 0; z-index: 5; background: var(--c-page); padding-block: var(--space-3);
  display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; border-bottom: 1px solid var(--c-rule); }
.res-tools input, .res-tools select { font: inherit; font-size: var(--size-sm); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--c-rule); border-radius: var(--radius-control); background: var(--c-sheet); color: var(--c-ink); }
.res-tools input { flex: 1 1 16rem; }
.res-view { display: inline-flex; border: 1px solid var(--c-rule); border-radius: var(--radius-control); overflow: hidden; }
.res-view button { font: inherit; font-size: var(--size-sm); padding: var(--space-2) var(--space-3); border: 0;
  background: var(--c-sheet); color: var(--c-muted); cursor: pointer; }
.res-view button[aria-pressed="true"] { background: var(--c-brand); color: var(--c-brand-ink); }
.res-chips { display: flex; flex-wrap: wrap; gap: var(--space-1); flex-basis: 100%; }
.chip { font: inherit; font-size: var(--size-xs); padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill);
  border: 1px solid var(--c-rule); background: var(--c-sheet); color: var(--c-ink); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--c-brand-soft); border-color: var(--c-brand); color: var(--c-brand); font-weight: 600; }
.res-count { margin: 0; font-size: var(--size-xs); color: var(--c-muted); flex-basis: 100%; }

.res-cat { margin-block-start: var(--space-7); scroll-margin-top: 9rem; }
.res-cat h2 { font-size: var(--size-xl); margin-block-end: var(--space-1); }
.res-blurb { color: var(--c-muted); margin-block-start: 0; }
.res-grid { list-style: none; padding: 0; display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.res-grid > .res { background: var(--c-sheet); border: 1px solid var(--c-rule); border-radius: var(--radius-sheet);
  padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.res-grid h3 { font-size: var(--size-base); margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; }
.res-grid h3 a { color: var(--c-ink); text-decoration: none; }
.res-grid h3 a:hover { color: var(--c-brand); text-decoration: underline; }
.res-grid p { margin: 0; font-size: var(--size-sm); }
.res-meta { color: var(--c-muted); font-size: var(--size-xs) !important; }
.res-ours { font-size: var(--size-xs); font-weight: 500; color: var(--c-brand); }
.res-tags { list-style: none; padding: 0; margin: auto 0 0; display: flex; flex-wrap: wrap; gap: var(--space-1); }
.res-tags li { font-size: 0.75rem; padding: 0 var(--space-2); border-radius: var(--radius-pill); background: var(--c-page); color: var(--c-muted); }

.res-note { color: var(--c-muted); font-size: var(--size-sm); }
.res-table-wrap { overflow: auto; max-height: 75vh; border: 1px solid var(--c-rule); border-radius: var(--radius-sheet); background: var(--c-sheet); }
.res-table { border-collapse: collapse; font-size: var(--size-xs); width: 100%; }
.res-table th, .res-table td { padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--c-rule); text-align: center; }
.res-table thead th { position: sticky; top: 0; background: var(--c-sheet); z-index: 1; white-space: nowrap; }
.res-table tbody th { text-align: left; position: sticky; left: 0; background: var(--c-sheet); white-space: nowrap; font-weight: 500; }
.res-table tbody th a { color: var(--c-ink); text-decoration: none; }
.res-table td span { color: var(--tone-3); font-weight: 700; }
.res-table tbody tr:hover th, .res-table tbody tr:hover td { background: var(--c-brand-soft); }

.res-suggest { margin-block-start: var(--space-8); padding: var(--space-5); border-radius: var(--radius-sheet);
  background: var(--c-sheet); border: 1px solid var(--c-rule); max-width: var(--measure-text); }
.res-suggest h2 { margin-block-start: 0; }

/* Chart headings read bottom to top, so each column is only as wide as a tick. */
.res-table thead th.res-vh { vertical-align: bottom; padding: var(--space-2) 0; width: 1.9rem; min-width: 1.9rem; }
.res-table th.res-vh span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block;
  white-space: nowrap; font-weight: 600; line-height: 1.9rem; }
.res-table thead th:first-child { vertical-align: bottom; text-align: left; position: sticky; left: 0; z-index: 2; }
.res-table td { padding-inline: 0; }
.res-table tbody tr:nth-child(even) th, .res-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--c-page) 45%, var(--c-sheet)); }

/* Phones: one swipeable row for groups and for features, two filters a row, toolbar not sticky. */
@media (max-width: 640px) {
  .res-page { padding-block: var(--space-4) var(--space-7); }
  .res-page h1 { font-size: var(--size-xl); }
  .res-page .lede { font-size: var(--size-base); }
  .res-jump ul, .res-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-inline: calc(-1 * var(--space-5)); padding-inline: var(--space-5); -webkit-overflow-scrolling: touch; }
  .res-jump ul::-webkit-scrollbar, .res-chips::-webkit-scrollbar { display: none; }
  .res-jump li, .chip { flex: 0 0 auto; white-space: nowrap; }
  .res-tools { position: static; display: grid; grid-template-columns: 1fr 1fr; }
  .res-tools input, .res-chips, .res-count { grid-column: 1 / -1; }
  .res-tools select { min-width: 0; width: 100%; }
  .res-view { justify-self: stretch; }
  .res-view button { flex: 1; }
  .res-cat { margin-block-start: var(--space-6); scroll-margin-top: var(--space-4); }
  .res-cat h2 { font-size: var(--size-lg); }
  .res-grid { grid-template-columns: 1fr; gap: var(--space-3); }
  .res-table-wrap { max-height: 80vh; margin-inline: calc(-1 * var(--space-2)); }
  .res-table tbody th { white-space: normal; min-width: 7.5rem; max-width: 8.5rem; line-height: 1.25; }
  .res-table thead th.res-vh { width: 1.55rem; min-width: 1.55rem; }
  .res-table th.res-vh span { line-height: 1.55rem; }
}

/* Front door: where are you starting? */
.res-doors { margin-block: var(--space-6) var(--space-7); }
.res-doors h2 { font-size: var(--size-lg); margin-block-end: var(--space-3); }
.res-doors ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.res-doors a { display: flex; flex-direction: column; gap: var(--space-1); height: 100%; padding: var(--space-4) var(--space-5);
  background: var(--c-sheet); border: 1px solid var(--c-rule); border-radius: var(--radius-sheet); text-decoration: none;
  color: var(--c-ink); box-shadow: inset 0 3px 0 var(--c-brand); }
.res-doors a:hover { border-color: var(--c-brand); }
.res-doors strong { font-size: var(--size-md); }
.res-doors span { color: var(--c-muted); font-size: var(--size-sm); }
.res-all-title { font-size: var(--size-xl); margin-block-end: 0; }

/* Toolbar, second version */
.res-tools { display: block; }
.res-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.res-row input { flex: 1 1 16rem; }
.res-sort { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--size-sm); color: var(--c-muted); }
.res-label { margin: var(--space-3) 0 var(--space-1); font-size: var(--size-xs); font-weight: 600; color: var(--c-muted); }
.chip-free { border-style: dashed; }
.res-more { margin-block-start: var(--space-2); font-size: var(--size-sm); }
.res-more summary { cursor: pointer; color: var(--c-muted); }
.res-selects { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block-start: var(--space-2); }
.res-active { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-block-start: var(--space-2); }
.res-active:empty { display: none; }
.res-tag { font: inherit; font-size: var(--size-xs); padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill);
  border: 0; background: var(--c-brand); color: var(--c-brand-ink); cursor: pointer; }
.res-count { margin-block-start: var(--space-2); }
.res-jump ul { margin-block: var(--space-4) 0; }
.res-group { display: none; font-size: var(--size-xs) !important; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.res-flat-mode .res-group { display: block; }
.res-flat { margin-block-start: var(--space-5); }
.res-fresh { color: var(--tone-3); }
.res-empty { padding: var(--space-6) 0; color: var(--c-muted); }
.res-empty button { font: inherit; color: var(--c-brand); background: none; border: 0; text-decoration: underline; cursor: pointer; }

/* Starter shelf pages */
.shelf-crumb { font-size: var(--size-sm); margin: 0 0 var(--space-3); }
.shelf-crumb a { color: var(--c-muted); }
.shelf { list-style: none; padding: 0; margin: var(--space-6) 0; display: grid; gap: var(--space-4); max-width: 46rem; }
.shelf > li { display: flex; gap: var(--space-4); padding: var(--space-4) var(--space-5); background: var(--c-sheet);
  border: 1px solid var(--c-rule); border-radius: var(--radius-sheet); }
.shelf-n { flex: 0 0 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--c-brand); color: var(--c-brand-ink);
  display: grid; place-items: center; font-weight: 700; }
.shelf h2 { font-size: var(--size-md); margin: 0 0 var(--space-1); }
.shelf h2 a { color: var(--c-ink); }
.shelf-why { margin: 0 0 var(--space-2); }
.shelf-url { display: none; }
.shelf-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.shelf-note { color: var(--c-muted); max-width: var(--measure-text); }
.shelf-others ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.shelf-others a { display: inline-block; padding: var(--space-1) var(--space-3); border: 1px solid var(--c-rule);
  border-radius: var(--radius-pill); text-decoration: none; color: var(--c-ink); background: var(--c-sheet); }

@media print {
  .site-header, .site-footer, .shelf-actions, .shelf-others, .shelf-crumb { display: none; }
  .shelf > li { break-inside: avoid; border-color: #999; }
  .shelf-url { display: inline; }
  body { background: #fff; }
}

@media (max-width: 640px) {
  .res-doors ul { grid-template-columns: 1fr 1fr; }
  .res-doors a { padding: var(--space-3); }
  .res-doors strong { font-size: var(--size-base); }
  .res-doors span { display: none; }
  .res-row { display: grid; grid-template-columns: 1fr auto; }
  .res-row input { grid-column: 1 / -1; }
  .res-view { display: none; }                    /* the chart is a desk view */
  .res-selects select { flex: 1 1 45%; }
  .chip { min-height: 2.75rem; }                  /* 44px touch targets */
  .shelf > li { padding: var(--space-3); gap: var(--space-3); }
}
/* The toolbar grew; it scrolls with the page now. */
.res-tools { position: static; border-bottom: 0; }

/* Cards open the preview panel */
.res-grid > .res { cursor: pointer; }
.res-grid > .res:hover { border-color: var(--c-brand); }

/* Preview panel */
.res-panel { border: 0; border-radius: var(--radius-sheet); padding: var(--space-5); width: min(32rem, calc(100vw - 2rem));
  background: var(--c-sheet); color: var(--c-ink); box-shadow: 0 20px 60px var(--c-shadow); }
.res-panel::backdrop { background: rgba(10, 12, 16, 0.45); }
.panel-head { display: flex; gap: var(--space-3); align-items: center; margin-block-end: var(--space-4); }
.panel-head h2 { margin: 0; font-size: var(--size-lg); }
.panel-group { margin: 0; color: var(--c-muted); font-size: var(--size-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.panel-logo { flex: 0 0 3.5rem; height: 3.5rem; border-radius: 14px; background: var(--c-page); display: grid; place-items: center;
  font-size: var(--size-lg); font-weight: 700; color: var(--c-brand); overflow: hidden; }
.panel-logo img { width: 48px; height: 48px; object-fit: contain; }
.panel-close { margin-inline-start: auto; align-self: flex-start; font: inherit; font-size: var(--size-md); background: none; border: 0;
  color: var(--c-muted); cursor: pointer; min-width: 2.75rem; min-height: 2.75rem; }
.panel-label { margin: 0 0 var(--space-1); font-size: var(--size-xs); font-weight: 600; color: var(--c-brand); }
.panel-maker blockquote { margin: 0 0 var(--space-4); padding-inline-start: var(--space-3); border-inline-start: 3px solid var(--c-brand-soft);
  font-size: var(--size-base); }
.panel-desc { margin: 0 0 var(--space-3); }
.res-panel .res-tags { margin-block-end: var(--space-3); }
.panel-visit { display: block; text-align: center; margin-block: var(--space-4) var(--space-3); padding: var(--space-3); }
.panel-claim { margin: 0; font-size: var(--size-xs); color: var(--c-muted); }

@media (max-width: 640px) {   /* a sheet that rises from the bottom */
  .res-panel { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    padding-block-end: calc(var(--space-5) + env(safe-area-inset-bottom)); }
}

/* Chart rows open the panel too */
#res-chart tr.res { cursor: pointer; }
#res-chart tr.res:hover { background: var(--c-page); }
