/* /icons/icons.css — the icon library: /icons/ and every /icons/<pack>.html.
   Loaded after /styles.css on the icon pages only; nothing here reaches any
   other page. Colours, the type family, the intro scale and the focus ring
   come from the site tokens in styles.css (:root); the line colours, radius,
   chips and menu surface are the same values /fonts uses, so the two
   libraries read as one system. */

.icons-page {
  --icons-radius: 8px;
  --icons-line: #e7e9ee;
  --icons-line-strong: #cfd4dd;
  --icons-ink: #000;
  --icons-tint: #f5f6f8;
  --icons-ease: cubic-bezier(0.2, 0.6, 0.3, 1);
}

.icons-main {
  padding-top: 28px;
  padding-bottom: 72px;
}

/* ---------- listing hero ---------- */

.icons-hero {
  padding: var(--intro-space-top) 0 clamp(28px, 2.4vw + 12px, 48px);
}
.icons-hero h1 {
  font-size: var(--intro-title-hero);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--icons-ink);
}
.icons-hero p {
  max-width: 760px;
  margin-top: var(--intro-title-gap);
  color: var(--text-muted);
  font-size: var(--intro-dek);
  line-height: 1.45;
}

.icons-section-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--icons-ink);
  margin-bottom: 16px;
}

/* ---------- glyphs used by the page chrome ---------- */

/* The <symbol> sprite the tiles <use>; it renders nothing itself. */
.icons-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icons-glyph {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- pack cards (listing) ---------- */

/* On /icons/ the packs follow the icon grid, so the listing opens on the
   search and the icons themselves. */
.icon-packs {
  margin-top: clamp(40px, 4vw + 16px, 64px);
}
.icon-pack-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.icon-pack-card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--icons-line);
  border-radius: var(--icons-radius);
  background: #fff;
  color: var(--icons-ink);
  text-decoration: none;
  transition: border-color 0.15s var(--icons-ease);
}
.icon-pack-card__link:hover {
  border-color: var(--icons-line-strong);
}
.icon-pack-card__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  aspect-ratio: 16 / 9;
  margin-bottom: 12px;
  border-radius: 6px;
  background: var(--icons-tint);
}
.icon-pack-card__preview img {
  width: 26px;
  height: 26px;
}
.icon-pack-card__preview--raster img {
  width: 40px;
  height: 40px;
}
.icon-pack-card__name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.icon-pack-card__meta {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- toolbar: style chips, search, category chips ---------- */

/* Search leads: a full-width field on its own row, then the chip rows. */
.icons-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
}
.icons-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.icons-chips--category {
  margin-top: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--icons-line);
  margin-bottom: 18px;
}

.icons-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--icons-line);
  border-radius: 999px;
  background: #fff;
  color: var(--icons-ink);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 0.15s var(--icons-ease),
    background-color 0.15s var(--icons-ease),
    color 0.15s var(--icons-ease);
}
.icons-chip:hover {
  border-color: var(--icons-line-strong);
}
/* A category the active style has no icons in (see src/client/icons.js). */
.icons-chip[hidden] {
  display: none;
}
/* Selected = inverted. aria-pressed carries the same state to assistive
   tech, so it is never communicated by colour alone. */
.icons-chip[aria-pressed="true"],
.icons-chip[aria-pressed="true"]:hover {
  background: var(--icons-ink);
  border-color: var(--icons-ink);
  color: #fff;
}
.icons-chips--category .icons-chip {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 13px;
}

.icons-search {
  position: relative;
  display: flex;
  align-items: center;
  order: -1;
  flex: 1 1 100%;
}
.icons-search .icons-glyph {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: #6b7485;
  pointer-events: none;
}
.icons-search input {
  width: 100%;
  height: 46px;
  min-width: 0;
  padding: 0 14px 0 42px;
  border: 1px solid var(--icons-line);
  border-radius: var(--icons-radius);
  background: #fff;
  color: var(--icons-ink);
  font-family: var(--sans);
  font-size: 15px;
}
.icons-search input::placeholder {
  color: #6b7485;
}
.icons-search input:hover {
  border-color: var(--icons-line-strong);
}

