/*
 * Glyph360 docs: what these pages add to the CDN's shared styles (/assets/tokens.css and
 * /assets/site.css), the gallery's search field, its segmented controls and the icon tiles.
 * Colors come from tokens.css, apart from the black the template mixes into the tiles' tinted
 * shadow; sizes are rem. The search field and the segmented control
 * take the reference template's values (the uiux skill's variants defaults: an outlined search
 * field with its shortcut hint, the raised selected segment that slides, Round 20). So do the
 * tiles (a raised card), the skeleton (a shimmer) and the empty state (an icon, centered).
 */

/* The gallery needs its script; without it the page says so instead. */
html:not(.js) .jsOnly { display: none; }
html.js .nojsOnly { display: none; }

.btn .glyph360 { font-size: 1rem; flex: none; }

/* ------------------------------------------------------------------ controls */

.galleryControls { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-6); align-items: flex-end; }

/* As the template's search field: its label above the box, which holds the magnifier, the hint and the clear button.
   It fills the row's height, so its label lines up with the legends beside it and its box with their tracks. */
.searchField { display: flex; flex-direction: column; justify-content: space-between; align-self: stretch; gap: var(--space-2); flex: 1 1 18rem; min-inline-size: 0; max-inline-size: calc(31ch + 5rem); }
.searchField > label { font: 600 var(--text-sm)/1.5 var(--font-sans); color: var(--text-primary); }
.searchBox { position: relative; display: flex; align-items: center; }
.searchIcon { position: absolute; z-index: 1; inset-inline-start: var(--space-3); font-size: 1.125rem; color: var(--text-secondary); pointer-events: none; }
.searchInput {
  inline-size: 100%; min-block-size: var(--control-md); padding: 0 calc(var(--space-3) + 2rem) 0 calc(var(--space-3) + 1.75rem);
  -webkit-appearance: none; appearance: none;
  border: 1px solid var(--border-control); border-radius: var(--radius-md); background-color: var(--raised); color: var(--text-primary);
  font: inherit; font-size: var(--text-md);
  transition: border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.searchInput::placeholder { color: var(--text-muted); opacity: 1; }
.searchInput::-webkit-search-cancel-button { display: none; }
@media (hover: hover) and (pointer: fine) { .searchInput:not(:focus):hover { border-color: var(--text-secondary); } }
/* The ring sits 1px off the field, as the template's search demo draws it. */
.searchInput:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; border-color: var(--accent-ring); }
/* The shortcut hint: on fine pointers only, while the field is empty and not focused. Its
   placeholder keeps clear of the wider "Ctrl K" hint. */
.searchKbd {
  position: absolute; inset-inline-end: var(--space-3); display: none; padding: 0 var(--space-1); min-inline-size: 1.5em; text-align: center;
  border: 1px solid var(--border-control); border-block-end-width: 2px; border-radius: min(var(--radius-sm), 0.375rem);
  background: var(--raised); color: var(--text-secondary); font: var(--text-xs)/1.5 var(--font-mono); white-space: nowrap;
  pointer-events: none; transition: opacity var(--dur-fast) var(--ease-out);
}
@media (pointer: fine) {
  .searchKbd { display: inline-block; }
  .searchInput { padding-inline-end: calc(var(--space-3) + 3.75rem); }
}
.searchInput:is(:focus, :not(:placeholder-shown)) ~ .searchKbd { opacity: 0; }
.searchClear {
  position: absolute; inset-inline-end: 0.25rem; display: inline-grid; place-items: center;
  inline-size: 2rem; block-size: 2rem; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); font-size: 1rem; cursor: pointer;
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), scale var(--dur-fast) var(--ease-out);
}
.searchClear[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) { .searchClear:hover { background: color-mix(in srgb, var(--text-primary) 5%, transparent); color: var(--text-primary); } }
.searchClear:active { scale: 0.97; }
@media (pointer: coarse) {
  .searchClear { inline-size: 2.75rem; block-size: 2.75rem; inset-inline-end: 0; }
  .searchInput { padding-inline-end: 3rem; }
}

