/*
 * Shop Index page (#87 release 2). The screen, sidebar, phone toolbar and drawer come from
 * directory-screen.css and drawer-menu.css (the Shop Directory's parts); this file adds the
 * names list, the A–Z bar and the checkboxes the Shop Directory gets from FacetWP's CSS.
 */

.shop-index__intro {
  width: min(100% - (var(--directory-container-padding-x, 16px) * 2), var(--directory-body-container-max, 1250px));
  margin: 16px auto 0;
}

/*
 * The two intro lines use the page width (YU 2026-10-31): at 760px the English lead left
 * "category." alone on a second line. Where text wraps, no word is left alone on the last line,
 * Japanese breaks between phrases and Korean between words (the whole page, so category names
 * and the legend too), and the link's name stays whole.
 */
.shop-index__lead,
.shop-index__about,
.shop-index__legend,
.shop-index__sort,
.shop-index__cat-label,
.shop-index__no-match,
.shop-index__empty {
  text-wrap: pretty;
}

.shop-index__intro :lang(ja),
.shop-index :lang(ja) {
  word-break: auto-phrase;
}

.shop-index__intro :lang(ko),
.shop-index :lang(ko) {
  word-break: keep-all;
}

.shop-index__about a {
  white-space: nowrap;
}

.shop-index__lead {
  margin: 0;
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
}

/* How this page differs from the Shop Directory, and the way back to it (YU 2026-10-29). */
.shop-index__about {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/*
 * Links and white-text buttons use the deep blue (ADR 0004, YU 2026-10-30): the lighter
 * --color-accent stays under 4.5:1 as text on white. The fallback keeps the colour until the
 * token from #913 is in this theme.
 */
.shop-index__about a,
.shop-index__back a {
  color: var(--color-accent-strong, #0a6a99);
}

.shop-index__back {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.4;
}

/*
 * Category checkboxes: FacetWP's grey box from the Shop Directory's sidebar (YU 2026-10-30;
 * checkbox.png / checkbox-on.png, drawn here in CSS so the page does not depend on the plugin).
 * The count stays apart from the name, smaller and on the right (YU 2026-10-31: "(1,320)" right
 * after the name was hard to read). The real checkbox stays for the keyboard and screen readers.
 */
.shop-index__cats {
  margin: 0;
  padding: 0;
  list-style: none;
}

.shop-index__cat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  color: var(--color-text-filter);
  font-size: 16px;
  line-height: 26.4px;
  cursor: pointer;
}

.shop-index__cat input {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid #6d6d6d;
  border-radius: 0;
  background: linear-gradient(#fff, #ededed);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.shop-index__cat input:checked {
  background: #757575;
  box-shadow: inset 0 0 0 1px #fff;
}

.shop-index__cat input:focus-visible {
  outline: 2px solid var(--color-accent-strong, #0a6a99);
  outline-offset: 2px;
}

/* High-contrast modes replace the colours above, so the box would not show its state: use the browser's own checkbox there. */
@media (forced-colors: active) {
  .shop-index__cat input {
    border: 0;
    background: none;
    box-shadow: none;
    -webkit-appearance: auto;
    appearance: auto;
  }
}

.shop-index__cat-label {
  flex: 1 1 auto;
  min-width: 0;
}

.shop-index__cat-count {
  color: var(--color-text-subtle);
  font-size: 13px;
}

.shop-index__group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.shop-index__clear,
.shop-index__clear-search {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent-strong, #0a6a99);
  font-size: 14px;
  cursor: pointer;
}

.shop-index__clear-search {
  margin-top: 8px;
  text-decoration: underline;
}

.shop-index__search {
  box-sizing: border-box;
  width: 100%;
}

/* Results head, legend and the A–Z bar (kept at the top while scrolling). */
.shop-index__results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.shop-index__results {
  color: var(--color-text-heading);
  font-size: 18px;
  font-weight: 700;
}

.shop-index__sort,
.shop-index__legend {
  color: var(--color-text-subtle);
  font-size: 14px;
}

.shop-index__legend {
  margin: 4px 0 12px;
}

.shop-index__az {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border-strong);
  background: var(--color-bg);
}

.shop-index__az ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shop-index__az a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  color: var(--color-text-heading);
  font-weight: 700;
  text-decoration: none;
}

.shop-index__az a[aria-disabled="true"] {
  border-color: var(--color-border);
  color: var(--color-border-strong);
  pointer-events: none;
}

/* Letters and names: four columns of names only (no card frame). */
.shop-index__letter {
  scroll-margin-top: 64px;
  padding-top: 20px;
}

.shop-index__letter-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-accent-soft);
}

.shop-index__letter-head h2 {
  margin: 0;
  color: var(--color-text-heading);
  font-size: 28px;
  line-height: 1.2;
}

.shop-index__letter-count {
  color: var(--color-text-subtle);
  font-size: 14px;
}

.shop-index__top {
  margin-left: auto;
  color: var(--color-accent-strong, #0a6a99);
  font-size: 14px;
}

.shop-index__names {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shop-index__names li {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.shop-index__names li[hidden],
.shop-index__letter[hidden] {
  display: none;
}

/* A name is an item of a list, so it has no arrow; the deep blue shows it is a link (ADR 0004). */
.shop-index__names a,
.shop-index__name {
  color: var(--color-text-emphasis);
  font-size: 15px;
  text-decoration: none;
}

.shop-index__names a {
  color: var(--color-accent-strong, #0a6a99);
}

.shop-index__names a:hover {
  text-decoration: underline;
}

.shop-index__latin {
  display: block;
  color: var(--color-text-subtle);
  font-size: 12px;
}

.shop-index__no-match,
.shop-index__empty {
  padding: 32px 0;
  color: var(--color-text);
  font-size: 16px;
}

.shop-index--empty .shop-index__empty {
  width: min(100% - 32px, 1250px);
  margin: 0 auto;
}

.shop-index__filters-count {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 700;
}

.shop-index__drawer-foot {
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

.shop-index__show {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--color-accent-strong, #0a6a99);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 999px) {
  .shop-index__names {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 689px) {
  .shop-index__names {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 16px;
  }

  .shop-index__az ol {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
}