.icons-count {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ---------- buttons ---------- */

.icons-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--icons-line-strong);
  border-radius: var(--icons-radius);
  background: #fff;
  color: var(--icons-ink);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s var(--icons-ease),
    border-color 0.15s var(--icons-ease);
}
.icons-btn:hover {
  border-color: var(--icons-ink);
}
.icons-btn[hidden] {
  display: none;
}
.icons-btn--primary {
  background: var(--icons-ink);
  border-color: var(--icons-ink);
  color: #fff;
}
.icons-btn--primary:hover {
  background: #262626;
}
/* Copy feedback is carried by the label text ("✓ Copied" / "Copy failed"),
   and announced through #icons-status; the border only reinforces it. */
.icons-btn[data-state="copied"] {
  border-color: var(--icons-ink);
}
.icons-btn--primary[data-state="copied"] {
  background: #262626;
}

/* ---------- the icon grid: a dense tile browser ----------

   Square tiles as small as the viewport allows, auto-filled rather than a
   fixed column count, so the same rules hold for 47 icons or 2,000. The icon
   is the content; its name and actions are revealed on hover (pointer
   devices) and on keyboard focus, and are never removed from the DOM, the
   tab order or the accessibility tree. */

.icon-grid {
  --tile: 104px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
  gap: 8px;
}

.icon-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 1;
}
.icon-card[hidden] {
  display: none;
}

.icon-card__preview {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid var(--icons-line);
  border-radius: var(--icons-radius);
  background: #fff;
  cursor: pointer;
  transition:
    border-color 0.15s var(--icons-ease),
    background-color 0.15s var(--icons-ease);
}
.icon-card__preview img {
  width: 28px;
  height: 28px;
}
.icon-card__preview--raster img {
  width: 56%;
  height: auto;
  aspect-ratio: 1 / 1;
}
.icon-card__preview:active {
  background: #f1f2f5;
}

/* The name, revealed with the actions. The tile's accessible name already
   carries it, so this copy is aria-hidden in the markup. */
.icon-card__caption {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--icons-ink);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.12s var(--icons-ease);
}

.icon-card__actions {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 1;
  display: flex;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s var(--icons-ease);
}

/* Reveal: hover on devices that have it; keyboard focus everywhere; and
   while a copy result is showing or a download menu is open. */
@media (hover: hover) {
  .icon-card:hover .icon-card__preview {
    background: var(--icons-tint);
    border-color: var(--icons-line-strong);
  }
  .icon-card:hover .icon-card__caption,
  .icon-card:hover .icon-card__actions {
    opacity: 1;
  }
  .icon-card:hover .icon-card__actions {
    pointer-events: auto;
  }
}
.icon-card:has(:focus-visible) .icon-card__caption,
.icon-card:has(:focus-visible) .icon-card__actions,
.icon-card:has([data-state]) .icon-card__actions,
.icon-card:has(.icon-download[open]) .icon-card__actions {
  opacity: 1;
  pointer-events: auto;
}
@supports not selector(:has(*)) {
  .icon-card:focus-within .icon-card__caption,
  .icon-card:focus-within .icon-card__actions {
    opacity: 1;
    pointer-events: auto;
  }
}
.icon-card:has(.icon-download[open]) .icon-card__actions {
  z-index: 30;
}

/* Compact icon buttons in the tile corner. Same wash and ink as the Fonts
   cards' icon buttons; white at rest so they read on the hovered tint. */
.icon-tile-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #fff;
  color: #3d4556;
  list-style: none;
  text-decoration: none;
  cursor: pointer;
}
.icon-tile-btn:hover,
.icon-download[open] > .icon-tile-btn {
  background: #f1f2f5;
  color: var(--icons-ink);
}
.icon-tile-btn:active {
  background: var(--icons-line);
}
.icon-tile-btn .icons-glyph {
  width: 16px;
  height: 16px;
}
.icon-tile-btn__done {
  display: none;
}
.icon-tile-btn[data-state="copied"] .icon-tile-btn__idle {
  display: none;
}
.icon-tile-btn[data-state="copied"] .icon-tile-btn__done {
  display: block;
}
.icon-tile-btn[data-state] {
  background: var(--icons-ink);
  color: #fff;
}
/* The button's label is written by the client ("✓ Copied" / "Copy failed")
   and announced through #icons-status. It is shown in the tile's caption
   slot below, because a tile is too narrow to widen the button itself. */