.choice { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.choice legend { padding: 0; margin-block-end: var(--space-2); font: 600 var(--text-sm)/1.5 var(--font-sans); color: var(--text-primary); }

/* Segmented controls built on radios, equal segments in one row. The selected label is bolder, so
   each label also holds a hidden bold copy of its text that sets its width, and nothing moves when
   the choice changes. The raised highlight is one element under the labels: docs.js measures it
   onto the segment picked, and it slides there once the page is ready (html[data-ready]). */
.seg { position: relative; isolation: isolate; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.125rem; padding: 0.1875rem; max-inline-size: 100%; background-color: var(--sunken); border: 1px solid var(--border-control); border-radius: var(--radius-md); }
.seg label { position: relative; z-index: 1; display: flex; min-inline-size: 0; }
.seg input { position: absolute; inset: 0; z-index: 1; margin: 0; opacity: 0; cursor: pointer; inline-size: 100%; block-size: 100%; }
.seg label > span {
  pointer-events: none; display: inline-grid; place-items: center; inline-size: 100%; min-block-size: var(--control-md); padding-inline: var(--space-4);
  border: 1px solid transparent; border-radius: max(0.125rem, calc(var(--radius-md) - 0.1875rem)); color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500; white-space: nowrap;
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), scale var(--dur-fast) var(--ease-out);
}
.seg label > span > span, .seg label > span::after { grid-area: 1 / 1; }
.seg label > span::after { content: attr(data-text); font-weight: 600; visibility: hidden; }
@media (hover: hover) and (pointer: fine) { .seg label:hover input:not(:checked) + span { color: var(--text-primary); background-color: color-mix(in srgb, var(--text-primary) 5%, transparent); } }
.seg input:checked + span { color: var(--text-primary); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.seg label:active input + span { scale: 0.97; }
.segThumb {
  position: absolute; z-index: 0; top: 0; left: 0; inline-size: var(--w, 0px); block-size: var(--h, 0px); transform: translate(var(--x, 0px), var(--y, 0px));
  border-radius: max(0.125rem, calc(var(--radius-md) - 0.1875rem)); pointer-events: none;
  background-color: var(--raised); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--border-control);
}
html[data-ready] .segThumb { transition: transform var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out); }
/* The selected segment answers the pointer too: its highlight deepens a step, and a press shrinks it with its label. */
@media (hover: hover) and (pointer: fine) {
  .seg:has(label:hover > input:checked:not(:focus-visible)) .segThumb { background-color: color-mix(in oklab, var(--raised), var(--text-primary) 6%); }
}
.seg:has(label:active > input:checked) .segThumb { transform: translate(var(--x, 0px), var(--y, 0px)) scale(0.97); }

.galleryNote, .galleryCount { color: var(--text-secondary); font-size: var(--text-sm); }

/* ------------------------------------------------------------------ the icons */

.iconGrid { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); }
.iconGrid[hidden] { display: none; }
/* Each tile is a raised card: the template's comfortable padding and gap, and its tinted shadow. */
.iconTile {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-4); min-width: 0;
  padding: var(--space-6);
  background: var(--raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  box-shadow: 0 6px 18px color-mix(in srgb, color-mix(in srgb, var(--accent-solid) 35%, #000) 22%, transparent);
}
.iconPreview { display: grid; place-items: center; inline-size: 3.5rem; block-size: 3.5rem; border-radius: var(--radius-md); background: var(--sunken); color: var(--text-primary); }
.iconGrid[data-size="24"] .iconPreview .glyph360 { font-size: 1.5rem; }
.iconGrid[data-size="20"] .iconPreview .glyph360 { font-size: 1.25rem; }
.iconGrid[data-size="16"] .iconPreview .glyph360 { font-size: 1rem; }
.iconName { max-inline-size: 100%; font-size: var(--text-xs); color: var(--text-secondary); overflow-wrap: anywhere; text-align: center; }
.iconTag { font-size: var(--text-xs); color: var(--text-muted); }
/* The Copy button wraps its label in a narrow tile, as the template's buttons do. */
.tileCopy { margin-block-start: auto; max-inline-size: 100%; white-space: normal; }
/* A refused copy: the button says so in the danger color, and the markup waits in a read-only field. */
.btn[data-failed] { color: var(--danger-text); border-color: var(--danger-text); }
.tileMarkup {
  inline-size: 100%; min-inline-size: 0; min-block-size: var(--control-sm); padding-inline: var(--space-2);
  border: 1px dashed var(--border-control); border-radius: var(--radius-sm); background: transparent; color: var(--text-primary);
  font: var(--text-xs)/1.5 var(--font-mono);
}

/* Placeholder tiles while icons.json loads: the same blocks as a tile (preview, name, Copy), with a shimmer. */
.skeleton .iconPreview, .skeletonLine { position: relative; overflow: hidden; background-color: color-mix(in srgb, var(--text-primary) 10%, var(--raised)); }
.skeletonLine { display: block; inline-size: 60%; block-size: 0.75rem; margin-block: 0.225rem; border-radius: var(--radius-sm); }
.skeletonLine.skeletonButton { inline-size: 5rem; block-size: var(--control-sm); margin-block: auto 0; border-radius: var(--radius-md); }
.skeleton .iconPreview::after, .skeletonLine::after {
  content: ""; position: absolute; inset: 0; translate: -100% 0;
  background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text-primary) 9%, transparent), transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .skeleton .iconPreview::after, .skeletonLine::after { animation: skeletonShimmer 1.4s var(--ease-in-out) infinite; }
  @keyframes skeletonShimmer { to { translate: 100% 0; } }
}

/* The empty state and the error state: centered, each with an icon in a tinted circle (danger for the error), and a title. */
.galleryEmpty, .galleryError {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-8) var(--space-6);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--raised);
  font-size: var(--text-sm); color: var(--text-secondary); text-align: center;
}
.emptyTitle { font-size: var(--text-md); line-height: 1.5; color: var(--text-primary); text-wrap: wrap; }
.galleryEmpty p, .galleryError p { max-inline-size: 46ch; line-height: 1.5; text-align: center; }
.galleryEmpty[hidden], .galleryError[hidden], .galleryError .btn[hidden] { display: none; }
.emptyArt { display: grid; place-items: center; inline-size: 3.5rem; block-size: 3.5rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 1.5rem; }
.emptyArt[data-tone="error"] { background: var(--danger-soft); color: var(--danger-text); }

@media (forced-colors: active) {
  .segThumb { display: none; }
  .seg label > span { border: 1px solid ButtonText; }
  .seg input:checked + span { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .seg input:focus-visible + span { outline-color: CanvasText; }
}