.icon-tile-btn__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.icon-card:has(.icon-tile-btn[data-state]) .icon-card__caption {
  opacity: 0;
}
.icon-card:has(.icon-tile-btn[data-state="copied"])::after,
.icon-card:has(.icon-tile-btn[data-state="failed"])::after {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--icons-ink);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
.icon-card:has(.icon-tile-btn[data-state="copied"])::after {
  content: "\2713  Copied";
}
.icon-card:has(.icon-tile-btn[data-state="failed"])::after {
  content: "Copy failed";
}

/* ---------- download disclosure ---------- */

.icon-download {
  position: relative;
  flex: none;
}
.icon-download > summary {
  list-style: none;
}
.icon-download > summary::-webkit-details-marker {
  display: none;
}
.icon-download__list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 140px;
  padding: 6px;
  border: 1px solid var(--icons-line);
  border-radius: var(--icons-radius);
  background: #fff;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}
/* Set by src/client/icons.js when right-aligning would leave the viewport. */
.icon-download__list--start {
  right: auto;
  left: 0;
}
.icon-download__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 5px;
  color: var(--icons-ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.icon-download__item:hover,
.icon-download__item:focus-visible {
  background: #f1f2f5;
}
.icon-download__item:focus-visible {
  outline-offset: -2px;
}
.icon-download__note {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------- empty state and note ---------- */

.icons-empty {
  padding: 56px 0;
  text-align: center;
  color: var(--text-muted);
}
.icons-empty[hidden] {
  display: none;
}
.icons-empty p + p {
  margin-top: 6px;
}
.icons-empty strong {
  color: var(--icons-ink);
}
.icons-empty .icons-btn {
  margin-top: 16px;
}

.icons-note {
  max-width: 760px;
  margin-top: 48px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}
.icons-page code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  color: var(--icons-ink);
}

/* ---------- pack page ---------- */

.icons-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--text-muted);
}
.icons-breadcrumb li + li::before {
  content: "/";
  margin-right: 6px;
  color: #9aa2b1;
}
.icons-breadcrumb a {
  text-decoration: none;
}
.icons-breadcrumb a:hover {
  color: var(--icons-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-pack-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding: clamp(20px, 3vw, 40px) 0 clamp(28px, 3vw + 8px, 48px);
}
.icon-pack-head h1 {
  font-size: var(--intro-title-section);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--icons-ink);
  overflow-wrap: anywhere;
}
.icon-pack-head__meta {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--icons-ink);
}
.icon-pack-head__desc {
  max-width: 640px;
  margin-top: 10px;
  font-size: var(--intro-dek);
  line-height: 1.45;
  color: var(--text-muted);
}
.icon-pack-head__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.icon-pack-head__buttons .icons-btn {
  min-height: 44px;
  padding: 0 16px;
  font-size: 14.5px;
}
.icon-pack-head__size {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}
@media (min-width: 768px) {
  .icon-pack-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    column-gap: 48px;
  }
  .icon-pack-head__actions {
    justify-self: end;
  }
}

/* ---------- detail dialog ---------- */

.icon-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--icons-line);
  border-radius: 12px;
  background: #fff;
  color: var(--icons-ink);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
  overflow: auto;
}
.icon-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.icon-dialog__inner {
  position: relative;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 28px;
  padding: 24px;
}
.icon-dialog__close {
  appearance: none;
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #3d4556;
  cursor: pointer;
}
.icon-dialog__close:hover {
  background: #f1f2f5;
  color: var(--icons-ink);
}
.icon-dialog__close .icons-glyph {
  width: 20px;
  height: 20px;
}
.icon-dialog__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border-radius: var(--icons-radius);
  background: var(--icons-tint);
}
.icon-dialog__preview img {
  width: 96px;
  height: 96px;
}
.icon-dialog__preview--raster img {
  width: 80%;
  height: auto;
  aspect-ratio: 1 / 1;
}

.icon-dialog__body {
  min-width: 0;
  padding-right: 32px;
}
.icon-dialog__title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.icon-dialog__meta {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
}
.icon-dialog__meta > div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}
.icon-dialog__meta dt {
  font-size: 13px;
  font-weight: 700;
}
.icon-dialog__meta dd {
  margin: 0;
  font-size: 14px;
  color: #3d4556;
}
.icon-dialog__meta a {
  color: var(--icons-ink);
}
.icon-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.icon-tags li {
  padding: 3px 9px;
  border: 1px solid var(--icons-line);
  border-radius: 999px;
  font-size: 12.5px;
  color: #3d4556;
}

.icon-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.icon-dialog__code {
  margin-top: 18px;
}
.icon-dialog__code[hidden] {
  display: none;
}
.icon-dialog__code summary {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.icon-dialog__code pre {
  max-height: 200px;
  margin: 8px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--icons-line);
  border-radius: var(--icons-radius);
  background: var(--icons-tint);
  font-size: 12px;
  line-height: 1.55;
}
.icon-dialog__code pre:focus-visible {
  outline-offset: -2px;
}

/* ---------- responsive ---------- */

@media (max-width: 1023px) {
  .icon-pack-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* Two columns make each card twice as wide as at 1440px; a 16:9 preview
     would then be ~200px tall around four small icons. A fixed band keeps
     the cards compact. */
  .icon-pack-card__preview {
    aspect-ratio: auto;
    height: 104px;
  }
  .icon-grid {
    --tile: 88px;
  }
}

@media (max-width: 767px) {
  .icons-toolbar {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }
  .icons-toolbar > * {
    min-width: 0;
  }
  /* One scrollable row of chips instead of a wrapped block. nowrap on the
     column above keeps that row from widening the page. */
  .icons-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -24px;
    padding: 2px 24px;
    scrollbar-width: none;
  }
  .icons-chips::-webkit-scrollbar {
    display: none;
  }
  .icons-chip {
    flex: none;
  }
  .icons-chips--category {
    padding-bottom: 16px;
  }

  .icon-dialog__inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 20px 16px;
  }
  .icon-dialog__preview {
    aspect-ratio: auto;
    height: 168px;
  }
  .icon-dialog__preview--raster img {
    width: auto;
    height: 140px;
  }
  .icon-dialog__body {
    padding-right: 0;
  }
}

@media (max-width: 479px) {
  .icon-grid {
    --tile: 68px;
    gap: 6px;
  }
  /* Glyphs only: 3D previews keep their tile-relative size from the base
     rule, which this selector used to override at equal specificity. */
  .icon-card__preview:not(.icon-card__preview--raster) img {
    width: 24px;
    height: 24px;
  }
  /* A phone tile (~68–87px) cannot hold the corner actions, the icon and the
     caption stacked on top of one another. So while its actions are
     revealed, a tile lays out as two zones: the actions stacked in a column
     at the right edge, and the icon centred in the space left of it. At rest
     nothing moves. The caption drops to the bottom edge, below the column. */
  .icon-card {
    container-type: inline-size;
  }
  .icon-tile-btn {
    width: 26px;
    height: 26px;
  }
  .icon-card__actions {
    top: 3px;
    right: 3px;
    flex-direction: column;
  }
  /* 3D previews are sized from the tile (not the padded preview box), so
     they keep their approved share of the tile when the column appears. */
  .icon-card__preview--raster img {
    width: 56cqw;
  }
  .icon-card:has(:focus-visible) .icon-card__preview,
  .icon-card:has([data-state]) .icon-card__preview,
  .icon-card:has(.icon-download[open]) .icon-card__preview {
    padding-right: 32px;
  }
  @media (hover: hover) {
    .icon-card:hover .icon-card__preview {
      padding-right: 32px;
    }
  }
  @supports not selector(:has(*)) {
    .icon-card:focus-within .icon-card__preview {
      padding-right: 32px;
    }
  }
  .icon-card__caption,
  .icon-card:has(.icon-tile-btn[data-state="copied"])::after,
  .icon-card:has(.icon-tile-btn[data-state="failed"])::after {
    bottom: 3px;
    font-size: 10.5px;
  }
  .icon-pack-card__preview {
    gap: 8px;
  }
  .icon-pack-card__preview img {
    width: 20px;
    height: 20px;
  }
  .icon-pack-card__preview--raster img {
    width: 28px;
    height: 28px;
  }
  .icon-pack-card__preview {
    height: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .icon-pack-card__link,
  .icons-chip,
  .icons-btn,
  .icon-card__preview,
  .icon-card__caption,
  .icon-card__actions {
    transition: none;
  }
}
